@hemia/auth-sdk 0.0.10 → 0.0.11

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.
@@ -1,4 +1,4 @@
1
- import { BadRequestError, CustomHttpError, InternalServerError, Get, Req, Res, Post, Controller, HttpError, METADATA_KEYS, ControllerRegistry } from '@hemia/common';
1
+ import { BadRequestError, CustomHttpError, InternalServerError, Get, Req, Res, Post, Controller, ManualRegister, HttpError, METADATA_KEYS, ControllerRegistry } from '@hemia/common';
2
2
  import { HMNetworkServices } from '@hemia/network-services';
3
3
  import { JwtManager } from '@hemia/jwt-manager';
4
4
  import { randomBytes, createHash } from 'crypto';
@@ -380,10 +380,10 @@ AuthService = __decorate([
380
380
  const AUTH_SERVICE_ID = Symbol.for('HemiaAuthService');
381
381
 
382
382
  /**
383
- * Controller AuthController
383
+ * Controller AuthSDKController
384
384
  * Gestiona automáticamente Login, Callback, Me y Logout.
385
385
  */
386
- let AuthController = class AuthController {
386
+ let AuthSDKController = class AuthSDKController {
387
387
  constructor(authService) {
388
388
  this.authService = authService;
389
389
  }
@@ -508,13 +508,13 @@ __decorate([
508
508
  __metadata("design:type", Function),
509
509
  __metadata("design:paramtypes", [Object, Object]),
510
510
  __metadata("design:returntype", Promise)
511
- ], AuthController.prototype, "login", null);
511
+ ], AuthSDKController.prototype, "login", null);
512
512
  __decorate([
513
513
  Get('/callback'),
514
514
  __metadata("design:type", Function),
515
515
  __metadata("design:paramtypes", [Object, Object]),
516
516
  __metadata("design:returntype", Promise)
517
- ], AuthController.prototype, "callback", null);
517
+ ], AuthSDKController.prototype, "callback", null);
518
518
  __decorate([
519
519
  Get('/me'),
520
520
  __param(0, Req()),
@@ -522,7 +522,7 @@ __decorate([
522
522
  __metadata("design:type", Function),
523
523
  __metadata("design:paramtypes", [Object, Object]),
524
524
  __metadata("design:returntype", Promise)
525
- ], AuthController.prototype, "me", null);
525
+ ], AuthSDKController.prototype, "me", null);
526
526
  __decorate([
527
527
  Post('/logout'),
528
528
  __param(0, Req()),
@@ -530,12 +530,13 @@ __decorate([
530
530
  __metadata("design:type", Function),
531
531
  __metadata("design:paramtypes", [Object, Object]),
532
532
  __metadata("design:returntype", Promise)
533
- ], AuthController.prototype, "logout", null);
534
- AuthController = __decorate([
533
+ ], AuthSDKController.prototype, "logout", null);
534
+ AuthSDKController = __decorate([
535
535
  Controller('/'),
536
+ ManualRegister(),
536
537
  __param(0, inject(AUTH_SERVICE_ID)),
537
538
  __metadata("design:paramtypes", [AuthService])
538
- ], AuthController);
539
+ ], AuthSDKController);
539
540
 
540
541
  class AuthCacheAdapter {
541
542
  constructor(externalCache) {
@@ -561,12 +562,12 @@ const authPlugin = (config, cacheFactory, options) => {
561
562
  const jwt = new JwtManager();
562
563
  return new AuthService(config, storageAdapter, network, jwt);
563
564
  }).inSingletonScope();
564
- Reflect.defineMetadata(METADATA_KEYS.BASE_PATH, options.basePath, AuthController);
565
- ControllerRegistry.register(AuthController);
566
- if (!container.isBound(AuthController)) {
567
- container.bind(AuthController).toSelf().inSingletonScope();
565
+ Reflect.defineMetadata(METADATA_KEYS.BASE_PATH, options.basePath, AuthSDKController);
566
+ ControllerRegistry.register(AuthSDKController);
567
+ if (!container.isBound(AuthSDKController)) {
568
+ container.bind(AuthSDKController).toSelf().inSingletonScope();
568
569
  }
569
570
  };
570
571
  };
571
572
 
