win-portal-auth-sdk 1.4.0 → 1.5.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.
Files changed (50) hide show
  1. package/README.md +7 -6
  2. package/dist/client/api/index.d.ts +1 -0
  3. package/dist/client/api/index.d.ts.map +1 -1
  4. package/dist/client/api/index.js +3 -1
  5. package/dist/client/api/todo.api.d.ts +31 -0
  6. package/dist/client/api/todo.api.d.ts.map +1 -0
  7. package/dist/client/api/todo.api.js +36 -0
  8. package/dist/client/auth-client.d.ts +2 -1
  9. package/dist/client/auth-client.d.ts.map +1 -1
  10. package/dist/client/auth-client.js +1 -0
  11. package/dist/index.d.ts +1 -6
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -11
  14. package/dist/types/index.d.ts +1 -0
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/types/index.js +2 -0
  17. package/dist/types/todo.types.d.ts +162 -0
  18. package/dist/types/todo.types.d.ts.map +1 -0
  19. package/dist/types/todo.types.js +18 -0
  20. package/package.json +3 -41
  21. package/dist/nestjs/decorators/current-token.decorator.d.ts +0 -29
  22. package/dist/nestjs/decorators/current-token.decorator.d.ts.map +0 -1
  23. package/dist/nestjs/decorators/current-token.decorator.js +0 -36
  24. package/dist/nestjs/decorators/current-user.decorator.d.ts +0 -26
  25. package/dist/nestjs/decorators/current-user.decorator.d.ts.map +0 -1
  26. package/dist/nestjs/decorators/current-user.decorator.js +0 -33
  27. package/dist/nestjs/decorators/index.d.ts +0 -9
  28. package/dist/nestjs/decorators/index.d.ts.map +0 -1
  29. package/dist/nestjs/decorators/index.js +0 -15
  30. package/dist/nestjs/decorators/public.decorator.d.ts +0 -31
  31. package/dist/nestjs/decorators/public.decorator.d.ts.map +0 -1
  32. package/dist/nestjs/decorators/public.decorator.js +0 -36
  33. package/dist/nestjs/guards/index.d.ts +0 -7
  34. package/dist/nestjs/guards/index.d.ts.map +0 -1
  35. package/dist/nestjs/guards/index.js +0 -11
  36. package/dist/nestjs/guards/oauth-auth.guard.d.ts +0 -139
  37. package/dist/nestjs/guards/oauth-auth.guard.d.ts.map +0 -1
  38. package/dist/nestjs/guards/oauth-auth.guard.js +0 -257
  39. package/dist/nestjs/index.d.ts +0 -28
  40. package/dist/nestjs/index.d.ts.map +0 -1
  41. package/dist/nestjs/index.js +0 -47
  42. package/dist/nestjs/middleware/index.d.ts +0 -7
  43. package/dist/nestjs/middleware/index.d.ts.map +0 -1
  44. package/dist/nestjs/middleware/index.js +0 -11
  45. package/dist/nestjs/middleware/request-context.middleware.d.ts +0 -62
  46. package/dist/nestjs/middleware/request-context.middleware.d.ts.map +0 -1
  47. package/dist/nestjs/middleware/request-context.middleware.js +0 -122
  48. package/dist/nestjs/types/request-context.types.d.ts +0 -69
  49. package/dist/nestjs/types/request-context.types.d.ts.map +0 -1
  50. package/dist/nestjs/types/request-context.types.js +0 -33
