win-portal-auth-sdk 1.1.2 → 1.3.0

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/README.md CHANGED
@@ -64,10 +64,23 @@ import authClient from '@/lib/auth-client';
64
64
 
65
65
  // Authentication
66
66
  const loginResult = await authClient.auth.login('user@example.com', 'password');
67
+
68
+ // ✅ Set JWT token with explicit type (recommended for better performance)
69
+ authClient.setToken(loginResult.token, 'jwt');
70
+
71
+ // Or use hybrid mode (backward compatible)
72
+ authClient.setToken(loginResult.token); // defaults to 'jwt'
73
+ authClient.setAuthType('hybrid'); // will try JWT first, then OAuth
74
+
67
75
  const profile = await authClient.auth.profile();
68
76
  const refreshed = await authClient.auth.refresh(refreshToken);
69
77
  await authClient.auth.logout();
70
78
 
79
+ // OAuth Token Usage
80
+ // ✅ Set OAuth token with explicit type (recommended for better performance)
81
+ const oauthToken = await authClient.oauth.exchangeCode(code, codeVerifier);
82
+ authClient.setToken(oauthToken.access_token, 'oauth');
83
+
71
84
  // TOTP (Two-Factor Authentication)
72
85
  // 1. Setup TOTP for user
73
86
  const totpSetup = await authClient.auth.setupTotp('My App');
@@ -116,6 +129,15 @@ await authClient.user.delete(userId);
116
129
  const health = await authClient.health.check();
117
130
  const isValid = await authClient.health.validateApiKey();
118
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
+
119
141
  // LINE Messaging