572
- export { AUTH_SERVICE_ID, AuthController, AuthService, InvalidTokenFormatError, SessionError, SessionExpiredError, SessionInvalidError, SessionNotFoundError, TokenRefreshFailedError, authPlugin };
573
+ export { AUTH_SERVICE_ID, AuthSDKController, AuthService, InvalidTokenFormatError, SessionError, SessionExpiredError, SessionInvalidError, SessionNotFoundError, TokenRefreshFailedError, authPlugin };
@@ -382,10 +382,10 @@ exports.AuthService = __decorate([
382
382
  const AUTH_SERVICE_ID = Symbol.for('HemiaAuthService');
383
383
 
384
384
  /**
385
- * Controller AuthController
385
+ * Controller AuthSDKController
386
386
  * Gestiona automáticamente Login, Callback, Me y Logout.
387
387
  */
388
- exports.AuthController = class AuthController {
388
+ exports.AuthSDKController = class AuthSDKController {
389
389
  constructor(authService) {
390
390
  this.authService = authService;
391
391
  }
@@ -510,13 +510,13 @@ __decorate([
510
510
  __metadata("design:type", Function),
511
511
  __metadata("design:paramtypes", [Object, Object]),
512
512
  __metadata("design:returntype", Promise)
513
- ], exports.AuthController.prototype, "login", null);
513
+ ], exports.AuthSDKController.prototype, "login", null);
514
514
  __decorate([
515
515
  common.Get('/callback'),
516
516
  __metadata("design:type", Function),
517
517
  __metadata("design:paramtypes", [Object, Object]),
518
518
  __metadata("design:returntype", Promise)
519
- ], exports.AuthController.prototype, "callback", null);
519
+ ], exports.AuthSDKController.prototype, "callback", null);
520
520
  __decorate([
521
521
  common.Get('/me'),
522
522
  __param(0, common.Req()),
@@ -524,7 +524,7 @@ __decorate([
524
524
  __metadata("design:type", Function),
525
525
  __metadata("design:paramtypes", [Object, Object]),
526
526
  __metadata("design:returntype", Promise)
527
- ], exports.AuthController.prototype, "me", null);
527
+ ], exports.AuthSDKController.prototype, "me", null);
528
528
  __decorate([
529
529
  common.Post('/logout'),
530
530
  __param(0, common.Req()),
@@ -532,12 +532,13 @@ __decorate([
532
532
  __metadata("design:type", Function),
533
533
  __metadata("design:paramtypes", [Object, Object]),
534
534
  __metadata("design:returntype", Promise)
535
- ], exports.AuthController.prototype, "logout", null);
536
- exports.AuthController = __decorate([
535
+ ], exports.AuthSDKController.prototype, "logout", null);
536
+ exports.AuthSDKController = __decorate([
537
537
  common.Controller('/'),
538
+ common.ManualRegister(),
538
539
  __param(0, inversify.inject(AUTH_SERVICE_ID)),
539
540
  __metadata("design:paramtypes", [exports.AuthService])
540
- ], exports.AuthController);
541
+ ], exports.AuthSDKController);
541
542
 
542
543
  class AuthCacheAdapter {
543
544
  constructor(externalCache) {
@@ -563,10 +564,10 @@ const authPlugin = (config, cacheFactory, options) => {
563
564
  const jwt = new jwtManager.JwtManager();
564
565
  return new exports.AuthService(config, storageAdapter, network, jwt);
565
566
  }).inSingletonScope();
566
- Reflect.defineMetadata(common.METADATA_KEYS.BASE_PATH, options.basePath, exports.AuthController);
567
- common.ControllerRegistry.register(exports.AuthController);
568
- if (!container.isBound(exports.AuthController)) {
569
- container.bind(exports.AuthController).toSelf().inSingletonScope();
567
+ Reflect.defineMetadata(common.METADATA_KEYS.BASE_PATH, options.basePath, exports.AuthSDKController);
568
+ common.ControllerRegistry.register(exports.AuthSDKController);
569
+ if (!container.isBound(exports.AuthSDKController)) {
570
+ container.bind(exports.AuthSDKController).toSelf().inSingletonScope();
570
571
  }
571
572
  };
572
573
  };
@@ -1,10 +1,10 @@
1
1
  import { Request, Response } from "express";
2
2
  import { AuthService } from "../services/auth.service";
3
3
  /**
4
- * Controller AuthController
4
+ * Controller AuthSDKController
5
5
  * Gestiona automáticamente Login, Callback, Me y Logout.
6
6
  */
7
- export declare class AuthController {
7
+ export declare class AuthSDKController {
8
8
  private readonly authService;
9
9
  constructor(authService: AuthService);
10
10
  login(req: Request, res: Response): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/auth-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Hemia SDK for authentication",
5
5
  "main": "dist/hemia-auth-sdk.js",
6
6
  "module": "dist/hemia-auth-sdk.esm.js",
@@ -11,11 +11,12 @@
11
11
  "build": "npm run clean && npm run tscBuild",
12
12
  "test": "jest --detectOpenHandles",
13
13
  "test:coverage": "jest --coverage",
14
- "test:watch": "jest --watch"
14
+ "test:watch": "jest --watch",
15
+ "prepublish": "npm run build"
15
16
  },
16
17
  "devDependencies": {
17
18
  "@hemia/cache-manager": "^0.0.5",
18
- "@hemia/common": "^0.0.9",
19
+ "@hemia/common": "^0.0.12",
19
20
  "@hemia/jwt-manager": "^0.0.4",
20
21
  "@hemia/network-services": "^0.0.3",
21
22
  "@rollup/plugin-commonjs": "^26.0.1",
@@ -43,7 +44,7 @@
43
44
  ],
44
45
  "peerDependencies": {
45
46
  "@hemia/cache-manager": "^0.0.5",
46
- "@hemia/common": "^0.0.9",
47
+ "@hemia/common": "^0.0.10",
47
48
  "@hemia/jwt-manager": "^0.0.4",
48
49
  "@hemia/network-services": "^0.0.3",
49
50
  "inversify": "^7.11.0",