win-portal-auth-sdk 1.2.1 → 1.3.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/README.md +102 -9
  2. package/dist/client/api/auth.api.d.ts +25 -1
  3. package/dist/client/api/auth.api.d.ts.map +1 -1
  4. package/dist/client/api/auth.api.js +30 -1
  5. package/dist/client/api/files.api.d.ts +0 -1
  6. package/dist/client/api/files.api.d.ts.map +1 -1
  7. package/dist/client/api/index.d.ts +2 -0
  8. package/dist/client/api/index.d.ts.map +1 -1
  9. package/dist/client/api/index.js +3 -1
  10. package/dist/client/api/license.api.d.ts +74 -0
  11. package/dist/client/api/license.api.d.ts.map +1 -0
  12. package/dist/client/api/license.api.js +50 -0
  13. package/dist/client/api/system-config.api.d.ts +11 -1
  14. package/dist/client/api/system-config.api.d.ts.map +1 -1
  15. package/dist/client/api/system-config.api.js +21 -0
  16. package/dist/client/auth-client.d.ts +278 -1
  17. package/dist/client/auth-client.d.ts.map +1 -1
  18. package/dist/client/auth-client.js +705 -10
  19. package/dist/client/index.d.ts +2 -0
  20. package/dist/client/index.d.ts.map +1 -1
  21. package/dist/client/index.js +15 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +5 -0
  25. package/dist/types/auth.types.d.ts +9 -0
  26. package/dist/types/auth.types.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +18 -0
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/system-config.types.d.ts +37 -0
  30. package/dist/types/system-config.types.d.ts.map +1 -1
  31. package/dist/utils/logger.d.ts +23 -0
  32. package/dist/utils/logger.d.ts.map +1 -0
  33. package/dist/utils/logger.js +49 -0
  34. package/dist/utils/token-utils.d.ts +60 -0
  35. package/dist/utils/token-utils.d.ts.map +1 -0
  36. package/dist/utils/token-utils.js +116 -0
  37. package/package.json +1 -2
  38. package/TYPE_SAFETY.md +0 -97
package/README.md CHANGED
@@ -129,6 +129,15 @@ await authClient.user.delete(userId);
129
129
  const health = await authClient.health.check();
130
130
  const isValid = await authClient.health.validateApiKey();
131
131
 
132
+ // License Information
133
+ const licenseResponse = await authClient.license.getInfo();
134
+ if (licenseResponse.data.success && licenseResponse.data.data) {
135
+ const license = licenseResponse.data.data;
136
+ console.log('License:', license.name);
137
+ console.log('Expires:', license.expires_at);
138
+ console.log('Modules:', license.module_codes);
139
+ }
140
+
132
141
  // LINE Messaging