120
142
  await authClient.line.sendTextMessage({
121
143
  userId: 'user-123',
@@ -231,7 +253,7 @@ export class UsersController {
231
253
 
232
254
  For complete documentation, examples, and advanced usage:
233
255
 
234
- **[View Full Middleware Guide →](./docs/MIDDLEWARE_USAGE.md)**
256
+ **[View Full Middleware Guide →](./docs/middleware/usage.md)**
235
257
 
236
258
  Includes:
237
259
 
@@ -320,19 +342,106 @@ const client = new AuthClient({
320
342
  - `line.sendNotification({ userId, title, message, type?, action_url?, priority? })` - Send formatted notification
321
343
  - `line.checkMessagingAvailability(userId)` - Check if user can receive LINE messages
322
344
 
323
- > 📖 **[LINE Messaging Guide →](./docs/line-messaging.md)** - Complete documentation with examples
345
+ > 📖 **[LINE Messaging Guide →](./docs/features/line-messaging.md)** - Complete documentation with examples
324
346
 
325
347
  **Health & Validation:**
326
348
 
327
349
  - `health.check()` - Check API health
328
350
  - `health.validateApiKey()` - Validate if API key is still active
329
351
 
352
+ **License Management:**
353
+
354
+ - `license.getInfo()` - Get current application license information (requires API Key)
355
+ - Returns license details including `module_codes`, `expires_at`, `is_expired`, etc.
356
+ - Automatically uses application from API key context
357
+ - No need to provide application code or ID
358
+
330
359
  #### Utility Methods
331
360
 
361
+ - `setToken(token, type?)` - Set authentication token
362
+ - `type`: `'jwt'` (default) | `'oauth'` | `'hybrid'`
363
+ - Recommended to specify type for better performance
364
+ - `getAuthType()` - Get current authentication type
365
+ - `setAuthType(type)` - Change authentication type
366
+ - `clearToken()` - Clear authentication token
367
+ - `getTokenMasked()` - Get masked token for display
332
368
  - `setApiKey(apiKey)` - Update API key
333
369
  - `getApiKeyMasked()` - Get masked API key for display
334
370
  - `getAxiosInstance()` - Get underlying axios instance
335
371
 
372
+ ## Authentication Types
373
+
374
+ The SDK supports three authentication types through the `X-Auth-Type` header:
375
+
376
+ ### JWT Authentication (Recommended for internal users)
377
+
378
+ ```typescript
379
+ // Login and get JWT token
380
+ const session = await authClient.auth.login('user@example.com', 'password');
381
+
382
+ // ✅ Specify 'jwt' for best performance (fast path validation)
383
+ authClient.setToken(session.token, 'jwt');
384
+
385
+ // All subsequent requests will include:
386
+ // Authorization: Bearer <jwt_token>
387
+ // X-Auth-Type: jwt
388
+ ```
389
+
390
+ **Use JWT when:**
391
+
392
+ - User logs in with username/password
393
+ - Internal application users
394
+ - Need session-based authentication
395
+
396
+ ### OAuth Authentication (Recommended for external apps)
397
+
398
+ ```typescript
399
+ // Exchange authorization code for tokens
400
+ const tokens = await authClient.oauth.exchangeCode(code, codeVerifier);
401
+
402
+ // ✅ Specify 'oauth' for best performance (fast path validation)
403
+ authClient.setToken(tokens.access_token, 'oauth');
404
+
405
+ // All subsequent requests will include:
406
+ // Authorization: Bearer <oauth_access_token>
407
+ // X-Auth-Type: oauth
408
+ ```
409
+
410
+ **Use OAuth when:**
411
+
412
+ - Third-party application integration
413
+ - User consent-based access
414
+ - Need scope-based permissions
415
+
416
+ ### Hybrid Mode (Backward compatible)
417
+
418
+ ```typescript
419
+ // Don't know token type or want automatic detection
420
+ authClient.setToken(someToken, 'hybrid');
421
+
422
+ // All subsequent requests will include:
423
+ // Authorization: Bearer <token>
424
+ // X-Auth-Type: hybrid
425
+
426
+ // API will try JWT first, then fallback to OAuth
427
+ ```
428
+
429
+ **Use Hybrid when:**
430
+
431
+ - Backward compatibility needed
432
+ - Token type is unknown
433
+ - Migrating from old implementation
434
+
435
+ ### Performance Comparison
436
+
437
+ | Auth Type | Validation | Performance | Use Case |
438
+ | --------- | -------------------- | ------------------------- | ------------------------------ |
439
+ | `jwt` | JWT only | ⚡ Fast (1 validation) | Internal users, password login |
440
+ | `oauth` | OAuth only | ⚡ Fast (1 validation) | External apps, OAuth flow |
441
+ | `hybrid` | JWT → OAuth fallback | 🐌 Slower (2 validations) | Unknown token type |
442
+
443
+ **💡 Tip:** Always specify `'jwt'` or `'oauth'` explicitly for ~50% faster authentication!
444
+
336
445
  ## Security Best Practices
337
446
 
338
447
  1. **Never commit API keys** - Use environment variables
@@ -371,13 +480,16 @@ try {
371
480
 
372
481
  📚 **[Complete Documentation →](./docs/README.md)**
373
482
 
374
- - [Frontend Examples](./docs/FRONTEND_EXAMPLES.md) - Next.js, React usage
375
- - [Middleware Guide](./docs/MIDDLEWARE_USAGE.md) - Express & NestJS
376
- - [Type Safety Guide](./TYPE_SAFETY.md) - Express type augmentation 🆕
377
- - [Type Names Guide](./TYPE_NAMES.md) - SDK-friendly type names 🆕
378
- - [Code Examples](./EXAMPLE.md) - Real-world usage examples 🆕
379
- - [Thai Documentation](./docs/USAGE_TH.md) - คู่มือภาษาไทย
380
- - [Publishing Guide](./docs/NPM_PUBLISH_GUIDE.md) - How to publish updates
483
+ - [API Functions Reference](./docs/api/functions.md) - สรุปฟังก์ชันทั้งหมดที่ SDK รองรับ 🆕
484
+ - [Frontend Examples](./docs/guides/frontend-examples.md) - Next.js, React usage
485
+ - [Middleware Guide](./docs/middleware/usage.md) - Express & NestJS
486
+ - [Type Safety Guide](./docs/middleware/type-safety.md) - Express type augmentation 🆕
487
+ - [Type Names Guide](./docs/guides/type-names.md) - SDK-friendly type names 🆕
488
+ - [Next.js Guide](./docs/guides/nextjs.md) - คู่มือ Next.js ภาษาไทย
489
+ - [OAuth Next.js Guide](./docs/guides/oauth-nextjs.md) - คู่มือ OAuth กับ Next.js
490
+ - [NestJS Guide](./docs/guides/nestjs.md) - คู่มือ NestJS
491
+ - [Thai Documentation](./docs/guides/getting-started.md) - คู่มือภาษาไทย
492
+ - [Publishing Guide](./docs/development/publish.md) - How to publish updates
381
493
 
382
494
  ## License
383
495
 
@@ -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,EAAoB,WAAW,EAAE,IAAI,EAAuB,UAAU,EAAe,MAAM,aAAa,CAAC;AAEhH,qBAAa,OAAO;IACN,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMlE;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAK5C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B;;OAEG;IACG,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAUzD;;;OAGG;IACG,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7C,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,EAA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C;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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,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,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAKjC;;;OAGG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,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/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Aa,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;