@tenxyte/core 0.9.0 → 0.9.3
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/LICENSE +21 -0
- package/README.md +362 -102
- package/dist/index.cjs +966 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1073 -15
- package/dist/index.d.ts +1073 -15
- package/dist/index.js +946 -35
- package/dist/index.js.map +1 -1
- package/package.json +15 -3
- package/patched-schema.json +0 -11388
- package/src/client.ts +0 -50
- package/src/config.ts +0 -0
- package/src/http/client.ts +0 -162
- package/src/http/index.ts +0 -1
- package/src/http/interceptors.ts +0 -117
- package/src/index.ts +0 -7
- package/src/modules/ai.ts +0 -178
- package/src/modules/auth.ts +0 -116
- package/src/modules/b2b.ts +0 -177
- package/src/modules/rbac.ts +0 -207
- package/src/modules/security.ts +0 -313
- package/src/modules/user.ts +0 -95
- package/src/storage/cookie.ts +0 -39
- package/src/storage/index.ts +0 -29
- package/src/storage/localStorage.ts +0 -75
- package/src/storage/memory.ts +0 -30
- package/src/types/api-schema.d.ts +0 -6590
- package/src/types/index.ts +0 -152
- package/src/utils/base64url.ts +0 -25
- package/src/utils/device_info.ts +0 -94
- package/src/utils/events.ts +0 -71
- package/src/utils/jwt.ts +0 -51
- package/tests/http.test.ts +0 -144
- package/tests/modules/auth.test.ts +0 -93
- package/tests/modules/rbac.test.ts +0 -95
- package/tests/modules/security.test.ts +0 -85
- package/tests/modules/user.test.ts +0 -76
- package/tests/storage.test.ts +0 -96
- package/tests/utils.test.ts +0 -71
- package/tsconfig.json +0 -26
- package/tsup.config.ts +0 -10
- package/vitest.config.ts +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryStorage implementation primarily used in Node.js (SSR)
|
|
3
|
+
* environments or as a fallback when browser storage is unavailable.
|
|
4
|
+
*/
|
|
5
|
+
declare class MemoryStorage implements TenxyteStorage {
|
|
6
|
+
private store;
|
|
7
|
+
constructor();
|
|
8
|
+
getItem(key: string): string | null;
|
|
9
|
+
setItem(key: string, value: string): void;
|
|
10
|
+
removeItem(key: string): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* LocalStorage wrapper for the browser.
|
|
16
|
+
* Degrades gracefully to MemoryStorage if localStorage is unavailable
|
|
17
|
+
* (e.g., SSR, Private Browsing mode strictness).
|
|
18
|
+
*/
|
|
19
|
+
declare class LocalStorage implements TenxyteStorage {
|
|
20
|
+
private fallbackMemoryStore;
|
|
21
|
+
private isAvailable;
|
|
22
|
+
constructor();
|
|
23
|
+
private checkAvailability;
|
|
24
|
+
getItem(key: string): string | null;
|
|
25
|
+
setItem(key: string, value: string): void;
|
|
26
|
+
removeItem(key: string): void;
|
|
27
|
+
clear(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* CookieStorage implementation
|
|
32
|
+
* Note: To be secure, tokens should be HttpOnly where possible.
|
|
33
|
+
* This class handles client-side cookies if necessary.
|
|
34
|
+
*/
|
|
35
|
+
declare class CookieStorage implements TenxyteStorage {
|
|
36
|
+
private defaultOptions;
|
|
37
|
+
constructor(options?: {
|
|
38
|
+
secure?: boolean;
|
|
39
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
40
|
+
});
|
|
41
|
+
getItem(key: string): string | null;
|
|
42
|
+
setItem(key: string, value: string): void;
|
|
43
|
+
removeItem(key: string): void;
|
|
44
|
+
clear(): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface TenxyteStorage {
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves a value from storage.
|
|
50
|
+
* @param key The key to retrieve
|
|
51
|
+
*/
|
|
52
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Saves a value to storage.
|
|
55
|
+
* @param key The key to store
|
|
56
|
+
* @param value The string value
|
|
57
|
+
*/
|
|
58
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Removes a specific key from storage.
|
|
61
|
+
* @param key The key to remove
|
|
62
|
+
*/
|
|
63
|
+
removeItem(key: string): void | Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Clears all storage keys managed by the SDK.
|
|
66
|
+
*/
|
|
67
|
+
clear(): void | Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Helper utility to build the device fingerprint required by Tenxyte security features.
|
|
72
|
+
* Format: `v=1|os=windows;osv=11|device=desktop|arch=x64|app=tenxyte;appv=1.0.0|runtime=chrome;rtv=122|tz=Europe/Paris`
|
|
73
|
+
*/
|
|
74
|
+
interface CustomDeviceInfo {
|
|
75
|
+
os?: string;
|
|
76
|
+
osVersion?: string;
|
|
77
|
+
device?: string;
|
|
78
|
+
arch?: string;
|
|
79
|
+
app?: string;
|
|
80
|
+
appVersion?: string;
|
|
81
|
+
runtime?: string;
|
|
82
|
+
runtimeVersion?: string;
|
|
83
|
+
timezone?: string;
|
|
84
|
+
}
|
|
85
|
+
declare function buildDeviceInfo(customInfo?: CustomDeviceInfo): string;
|
|
86
|
+
|
|
1
87
|
interface HttpClientOptions {
|
|
2
88
|
baseUrl: string;
|
|
3
89
|
timeoutMs?: number;
|
|
@@ -16,6 +102,7 @@ type RequestConfig = Omit<RequestInit, 'body' | 'headers'> & {
|
|
|
16
102
|
declare class TenxyteHttpClient {
|
|
17
103
|
private baseUrl;
|
|
18
104
|
private defaultHeaders;
|
|
105
|
+
private timeoutMs;
|
|
19
106
|
private requestInterceptors;
|
|
20
107
|
private responseInterceptors;
|
|
21
108
|
constructor(options: HttpClientOptions);
|
|
@@ -30,8 +117,211 @@ declare class TenxyteHttpClient {
|
|
|
30
117
|
post<T>(endpoint: string, data?: unknown, config?: Omit<RequestConfig, 'method' | 'body'>): Promise<T>;
|
|
31
118
|
put<T>(endpoint: string, data?: unknown, config?: Omit<RequestConfig, 'method' | 'body'>): Promise<T>;
|
|
32
119
|
patch<T>(endpoint: string, data?: unknown, config?: Omit<RequestConfig, 'method' | 'body'>): Promise<T>;
|
|
33
|
-
delete<T>(endpoint: string, config?: Omit<RequestConfig, 'method' | 'body'>): Promise<T>;
|
|
120
|
+
delete<T>(endpoint: string, data?: unknown, config?: Omit<RequestConfig, 'method' | 'body'>): Promise<T>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface TenxyteContext {
|
|
124
|
+
activeOrgSlug: string | null;
|
|
125
|
+
agentTraceId: string | null;
|
|
126
|
+
}
|
|
127
|
+
declare function createAuthInterceptor(storage: TenxyteStorage, context: TenxyteContext): (request: RequestConfig & {
|
|
128
|
+
url: string;
|
|
129
|
+
}) => Promise<{
|
|
130
|
+
headers: {
|
|
131
|
+
[x: string]: string;
|
|
132
|
+
};
|
|
133
|
+
cache?: RequestCache | undefined;
|
|
134
|
+
credentials?: RequestCredentials | undefined;
|
|
135
|
+
integrity?: string | undefined;
|
|
136
|
+
keepalive?: boolean | undefined;
|
|
137
|
+
method?: string | undefined;
|
|
138
|
+
mode?: RequestMode | undefined;
|
|
139
|
+
priority?: RequestPriority | undefined;
|
|
140
|
+
redirect?: RequestRedirect | undefined;
|
|
141
|
+
referrer?: string | undefined;
|
|
142
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
143
|
+
signal?: (AbortSignal | null) | undefined;
|
|
144
|
+
window?: null | undefined;
|
|
145
|
+
body?: unknown;
|
|
146
|
+
params?: Record<string, string | number | boolean>;
|
|
147
|
+
url: string;
|
|
148
|
+
}>;
|
|
149
|
+
declare function createRefreshInterceptor(client: TenxyteHttpClient, storage: TenxyteStorage, onSessionExpired: () => void, onTokenRefreshed?: (accessToken: string, refreshToken?: string) => void): (response: Response, request: {
|
|
150
|
+
url: string;
|
|
151
|
+
config: RequestConfig;
|
|
152
|
+
}) => Promise<Response>;
|
|
153
|
+
/** Configuration for the automatic retry middleware. */
|
|
154
|
+
interface RetryConfig {
|
|
155
|
+
/** Maximum number of retries per request. Defaults to 3. */
|
|
156
|
+
maxRetries?: number;
|
|
157
|
+
/** Retry on HTTP 429 (Too Many Requests). Defaults to true. */
|
|
158
|
+
retryOn429?: boolean;
|
|
159
|
+
/** Retry on network errors (fetch failures, timeouts). Defaults to true. */
|
|
160
|
+
retryOnNetworkError?: boolean;
|
|
161
|
+
/** Base delay in ms for exponential backoff. Defaults to 1000. */
|
|
162
|
+
baseDelayMs?: number;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates a response interceptor that retries failed requests with exponential backoff.
|
|
166
|
+
* Respects the `Retry-After` header when present on 429 responses.
|
|
167
|
+
*/
|
|
168
|
+
declare function createRetryInterceptor(config?: RetryConfig, logger?: TenxyteLogger): (response: Response, request: {
|
|
169
|
+
url: string;
|
|
170
|
+
config: RequestConfig;
|
|
171
|
+
}) => Promise<Response>;
|
|
172
|
+
declare function createDeviceInfoInterceptor(override?: CustomDeviceInfo): (request: RequestConfig & {
|
|
173
|
+
url: string;
|
|
174
|
+
}) => Omit<RequestInit, "body" | "headers"> & {
|
|
175
|
+
body?: unknown;
|
|
176
|
+
headers?: Record<string, string>;
|
|
177
|
+
params?: Record<string, string | number | boolean>;
|
|
178
|
+
} & {
|
|
179
|
+
url: string;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Semantic version of the SDK, kept in sync with package.json.
|
|
184
|
+
* Sent as X-SDK-Version header when diagnostics are enabled.
|
|
185
|
+
*/
|
|
186
|
+
declare const SDK_VERSION = "0.9.0";
|
|
187
|
+
/**
|
|
188
|
+
* Log level controlling the verbosity of the SDK internal logger.
|
|
189
|
+
*
|
|
190
|
+
* - `'silent'` — No output (default).
|
|
191
|
+
* - `'error'` — Errors only.
|
|
192
|
+
* - `'warn'` — Errors and warnings.
|
|
193
|
+
* - `'debug'` — Verbose output including debug traces.
|
|
194
|
+
*/
|
|
195
|
+
type LogLevel = 'silent' | 'error' | 'warn' | 'debug';
|
|
196
|
+
/**
|
|
197
|
+
* Pluggable logger interface accepted by the SDK.
|
|
198
|
+
* Any object satisfying this contract (e.g. `console`) can be passed as `logger`.
|
|
199
|
+
*/
|
|
200
|
+
interface TenxyteLogger {
|
|
201
|
+
/** Verbose diagnostic messages (interceptors, token lifecycle, etc.) */
|
|
202
|
+
debug(message: string, ...args: unknown[]): void;
|
|
203
|
+
/** Non-critical issues that deserve attention (deprecated usage, retry fallback, etc.) */
|
|
204
|
+
warn(message: string, ...args: unknown[]): void;
|
|
205
|
+
/** Unrecoverable errors (network failures, malformed responses, etc.) */
|
|
206
|
+
error(message: string, ...args: unknown[]): void;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Configuration object accepted by {@link TenxyteClient}.
|
|
210
|
+
*
|
|
211
|
+
* Only `baseUrl` is required — every other option has a sensible default.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* import { TenxyteClient } from '@tenxyte/core';
|
|
216
|
+
*
|
|
217
|
+
* const tx = new TenxyteClient({
|
|
218
|
+
* baseUrl: 'https://api.my-service.com',
|
|
219
|
+
* headers: { 'X-Access-Key': 'pkg_abc123' },
|
|
220
|
+
* autoRefresh: true,
|
|
221
|
+
* autoDeviceInfo: true,
|
|
222
|
+
* timeoutMs: 10_000,
|
|
223
|
+
* onSessionExpired: () => router.push('/login'),
|
|
224
|
+
* });
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
interface TenxyteClientConfig {
|
|
228
|
+
/** Base URL of the Tenxyte-powered API, without a trailing slash. */
|
|
229
|
+
baseUrl: string;
|
|
230
|
+
/** Extra HTTP headers merged into every outgoing request (e.g. X-Access-Key, X-Access-Secret). */
|
|
231
|
+
headers?: Record<string, string>;
|
|
232
|
+
/**
|
|
233
|
+
* Persistent token storage back-end.
|
|
234
|
+
* The SDK ships with MemoryStorage, LocalStorageAdapter, and CookieStorage.
|
|
235
|
+
* Defaults to MemoryStorage (in-memory, lost on page reload / process exit).
|
|
236
|
+
*/
|
|
237
|
+
storage?: TenxyteStorage;
|
|
238
|
+
/**
|
|
239
|
+
* When true, the SDK automatically attaches a response interceptor that
|
|
240
|
+
* intercepts 401 responses, attempts a silent token refresh via
|
|
241
|
+
* POST /refresh/, and replays the original request on success.
|
|
242
|
+
* Defaults to true.
|
|
243
|
+
*/
|
|
244
|
+
autoRefresh?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* When true, the SDK injects a device_info payload (built by
|
|
247
|
+
* buildDeviceInfo()) into every authentication request body
|
|
248
|
+
* (/login/email/, /login/phone/, /register/, /social/*).
|
|
249
|
+
* Set to false if you supply your own fingerprint or run in an
|
|
250
|
+
* environment where the auto-detected info is irrelevant (e.g. CI).
|
|
251
|
+
* Defaults to true.
|
|
252
|
+
*/
|
|
253
|
+
autoDeviceInfo?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Global request timeout in milliseconds.
|
|
256
|
+
* When set, every fetch call is wrapped with an AbortController.
|
|
257
|
+
* If the timer fires before the response arrives, the SDK throws a
|
|
258
|
+
* TenxyteError with code TIMEOUT.
|
|
259
|
+
* Defaults to undefined (no timeout).
|
|
260
|
+
*/
|
|
261
|
+
timeoutMs?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Callback invoked whenever the active session can no longer be recovered
|
|
264
|
+
* (e.g. refresh token is expired or revoked).
|
|
265
|
+
* This is a convenience shortcut equivalent to tx.on('session:expired', callback).
|
|
266
|
+
*/
|
|
267
|
+
onSessionExpired?: () => void;
|
|
268
|
+
/**
|
|
269
|
+
* Custom logger implementation.
|
|
270
|
+
* Defaults to a silent no-op logger. Pass console for quick debugging
|
|
271
|
+
* or supply any object that satisfies the TenxyteLogger interface.
|
|
272
|
+
*/
|
|
273
|
+
logger?: TenxyteLogger;
|
|
274
|
+
/**
|
|
275
|
+
* Controls the verbosity of the built-in logger when no custom logger
|
|
276
|
+
* is provided. Defaults to 'silent'.
|
|
277
|
+
*/
|
|
278
|
+
logLevel?: LogLevel;
|
|
279
|
+
/**
|
|
280
|
+
* Override or supplement the auto-detected device information.
|
|
281
|
+
* When provided, these values are merged on top of the auto-detected
|
|
282
|
+
* fingerprint built by `buildDeviceInfo()`. Only relevant when
|
|
283
|
+
* `autoDeviceInfo` is `true`.
|
|
284
|
+
*/
|
|
285
|
+
deviceInfoOverride?: CustomDeviceInfo;
|
|
286
|
+
/**
|
|
287
|
+
* When provided, the SDK attaches a response interceptor that
|
|
288
|
+
* automatically retries failed requests (429 / 5xx / network errors)
|
|
289
|
+
* with exponential backoff. Pass `{}` for sensible defaults.
|
|
290
|
+
*/
|
|
291
|
+
retryConfig?: RetryConfig;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Fully resolved configuration where every optional field has been
|
|
295
|
+
* filled with its default value. This is the shape used internally
|
|
296
|
+
* by TenxyteClient after calling {@link resolveConfig}.
|
|
297
|
+
*/
|
|
298
|
+
interface ResolvedTenxyteConfig {
|
|
299
|
+
baseUrl: string;
|
|
300
|
+
headers: Record<string, string>;
|
|
301
|
+
storage: TenxyteStorage;
|
|
302
|
+
autoRefresh: boolean;
|
|
303
|
+
autoDeviceInfo: boolean;
|
|
304
|
+
timeoutMs: number | undefined;
|
|
305
|
+
onSessionExpired: (() => void) | undefined;
|
|
306
|
+
logger: TenxyteLogger;
|
|
307
|
+
logLevel: LogLevel;
|
|
308
|
+
deviceInfoOverride: CustomDeviceInfo | undefined;
|
|
309
|
+
retryConfig: RetryConfig | undefined;
|
|
34
310
|
}
|
|
311
|
+
/** Silent no-op logger used when the consumer does not provide one. */
|
|
312
|
+
declare const NOOP_LOGGER: TenxyteLogger;
|
|
313
|
+
/**
|
|
314
|
+
* Merges user-provided configuration with sensible defaults.
|
|
315
|
+
*
|
|
316
|
+
* Default values:
|
|
317
|
+
* - storage: new MemoryStorage()
|
|
318
|
+
* - autoRefresh: true
|
|
319
|
+
* - autoDeviceInfo: true
|
|
320
|
+
* - headers: {}
|
|
321
|
+
* - logLevel: 'silent'
|
|
322
|
+
* - logger: NOOP_LOGGER
|
|
323
|
+
*/
|
|
324
|
+
declare function resolveConfig(config: TenxyteClientConfig): ResolvedTenxyteConfig;
|
|
35
325
|
|
|
36
326
|
interface components {
|
|
37
327
|
schemas: {
|
|
@@ -957,7 +1247,7 @@ interface TenxyteError {
|
|
|
957
1247
|
details?: Record<string, string[]> | string;
|
|
958
1248
|
retry_after?: number;
|
|
959
1249
|
}
|
|
960
|
-
type TenxyteErrorCode = 'LOGIN_FAILED' | 'INVALID_CREDENTIALS' | 'ACCOUNT_LOCKED' | 'ACCOUNT_BANNED' | '2FA_REQUIRED' | 'ADMIN_2FA_SETUP_REQUIRED' | 'TOKEN_EXPIRED' | 'TOKEN_BLACKLISTED' | 'REFRESH_FAILED' | 'PERMISSION_DENIED' | 'SESSION_LIMIT_EXCEEDED' | 'DEVICE_LIMIT_EXCEEDED' | 'RATE_LIMITED' | 'INVALID_OTP' | 'OTP_EXPIRED' | 'INVALID_PROVIDER' | 'SOCIAL_AUTH_FAILED' | 'VALIDATION_URL_REQUIRED' | 'INVALID_TOKEN' | 'CONFIRMATION_REQUIRED' | 'PASSWORD_REQUIRED' | 'INVALID_PASSWORD' | 'INVALID_DEVICE_INFO' | 'ORG_NOT_FOUND' | 'NOT_ORG_MEMBER' | 'NOT_OWNER' | 'ALREADY_MEMBER' | 'MEMBER_LIMIT_EXCEEDED' | 'HAS_CHILDREN' | 'CIRCULAR_HIERARCHY' | 'LAST_OWNER_REQUIRED' | 'INVITATION_EXISTS' | 'INVALID_ROLE' | 'AGENT_NOT_FOUND' | 'AGENT_SUSPENDED' | 'AGENT_REVOKED' | 'AGENT_EXPIRED' | 'BUDGET_EXCEEDED' | 'RATE_LIMIT_EXCEEDED' | 'HEARTBEAT_MISSING' | 'AIRS_DISABLED';
|
|
1250
|
+
type TenxyteErrorCode = 'LOGIN_FAILED' | 'INVALID_CREDENTIALS' | 'ACCOUNT_LOCKED' | 'ACCOUNT_BANNED' | '2FA_REQUIRED' | 'ADMIN_2FA_SETUP_REQUIRED' | 'TOKEN_EXPIRED' | 'TOKEN_BLACKLISTED' | 'REFRESH_FAILED' | 'PERMISSION_DENIED' | 'SESSION_LIMIT_EXCEEDED' | 'DEVICE_LIMIT_EXCEEDED' | 'RATE_LIMITED' | 'INVALID_OTP' | 'OTP_EXPIRED' | 'INVALID_PROVIDER' | 'SOCIAL_AUTH_FAILED' | 'VALIDATION_URL_REQUIRED' | 'INVALID_TOKEN' | 'CONFIRMATION_REQUIRED' | 'PASSWORD_REQUIRED' | 'INVALID_PASSWORD' | 'INVALID_DEVICE_INFO' | 'ORG_NOT_FOUND' | 'NOT_ORG_MEMBER' | 'NOT_OWNER' | 'ALREADY_MEMBER' | 'MEMBER_LIMIT_EXCEEDED' | 'HAS_CHILDREN' | 'CIRCULAR_HIERARCHY' | 'LAST_OWNER_REQUIRED' | 'INVITATION_EXISTS' | 'INVALID_ROLE' | 'AGENT_NOT_FOUND' | 'AGENT_SUSPENDED' | 'AGENT_REVOKED' | 'AGENT_EXPIRED' | 'BUDGET_EXCEEDED' | 'RATE_LIMIT_EXCEEDED' | 'HEARTBEAT_MISSING' | 'AIRS_DISABLED' | 'TIMEOUT' | 'NETWORK_ERROR';
|
|
961
1251
|
/**
|
|
962
1252
|
* Organization Structure defining a B2B tenant or hierarchical unit.
|
|
963
1253
|
*/
|
|
@@ -1029,18 +1319,58 @@ interface LoginEmailOptions {
|
|
|
1029
1319
|
interface LoginPhoneOptions {
|
|
1030
1320
|
totp_code?: string;
|
|
1031
1321
|
}
|
|
1032
|
-
|
|
1322
|
+
interface RegisterRequest {
|
|
1323
|
+
/** Email address (required unless phone-based registration). */
|
|
1324
|
+
email?: string | null;
|
|
1325
|
+
/** International phone country code (e.g. "+33"). */
|
|
1326
|
+
phone_country_code?: string | null;
|
|
1327
|
+
/** Phone number without country code. */
|
|
1328
|
+
phone_number?: string | null;
|
|
1329
|
+
/** Account password. */
|
|
1330
|
+
password: string;
|
|
1331
|
+
/** User's first name. */
|
|
1332
|
+
first_name?: string;
|
|
1333
|
+
/** User's last name. */
|
|
1334
|
+
last_name?: string;
|
|
1335
|
+
/** Username (if enabled by the backend). */
|
|
1336
|
+
username?: string;
|
|
1337
|
+
/** If true, the user is logged in immediately after registration (JWT tokens returned). */
|
|
1338
|
+
login?: boolean;
|
|
1339
|
+
}
|
|
1033
1340
|
interface MagicLinkRequest {
|
|
1034
1341
|
email: string;
|
|
1342
|
+
/** URL used to build the verification link (required). */
|
|
1343
|
+
validation_url: string;
|
|
1035
1344
|
}
|
|
1036
1345
|
interface SocialLoginRequest {
|
|
1037
1346
|
access_token?: string;
|
|
1038
1347
|
authorization_code?: string;
|
|
1039
1348
|
id_token?: string;
|
|
1040
1349
|
}
|
|
1350
|
+
/** Response from the registration endpoint (may include tokens if `login: true`). */
|
|
1351
|
+
interface RegisterResponse {
|
|
1352
|
+
message?: string;
|
|
1353
|
+
user_id?: string;
|
|
1354
|
+
access_token?: string;
|
|
1355
|
+
refresh_token?: string;
|
|
1356
|
+
token_type?: string;
|
|
1357
|
+
expires_in?: number;
|
|
1358
|
+
}
|
|
1359
|
+
/** Response from the magic link request endpoint. */
|
|
1360
|
+
interface MagicLinkResponse {
|
|
1361
|
+
message?: string;
|
|
1362
|
+
expires_in_minutes?: number;
|
|
1363
|
+
/** Masked email for security. */
|
|
1364
|
+
sent_to?: string;
|
|
1365
|
+
}
|
|
1041
1366
|
declare class AuthModule {
|
|
1042
1367
|
private client;
|
|
1043
|
-
|
|
1368
|
+
private storage?;
|
|
1369
|
+
private onTokens?;
|
|
1370
|
+
private onLogout?;
|
|
1371
|
+
constructor(client: TenxyteHttpClient, storage?: TenxyteStorage | undefined, onTokens?: ((accessToken: string, refreshToken?: string) => void) | undefined, onLogout?: (() => void) | undefined);
|
|
1372
|
+
private clearTokens;
|
|
1373
|
+
private persistTokens;
|
|
1044
1374
|
/**
|
|
1045
1375
|
* Authenticate a user with their email and password.
|
|
1046
1376
|
* @param data - The login credentials and optional TOTP code if 2FA is required.
|
|
@@ -1059,7 +1389,7 @@ declare class AuthModule {
|
|
|
1059
1389
|
* @param data - The registration details (email, password, etc.).
|
|
1060
1390
|
* @returns The registered user data or a confirmation message.
|
|
1061
1391
|
*/
|
|
1062
|
-
register(data: RegisterRequest): Promise<
|
|
1392
|
+
register(data: RegisterRequest): Promise<RegisterResponse>;
|
|
1063
1393
|
/**
|
|
1064
1394
|
* Logout from the current session.
|
|
1065
1395
|
* Informs the backend to immediately revoke the specified refresh token.
|
|
@@ -1071,11 +1401,18 @@ declare class AuthModule {
|
|
|
1071
1401
|
* Revokes all refresh tokens currently assigned to the user.
|
|
1072
1402
|
*/
|
|
1073
1403
|
logoutAll(): Promise<void>;
|
|
1404
|
+
/**
|
|
1405
|
+
* Manually refresh the access token using a valid refresh token.
|
|
1406
|
+
* The refresh token is automatically rotated for improved security.
|
|
1407
|
+
* @param refreshToken - The current refresh token.
|
|
1408
|
+
* @returns A new token pair (access + rotated refresh).
|
|
1409
|
+
*/
|
|
1410
|
+
refreshToken(refreshToken: string): Promise<TokenPair>;
|
|
1074
1411
|
/**
|
|
1075
1412
|
* Request a Magic Link for passwordless sign-in.
|
|
1076
1413
|
* @param data - The email to send the logic link to.
|
|
1077
1414
|
*/
|
|
1078
|
-
requestMagicLink(data: MagicLinkRequest): Promise<
|
|
1415
|
+
requestMagicLink(data: MagicLinkRequest): Promise<MagicLinkResponse>;
|
|
1079
1416
|
/**
|
|
1080
1417
|
* Verifies a magic link token extracted from the URL.
|
|
1081
1418
|
* @param token - The cryptographic token received via email.
|
|
@@ -1387,6 +1724,16 @@ declare class RbacModule {
|
|
|
1387
1724
|
}): Promise<Permission>;
|
|
1388
1725
|
/** Destroys an atomic Permission permanently. Any Roles referencing it will be stripped of this grant automatically. */
|
|
1389
1726
|
deletePermission(permissionId: string): Promise<void>;
|
|
1727
|
+
/**
|
|
1728
|
+
* Retrieve all roles assigned to a specific user.
|
|
1729
|
+
* @param userId - The target user ID.
|
|
1730
|
+
*/
|
|
1731
|
+
getUserRoles(userId: string): Promise<Record<string, unknown>>;
|
|
1732
|
+
/**
|
|
1733
|
+
* Retrieve all permissions directly assigned to a specific user (excluding role-based permissions).
|
|
1734
|
+
* @param userId - The target user ID.
|
|
1735
|
+
*/
|
|
1736
|
+
getUserPermissions(userId: string): Promise<Record<string, unknown>>;
|
|
1390
1737
|
/**
|
|
1391
1738
|
* Attach a given Role globally to a user entity.
|
|
1392
1739
|
* Use sparingly if B2B multi-tenancy contexts are preferred.
|
|
@@ -1423,27 +1770,37 @@ declare class UserModule {
|
|
|
1423
1770
|
private client;
|
|
1424
1771
|
constructor(client: TenxyteHttpClient);
|
|
1425
1772
|
/** Retrieve your current comprehensive Profile metadata matching the active network bearer token. */
|
|
1426
|
-
getProfile(): Promise<
|
|
1773
|
+
getProfile(): Promise<TenxyteUser>;
|
|
1427
1774
|
/** Modify your active profile core details or injected application metadata. */
|
|
1428
|
-
updateProfile(data: UpdateProfileParams): Promise<
|
|
1775
|
+
updateProfile(data: UpdateProfileParams): Promise<TenxyteUser>;
|
|
1429
1776
|
/**
|
|
1430
1777
|
* Upload an avatar using FormData.
|
|
1431
1778
|
* Ensure the environment supports FormData (browser or Node.js v18+).
|
|
1432
1779
|
* @param formData The FormData object containing the 'avatar' field.
|
|
1433
1780
|
*/
|
|
1434
|
-
uploadAvatar(formData: FormData): Promise<
|
|
1781
|
+
uploadAvatar(formData: FormData): Promise<TenxyteUser>;
|
|
1435
1782
|
/**
|
|
1783
|
+
* @deprecated Use `gdpr.requestAccountDeletion()` instead. This proxy will be removed in a future release.
|
|
1436
1784
|
* Trigger self-deletion of an entire account data boundary.
|
|
1437
1785
|
* @param password - Requires the active system password as destructive proof of intent.
|
|
1438
1786
|
* @param otpCode - (Optional) If an OTP was queried prior to attempting account deletion.
|
|
1439
1787
|
*/
|
|
1440
1788
|
deleteAccount(password: string, otpCode?: string): Promise<void>;
|
|
1789
|
+
/**
|
|
1790
|
+
* Retrieve the roles and permissions of the currently authenticated user.
|
|
1791
|
+
* @returns An object containing `roles[]` and `permissions[]`.
|
|
1792
|
+
*/
|
|
1793
|
+
getMyRoles(): Promise<{
|
|
1794
|
+
roles: any[];
|
|
1795
|
+
permissions: any[];
|
|
1796
|
+
[key: string]: unknown;
|
|
1797
|
+
}>;
|
|
1441
1798
|
/** (Admin only) Lists users paginated matching criteria. */
|
|
1442
|
-
listUsers(params?: Record<string, any>): Promise<
|
|
1799
|
+
listUsers(params?: Record<string, any>): Promise<PaginatedResponse<TenxyteUser>>;
|
|
1443
1800
|
/** (Admin only) Gets deterministic data related to a remote unassociated user. */
|
|
1444
|
-
getUser(userId: string): Promise<
|
|
1801
|
+
getUser(userId: string): Promise<TenxyteUser>;
|
|
1445
1802
|
/** (Admin only) Modifies configuration/details or capacity bounds related to a remote unassociated user. */
|
|
1446
|
-
adminUpdateUser(userId: string, data: AdminUpdateUserParams): Promise<
|
|
1803
|
+
adminUpdateUser(userId: string, data: AdminUpdateUserParams): Promise<TenxyteUser>;
|
|
1447
1804
|
/** (Admin only) Force obliterate a User boundary. Can affect relational database stability if not bound carefully. */
|
|
1448
1805
|
adminDeleteUser(userId: string): Promise<void>;
|
|
1449
1806
|
/** (Admin only) Apply a permanent suspension / ban state globally on a user token footprint. */
|
|
@@ -1587,7 +1944,8 @@ declare class AiModule {
|
|
|
1587
1944
|
private client;
|
|
1588
1945
|
private agentToken;
|
|
1589
1946
|
private traceId;
|
|
1590
|
-
|
|
1947
|
+
private logger?;
|
|
1948
|
+
constructor(client: TenxyteHttpClient, logger?: TenxyteLogger);
|
|
1591
1949
|
/**
|
|
1592
1950
|
* Create an AgentToken granting specific deterministic limits to an AI Agent.
|
|
1593
1951
|
*/
|
|
@@ -1672,11 +2030,608 @@ declare class AiModule {
|
|
|
1672
2030
|
}>;
|
|
1673
2031
|
}
|
|
1674
2032
|
|
|
2033
|
+
/**
|
|
2034
|
+
* Represents an application (API client) registered in the Tenxyte platform.
|
|
2035
|
+
* The `access_secret` is never returned after creation — only `access_key` is visible.
|
|
2036
|
+
*/
|
|
2037
|
+
interface Application {
|
|
2038
|
+
id: string;
|
|
2039
|
+
name: string;
|
|
2040
|
+
description?: string;
|
|
2041
|
+
access_key: string;
|
|
2042
|
+
is_active: boolean;
|
|
2043
|
+
created_at: string;
|
|
2044
|
+
updated_at: string;
|
|
2045
|
+
}
|
|
2046
|
+
/**
|
|
2047
|
+
* Parameters accepted by `listApplications()`.
|
|
2048
|
+
*/
|
|
2049
|
+
interface ApplicationListParams {
|
|
2050
|
+
/** Search within name and description. */
|
|
2051
|
+
search?: string;
|
|
2052
|
+
/** Filter by active status. */
|
|
2053
|
+
is_active?: boolean;
|
|
2054
|
+
/** Sort field: `name`, `is_active`, `created_at`, `updated_at`. */
|
|
2055
|
+
ordering?: string;
|
|
2056
|
+
/** Page number (1-indexed). */
|
|
2057
|
+
page?: number;
|
|
2058
|
+
/** Items per page (max 100). */
|
|
2059
|
+
page_size?: number;
|
|
2060
|
+
}
|
|
2061
|
+
/**
|
|
2062
|
+
* Body accepted by `createApplication()`.
|
|
2063
|
+
*/
|
|
2064
|
+
interface ApplicationCreateData {
|
|
2065
|
+
name: string;
|
|
2066
|
+
description?: string;
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Response returned by `createApplication()`.
|
|
2070
|
+
* **`client_secret` is only shown once at creation time.**
|
|
2071
|
+
*/
|
|
2072
|
+
interface ApplicationCreateResponse {
|
|
2073
|
+
id: number;
|
|
2074
|
+
name: string;
|
|
2075
|
+
description?: string;
|
|
2076
|
+
client_id: string;
|
|
2077
|
+
client_secret: string;
|
|
2078
|
+
is_active: boolean;
|
|
2079
|
+
created_at: string;
|
|
2080
|
+
secret_rotation_warning?: string;
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Body accepted by `updateApplication()` (PUT — full replace).
|
|
2084
|
+
*/
|
|
2085
|
+
interface ApplicationUpdateData {
|
|
2086
|
+
name?: string;
|
|
2087
|
+
description?: string;
|
|
2088
|
+
is_active?: boolean;
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Response returned by `regenerateCredentials()`.
|
|
2092
|
+
* **`credentials.access_secret` is only shown once.**
|
|
2093
|
+
*/
|
|
2094
|
+
interface ApplicationRegenerateResponse {
|
|
2095
|
+
message?: string;
|
|
2096
|
+
application?: Record<string, unknown>;
|
|
2097
|
+
credentials?: {
|
|
2098
|
+
access_key?: string;
|
|
2099
|
+
access_secret?: string;
|
|
2100
|
+
};
|
|
2101
|
+
warning?: string;
|
|
2102
|
+
old_credentials_invalidated?: boolean;
|
|
2103
|
+
}
|
|
2104
|
+
declare class ApplicationsModule {
|
|
2105
|
+
private client;
|
|
2106
|
+
constructor(client: TenxyteHttpClient);
|
|
2107
|
+
/**
|
|
2108
|
+
* List all registered applications (paginated).
|
|
2109
|
+
* @param params - Optional filters: `search`, `is_active`, `ordering`, `page`, `page_size`.
|
|
2110
|
+
* @returns A paginated list of applications.
|
|
2111
|
+
*/
|
|
2112
|
+
listApplications(params?: ApplicationListParams): Promise<PaginatedResponse<Application>>;
|
|
2113
|
+
/**
|
|
2114
|
+
* Create a new application.
|
|
2115
|
+
* @param data - The application name and optional description.
|
|
2116
|
+
* @returns The created application including one-time `client_secret`.
|
|
2117
|
+
*/
|
|
2118
|
+
createApplication(data: ApplicationCreateData): Promise<ApplicationCreateResponse>;
|
|
2119
|
+
/**
|
|
2120
|
+
* Get a single application by its ID.
|
|
2121
|
+
* @param appId - The application ID.
|
|
2122
|
+
* @returns The application details (secret is never included).
|
|
2123
|
+
*/
|
|
2124
|
+
getApplication(appId: string): Promise<Application>;
|
|
2125
|
+
/**
|
|
2126
|
+
* Fully update an application (PUT — all fields replaced).
|
|
2127
|
+
* @param appId - The application ID.
|
|
2128
|
+
* @param data - The full updated application data.
|
|
2129
|
+
* @returns The updated application.
|
|
2130
|
+
*/
|
|
2131
|
+
updateApplication(appId: string, data: ApplicationUpdateData): Promise<Application>;
|
|
2132
|
+
/**
|
|
2133
|
+
* Partially update an application (PATCH — only provided fields are changed).
|
|
2134
|
+
* @param appId - The application ID.
|
|
2135
|
+
* @param data - The fields to update.
|
|
2136
|
+
* @returns The updated application.
|
|
2137
|
+
*/
|
|
2138
|
+
patchApplication(appId: string, data: Partial<ApplicationUpdateData>): Promise<Application>;
|
|
2139
|
+
/**
|
|
2140
|
+
* Delete an application permanently.
|
|
2141
|
+
* @param appId - The application ID.
|
|
2142
|
+
*/
|
|
2143
|
+
deleteApplication(appId: string): Promise<void>;
|
|
2144
|
+
/**
|
|
2145
|
+
* Regenerate credentials for an application.
|
|
2146
|
+
* **Warning:** Old credentials are immediately invalidated. The new secret is shown only once.
|
|
2147
|
+
* @param appId - The application ID.
|
|
2148
|
+
* @param confirmation - Must be the string `"REGENERATE"` to confirm the irreversible action.
|
|
2149
|
+
* @returns The new credentials (access_key + access_secret shown once).
|
|
2150
|
+
*/
|
|
2151
|
+
regenerateCredentials(appId: string, confirmation?: string): Promise<ApplicationRegenerateResponse>;
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
/**
|
|
2155
|
+
* All possible audit log action types.
|
|
2156
|
+
*/
|
|
2157
|
+
type AuditAction = 'login' | 'login_failed' | 'logout' | 'logout_all' | 'token_refresh' | 'password_change' | 'password_reset_request' | 'password_reset_complete' | '2fa_enabled' | '2fa_disabled' | '2fa_backup_used' | 'account_created' | 'account_locked' | 'account_unlocked' | 'email_verified' | 'phone_verified' | 'role_assigned' | 'role_removed' | 'permission_changed' | 'app_created' | 'app_credentials_regenerated' | 'account_deleted' | 'suspicious_activity' | 'session_limit_exceeded' | 'device_limit_exceeded' | 'new_device_detected' | 'agent_action';
|
|
2158
|
+
/** An audit log entry. */
|
|
2159
|
+
interface AuditLog {
|
|
2160
|
+
id: string;
|
|
2161
|
+
user?: number | null;
|
|
2162
|
+
user_email: string;
|
|
2163
|
+
action: AuditAction;
|
|
2164
|
+
ip_address?: string | null;
|
|
2165
|
+
user_agent?: string;
|
|
2166
|
+
application?: number | null;
|
|
2167
|
+
application_name: string;
|
|
2168
|
+
details?: unknown;
|
|
2169
|
+
created_at: string;
|
|
2170
|
+
}
|
|
2171
|
+
/** A login attempt record. */
|
|
2172
|
+
interface LoginAttempt {
|
|
2173
|
+
id: string;
|
|
2174
|
+
identifier: string;
|
|
2175
|
+
ip_address: string;
|
|
2176
|
+
application?: number | null;
|
|
2177
|
+
success?: boolean;
|
|
2178
|
+
failure_reason?: string;
|
|
2179
|
+
created_at: string;
|
|
2180
|
+
}
|
|
2181
|
+
/** A blacklisted (revoked) JWT token. */
|
|
2182
|
+
interface BlacklistedToken {
|
|
2183
|
+
id: string;
|
|
2184
|
+
token_jti: string;
|
|
2185
|
+
user?: number | null;
|
|
2186
|
+
user_email: string;
|
|
2187
|
+
blacklisted_at: string;
|
|
2188
|
+
expires_at: string;
|
|
2189
|
+
reason?: string;
|
|
2190
|
+
is_expired: string;
|
|
2191
|
+
}
|
|
2192
|
+
/** A refresh token as seen from the admin view (token value hidden). */
|
|
2193
|
+
interface RefreshTokenInfo {
|
|
2194
|
+
id: string;
|
|
2195
|
+
user: number;
|
|
2196
|
+
user_email: string;
|
|
2197
|
+
application: number;
|
|
2198
|
+
application_name: string;
|
|
2199
|
+
device_info?: string;
|
|
2200
|
+
ip_address?: string | null;
|
|
2201
|
+
is_revoked?: boolean;
|
|
2202
|
+
is_expired: string;
|
|
2203
|
+
expires_at: string;
|
|
2204
|
+
created_at: string;
|
|
2205
|
+
last_used_at: string;
|
|
2206
|
+
}
|
|
2207
|
+
/** Parameters accepted by `listAuditLogs()`. */
|
|
2208
|
+
interface AuditLogListParams {
|
|
2209
|
+
/** Filter by user ID. */
|
|
2210
|
+
user_id?: string;
|
|
2211
|
+
/** Filter by action (login, login_failed, password_change, etc.). */
|
|
2212
|
+
action?: string;
|
|
2213
|
+
/** Filter by IP address. */
|
|
2214
|
+
ip_address?: string;
|
|
2215
|
+
/** Filter by application ID. */
|
|
2216
|
+
application_id?: string;
|
|
2217
|
+
/** After date (YYYY-MM-DD). */
|
|
2218
|
+
date_from?: string;
|
|
2219
|
+
/** Before date (YYYY-MM-DD). */
|
|
2220
|
+
date_to?: string;
|
|
2221
|
+
/** Sort field: `created_at`, `action`, `user`. */
|
|
2222
|
+
ordering?: string;
|
|
2223
|
+
/** Page number (1-indexed). */
|
|
2224
|
+
page?: number;
|
|
2225
|
+
/** Items per page (max 100). */
|
|
2226
|
+
page_size?: number;
|
|
2227
|
+
}
|
|
2228
|
+
/** Parameters accepted by `listLoginAttempts()`. */
|
|
2229
|
+
interface LoginAttemptListParams {
|
|
2230
|
+
/** Filter by identifier (email/phone). */
|
|
2231
|
+
identifier?: string;
|
|
2232
|
+
/** Filter by IP address. */
|
|
2233
|
+
ip_address?: string;
|
|
2234
|
+
/** Filter by success/failure. */
|
|
2235
|
+
success?: boolean;
|
|
2236
|
+
/** After date (YYYY-MM-DD). */
|
|
2237
|
+
date_from?: string;
|
|
2238
|
+
/** Before date (YYYY-MM-DD). */
|
|
2239
|
+
date_to?: string;
|
|
2240
|
+
/** Sort field: `created_at`, `identifier`, `ip_address`. */
|
|
2241
|
+
ordering?: string;
|
|
2242
|
+
/** Page number (1-indexed). */
|
|
2243
|
+
page?: number;
|
|
2244
|
+
/** Items per page (max 100). */
|
|
2245
|
+
page_size?: number;
|
|
2246
|
+
}
|
|
2247
|
+
/** Parameters accepted by `listBlacklistedTokens()`. */
|
|
2248
|
+
interface BlacklistedTokenListParams {
|
|
2249
|
+
/** Filter by user ID. */
|
|
2250
|
+
user_id?: string;
|
|
2251
|
+
/** Filter by reason (`logout`, `password_change`, `security`). */
|
|
2252
|
+
reason?: string;
|
|
2253
|
+
/** Filter by expired (true/false). */
|
|
2254
|
+
expired?: boolean;
|
|
2255
|
+
/** Sort field: `blacklisted_at`, `expires_at`. */
|
|
2256
|
+
ordering?: string;
|
|
2257
|
+
/** Page number (1-indexed). */
|
|
2258
|
+
page?: number;
|
|
2259
|
+
/** Items per page (max 100). */
|
|
2260
|
+
page_size?: number;
|
|
2261
|
+
}
|
|
2262
|
+
/** Parameters accepted by `listRefreshTokens()`. */
|
|
2263
|
+
interface RefreshTokenListParams {
|
|
2264
|
+
/** Filter by user ID. */
|
|
2265
|
+
user_id?: string;
|
|
2266
|
+
/** Filter by application ID. */
|
|
2267
|
+
application_id?: string;
|
|
2268
|
+
/** Filter by revoked status. */
|
|
2269
|
+
is_revoked?: boolean;
|
|
2270
|
+
/** Filter by expired status. */
|
|
2271
|
+
expired?: boolean;
|
|
2272
|
+
/** Sort field: `created_at`, `expires_at`, `last_used_at`. */
|
|
2273
|
+
ordering?: string;
|
|
2274
|
+
/** Page number (1-indexed). */
|
|
2275
|
+
page?: number;
|
|
2276
|
+
/** Items per page (max 100). */
|
|
2277
|
+
page_size?: number;
|
|
2278
|
+
}
|
|
2279
|
+
declare class AdminModule {
|
|
2280
|
+
private client;
|
|
2281
|
+
constructor(client: TenxyteHttpClient);
|
|
2282
|
+
/**
|
|
2283
|
+
* List audit log entries (paginated).
|
|
2284
|
+
* @param params - Optional filters and pagination.
|
|
2285
|
+
*/
|
|
2286
|
+
listAuditLogs(params?: AuditLogListParams): Promise<PaginatedResponse<AuditLog>>;
|
|
2287
|
+
/**
|
|
2288
|
+
* Get a single audit log entry by ID.
|
|
2289
|
+
* @param logId - The audit log entry ID.
|
|
2290
|
+
*/
|
|
2291
|
+
getAuditLog(logId: string): Promise<AuditLog>;
|
|
2292
|
+
/**
|
|
2293
|
+
* List login attempt records (paginated).
|
|
2294
|
+
* @param params - Optional filters and pagination.
|
|
2295
|
+
*/
|
|
2296
|
+
listLoginAttempts(params?: LoginAttemptListParams): Promise<PaginatedResponse<LoginAttempt>>;
|
|
2297
|
+
/**
|
|
2298
|
+
* List blacklisted (revoked) JWT tokens (paginated).
|
|
2299
|
+
* @param params - Optional filters and pagination.
|
|
2300
|
+
*/
|
|
2301
|
+
listBlacklistedTokens(params?: BlacklistedTokenListParams): Promise<PaginatedResponse<BlacklistedToken>>;
|
|
2302
|
+
/**
|
|
2303
|
+
* Remove expired blacklisted tokens.
|
|
2304
|
+
* @returns A summary object with cleanup results.
|
|
2305
|
+
*/
|
|
2306
|
+
cleanupBlacklistedTokens(): Promise<Record<string, unknown>>;
|
|
2307
|
+
/**
|
|
2308
|
+
* List refresh tokens (admin view — token values are hidden).
|
|
2309
|
+
* @param params - Optional filters and pagination.
|
|
2310
|
+
*/
|
|
2311
|
+
listRefreshTokens(params?: RefreshTokenListParams): Promise<PaginatedResponse<RefreshTokenInfo>>;
|
|
2312
|
+
/**
|
|
2313
|
+
* Revoke a specific refresh token.
|
|
2314
|
+
* @param tokenId - The refresh token ID.
|
|
2315
|
+
* @returns The updated refresh token record.
|
|
2316
|
+
*/
|
|
2317
|
+
revokeRefreshToken(tokenId: string): Promise<RefreshTokenInfo>;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
/** Body accepted by `requestAccountDeletion()`. */
|
|
2321
|
+
interface AccountDeletionRequestData {
|
|
2322
|
+
/** Current password (required for confirmation). */
|
|
2323
|
+
password: string;
|
|
2324
|
+
/** 6-digit OTP code (required if 2FA is enabled). */
|
|
2325
|
+
otp_code?: string;
|
|
2326
|
+
/** Optional reason for the deletion request. */
|
|
2327
|
+
reason?: string;
|
|
2328
|
+
}
|
|
2329
|
+
/** Response returned by `requestAccountDeletion()`. */
|
|
2330
|
+
interface AccountDeletionRequestResponse {
|
|
2331
|
+
message?: string;
|
|
2332
|
+
deletion_request_id?: number;
|
|
2333
|
+
scheduled_deletion_date?: string;
|
|
2334
|
+
grace_period_days?: number;
|
|
2335
|
+
cancellation_token?: string;
|
|
2336
|
+
data_retention_policy?: {
|
|
2337
|
+
anonymization_after?: string;
|
|
2338
|
+
final_deletion_after?: string;
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
/** Response returned by `confirmAccountDeletion()`. */
|
|
2342
|
+
interface AccountDeletionConfirmResponse {
|
|
2343
|
+
message?: string;
|
|
2344
|
+
deletion_confirmed?: boolean;
|
|
2345
|
+
grace_period_ends?: string;
|
|
2346
|
+
cancellation_instructions?: string;
|
|
2347
|
+
}
|
|
2348
|
+
/** Response returned by `cancelAccountDeletion()`. */
|
|
2349
|
+
interface AccountDeletionCancelResponse {
|
|
2350
|
+
message?: string;
|
|
2351
|
+
deletion_cancelled?: boolean;
|
|
2352
|
+
account_reactivated?: boolean;
|
|
2353
|
+
cancellation_time?: string;
|
|
2354
|
+
security_note?: string;
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* Deletion status for the current user.
|
|
2358
|
+
* The shape is not strictly defined by the API schema — it returns a generic object.
|
|
2359
|
+
*/
|
|
2360
|
+
type DeletionStatus = Record<string, unknown>;
|
|
2361
|
+
/** Response returned by `exportUserData()`. */
|
|
2362
|
+
interface UserDataExport {
|
|
2363
|
+
user_info?: Record<string, unknown>;
|
|
2364
|
+
roles?: unknown[];
|
|
2365
|
+
permissions?: unknown[];
|
|
2366
|
+
applications?: unknown[];
|
|
2367
|
+
audit_logs?: unknown[];
|
|
2368
|
+
export_metadata?: Record<string, unknown>;
|
|
2369
|
+
}
|
|
2370
|
+
/** Possible statuses for a deletion request. */
|
|
2371
|
+
type DeletionRequestStatus = 'pending' | 'confirmation_sent' | 'confirmed' | 'completed' | 'cancelled';
|
|
2372
|
+
/** A GDPR account deletion request (admin view). */
|
|
2373
|
+
interface DeletionRequest {
|
|
2374
|
+
id: string;
|
|
2375
|
+
user: number;
|
|
2376
|
+
user_email: string;
|
|
2377
|
+
status?: DeletionRequestStatus;
|
|
2378
|
+
requested_at: string;
|
|
2379
|
+
confirmed_at?: string | null;
|
|
2380
|
+
grace_period_ends_at?: string | null;
|
|
2381
|
+
completed_at?: string | null;
|
|
2382
|
+
ip_address?: string | null;
|
|
2383
|
+
reason?: string;
|
|
2384
|
+
admin_notes?: string;
|
|
2385
|
+
processed_by?: number | null;
|
|
2386
|
+
processed_by_email: string;
|
|
2387
|
+
is_grace_period_expired: string;
|
|
2388
|
+
}
|
|
2389
|
+
/** Parameters accepted by `listDeletionRequests()`. */
|
|
2390
|
+
interface DeletionRequestListParams {
|
|
2391
|
+
/** Filter by user ID. */
|
|
2392
|
+
user_id?: number;
|
|
2393
|
+
/** Filter by request status. */
|
|
2394
|
+
status?: DeletionRequestStatus;
|
|
2395
|
+
/** After date (YYYY-MM-DD). */
|
|
2396
|
+
date_from?: string;
|
|
2397
|
+
/** Before date (YYYY-MM-DD). */
|
|
2398
|
+
date_to?: string;
|
|
2399
|
+
/** Filter requests whose grace period expires within 7 days. */
|
|
2400
|
+
grace_period_expiring?: boolean;
|
|
2401
|
+
/** Sort field: `requested_at`, `confirmed_at`, `grace_period_ends_at`, `user__email`. */
|
|
2402
|
+
ordering?: string;
|
|
2403
|
+
/** Page number (1-indexed). */
|
|
2404
|
+
page?: number;
|
|
2405
|
+
/** Items per page (max 100). */
|
|
2406
|
+
page_size?: number;
|
|
2407
|
+
}
|
|
2408
|
+
/** Body accepted by `processDeletionRequest()`. */
|
|
2409
|
+
interface ProcessDeletionRequestData {
|
|
2410
|
+
/** Must be `"PERMANENTLY DELETE"` to confirm the irreversible action. */
|
|
2411
|
+
confirmation: string;
|
|
2412
|
+
/** Optional admin notes. */
|
|
2413
|
+
admin_notes?: string;
|
|
2414
|
+
}
|
|
2415
|
+
/** Response returned by `processDeletionRequest()`. */
|
|
2416
|
+
interface ProcessDeletionResponse {
|
|
2417
|
+
message?: string;
|
|
2418
|
+
deletion_completed?: boolean;
|
|
2419
|
+
processed_at?: string;
|
|
2420
|
+
data_anonymized?: boolean;
|
|
2421
|
+
audit_log_id?: number;
|
|
2422
|
+
user_notified?: boolean;
|
|
2423
|
+
}
|
|
2424
|
+
/** Response returned by `processExpiredDeletions()`. */
|
|
2425
|
+
interface ProcessExpiredDeletionsResponse {
|
|
2426
|
+
message?: string;
|
|
2427
|
+
processed_count?: number;
|
|
2428
|
+
failed_count?: number;
|
|
2429
|
+
skipped_count?: number;
|
|
2430
|
+
processing_time?: number;
|
|
2431
|
+
details?: {
|
|
2432
|
+
request_id?: number;
|
|
2433
|
+
user_email?: string;
|
|
2434
|
+
status?: string;
|
|
2435
|
+
grace_period_expired?: string;
|
|
2436
|
+
}[];
|
|
2437
|
+
}
|
|
2438
|
+
declare class GdprModule {
|
|
2439
|
+
private client;
|
|
2440
|
+
constructor(client: TenxyteHttpClient);
|
|
2441
|
+
/**
|
|
2442
|
+
* Request account deletion (GDPR-compliant).
|
|
2443
|
+
* Initiates a 30-day grace period during which the user can cancel.
|
|
2444
|
+
* @param data - Password (+ optional OTP code and reason).
|
|
2445
|
+
*/
|
|
2446
|
+
requestAccountDeletion(data: AccountDeletionRequestData): Promise<AccountDeletionRequestResponse>;
|
|
2447
|
+
/**
|
|
2448
|
+
* Confirm the account deletion using the token received by email.
|
|
2449
|
+
* The token is valid for 24 hours. After confirmation the account enters the 30-day grace period.
|
|
2450
|
+
* @param token - The confirmation token from the email.
|
|
2451
|
+
*/
|
|
2452
|
+
confirmAccountDeletion(token: string): Promise<AccountDeletionConfirmResponse>;
|
|
2453
|
+
/**
|
|
2454
|
+
* Cancel a pending account deletion during the grace period.
|
|
2455
|
+
* The account is immediately reactivated.
|
|
2456
|
+
* @param password - The current password for security.
|
|
2457
|
+
*/
|
|
2458
|
+
cancelAccountDeletion(password: string): Promise<AccountDeletionCancelResponse>;
|
|
2459
|
+
/**
|
|
2460
|
+
* Get the deletion status for the current user.
|
|
2461
|
+
* Includes pending, confirmed, or cancelled requests.
|
|
2462
|
+
*/
|
|
2463
|
+
getAccountDeletionStatus(): Promise<DeletionStatus>;
|
|
2464
|
+
/**
|
|
2465
|
+
* Export all personal data (GDPR right to data portability).
|
|
2466
|
+
* @param password - The current password for security.
|
|
2467
|
+
*/
|
|
2468
|
+
exportUserData(password: string): Promise<UserDataExport>;
|
|
2469
|
+
/**
|
|
2470
|
+
* List deletion requests (admin, paginated).
|
|
2471
|
+
* @param params - Optional filters and pagination.
|
|
2472
|
+
*/
|
|
2473
|
+
listDeletionRequests(params?: DeletionRequestListParams): Promise<PaginatedResponse<DeletionRequest>>;
|
|
2474
|
+
/**
|
|
2475
|
+
* Get a single deletion request by ID.
|
|
2476
|
+
* @param requestId - The deletion request ID.
|
|
2477
|
+
*/
|
|
2478
|
+
getDeletionRequest(requestId: string): Promise<DeletionRequest>;
|
|
2479
|
+
/**
|
|
2480
|
+
* Process (execute) a confirmed deletion request.
|
|
2481
|
+
* **WARNING:** This is irreversible and permanently destroys all user data.
|
|
2482
|
+
* @param requestId - The deletion request ID.
|
|
2483
|
+
* @param data - Must include `{ confirmation: "PERMANENTLY DELETE" }`.
|
|
2484
|
+
*/
|
|
2485
|
+
processDeletionRequest(requestId: string | number, data: ProcessDeletionRequestData): Promise<ProcessDeletionResponse>;
|
|
2486
|
+
/**
|
|
2487
|
+
* Batch-process all confirmed deletion requests whose 30-day grace period has expired.
|
|
2488
|
+
* Typically run by a daily cron job.
|
|
2489
|
+
*/
|
|
2490
|
+
processExpiredDeletions(): Promise<ProcessExpiredDeletionsResponse>;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
/** Parameters accepted by `getStats()`. */
|
|
2494
|
+
interface DashboardStatsParams {
|
|
2495
|
+
/** Analysis period (default: `"7d"`). */
|
|
2496
|
+
period?: '7d' | '30d' | '90d';
|
|
2497
|
+
/** Include comparison with previous period. */
|
|
2498
|
+
compare?: boolean;
|
|
2499
|
+
}
|
|
2500
|
+
/** Global dashboard statistics returned by `getStats()`. */
|
|
2501
|
+
interface DashboardStats {
|
|
2502
|
+
summary?: {
|
|
2503
|
+
total_users?: number;
|
|
2504
|
+
active_users?: number;
|
|
2505
|
+
total_organizations?: number;
|
|
2506
|
+
total_applications?: number;
|
|
2507
|
+
active_sessions?: number;
|
|
2508
|
+
pending_deletions?: number;
|
|
2509
|
+
};
|
|
2510
|
+
trends?: {
|
|
2511
|
+
user_growth?: number;
|
|
2512
|
+
login_success_rate?: number;
|
|
2513
|
+
application_usage?: number;
|
|
2514
|
+
security_incidents?: number;
|
|
2515
|
+
};
|
|
2516
|
+
organization_context?: {
|
|
2517
|
+
current_org?: Record<string, unknown> | null;
|
|
2518
|
+
user_role?: string;
|
|
2519
|
+
accessible_orgs?: number;
|
|
2520
|
+
org_specific_stats?: Record<string, unknown>;
|
|
2521
|
+
};
|
|
2522
|
+
quick_actions?: {
|
|
2523
|
+
action?: string;
|
|
2524
|
+
count?: number;
|
|
2525
|
+
priority?: string;
|
|
2526
|
+
}[];
|
|
2527
|
+
charts?: {
|
|
2528
|
+
daily_logins?: unknown[];
|
|
2529
|
+
user_registrations?: unknown[];
|
|
2530
|
+
security_events?: unknown[];
|
|
2531
|
+
};
|
|
2532
|
+
}
|
|
2533
|
+
/**
|
|
2534
|
+
* Authentication statistics returned by `getAuthStats()`.
|
|
2535
|
+
* Login stats, methods, registrations, tokens, top failure reasons, 7-day graphs.
|
|
2536
|
+
*/
|
|
2537
|
+
type AuthStats = Record<string, unknown>;
|
|
2538
|
+
/**
|
|
2539
|
+
* Security statistics returned by `getSecurityStats()`.
|
|
2540
|
+
* Audit summary, blacklisted tokens, suspicious activity, 2FA adoption.
|
|
2541
|
+
*/
|
|
2542
|
+
type SecurityStats = Record<string, unknown>;
|
|
2543
|
+
/**
|
|
2544
|
+
* GDPR statistics returned by `getGdprStats()`.
|
|
2545
|
+
* Deletion requests by status, data exports.
|
|
2546
|
+
*/
|
|
2547
|
+
type GdprStats = Record<string, unknown>;
|
|
2548
|
+
/**
|
|
2549
|
+
* Organization statistics returned by `getOrganizationStats()`.
|
|
2550
|
+
* Organizations, members, roles, top organizations.
|
|
2551
|
+
*/
|
|
2552
|
+
type OrgStats = Record<string, unknown>;
|
|
2553
|
+
declare class DashboardModule {
|
|
2554
|
+
private client;
|
|
2555
|
+
constructor(client: TenxyteHttpClient);
|
|
2556
|
+
/**
|
|
2557
|
+
* Get global cross-module dashboard statistics.
|
|
2558
|
+
* Data varies based on the organizational context (`X-Org-Slug`) and permissions.
|
|
2559
|
+
* Covers users, authentication, applications, security, and GDPR metrics.
|
|
2560
|
+
* Charts span the last 7 days with previous-period comparisons.
|
|
2561
|
+
* @param params - Optional period and comparison flag.
|
|
2562
|
+
*/
|
|
2563
|
+
getStats(params?: DashboardStatsParams): Promise<DashboardStats>;
|
|
2564
|
+
/**
|
|
2565
|
+
* Get authentication-specific statistics.
|
|
2566
|
+
* Includes login stats, methods breakdown, registrations, tokens, top failure reasons, and 7-day graphs.
|
|
2567
|
+
*/
|
|
2568
|
+
getAuthStats(): Promise<AuthStats>;
|
|
2569
|
+
/**
|
|
2570
|
+
* Get security-specific statistics.
|
|
2571
|
+
* Includes audit summary, blacklisted tokens, suspicious activity, and 2FA adoption.
|
|
2572
|
+
*/
|
|
2573
|
+
getSecurityStats(): Promise<SecurityStats>;
|
|
2574
|
+
/**
|
|
2575
|
+
* Get GDPR-specific statistics.
|
|
2576
|
+
* Includes deletion requests by status and data export metrics.
|
|
2577
|
+
*/
|
|
2578
|
+
getGdprStats(): Promise<GdprStats>;
|
|
2579
|
+
/**
|
|
2580
|
+
* Get organization-specific statistics.
|
|
2581
|
+
* Includes organizations, members, roles, and top organizations.
|
|
2582
|
+
*/
|
|
2583
|
+
getOrganizationStats(): Promise<OrgStats>;
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
interface DecodedTenxyteToken {
|
|
2587
|
+
exp?: number;
|
|
2588
|
+
iat?: number;
|
|
2589
|
+
sub?: string;
|
|
2590
|
+
roles?: string[];
|
|
2591
|
+
permissions?: string[];
|
|
2592
|
+
[key: string]: any;
|
|
2593
|
+
}
|
|
2594
|
+
/**
|
|
2595
|
+
* Decodes the payload of a JWT without verifying the signature.
|
|
2596
|
+
* Suitable for client-side routing and UI state.
|
|
2597
|
+
*/
|
|
2598
|
+
declare function decodeJwt(token: string): DecodedTenxyteToken | null;
|
|
2599
|
+
|
|
2600
|
+
/**
|
|
2601
|
+
* Map of all SDK events and their associated payload types.
|
|
2602
|
+
*/
|
|
2603
|
+
interface TenxyteEventMap {
|
|
2604
|
+
/** Fired when the active session can no longer be recovered (refresh token expired/revoked). */
|
|
2605
|
+
'session:expired': void;
|
|
2606
|
+
/** Fired after a successful silent token refresh. Payload is the new access token. */
|
|
2607
|
+
'token:refreshed': {
|
|
2608
|
+
accessToken: string;
|
|
2609
|
+
};
|
|
2610
|
+
/** Fired after tokens are persisted to storage (login, register, refresh). */
|
|
2611
|
+
'token:stored': {
|
|
2612
|
+
accessToken: string;
|
|
2613
|
+
refreshToken?: string;
|
|
2614
|
+
};
|
|
2615
|
+
/** Fired when an AI agent action requires human-in-the-loop approval (HTTP 202). */
|
|
2616
|
+
'agent:awaiting_approval': {
|
|
2617
|
+
action: unknown;
|
|
2618
|
+
};
|
|
2619
|
+
/** Fired on unrecoverable SDK errors that are not tied to a specific call. */
|
|
2620
|
+
'error': {
|
|
2621
|
+
error: unknown;
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
1675
2624
|
/**
|
|
1676
2625
|
* The primary entry point for the Tenxyte SDK.
|
|
1677
2626
|
* Groups together logic for authentication, security, organization switching, and AI control.
|
|
1678
2627
|
*/
|
|
1679
2628
|
declare class TenxyteClient {
|
|
2629
|
+
/** Fully resolved configuration (all defaults applied). */
|
|
2630
|
+
readonly config: ResolvedTenxyteConfig;
|
|
2631
|
+
/** Persistent token storage back-end (defaults to MemoryStorage). */
|
|
2632
|
+
readonly storage: TenxyteStorage;
|
|
2633
|
+
/** Shared mutable context used by interceptors (org slug, agent trace ID). */
|
|
2634
|
+
readonly context: TenxyteContext;
|
|
1680
2635
|
/** The core HTTP wrapper handling network interception and parsing */
|
|
1681
2636
|
http: TenxyteHttpClient;
|
|
1682
2637
|
/** Authentication module (Login, Signup, Magic link, session handling) */
|
|
@@ -1691,8 +2646,22 @@ declare class TenxyteClient {
|
|
|
1691
2646
|
b2b: B2bModule;
|
|
1692
2647
|
/** AIRS - AI Responsibility & Security module (Agent tokens, Circuit breakers, HITL) */
|
|
1693
2648
|
ai: AiModule;
|
|
2649
|
+
/** Applications module (API client CRUD, credential management) */
|
|
2650
|
+
applications: ApplicationsModule;
|
|
2651
|
+
/** Admin module (audit logs, login attempts, blacklisted tokens, refresh tokens) */
|
|
2652
|
+
admin: AdminModule;
|
|
2653
|
+
/** GDPR module (account deletion, data export, deletion request management) */
|
|
2654
|
+
gdpr: GdprModule;
|
|
2655
|
+
/** Dashboard module (global, auth, security, GDPR, organization statistics) */
|
|
2656
|
+
dashboard: DashboardModule;
|
|
2657
|
+
/** Internal event emitter used via composition. */
|
|
2658
|
+
private emitter;
|
|
1694
2659
|
/**
|
|
1695
2660
|
* Initializes the SDK with connection details for your Tenxyte-powered API.
|
|
2661
|
+
*
|
|
2662
|
+
* Accepts the full TenxyteClientConfig. Minimal usage with just { baseUrl }
|
|
2663
|
+
* is still supported for backward compatibility.
|
|
2664
|
+
*
|
|
1696
2665
|
* @param options Configuration options including `baseUrl` and custom headers like `X-Access-Key`
|
|
1697
2666
|
*
|
|
1698
2667
|
* @example
|
|
@@ -1703,7 +2672,96 @@ declare class TenxyteClient {
|
|
|
1703
2672
|
* });
|
|
1704
2673
|
* ```
|
|
1705
2674
|
*/
|
|
1706
|
-
constructor(options:
|
|
2675
|
+
constructor(options: TenxyteClientConfig);
|
|
2676
|
+
/** Subscribe to an SDK event. Returns an unsubscribe function. */
|
|
2677
|
+
on<K extends keyof TenxyteEventMap>(event: K, callback: (payload: TenxyteEventMap[K]) => void): () => void;
|
|
2678
|
+
/** Subscribe to an SDK event exactly once. Returns an unsubscribe function. */
|
|
2679
|
+
once<K extends keyof TenxyteEventMap>(event: K, callback: (payload: TenxyteEventMap[K]) => void): () => void;
|
|
2680
|
+
/** Unsubscribe a previously registered callback from an SDK event. */
|
|
2681
|
+
off<K extends keyof TenxyteEventMap>(event: K, callback: (payload: TenxyteEventMap[K]) => void): void;
|
|
2682
|
+
/** Emit an SDK event (internal use). */
|
|
2683
|
+
emit<K extends keyof TenxyteEventMap>(event: K, payload: TenxyteEventMap[K]): void;
|
|
2684
|
+
/**
|
|
2685
|
+
* Check whether a valid (non-expired) access token exists in storage.
|
|
2686
|
+
* Performs a synchronous JWT expiry check — no network call.
|
|
2687
|
+
*/
|
|
2688
|
+
isAuthenticated(): Promise<boolean>;
|
|
2689
|
+
/**
|
|
2690
|
+
* Return the current access token from storage, or `null` if absent.
|
|
2691
|
+
*/
|
|
2692
|
+
getAccessToken(): Promise<string | null>;
|
|
2693
|
+
/**
|
|
2694
|
+
* Decode the current access token and return the JWT payload.
|
|
2695
|
+
* Returns `null` if no token is stored or if decoding fails.
|
|
2696
|
+
* No network call is made — this reads from the cached JWT.
|
|
2697
|
+
*/
|
|
2698
|
+
getCurrentUser(): Promise<DecodedTenxyteToken | null>;
|
|
2699
|
+
/**
|
|
2700
|
+
* Check whether the stored access token is expired without making a network call.
|
|
2701
|
+
* Returns `true` if expired or if no token is present.
|
|
2702
|
+
*/
|
|
2703
|
+
isTokenExpired(): Promise<boolean>;
|
|
2704
|
+
/** Synchronous helper: checks JWT `exp` claim against current time. */
|
|
2705
|
+
private isTokenExpiredSync;
|
|
2706
|
+
/**
|
|
2707
|
+
* Returns a synchronous snapshot of the SDK state.
|
|
2708
|
+
* Designed for consumption by framework wrappers (React, Vue, etc.).
|
|
2709
|
+
* Note: This is async because storage access may be async.
|
|
2710
|
+
*/
|
|
2711
|
+
getState(): Promise<TenxyteClientState>;
|
|
2712
|
+
}
|
|
2713
|
+
/**
|
|
2714
|
+
* Snapshot of the SDK state, intended for framework wrappers.
|
|
2715
|
+
*
|
|
2716
|
+
* **Event contract for reactive bindings:**
|
|
2717
|
+
* - `token:stored` → re-read state (login, register, refresh succeeded)
|
|
2718
|
+
* - `token:refreshed` → access token was silently rotated
|
|
2719
|
+
* - `session:expired` → clear authenticated state
|
|
2720
|
+
* - `agent:awaiting_approval` → an AI action needs human confirmation
|
|
2721
|
+
* - `error` → unrecoverable SDK error
|
|
2722
|
+
*/
|
|
2723
|
+
interface TenxyteClientState {
|
|
2724
|
+
/** Whether the user has a valid, non-expired access token. */
|
|
2725
|
+
isAuthenticated: boolean;
|
|
2726
|
+
/** Decoded JWT payload of the current access token, or `null`. */
|
|
2727
|
+
user: DecodedTenxyteToken | null;
|
|
2728
|
+
/** Raw access token string, or `null`. */
|
|
2729
|
+
accessToken: string | null;
|
|
2730
|
+
/** Currently active organization slug, or `null`. */
|
|
2731
|
+
activeOrg: string | null;
|
|
2732
|
+
/** Whether the SDK is operating in AI Agent mode. */
|
|
2733
|
+
isAgentMode: boolean;
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
/**
|
|
2737
|
+
* Lightweight EventEmitter for TenxyteClient.
|
|
2738
|
+
* Provides `.on`, `.once`, `.off`, and `.emit`.
|
|
2739
|
+
*/
|
|
2740
|
+
declare class EventEmitter<Events extends Record<string, any>> {
|
|
2741
|
+
private events;
|
|
2742
|
+
constructor();
|
|
2743
|
+
/**
|
|
2744
|
+
* Subscribe to an event.
|
|
2745
|
+
* @param event The event name
|
|
2746
|
+
* @param callback The callback function
|
|
2747
|
+
* @returns Unsubscribe function
|
|
2748
|
+
*/
|
|
2749
|
+
on<K extends keyof Events>(event: K, callback: (payload: Events[K]) => void): () => void;
|
|
2750
|
+
/**
|
|
2751
|
+
* Unsubscribe from an event.
|
|
2752
|
+
* @param event The event name
|
|
2753
|
+
* @param callback The exact callback function that was passed to .on()
|
|
2754
|
+
*/
|
|
2755
|
+
off<K extends keyof Events>(event: K, callback: (payload: Events[K]) => void): void;
|
|
2756
|
+
/**
|
|
2757
|
+
* Subscribe to an event exactly once.
|
|
2758
|
+
*/
|
|
2759
|
+
once<K extends keyof Events>(event: K, callback: (payload: Events[K]) => void): () => void;
|
|
2760
|
+
/**
|
|
2761
|
+
* Emit an event internally.
|
|
2762
|
+
*/
|
|
2763
|
+
emit<K extends keyof Events>(event: K, payload: Events[K]): void;
|
|
2764
|
+
removeAllListeners(): void;
|
|
1707
2765
|
}
|
|
1708
2766
|
|
|
1709
|
-
export { type AdminUpdateUserParams, type AgentPendingAction, type AgentTokenSummary, AuthModule, type GeneratedSchema, type HttpClientOptions, type LoginEmailOptions, type LoginPhoneOptions, type MagicLinkRequest, type Organization, type PaginatedResponse, type Permission, RbacModule, type RegisterRequest, type RequestConfig, type Role, SecurityModule, type SocialLoginRequest, TenxyteClient, type TenxyteError, type TenxyteErrorCode, TenxyteHttpClient, type TenxyteUser, type TokenPair, type UpdateProfileParams, UserModule };
|
|
2767
|
+
export { type AccountDeletionCancelResponse, type AccountDeletionConfirmResponse, type AccountDeletionRequestData, type AccountDeletionRequestResponse, AdminModule, type AdminUpdateUserParams, type AgentPendingAction, type AgentTokenSummary, AiModule, type Application, type ApplicationCreateData, type ApplicationCreateResponse, type ApplicationListParams, type ApplicationRegenerateResponse, type ApplicationUpdateData, ApplicationsModule, type AuditAction, type AuditLog, type AuditLogListParams, AuthModule, type AuthStats, B2bModule, type BlacklistedToken, type BlacklistedTokenListParams, CookieStorage, type CustomDeviceInfo, DashboardModule, type DashboardStats, type DashboardStatsParams, type DecodedTenxyteToken, type DeletionRequest, type DeletionRequestListParams, type DeletionRequestStatus, type DeletionStatus, EventEmitter, GdprModule, type GdprStats, type GeneratedSchema, type HttpClientOptions, LocalStorage, type LogLevel, type LoginAttempt, type LoginAttemptListParams, type LoginEmailOptions, type LoginPhoneOptions, type MagicLinkRequest, type MagicLinkResponse, MemoryStorage, NOOP_LOGGER, type OrgMembership, type OrgStats, type OrgTreeNode, type Organization, type PaginatedResponse, type Permission, type ProcessDeletionRequestData, type ProcessDeletionResponse, type ProcessExpiredDeletionsResponse, RbacModule, type RefreshTokenInfo, type RefreshTokenListParams, type RegisterRequest, type RegisterResponse, type RequestConfig, type ResolvedTenxyteConfig, type RetryConfig, type Role, SDK_VERSION, SecurityModule, type SecurityStats, type SocialLoginRequest, TenxyteClient, type TenxyteClientConfig, type TenxyteClientState, type TenxyteContext, type TenxyteError, type TenxyteErrorCode, type TenxyteEventMap, TenxyteHttpClient, type TenxyteLogger, type TenxyteStorage, type TenxyteUser, type TokenPair, type UpdateProfileParams, type UserDataExport, UserModule, buildDeviceInfo, createAuthInterceptor, createDeviceInfoInterceptor, createRefreshInterceptor, createRetryInterceptor, decodeJwt, resolveConfig };
|