133
142
  await authClient.line.sendTextMessage({
134
143
  userId: 'user-123',
@@ -244,7 +253,7 @@ export class UsersController {
244
253
 
245
254
  For complete documentation, examples, and advanced usage:
246
255
 
247
- **[View Full Middleware Guide →](./docs/MIDDLEWARE_USAGE.md)**
256
+ **[View Full Middleware Guide →](./docs/middleware/usage.md)**
248
257
 
249
258
  Includes:
250
259
 
@@ -296,9 +305,27 @@ const client = new AuthClient({
296
305
  baseURL?: string; // Optional: Base URL for requests
297
306
  apiKeyHeader?: string; // Optional: Custom header name (default: 'X-API-Key')
298
307
  timeout?: number; // Optional: Request timeout (default: 30000ms)
308
+ advanced?: { // Optional: Advanced configuration
309
+ activityThrottleMs?: number; // Activity handler throttle (default: 1000ms)
310
+ refreshTimeoutMs?: number; // Refresh token timeout (default: 5000ms)
311
+ }
299
312
  })
300
313
  ```
301
314
 
315
+ **Advanced Configuration:**
316
+
317
+ ```typescript
318
+ // ปรับแต่ง performance และ timeout settings
319
+ const client = new AuthClient({
320
+ apiKey: 'your-api-key',
321
+ baseURL: 'https://api.example.com',
322
+ advanced: {
323
+ activityThrottleMs: 500, // ลด throttle time สำหรับ responsive มากขึ้น (แต่ใช้ CPU มากขึ้น)
324
+ refreshTimeoutMs: 10000, // เพิ่ม timeout สำหรับ slow network
325
+ }
326
+ });
327
+ ```
328
+
302
329
  #### HTTP Methods
303
330
 
304
331
  - `get<T>(url, config?)` - GET request
@@ -333,13 +360,20 @@ const client = new AuthClient({
333
360
  - `line.sendNotification({ userId, title, message, type?, action_url?, priority? })` - Send formatted notification
334
361
  - `line.checkMessagingAvailability(userId)` - Check if user can receive LINE messages
335
362
 
336
- > 📖 **[LINE Messaging Guide →](./docs/line-messaging.md)** - Complete documentation with examples
363
+ > 📖 **[LINE Messaging Guide →](./docs/features/line-messaging.md)** - Complete documentation with examples
337
364
 
338
365
  **Health & Validation:**
339
366
 
340
367
  - `health.check()` - Check API health
341
368
  - `health.validateApiKey()` - Validate if API key is still active
342
369
 
370
+ **License Management:**
371
+
372
+ - `license.getInfo()` - Get current application license information (requires API Key)
373
+ - Returns license details including `module_codes`, `expires_at`, `is_expired`, etc.
374
+ - Automatically uses application from API key context
375
+ - No need to provide application code or ID
376
+
343
377
  #### Utility Methods
344
378
 
345
379
  - `setToken(token, type?)` - Set authentication token
@@ -353,6 +387,62 @@ const client = new AuthClient({
353
387
  - `getApiKeyMasked()` - Get masked API key for display
354
388
  - `getAxiosInstance()` - Get underlying axios instance
355
389
 
390
+ #### Session Management
391
+
392
+ **Inactivity Detection:**
393
+
394
+ - `enableInactivityDetection(options)` - Enable inactivity detection ที่จับ user activity (mouse/keyboard/touch/scroll)
395
+ - จับ user activity และ trigger callback เมื่อ inactivity timeout
396
+ - ใช้ timeout และ warning time จาก session management config เป็น default
397
+ - Support SSR (Next.js) โดยไม่ error
398
+
399
+ ```typescript
400
+ // Enable inactivity detection
401
+ await authClient.enableInactivityDetection({
402
+ callbacks: {
403
+ onInactivityWarning: (remainingSeconds) => {
404
+ console.log(`Inactivity warning: ${remainingSeconds} seconds remaining`);
405
+ // แสดง notification หรือ dialog
406
+ alert(`Session will expire in ${remainingSeconds} seconds due to inactivity`);
407
+ },
408
+ onInactivityTimeout: () => {
409
+ console.log('Inactivity timeout');
410
+ // Redirect to login หรือ logout
411
+ authClient.clearToken();
412
+ window.location.href = '/login';
413
+ }
414
+ },
415
+ timeoutSeconds: 1800, // 30 minutes (optional, default: จาก session management config)
416
+ warningSeconds: 300, // 5 minutes warning (optional, default: จาก session management config)
417
+ events: ['mousemove', 'keydown', 'touchstart', 'scroll'] // (optional, default: ทั้งหมด)
418
+ });
419
+
420
+ // Disable inactivity detection
421
+ authClient.disableInactivityDetection();
422
+ ```
423
+
424
+ **Session Expiration Monitoring:**
425
+
426
+ - `enableSessionExpirationMonitoring(options)` - Enable session expiration monitoring
427
+ - ตรวจสอบ session expiration ตาม config จาก settings/sessions
428
+ - เรียก callback เมื่อใกล้หมดอายุ
429
+
430
+ ```typescript
431
+ await authClient.enableSessionExpirationMonitoring({
432
+ callbacks: {
433
+ onSessionExpiring: (remainingMinutes, expirationType) => {
434
+ console.log(`Session will expire in ${remainingMinutes} minutes (${expirationType})`);
435
+ // แสดง notification หรือ dialog
436
+ },
437
+ onSessionExpired: () => {
438
+ console.log('Session expired');
439
+ // Redirect to login
440
+ }
441
+ },
442
+ checkIntervalSeconds: 30 // ตรวจสอบทุก 30 วินาที
443
+ });
444
+ ```
445
+
356
446
  ## Authentication Types
357
447
 
358
448
  The SDK supports three authentication types through the `X-Auth-Type` header:
@@ -464,13 +554,16 @@ try {
464
554
 
465
555
  📚 **[Complete Documentation →](./docs/README.md)**
466
556
 
467
- - [Frontend Examples](./docs/FRONTEND_EXAMPLES.md) - Next.js, React usage
468
- - [Middleware Guide](./docs/MIDDLEWARE_USAGE.md) - Express & NestJS
469
- - [Type Safety Guide](./TYPE_SAFETY.md) - Express type augmentation 🆕
470
- - [Type Names Guide](./TYPE_NAMES.md) - SDK-friendly type names 🆕
471
- - [Code Examples](./EXAMPLE.md) - Real-world usage examples 🆕
472
- - [Thai Documentation](./docs/USAGE_TH.md) - คู่มือภาษาไทย
473
- - [Publishing Guide](./docs/NPM_PUBLISH_GUIDE.md) - How to publish updates
557
+ - [API Functions Reference](./docs/api/functions.md) - สรุปฟังก์ชันทั้งหมดที่ SDK รองรับ 🆕
558
+ - [Frontend Examples](./docs/guides/frontend-examples.md) - Next.js, React usage
559
+ - [Middleware Guide](./docs/middleware/usage.md) - Express & NestJS
560
+ - [Type Safety Guide](./docs/middleware/type-safety.md) - Express type augmentation 🆕
561
+ - [Type Names Guide](./docs/guides/type-names.md) - SDK-friendly type names 🆕
562
+ - [Next.js Guide](./docs/guides/nextjs.md) - คู่มือ Next.js ภาษาไทย
563
+ - [OAuth Next.js Guide](./docs/guides/oauth-nextjs.md) - คู่มือ OAuth กับ Next.js
564
+ - [NestJS Guide](./docs/guides/nestjs.md) - คู่มือ NestJS
565
+ - [Thai Documentation](./docs/guides/getting-started.md) - คู่มือภาษาไทย
566
+ - [Publishing Guide](./docs/development/publish.md) - How to publish updates
474
567
 
475
568
  ## License
476
569
 
@@ -28,9 +28,33 @@ export declare class AuthAPI {
28
28
  */
29
29
  profile(): Promise<User>;
30
30
  /**
31
- * Refresh access token
31
+ * Refresh access token using session (for web portal)
32
+ * Uses current session to refresh access token
32
33
  */
33
34
  refresh(refresh_token: string): Promise<AuthTokens>;
35
+ /**
36
+ * Refresh access token using refresh token (for mobile apps and long-lived sessions)
37
+ * This endpoint uses refresh token flow and supports token rotation
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const session = await authClient.auth.refreshWithToken(refreshToken, {
42
+ * ip_address: '192.168.1.1',
43
+ * user_agent: 'MyApp/1.0',
44
+ * device_id: 'device-123'
45
+ * });
46
+ * authClient.setToken(session.access_token);
47
+ * if (session.refresh_token) {
48
+ * // Store new refresh token if rotated
49
+ * tokenManager.setRefreshToken(session.refresh_token);
50
+ * }
51
+ * ```
52
+ */
53
+ refreshWithToken(refreshToken: string, options?: {
54
+ ip_address?: string;
55
+ user_agent?: string;
56
+ device_id?: string;
57
+ }): Promise<AuthSession>;
34
58
  /**
35
59
  * Setup TOTP for user account
36
60
  * Returns QR code and backup codes
@@ -1 +1 @@
1
- {"version":3,"file":"auth.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/auth.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAo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,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAcF;;OAEG;IACG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAKpE;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC;QAC7B,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,EAAE,OAAO,CAAC;QACrB,sBAAsB,EAAE,MAAM,CAAC;QAC/B,YAAY,CAAC,EAAE,IAAI,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAeF;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAK/D;;;OAGG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC;IASvB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAKnD;;;OAGG;IACG,yBAAyB,IAAI,OAAO,CAAC;QACzC,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CASH"}
@@ -38,13 +38,42 @@ class AuthAPI {
38
38
  return response.data.data;
39
39
  }
40
40
  /**
41
- * Refresh access token
41
+ * Refresh access token using session (for web portal)
42
+ * Uses current session to refresh access token
42
43
  */
43
44
  async refresh(refresh_token) {
44
45
  const payload = { refresh_token };
45
46
  const response = await this.client.post('/auth/refresh', payload);
46
47
  return response.data.data;
47
48
  }
49
+ /**
50
+ * Refresh access token using refresh token (for mobile apps and long-lived sessions)
51
+ * This endpoint uses refresh token flow and supports token rotation
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const session = await authClient.auth.refreshWithToken(refreshToken, {
56
+ * ip_address: '192.168.1.1',
57
+ * user_agent: 'MyApp/1.0',
58
+ * device_id: 'device-123'
59
+ * });
60
+ * authClient.setToken(session.access_token);
61
+ * if (session.refresh_token) {
62
+ * // Store new refresh token if rotated
63
+ * tokenManager.setRefreshToken(session.refresh_token);
64
+ * }
65
+ * ```
66
+ */
67
+ async refreshWithToken(refreshToken, options) {
68
+ const payload = {
69
+ refresh_token: refreshToken,
70
+ ...(options?.ip_address && { ip_address: options.ip_address }),
71
+ ...(options?.user_agent && { user_agent: options.user_agent }),
72
+ ...(options?.device_id && { device_id: options.device_id }),
73
+ };
74
+ const response = await this.client.post('/auth/refresh-token', payload);
75
+ return response.data.data;
76
+ }
48
77
  // ==========================================
49
78
  // TOTP (Two-Factor Authentication) Methods
50
79
  // ==========================================
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { AuthClient } from '../auth-client';
3
2
  import { File, FileUpdateData, FileSearchParams } from '../../types';
4
3
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"files.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/files.api.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,aAAa,CAAC;AAElF;;;;GAIG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;OAGG;IACG,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/C;;;OAGG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC;;;;OAIG;IACH,aA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I,CAAC;IAKnE;;;OAGG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAKtD;;;OAGG;IACG,MAAM,CAAC,YAAY,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC;QACrD,IAAI,EAAE,IAAI,EAAE,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAYF;;;OAGG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CAMrF"}
@@ -8,6 +8,8 @@ export { HealthAPI } from './health.api';
8
8
  export { SystemConfigAPI } from './system-config.api';
9
9
  export { FilesAPI } from './files.api';
10
10
  export { EventLogApi } from './event-log.api';
11
+ export { LicenseAPI } from './license.api';
12
+ export type { ApplicationLicenseResponse } from './license.api';
11
13
  export { OAuthAPI } from './oauth.api';
12
14
  export type { OAuthConfig, AuthorizationUrlOptions, TokenResponse, UserInfo, DiscoveryDocument } from './oauth.api';
13
15
  export { generatePKCE, generateState } from './oauth.api';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,YAAY,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Central export point for all API namespaces
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.LineAPI = exports.generateState = exports.generatePKCE = exports.OAuthAPI = exports.EventLogApi = exports.FilesAPI = exports.SystemConfigAPI = exports.HealthAPI = exports.AuthAPI = void 0;
8
+ exports.LineAPI = exports.generateState = exports.generatePKCE = exports.OAuthAPI = exports.LicenseAPI = exports.EventLogApi = exports.FilesAPI = exports.SystemConfigAPI = exports.HealthAPI = exports.AuthAPI = void 0;
9
9
  var auth_api_1 = require("./auth.api");
10
10
  Object.defineProperty(exports, "AuthAPI", { enumerable: true, get: function () { return auth_api_1.AuthAPI; } });
11
11
  var health_api_1 = require("./health.api");
@@ -16,6 +16,8 @@ var files_api_1 = require("./files.api");
16
16
  Object.defineProperty(exports, "FilesAPI", { enumerable: true, get: function () { return files_api_1.FilesAPI; } });
17
17
  var event_log_api_1 = require("./event-log.api");
18
18
  Object.defineProperty(exports, "EventLogApi", { enumerable: true, get: function () { return event_log_api_1.EventLogApi; } });
19
+ var license_api_1 = require("./license.api");
20
+ Object.defineProperty(exports, "LicenseAPI", { enumerable: true, get: function () { return license_api_1.LicenseAPI; } });
19
21
  var oauth_api_1 = require("./oauth.api");
20
22
  Object.defineProperty(exports, "OAuthAPI", { enumerable: true, get: function () { return oauth_api_1.OAuthAPI; } });
21
23
  var oauth_api_2 = require("./oauth.api");
@@ -0,0 +1,74 @@
1
+ /**
2
+ * License API
3
+ *
4
+ * API สำหรับดึงข้อมูล License ของ Application
5
+ * ใช้ API Key authentication เท่านั้น
6
+ */
7
+ import { AxiosResponse } from 'axios';
8
+ import { AuthClient } from '../auth-client';
9
+ import { ApiResponse } from '../../types';
10
+ /**
11
+ * Application License Response
12
+ *
13
+ * @description License information returned from the API
14
+ * Includes all license fields plus computed fields like expiration status
15
+ */
16
+ export interface ApplicationLicenseResponse {
17
+ id: string;
18
+ application_id: string;
19
+ name: string;
20
+ license_key?: string;
21
+ description?: string;
22
+ file_id?: string;
23
+ expires_at?: string;
24
+ is_active: boolean;
25
+ status: string;
26
+ created_at: string;
27
+ updated_at: string;
28
+ created_by?: string;
29
+ updated_by?: string;
30
+ file_url?: string;
31
+ file_name?: string;
32
+ file_size?: number;
33
+ is_expired?: boolean;
34
+ days_until_expiry?: number;
35
+ module_codes?: string[];
36
+ }
37
+ /**
38
+ * License API Namespace
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const client = new AuthClient({ apiKey: '...', baseURL: '...' });
43
+ * const license = await client.license.getInfo();
44
+ * ```
45
+ */
46
+ export declare class LicenseAPI {
47
+ private client;
48
+ constructor(client: AuthClient);
49
+ /**
50
+ * ดึงข้อมูล License ของตัวเองโดยใช้ API Key
51
+ * GET /applications/licenses/info
52
+ *
53
+ * สำหรับ SDK ที่ส่ง X-API-Key header มาอยู่แล้ว
54
+ * ไม่ต้องส่ง application code หรือ application_id
55
+ * ดึงข้อมูลจาก API key โดยอัตโนมัติ
56
+ *
57
+ * ⚠️ ต้องมี API Key เท่านั้น - ไม่มี API Key จะไม่สามารถดึงข้อมูลได้
58
+ *
59
+ * @returns License information หรือ null ถ้าไม่มี active license
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const response = await client.license.getInfo();
64
+ * if (response.data.success && response.data.data) {
65
+ * const license = response.data.data;
66
+ * console.log('License:', license.name);
67
+ * console.log('Expires:', license.expires_at);
68
+ * console.log('Modules:', license.module_codes);
69
+ * }
70
+ * ```
71
+ */
72
+ getInfo(): Promise<AxiosResponse<ApiResponse<ApplicationLicenseResponse | null>>>;
73
+ }
74
+ //# sourceMappingURL=license.api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/license.api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC,CAAC;CAGxF"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * License API
4
+ *
5
+ * API สำหรับดึงข้อมูล License ของ Application
6
+ * ใช้ API Key authentication เท่านั้น
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LicenseAPI = void 0;
10
+ /**
11
+ * License API Namespace
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const client = new AuthClient({ apiKey: '...', baseURL: '...' });
16
+ * const license = await client.license.getInfo();
17
+ * ```
18
+ */
19
+ class LicenseAPI {
20
+ constructor(client) {
21
+ this.client = client;
22
+ }
23
+ /**
24
+ * ดึงข้อมูล License ของตัวเองโดยใช้ API Key
25
+ * GET /applications/licenses/info
26
+ *
27
+ * สำหรับ SDK ที่ส่ง X-API-Key header มาอยู่แล้ว
28
+ * ไม่ต้องส่ง application code หรือ application_id
29
+ * ดึงข้อมูลจาก API key โดยอัตโนมัติ
30
+ *
31
+ * ⚠️ ต้องมี API Key เท่านั้น - ไม่มี API Key จะไม่สามารถดึงข้อมูลได้
32
+ *
33
+ * @returns License information หรือ null ถ้าไม่มี active license
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const response = await client.license.getInfo();
38
+ * if (response.data.success && response.data.data) {
39
+ * const license = response.data.data;
40
+ * console.log('License:', license.name);
41
+ * console.log('Expires:', license.expires_at);
42
+ * console.log('Modules:', license.module_codes);
43
+ * }
44
+ * ```
45
+ */
46
+ async getInfo() {
47
+ return this.client.get('/applications/licenses/info');
48
+ }
49
+ }
50
+ exports.LicenseAPI = LicenseAPI;
@@ -1,5 +1,5 @@
1
1
  import { AuthClient } from '../auth-client';
2
- import { SystemConfig, SystemConfigByCategory } from '../../types';
2
+ import { SystemConfig, SystemConfigByCategory, SecurityJwtConfig, SessionManagementConfig } from '../../types';
3
3
  /**
4
4
  * System Config API
5
5
  * Methods for retrieving system configurations
@@ -23,5 +23,15 @@ export declare class SystemConfigAPI {
23
23
  * ดึง security configs ทั้งหมด (convenience method)
24
24
  */
25
25
  security(): Promise<SystemConfigByCategory>;
26
+ /**
27
+ * GET /system-configs/categories/security/jwt
28
+ * ดึง JWT configuration (convenience method)
29
+ */
30
+ getSecurityJwtConfig(): Promise<SecurityJwtConfig>;
31
+ /**
32
+ * GET /system-configs/categories/security/session-management
33
+ * ดึง Session Management configuration (convenience method)
34
+ */
35
+ getSessionManagement(): Promise<SessionManagementConfig>;
26
36
  }
27
37
  //# sourceMappingURL=system-config.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system-config.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/system-config.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAe,MAAM,aAAa,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;OAGG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAOtE;;;OAGG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAK/E;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAGlD"}
1
+ {"version":3,"file":"system-config.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/system-config.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,uBAAuB,EAAe,MAAM,aAAa,CAAC;AAE5H;;;;GAIG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;OAGG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAOtE;;;OAGG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAK/E;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAIjD;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAKxD;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,uBAAuB,CAAC;CAS/D"}
@@ -33,5 +33,26 @@ class SystemConfigAPI {
33
33
  async security() {
34
34
  return this.getByCategory('security');
35
35
  }
36
+ /**
37
+ * GET /system-configs/categories/security/jwt
38
+ * ดึง JWT configuration (convenience method)
39
+ */
40
+ async getSecurityJwtConfig() {
41
+ const config = await this.getByCategoryAndKey('security', 'jwt');
42
+ return config.value;
43
+ }
44
+ /**
45
+ * GET /system-configs/categories/security/session-management
46
+ * ดึง Session Management configuration (convenience method)
47
+ */
48
+ async getSessionManagement() {
49
+ const securityConfigs = await this.security();
50
+ // Key ใน database เป็น session_management (snake_case)
51
+ const sessionManagement = securityConfigs['session_management'] || securityConfigs['session-management'];
52
+ if (!sessionManagement) {
53
+ throw new Error('Session management configuration not found');
54
+ }
55
+ return sessionManagement;
56
+ }
36
57
  }
37
58
  exports.SystemConfigAPI = SystemConfigAPI;