@@ -1,62 +0,0 @@
1
- /**
2
- * Request Context Middleware
3
- *
4
- * Optional middleware for managing request context with RequestContextService.
5
- * This middleware creates a request context with requestId, ipAddress, userAgent,
6
- * and runs the request within AsyncLocalStorage context.
7
- *
8
- * Note: This middleware requires RequestContextService to be available in the application.
9
- * If RequestContextService is not available, the middleware will still work but
10
- * won't set up the context.
11
- *
12
- * @example
13
- * ```typescript
14
- * // In your AppModule
15
- * import { RequestContextMiddleware } from 'win-portal-auth-sdk/nestjs';
16
- *
17
- * @Module({})
18
- * export class AppModule implements NestModule {
19
- * configure(consumer: MiddlewareConsumer) {
20
- * consumer.apply(RequestContextMiddleware).forRoutes('*');
21
- * }
22
- * }
23
- * ```
24
- */
25
- /**
26
- * Request Context Middleware Class
27
- *
28
- * Creates request context and runs request within AsyncLocalStorage context.
29
- */
30
- export declare class RequestContextMiddleware {
31
- /**
32
- * Generate request ID
33
- * Uses uuid v4 if available, otherwise generates a simple ID
34
- */
35
- private generateRequestId;
36
- /**
37
- * Get client IP address from request
38
- */
39
- private getClientIP;
40
- /**
41
- * Middleware handler
42
- */
43
- use(req: any, res: any, next: () => void): void;
44
- }
45
- /**
46
- * Factory function to create RequestContextMiddleware
47
- *
48
- * @example
49
- * ```typescript
50
- * // In your AppModule
51
- * import { createRequestContextMiddleware } from 'win-portal-auth-sdk/nestjs';
52
- *
53
- * @Module({})
54
- * export class AppModule implements NestModule {
55
- * configure(consumer: MiddlewareConsumer) {
56
- * consumer.apply(createRequestContextMiddleware()).forRoutes('*');
57
- * }
58
- * }
59
- * ```
60
- */
61
- export declare function createRequestContextMiddleware(): RequestContextMiddleware;
62
- //# sourceMappingURL=request-context.middleware.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-context.middleware.d.ts","sourceRoot":"","sources":["../../../src/nestjs/middleware/request-context.middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH;;;;GAIG;AACH,qBAAa,wBAAwB;IACnC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;OAEG;IACH,OAAO,CAAC,WAAW;IAUnB;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI;CA2ChD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,8BAA8B,6BAE7C"}
@@ -1,122 +0,0 @@
1
- "use strict";
2
- /**
3
- * Request Context Middleware
4
- *
5
- * Optional middleware for managing request context with RequestContextService.
6
- * This middleware creates a request context with requestId, ipAddress, userAgent,
7
- * and runs the request within AsyncLocalStorage context.
8
- *
9
- * Note: This middleware requires RequestContextService to be available in the application.
10
- * If RequestContextService is not available, the middleware will still work but
11
- * won't set up the context.
12
- *
13
- * @example
14
- * ```typescript
15
- * // In your AppModule
16
- * import { RequestContextMiddleware } from 'win-portal-auth-sdk/nestjs';
17
- *
18
- * @Module({})
19
- * export class AppModule implements NestModule {
20
- * configure(consumer: MiddlewareConsumer) {
21
- * consumer.apply(RequestContextMiddleware).forRoutes('*');
22
- * }
23
- * }
24
- * ```
25
- */
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.createRequestContextMiddleware = exports.RequestContextMiddleware = void 0;
28
- const request_context_types_1 = require("../types/request-context.types");
29
- /**
30
- * Request Context Middleware Class
31
- *
32
- * Creates request context and runs request within AsyncLocalStorage context.
33
- */
34
- class RequestContextMiddleware {
35
- /**
36
- * Generate request ID
37
- * Uses uuid v4 if available, otherwise generates a simple ID
38
- */
39
- generateRequestId() {
40
- try {
41
- const { v4: uuidv4 } = require('uuid');
42
- return uuidv4();
43
- }
44
- catch {
45
- // Fallback if uuid is not available
46
- return `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
47
- }
48
- }
49
- /**
50
- * Get client IP address from request
51
- */
52
- getClientIP(req) {
53
- return (req.headers['x-forwarded-for']?.split(',')[0]?.trim() ||
54
- req.headers['x-real-ip'] ||
55
- req.connection?.remoteAddress ||
56
- req.socket?.remoteAddress ||
57
- '127.0.0.1');
58
- }
59
- /**
60
- * Middleware handler
61
- */
62
- use(req, res, next) {
63
- const requestId = this.generateRequestId();
64
- const ipAddress = this.getClientIP(req);
65
- const userAgent = req.get('user-agent') || req.headers['user-agent'] || 'Unknown';
66
- const origin = req.get('origin') || req.get('referer');
67
- // Set request ID in response headers for debugging
68
- if (res && typeof res.setHeader === 'function') {
69
- res.setHeader('X-Request-ID', requestId);
70
- }
71
- // Store context in request object
72
- const requestContext = {
73
- requestId,
74
- ipAddress,
75
- userAgent,
76
- origin,
77
- method: req.method,
78
- url: req.url,
79
- timestamp: new Date(),
80
- };
81
- // Attach to request object
82
- req.requestContext = requestContext;
83
- // Try to use RequestContextService if available
84
- const requestContextService = (0, request_context_types_1.getRequestContextService)();
85
- if (requestContextService) {
86
- try {
87
- // Run the entire request pipeline within AsyncLocalStorage context
88
- requestContextService.runWithContext(req, () => {
89
- next();
90
- });
91
- return;
92
- }
93
- catch (error) {
94
- // RequestContextService not available or error
95
- // Continue without it
96
- }
97
- }
98
- // If RequestContextService is not available, just continue
99
- next();
100
- }
101
- }
102
- exports.RequestContextMiddleware = RequestContextMiddleware;
103
- /**
104
- * Factory function to create RequestContextMiddleware
105
- *
106
- * @example
107
- * ```typescript
108
- * // In your AppModule
109
- * import { createRequestContextMiddleware } from 'win-portal-auth-sdk/nestjs';
110
- *
111
- * @Module({})
112
- * export class AppModule implements NestModule {
113
- * configure(consumer: MiddlewareConsumer) {
114
- * consumer.apply(createRequestContextMiddleware()).forRoutes('*');
115
- * }
116
- * }
117
- * ```
118
- */
119
- function createRequestContextMiddleware() {
120
- return new RequestContextMiddleware();
121
- }
122
- exports.createRequestContextMiddleware = createRequestContextMiddleware;
@@ -1,69 +0,0 @@
1
- /**
2
- * Request Context Types
3
- *
4
- * Type definitions for optional RequestContextService integration
5
- * These types allow SDK components to work with RequestContextService
6
- * if it's available in the application, without requiring it as a dependency.
7
- */
8
- /**
9
- * Request Context Data Interface
10
- *
11
- * Matches the structure used by RequestContextService in applications
12
- */
13
- export interface RequestContextData {
14
- requestId: string;
15
- ipAddress: string;
16
- userAgent: string;
17
- origin?: string;
18
- userId?: string;
19
- userEmail?: string;
20
- sessionId?: string;
21
- method: string;
22
- url: string;
23
- timestamp: Date;
24
- authToken?: string;
25
- permissions?: string[];
26
- roles?: Array<{
27
- id: string;
28
- name: string;
29
- }>;
30
- roleCodes?: string[];
31
- applicationId?: string;
32
- applicationName?: string;
33
- apiKeyId?: string;
34
- }
35
- /**
36
- * Optional RequestContextService Interface
37
- *
38
- * This interface represents the static methods available on RequestContextService
39
- * that SDK components can use if the service is available.
40
- */
41
- export interface RequestContextServiceInterface {
42
- /**
43
- * Get current request context
44
- */
45
- getContext(): RequestContextData | undefined;
46
- /**
47
- * Run function with request context
48
- */
49
- runWithContext<T>(req: any, fn: () => T): T;
50
- /**
51
- * Set user info in current context
52
- */
53
- setUserInfo(userId: string, userEmail: string, sessionId?: string, authToken?: string): void;
54
- /**
55
- * Set user permissions and roles in context
56
- */
57
- setUserPermissions(permissions: string[], roles: string[] | Array<{
58
- id: string;
59
- name: string;
60
- }>): void;
61
- }
62
- /**
63
- * Helper function to safely access RequestContextService
64
- *
65
- * This function checks if RequestContextService is available and returns
66
- * a typed interface if it exists, or undefined if not.
67
- */
68
- export declare function getRequestContextService(): RequestContextServiceInterface | undefined;
69
- //# sourceMappingURL=request-context.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-context.types.d.ts","sourceRoot":"","sources":["../../../src/nestjs/types/request-context.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,UAAU,IAAI,kBAAkB,GAAG,SAAS,CAAC;IAE7C;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAE5C;;OAEG;IACH,WAAW,CACT,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAAC;IAER;;OAEG;IACH,kBAAkB,CAChB,WAAW,EAAE,MAAM,EAAE,EACrB,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GACpD,IAAI,CAAC;CACT;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,8BAA8B,GAAG,SAAS,CAcrF"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- /**
3
- * Request Context Types
4
- *
5
- * Type definitions for optional RequestContextService integration
6
- * These types allow SDK components to work with RequestContextService
7
- * if it's available in the application, without requiring it as a dependency.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getRequestContextService = void 0;
11
- /**
12
- * Helper function to safely access RequestContextService
13
- *
14
- * This function checks if RequestContextService is available and returns
15
- * a typed interface if it exists, or undefined if not.
16
- */
17
- function getRequestContextService() {
18
- // Try to access RequestContextService from global scope or module
19
- // This is a safe way to check if the service exists without requiring it
20
- try {
21
- // Check if RequestContextService exists in the runtime
22
- // Applications that use RequestContextService will have it available
23
- const RequestContextService = global.RequestContextService;
24
- if (RequestContextService && typeof RequestContextService.setUserInfo === 'function') {
25
- return RequestContextService;
26
- }
27
- }
28
- catch {
29
- // RequestContextService not available
30
- }
31
- return undefined;
32
- }
33
- exports.getRequestContextService = getRequestContextService;