@ackplus/nest-auth 0.1.44 → 0.1.46
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 +102 -1
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -1
- package/src/index.js.map +1 -1
- package/src/lib/auth/services/auth.service.d.ts +3 -1
- package/src/lib/auth/services/auth.service.js +253 -187
- package/src/lib/auth/services/auth.service.js.map +1 -1
- package/src/lib/core/core.module.js +3 -0
- package/src/lib/core/core.module.js.map +1 -1
- package/src/lib/core/interfaces/auth-module-options.interface.d.ts +2 -0
- package/src/lib/core/services/auth-config.service.js +7 -0
- package/src/lib/core/services/auth-config.service.js.map +1 -1
- package/src/lib/core/services/debug-logger.service.d.ts +38 -0
- package/src/lib/core/services/debug-logger.service.js +156 -0
- package/src/lib/core/services/debug-logger.service.js.map +1 -0
- package/src/lib/nest-auth.module.js +7 -0
- package/src/lib/nest-auth.module.js.map +1 -1
- package/src/lib/tenant/services/tenant.service.d.ts +3 -1
- package/src/lib/tenant/services/tenant.service.js +13 -3
- package/src/lib/tenant/services/tenant.service.js.map +1 -1
- package/src/lib/user/services/user.service.d.ts +3 -1
- package/src/lib/user/services/user.service.js +157 -86
- package/src/lib/user/services/user.service.js.map +1 -1
package/README.md
CHANGED
|
@@ -410,7 +410,108 @@ NestAuthModule.forRoot({
|
|
|
410
410
|
- **Automatic tenant resolution**: No need to specify tenant ID in auth operations
|
|
411
411
|
- **Backward compatibility**: Existing apps can add this without breaking changes
|
|
412
412
|
|
|
413
|
-
For detailed examples and configuration options, see
|
|
413
|
+
For detailed examples and configuration options, see the Default Tenant Configuration section above.
|
|
414
|
+
|
|
415
|
+
## Debug Logging
|
|
416
|
+
|
|
417
|
+
The nest-auth package includes comprehensive debug logging to help you troubleshoot issues during development. Debug logging is configurable and can provide detailed insights into authentication flows, user operations, and more.
|
|
418
|
+
|
|
419
|
+
### Enable Debug Logging
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
NestAuthModule.forRoot({
|
|
423
|
+
jwt: { secret: 'your-secret' },
|
|
424
|
+
debug: {
|
|
425
|
+
enabled: true,
|
|
426
|
+
level: 'debug', // 'error' | 'warn' | 'info' | 'debug' | 'verbose'
|
|
427
|
+
prefix: '[NestAuth]',
|
|
428
|
+
includeTimestamp: true,
|
|
429
|
+
includeContext: true
|
|
430
|
+
},
|
|
431
|
+
// ... other options
|
|
432
|
+
})
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Debug Configuration Options
|
|
436
|
+
|
|
437
|
+
- **`enabled`** (default: `false`): Enable/disable debug logging
|
|
438
|
+
- **`level`** (default: `'info'`): Log level - controls which messages are shown
|
|
439
|
+
- **`prefix`** (default: `'[NestAuth]'`): Prefix for all log messages
|
|
440
|
+
- **`includeTimestamp`** (default: `true`): Include timestamp in log messages
|
|
441
|
+
- **`includeContext`** (default: `true`): Include context (service name) in log messages
|
|
442
|
+
|
|
443
|
+
### Log Levels
|
|
444
|
+
|
|
445
|
+
- **`error`**: Only error messages
|
|
446
|
+
- **`warn`**: Errors and warnings
|
|
447
|
+
- **`info`**: Errors, warnings, and info messages
|
|
448
|
+
- **`debug`**: All above plus debug messages
|
|
449
|
+
- **`verbose`**: All messages including verbose debugging
|
|
450
|
+
|
|
451
|
+
### What Gets Logged
|
|
452
|
+
|
|
453
|
+
With debug logging enabled, you'll see detailed information about:
|
|
454
|
+
|
|
455
|
+
#### User Operations
|
|
456
|
+
- User creation attempts and results
|
|
457
|
+
- User lookup operations
|
|
458
|
+
- Identity creation and linking
|
|
459
|
+
- User validation steps
|
|
460
|
+
|
|
461
|
+
#### Authentication Operations
|
|
462
|
+
- Login attempts with provider information
|
|
463
|
+
- Signup processes step-by-step
|
|
464
|
+
- Token generation and validation
|
|
465
|
+
- Session creation and management
|
|
466
|
+
- MFA verification processes
|
|
467
|
+
|
|
468
|
+
#### Tenant Operations
|
|
469
|
+
- Default tenant resolution
|
|
470
|
+
- Tenant creation and lookup
|
|
471
|
+
- Multi-tenant routing decisions
|
|
472
|
+
|
|
473
|
+
#### Error Handling
|
|
474
|
+
- Detailed error contexts with stack traces
|
|
475
|
+
- Input data that caused errors (sensitive data masked)
|
|
476
|
+
- Operation states when errors occurred
|
|
477
|
+
|
|
478
|
+
### Example Debug Output
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
[NestAuth] [2024-01-15T10:30:45.123Z] [AuthService] Entering function: signup | Data: {
|
|
482
|
+
"params": {
|
|
483
|
+
"email": "user@example.com",
|
|
484
|
+
"hasPassword": true
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
[NestAuth] [2024-01-15T10:30:45.125Z] [AuthService] Auth Operation: signup | Data: {
|
|
489
|
+
"operation": "signup",
|
|
490
|
+
"providerId": "email|phone",
|
|
491
|
+
"email": "user@example.com",
|
|
492
|
+
"resolvedTenantId": "tenant-123"
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
[NestAuth] [2024-01-15T10:30:45.127Z] [UserService] User Operation: createUser | Data: {
|
|
496
|
+
"operation": "createUser",
|
|
497
|
+
"email": true,
|
|
498
|
+
"resolvedTenantId": "tenant-123"
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### Development vs Production
|
|
503
|
+
|
|
504
|
+
- **Development**: Use `debug` or `verbose` level for detailed troubleshooting
|
|
505
|
+
- **Production**: Use `error` or `warn` level, or disable entirely for performance
|
|
506
|
+
|
|
507
|
+
### Performance Considerations
|
|
508
|
+
|
|
509
|
+
Debug logging adds minimal overhead when disabled. When enabled at `debug` or `verbose` levels, there is some performance impact due to:
|
|
510
|
+
- JSON serialization of data objects
|
|
511
|
+
- Additional function calls
|
|
512
|
+
- Console I/O operations
|
|
513
|
+
|
|
514
|
+
For production use, consider using `info` level or lower.
|
|
414
515
|
|
|
415
516
|
## License
|
|
416
517
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export * from './lib/tenant';
|
|
|
8
8
|
export * from './lib/core';
|
|
9
9
|
export { AuthModuleOptions, AuthModuleAsyncOptions, AuthModuleOptionsFactory, DefaultTenantOptions } from './lib/core/interfaces/auth-module-options.interface';
|
|
10
10
|
export { AuthConfigService } from './lib/core/services/auth-config.service';
|
|
11
|
+
export { DebugLoggerService, DebugLogLevel, DebugLogOptions } from './lib/core/services/debug-logger.service';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthConfigService = void 0;
|
|
3
|
+
exports.DebugLogLevel = exports.DebugLoggerService = exports.AuthConfigService = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./lib/nest-auth.module"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./lib/auth.constants"), exports);
|
|
@@ -12,4 +12,7 @@ tslib_1.__exportStar(require("./lib/tenant"), exports);
|
|
|
12
12
|
tslib_1.__exportStar(require("./lib/core"), exports);
|
|
13
13
|
var auth_config_service_1 = require("./lib/core/services/auth-config.service");
|
|
14
14
|
Object.defineProperty(exports, "AuthConfigService", { enumerable: true, get: function () { return auth_config_service_1.AuthConfigService; } });
|
|
15
|
+
var debug_logger_service_1 = require("./lib/core/services/debug-logger.service");
|
|
16
|
+
Object.defineProperty(exports, "DebugLoggerService", { enumerable: true, get: function () { return debug_logger_service_1.DebugLoggerService; } });
|
|
17
|
+
Object.defineProperty(exports, "DebugLogLevel", { enumerable: true, get: function () { return debug_logger_service_1.DebugLogLevel; } });
|
|
15
18
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nest-auth/src/index.ts"],"names":[],"mappings":";;;;AAAA,iEAAuC;AAEvC,+DAAqC;AAGrC,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,qDAA2B;AAC3B,uDAA6B;AAC7B,qDAA2B;AAM3B,+EAA4E;AAAnE,wHAAA,iBAAiB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nest-auth/src/index.ts"],"names":[],"mappings":";;;;AAAA,iEAAuC;AAEvC,+DAAqC;AAGrC,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,qDAA2B;AAC3B,uDAA6B;AAC7B,qDAA2B;AAM3B,+EAA4E;AAAnE,wHAAA,iBAAiB,OAAA;AAG1B,iFAA8G;AAArG,0HAAA,kBAAkB,OAAA;AAAE,qHAAA,aAAa,OAAA"}
|
|
@@ -14,6 +14,7 @@ import { ForgotPasswordRequestDto } from '../dto/requests/forgot-password.reques
|
|
|
14
14
|
import { ResetPasswordRequestDto } from '../dto/requests/reset-password.request.dto';
|
|
15
15
|
import { AuthProviderRegistryService } from '../../core/services/auth-provider-registry.service';
|
|
16
16
|
import { TenantService } from '../../tenant/services/tenant.service';
|
|
17
|
+
import { DebugLoggerService } from '../../core/services/debug-logger.service';
|
|
17
18
|
export declare class AuthService {
|
|
18
19
|
private readonly userRepository;
|
|
19
20
|
private otpRepository;
|
|
@@ -23,7 +24,8 @@ export declare class AuthService {
|
|
|
23
24
|
private readonly jwtService;
|
|
24
25
|
private readonly eventEmitter;
|
|
25
26
|
private readonly tenantService;
|
|
26
|
-
|
|
27
|
+
private readonly debugLogger;
|
|
28
|
+
constructor(userRepository: Repository<NestAuthUser>, otpRepository: Repository<NestAuthOTP>, authProviderRegistry: AuthProviderRegistryService, mfaService: MfaService, sessionService: BaseSessionService, jwtService: JwtService, eventEmitter: EventEmitter2, tenantService: TenantService, debugLogger: DebugLoggerService);
|
|
27
29
|
getUserWithRolesAndPermissions(userId: string, relations?: string[]): Promise<NestAuthUser>;
|
|
28
30
|
getUser(): Promise<NestAuthUser>;
|
|
29
31
|
signup(input: SignupRequestDto): Promise<AuthResponseDto>;
|