@tsed/passport 8.0.0-alpha.4 → 8.0.0-alpha.6

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 (63) hide show
  1. package/package.json +10 -11
  2. package/lib/cjs/PassportModule.js +0 -66
  3. package/lib/cjs/PassportModule.js.map +0 -1
  4. package/lib/cjs/contants/constants.js +0 -5
  5. package/lib/cjs/contants/constants.js.map +0 -1
  6. package/lib/cjs/decorators/args.js +0 -18
  7. package/lib/cjs/decorators/args.js.map +0 -1
  8. package/lib/cjs/decorators/authenticate.js +0 -19
  9. package/lib/cjs/decorators/authenticate.js.map +0 -1
  10. package/lib/cjs/decorators/authorize.js +0 -19
  11. package/lib/cjs/decorators/authorize.js.map +0 -1
  12. package/lib/cjs/decorators/protocol.js +0 -25
  13. package/lib/cjs/decorators/protocol.js.map +0 -1
  14. package/lib/cjs/domain/UserInfo.js +0 -22
  15. package/lib/cjs/domain/UserInfo.js.map +0 -1
  16. package/lib/cjs/errors/PassportException.js +0 -12
  17. package/lib/cjs/errors/PassportException.js.map +0 -1
  18. package/lib/cjs/errors/PassportMessage.js +0 -12
  19. package/lib/cjs/errors/PassportMessage.js.map +0 -1
  20. package/lib/cjs/index.js +0 -26
  21. package/lib/cjs/index.js.map +0 -1
  22. package/lib/cjs/interfaces/BeforeInstall.js +0 -3
  23. package/lib/cjs/interfaces/BeforeInstall.js.map +0 -1
  24. package/lib/cjs/interfaces/OnInstall.js +0 -3
  25. package/lib/cjs/interfaces/OnInstall.js.map +0 -1
  26. package/lib/cjs/interfaces/OnVerify.js +0 -3
  27. package/lib/cjs/interfaces/OnVerify.js.map +0 -1
  28. package/lib/cjs/interfaces/ProtocolMethods.js +0 -3
  29. package/lib/cjs/interfaces/ProtocolMethods.js.map +0 -1
  30. package/lib/cjs/interfaces/ProtocolOptions.js +0 -3
  31. package/lib/cjs/interfaces/ProtocolOptions.js.map +0 -1
  32. package/lib/cjs/interfaces/interfaces.js +0 -3
  33. package/lib/cjs/interfaces/interfaces.js.map +0 -1
  34. package/lib/cjs/middlewares/PassportMiddleware.js +0 -46
  35. package/lib/cjs/middlewares/PassportMiddleware.js.map +0 -1
  36. package/lib/cjs/package.json +0 -3
  37. package/lib/cjs/services/PassportSerializerService.js +0 -42
  38. package/lib/cjs/services/PassportSerializerService.js.map +0 -1
  39. package/lib/cjs/services/ProtocolsService.js +0 -151
  40. package/lib/cjs/services/ProtocolsService.js.map +0 -1
  41. package/lib/cjs/utils/getProtocolsFromRequest.js +0 -36
  42. package/lib/cjs/utils/getProtocolsFromRequest.js.map +0 -1
  43. package/lib/esm/package.json +0 -3
  44. package/lib/types-esm/PassportModule.d.ts +0 -19
  45. package/lib/types-esm/contants/constants.d.ts +0 -1
  46. package/lib/types-esm/decorators/args.d.ts +0 -6
  47. package/lib/types-esm/decorators/authenticate.d.ts +0 -6
  48. package/lib/types-esm/decorators/authorize.d.ts +0 -6
  49. package/lib/types-esm/decorators/protocol.d.ts +0 -11
  50. package/lib/types-esm/domain/UserInfo.d.ts +0 -5
  51. package/lib/types-esm/errors/PassportException.d.ts +0 -4
  52. package/lib/types-esm/errors/PassportMessage.d.ts +0 -5
  53. package/lib/types-esm/index.d.ts +0 -22
  54. package/lib/types-esm/interfaces/BeforeInstall.d.ts +0 -3
  55. package/lib/types-esm/interfaces/OnInstall.d.ts +0 -4
  56. package/lib/types-esm/interfaces/OnVerify.d.ts +0 -3
  57. package/lib/types-esm/interfaces/ProtocolMethods.d.ts +0 -5
  58. package/lib/types-esm/interfaces/ProtocolOptions.d.ts +0 -7
  59. package/lib/types-esm/interfaces/interfaces.d.ts +0 -19
  60. package/lib/types-esm/middlewares/PassportMiddleware.d.ts +0 -7
  61. package/lib/types-esm/services/PassportSerializerService.d.ts +0 -9
  62. package/lib/types-esm/services/ProtocolsService.d.ts +0 -54
  63. package/lib/types-esm/utils/getProtocolsFromRequest.d.ts +0 -4
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@tsed/passport",
3
3
  "description": "Passport package for Ts.ED framework",
4
- "type": "commonjs",
5
- "version": "8.0.0-alpha.4",
4
+ "type": "module",
5
+ "version": "8.0.0-alpha.6",
6
6
  "source": "./src/index.ts",
7
- "main": "./lib/cjs/index.js",
7
+ "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./lib/types/index.d.ts",
13
13
  "import": "./lib/esm/index.js",
14
- "require": "./lib/cjs/index.js",
15
14
  "default": "./lib/cjs/index.js"
16
15
  }
17
16
  },
@@ -28,12 +27,12 @@
28
27
  "tslib": "2.6.1"
29
28
  },
30
29
  "devDependencies": {
31
- "@tsed/barrels": "8.0.0-alpha.4",
32
- "@tsed/common": "8.0.0-alpha.4",
33
- "@tsed/core": "8.0.0-alpha.4",
34
- "@tsed/di": "8.0.0-alpha.4",
35
- "@tsed/platform-router": "8.0.0-alpha.4",
36
- "@tsed/typescript": "8.0.0-alpha.4",
30
+ "@tsed/barrels": "8.0.0-alpha.6",
31
+ "@tsed/common": "8.0.0-alpha.6",
32
+ "@tsed/core": "8.0.0-alpha.6",
33
+ "@tsed/di": "8.0.0-alpha.6",
34
+ "@tsed/platform-router": "8.0.0-alpha.6",
35
+ "@tsed/typescript": "8.0.0-alpha.6",
37
36
  "@types/passport": "1.0.16",
38
37
  "@types/passport-http": "0.3.11",
39
38
  "@types/passport-local": "1.0.38",
@@ -47,7 +46,7 @@
47
46
  "vitest": "2.0.4"
48
47
  },
49
48
  "peerDependencies": {
50
- "@tsed/common": "8.0.0-alpha.4",
49
+ "@tsed/common": "8.0.0-alpha.6",
51
50
  "passport": ">=0.4.1"
52
51
  },
53
52
  "peerDependenciesMeta": {
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PassportModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const passport_1 = tslib_1.__importDefault(require("passport"));
7
- const PassportSerializerService_js_1 = require("./services/PassportSerializerService.js");
8
- const ProtocolsService_js_1 = require("./services/ProtocolsService.js");
9
- /**
10
- * @ignore
11
- */
12
- let PassportModule = class PassportModule {
13
- constructor(app, protocolsService, passportSerializer) {
14
- this.app = app;
15
- this.protocolsService = protocolsService;
16
- this.passportSerializer = passportSerializer;
17
- }
18
- async $onInit() {
19
- passport_1.default.serializeUser(this.passportSerializer.serialize.bind(this.passportSerializer));
20
- passport_1.default.deserializeUser(this.passportSerializer.deserialize.bind(this.passportSerializer));
21
- const promises = this.protocolsService.getProtocols().map((provider) => this.protocolsService.invoke(provider));
22
- await Promise.all(promises);
23
- return undefined;
24
- }
25
- $beforeRoutesInit() {
26
- const { userProperty, pauseStream } = this;
27
- switch (this.platformName) {
28
- case "express":
29
- this.app.use(passport_1.default.initialize({ userProperty }));
30
- !this.disableSession && this.app.use(passport_1.default.session({ pauseStream }));
31
- return;
32
- default:
33
- this.logger.warn(`Platform "${this.platformName}" not supported by @tsed/passport`);
34
- }
35
- }
36
- };
37
- tslib_1.__decorate([
38
- (0, common_1.Constant)("passport.userProperty"),
39
- tslib_1.__metadata("design:type", String)
40
- ], PassportModule.prototype, "userProperty", void 0);
41
- tslib_1.__decorate([
42
- (0, common_1.Constant)("passport.pauseStream"),
43
- tslib_1.__metadata("design:type", Boolean)
44
- ], PassportModule.prototype, "pauseStream", void 0);
45
- tslib_1.__decorate([
46
- (0, common_1.Constant)("passport.disableSession", false),
47
- tslib_1.__metadata("design:type", Boolean)
48
- ], PassportModule.prototype, "disableSession", void 0);
49
- tslib_1.__decorate([
50
- (0, common_1.Constant)("PLATFORM_NAME"),
51
- tslib_1.__metadata("design:type", String)
52
- ], PassportModule.prototype, "platformName", void 0);
53
- tslib_1.__decorate([
54
- (0, common_1.Inject)(),
55
- tslib_1.__metadata("design:type", common_1.Logger)
56
- ], PassportModule.prototype, "logger", void 0);
57
- PassportModule = tslib_1.__decorate([
58
- (0, common_1.Module)({
59
- scope: common_1.ProviderScope.SINGLETON
60
- }),
61
- tslib_1.__metadata("design:paramtypes", [common_1.PlatformApplication,
62
- ProtocolsService_js_1.ProtocolsService,
63
- PassportSerializerService_js_1.PassportSerializerService])
64
- ], PassportModule);
65
- exports.PassportModule = PassportModule;
66
- //# sourceMappingURL=PassportModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PassportModule.js","sourceRoot":"","sources":["../../src/PassportModule.ts"],"names":[],"mappings":";;;;AAAA,yCAAsI;AACtI,gEAAgC;AAChC,0FAAkF;AAClF,wEAAgE;AAEhE;;GAEG;AAII,IAAM,cAAc,GAApB,MAAM,cAAc;IAgBzB,YACU,GAAwB,EACxB,gBAAkC,EAClC,kBAA6C;QAF7C,QAAG,GAAH,GAAG,CAAqB;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,uBAAkB,GAAlB,kBAAkB,CAA2B;IACpD,CAAC;IAEJ,KAAK,CAAC,OAAO;QACX,kBAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACxF,kBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAE5F,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE1H,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iBAAiB;QACf,MAAM,EAAC,YAAY,EAAE,WAAW,EAAC,GAAG,IAAI,CAAC;QACzC,QAAQ,IAAI,CAAC,YAAY,EAAE;YACzB,KAAK,SAAS;gBACZ,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,kBAAQ,CAAC,UAAU,CAAC,EAAC,YAAY,EAAC,CAAC,CAAC,CAAC;gBAClD,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,kBAAQ,CAAC,OAAO,CAAC,EAAC,WAAW,EAAC,CAAC,CAAC,CAAC;gBAEtE,OAAO;YAET;gBACE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,YAAY,mCAAmC,CAAC,CAAC;SACvF;IACH,CAAC;CACF,CAAA;AA5CC;IAAC,IAAA,iBAAQ,EAAC,uBAAuB,CAAC;;oDACb;AAErB;IAAC,IAAA,iBAAQ,EAAC,sBAAsB,CAAC;;mDACZ;AAErB;IAAC,IAAA,iBAAQ,EAAC,yBAAyB,EAAE,KAAK,CAAC;;sDACnB;AAExB;IAAC,IAAA,iBAAQ,EAAC,eAAe,CAAC;;oDACL;AAErB;IAAC,IAAA,eAAM,GAAE;sCACD,eAAM;8CAAC;AAdJ,cAAc;IAH1B,IAAA,eAAM,EAAC;QACN,KAAK,EAAE,sBAAa,CAAC,SAAS;KAC/B,CAAC;6CAkBe,4BAAmB;QACN,sCAAgB;QACd,wDAAyB;GAnB5C,cAAc,CA6C1B;AA7CY,wCAAc"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROVIDER_TYPE_PROTOCOL = void 0;
4
- exports.PROVIDER_TYPE_PROTOCOL = "protocol";
5
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/contants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,UAAU,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Arg = exports.Args = void 0;
4
- const common_1 = require("@tsed/common");
5
- const core_1 = require("@tsed/core");
6
- /**
7
- * Inject args resolve by the passport strategy on verify method.
8
- * @decorator
9
- */
10
- function Args() {
11
- return (0, core_1.useDecorators)((0, common_1.Context)("PROTOCOL_ARGS"));
12
- }
13
- exports.Args = Args;
14
- function Arg(index) {
15
- return (0, core_1.useDecorators)((0, common_1.Context)(`PROTOCOL_ARGS.${index}`));
16
- }
17
- exports.Arg = Arg;
18
- //# sourceMappingURL=args.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"args.js","sourceRoot":"","sources":["../../../src/decorators/args.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qCAAyC;AAEzC;;;GAGG;AACH,SAAgB,IAAI;IAClB,OAAO,IAAA,oBAAa,EAAC,IAAA,gBAAO,EAAC,eAAe,CAAC,CAAC,CAAC;AACjD,CAAC;AAFD,oBAEC;AAED,SAAgB,GAAG,CAAC,KAAa;IAC/B,OAAO,IAAA,oBAAa,EAAC,IAAA,gBAAO,EAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAFD,kBAEC"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Authenticate = void 0;
4
- const platform_middlewares_1 = require("@tsed/platform-middlewares");
5
- const core_1 = require("@tsed/core");
6
- const schema_1 = require("@tsed/schema");
7
- const PassportMiddleware_js_1 = require("../middlewares/PassportMiddleware.js");
8
- function Authenticate(protocol = "*", options = {}) {
9
- return (0, core_1.useDecorators)((0, platform_middlewares_1.UseAuth)(PassportMiddleware_js_1.PassportMiddleware, {
10
- protocol,
11
- method: "authenticate",
12
- originalUrl: options.originalUrl === undefined ? true : options.originalUrl,
13
- options
14
- }), ...Object.entries(options.security || {}).map(([key, value]) => {
15
- return (0, schema_1.Security)(key, ...value);
16
- }));
17
- }
18
- exports.Authenticate = Authenticate;
19
- //# sourceMappingURL=authenticate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../../src/decorators/authenticate.ts"],"names":[],"mappings":";;;AAAA,qEAAmD;AACnD,qCAAyC;AACzC,yCAAsC;AAEtC,gFAAwE;AAOxE,SAAgB,YAAY,CAAC,WAA8B,GAAG,EAAE,UAA+B,EAAE;IAC/F,OAAO,IAAA,oBAAa,EAClB,IAAA,8BAAO,EAAC,0CAAkB,EAAE;QAC1B,QAAQ;QACR,MAAM,EAAE,cAAc;QACtB,WAAW,EAAE,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW;QAC3E,OAAO;KACR,CAAC,EACF,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7D,OAAO,IAAA,iBAAQ,EAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,oCAYC"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Authorize = void 0;
4
- const platform_middlewares_1 = require("@tsed/platform-middlewares");
5
- const core_1 = require("@tsed/core");
6
- const schema_1 = require("@tsed/schema");
7
- const PassportMiddleware_js_1 = require("../middlewares/PassportMiddleware.js");
8
- function Authorize(protocol = "*", options = {}) {
9
- return (0, core_1.useDecorators)((0, platform_middlewares_1.UseAuth)(PassportMiddleware_js_1.PassportMiddleware, {
10
- protocol,
11
- method: "authorize",
12
- originalUrl: options.originalUrl === undefined ? true : options.originalUrl,
13
- options
14
- }), ...Object.entries(options.security || {}).map(([key, value]) => {
15
- return (0, schema_1.Security)(key, ...value);
16
- }));
17
- }
18
- exports.Authorize = Authorize;
19
- //# sourceMappingURL=authorize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/decorators/authorize.ts"],"names":[],"mappings":";;;AAAA,qEAAmD;AACnD,qCAAyC;AACzC,yCAAsC;AAEtC,gFAAwE;AAOxE,SAAgB,SAAS,CAAC,WAA8B,GAAG,EAAE,UAA4B,EAAE;IACzF,OAAO,IAAA,oBAAa,EAClB,IAAA,8BAAO,EAAC,0CAAkB,EAAE;QAC1B,QAAQ;QACR,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW;QAC3E,OAAO;KACR,CAAC,EACF,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7D,OAAO,IAAA,iBAAQ,EAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,8BAYC"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Protocol = void 0;
4
- const core_1 = require("@tsed/core");
5
- const di_1 = require("@tsed/di");
6
- const constants_js_1 = require("../contants/constants.js");
7
- /**
8
- * Declare a new Protocol base on a Passport Strategy
9
- *
10
- * @decorator
11
- * @class
12
- */
13
- function Protocol(options) {
14
- return (0, core_1.useDecorators)((0, di_1.Injectable)({
15
- type: constants_js_1.PROVIDER_TYPE_PROTOCOL
16
- }), (0, core_1.StoreSet)("protocol", options), (0, di_1.Configuration)({
17
- passport: {
18
- protocols: {
19
- [options.name]: options
20
- }
21
- }
22
- }));
23
- }
24
- exports.Protocol = Protocol;
25
- //# sourceMappingURL=protocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/decorators/protocol.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAAmD;AAEnD,2DAAgE;AAEhE;;;;;GAKG;AACH,SAAgB,QAAQ,CAAU,OAAoC;IACpE,OAAO,IAAA,oBAAa,EAClB,IAAA,eAAU,EAAC;QACT,IAAI,EAAE,qCAAsB;KAC7B,CAAC,EACF,IAAA,eAAQ,EAAC,UAAU,EAAE,OAAO,CAAC,EAC7B,IAAA,kBAAa,EAAC;QACZ,QAAQ,EAAE;YACR,SAAS,EAAE;gBACT,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO;aACxB;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAdD,4BAcC"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserInfo = void 0;
4
- const tslib_1 = require("tslib");
5
- const schema_1 = require("@tsed/schema");
6
- class UserInfo {
7
- }
8
- tslib_1.__decorate([
9
- (0, schema_1.Property)(),
10
- tslib_1.__metadata("design:type", String)
11
- ], UserInfo.prototype, "id", void 0);
12
- tslib_1.__decorate([
13
- (0, schema_1.Property)(),
14
- (0, schema_1.Format)("email"),
15
- tslib_1.__metadata("design:type", String)
16
- ], UserInfo.prototype, "email", void 0);
17
- tslib_1.__decorate([
18
- (0, schema_1.Property)(),
19
- tslib_1.__metadata("design:type", String)
20
- ], UserInfo.prototype, "password", void 0);
21
- exports.UserInfo = UserInfo;
22
- //# sourceMappingURL=UserInfo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserInfo.js","sourceRoot":"","sources":["../../../src/domain/UserInfo.ts"],"names":[],"mappings":";;;;AAAA,yCAA8C;AAE9C,MAAa,QAAQ;CAUpB;AATC;IAAC,IAAA,iBAAQ,GAAE;;oCACA;AAEX;IAAC,IAAA,iBAAQ,GAAE;IACV,IAAA,eAAM,EAAC,OAAO,CAAC;;uCACF;AAEd;IAAC,IAAA,iBAAQ,GAAE;;0CACM;AATnB,4BAUC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PassportException = void 0;
4
- const exceptions_1 = require("@tsed/exceptions");
5
- class PassportException extends exceptions_1.Exception {
6
- constructor(error) {
7
- super(error.status || 500, error.message);
8
- this.name = error.name || this.name;
9
- }
10
- }
11
- exports.PassportException = PassportException;
12
- //# sourceMappingURL=PassportException.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PassportException.js","sourceRoot":"","sources":["../../../src/errors/PassportException.ts"],"names":[],"mappings":";;;AAAA,iDAA2C;AAE3C,MAAa,iBAAkB,SAAQ,sBAAS;IAC9C,YAAY,KAAU;QACpB,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;IACtC,CAAC;CACF;AALD,8CAKC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PassportMessage = void 0;
4
- const exceptions_1 = require("@tsed/exceptions");
5
- class PassportMessage extends exceptions_1.Unauthorized {
6
- constructor(message, opts = {}) {
7
- super(message);
8
- this.opts = opts;
9
- }
10
- }
11
- exports.PassportMessage = PassportMessage;
12
- //# sourceMappingURL=PassportMessage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PassportMessage.js","sourceRoot":"","sources":["../../../src/errors/PassportMessage.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAE9C,MAAa,eAAgB,SAAQ,yBAAY;IAC/C,YAAY,OAAe,EAAS,OAAgC,EAAE;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC;QADmB,SAAI,GAAJ,IAAI,CAA8B;IAEtE,CAAC;CACF;AAJD,0CAIC"}
package/lib/cjs/index.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @file Automatically generated by @tsed/barrels.
6
- */
7
- tslib_1.__exportStar(require("./contants/constants.js"), exports);
8
- tslib_1.__exportStar(require("./decorators/args.js"), exports);
9
- tslib_1.__exportStar(require("./decorators/authenticate.js"), exports);
10
- tslib_1.__exportStar(require("./decorators/authorize.js"), exports);
11
- tslib_1.__exportStar(require("./decorators/protocol.js"), exports);
12
- tslib_1.__exportStar(require("./domain/UserInfo.js"), exports);
13
- tslib_1.__exportStar(require("./errors/PassportException.js"), exports);
14
- tslib_1.__exportStar(require("./errors/PassportMessage.js"), exports);
15
- tslib_1.__exportStar(require("./interfaces/BeforeInstall.js"), exports);
16
- tslib_1.__exportStar(require("./interfaces/interfaces.js"), exports);
17
- tslib_1.__exportStar(require("./interfaces/OnInstall.js"), exports);
18
- tslib_1.__exportStar(require("./interfaces/OnVerify.js"), exports);
19
- tslib_1.__exportStar(require("./interfaces/ProtocolMethods.js"), exports);
20
- tslib_1.__exportStar(require("./interfaces/ProtocolOptions.js"), exports);
21
- tslib_1.__exportStar(require("./middlewares/PassportMiddleware.js"), exports);
22
- tslib_1.__exportStar(require("./PassportModule.js"), exports);
23
- tslib_1.__exportStar(require("./services/PassportSerializerService.js"), exports);
24
- tslib_1.__exportStar(require("./services/ProtocolsService.js"), exports);
25
- tslib_1.__exportStar(require("./utils/getProtocolsFromRequest.js"), exports);
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,kEAAwC;AACxC,+DAAqC;AACrC,uEAA6C;AAC7C,oEAA0C;AAC1C,mEAAyC;AACzC,+DAAqC;AACrC,wEAA8C;AAC9C,sEAA4C;AAC5C,wEAA8C;AAC9C,qEAA2C;AAC3C,oEAA0C;AAC1C,mEAAyC;AACzC,0EAAgD;AAChD,0EAAgD;AAChD,8EAAoD;AACpD,8DAAoC;AACpC,kFAAwD;AACxD,yEAA+C;AAC/C,6EAAmD"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=BeforeInstall.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BeforeInstall.js","sourceRoot":"","sources":["../../../src/interfaces/BeforeInstall.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=OnInstall.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OnInstall.js","sourceRoot":"","sources":["../../../src/interfaces/OnInstall.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=OnVerify.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OnVerify.js","sourceRoot":"","sources":["../../../src/interfaces/OnVerify.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ProtocolMethods.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProtocolMethods.js","sourceRoot":"","sources":["../../../src/interfaces/ProtocolMethods.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ProtocolOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProtocolOptions.js","sourceRoot":"","sources":["../../../src/interfaces/ProtocolOptions.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var PassportMiddleware_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PassportMiddleware = void 0;
5
- const tslib_1 = require("tslib");
6
- const di_1 = require("@tsed/di");
7
- const platform_middlewares_1 = require("@tsed/platform-middlewares");
8
- const common_1 = require("@tsed/common");
9
- const ProtocolsService_js_1 = require("../services/ProtocolsService.js");
10
- const getProtocolsFromRequest_js_1 = require("../utils/getProtocolsFromRequest.js");
11
- let PassportMiddleware = PassportMiddleware_1 = class PassportMiddleware {
12
- shouldSkip(ctx) {
13
- const request = ctx.getRequest();
14
- return request.user && request.isAuthenticated();
15
- }
16
- async use(ctx) {
17
- const endpoint = ctx.endpoint;
18
- const request = ctx.getRequest();
19
- if (this.shouldSkip(ctx)) {
20
- return;
21
- }
22
- const { options, protocol, method, originalUrl = true } = endpoint.store.get(PassportMiddleware_1);
23
- const protocols = (0, getProtocolsFromRequest_js_1.getProtocolsFromRequest)(request, protocol, this.protocolsService.getProtocolsNames());
24
- if (originalUrl) {
25
- request.url = request.originalUrl;
26
- }
27
- await (method === "authenticate"
28
- ? this.protocolsService.authenticate(protocols, options, ctx)
29
- : this.protocolsService.authorize(protocols, options, ctx));
30
- }
31
- };
32
- tslib_1.__decorate([
33
- (0, di_1.Inject)(ProtocolsService_js_1.ProtocolsService),
34
- tslib_1.__metadata("design:type", ProtocolsService_js_1.ProtocolsService)
35
- ], PassportMiddleware.prototype, "protocolsService", void 0);
36
- tslib_1.__decorate([
37
- tslib_1.__param(0, (0, common_1.Context)()),
38
- tslib_1.__metadata("design:type", Function),
39
- tslib_1.__metadata("design:paramtypes", [Object]),
40
- tslib_1.__metadata("design:returntype", Promise)
41
- ], PassportMiddleware.prototype, "use", null);
42
- PassportMiddleware = PassportMiddleware_1 = tslib_1.__decorate([
43
- (0, platform_middlewares_1.Middleware)()
44
- ], PassportMiddleware);
45
- exports.PassportMiddleware = PassportMiddleware;
46
- //# sourceMappingURL=PassportMiddleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":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AAgB;4DAAC;AAO7B;IAAK,mBAAA,IAAA,gBAAO,GAAE,CAAA;;;;6CAiBnB;AA1BU,kBAAkB;IAD9B,IAAA,iCAAU,GAAE;GACA,kBAAkB,CA2B9B;AA3BY,gDAAkB"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PassportSerializerService = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const json_mapper_1 = require("@tsed/json-mapper");
7
- const UserInfo_js_1 = require("../domain/UserInfo.js");
8
- /**
9
- * @ignore
10
- */
11
- let PassportSerializerService = class PassportSerializerService {
12
- serialize(user, done) {
13
- try {
14
- const obj = (0, json_mapper_1.serialize)(user, { type: this.model });
15
- // remove password from serialized object
16
- obj.password = undefined;
17
- done(null, JSON.stringify(obj));
18
- }
19
- catch (er) {
20
- // istanbul ignore next
21
- done(er);
22
- }
23
- }
24
- deserialize(obj, done) {
25
- try {
26
- const user = (0, json_mapper_1.deserialize)(JSON.parse(obj), { type: this.model });
27
- done(null, user);
28
- }
29
- catch (er) {
30
- done(er);
31
- }
32
- }
33
- };
34
- tslib_1.__decorate([
35
- (0, di_1.Constant)("passport.userInfoModel", UserInfo_js_1.UserInfo),
36
- tslib_1.__metadata("design:type", Object)
37
- ], PassportSerializerService.prototype, "model", void 0);
38
- PassportSerializerService = tslib_1.__decorate([
39
- (0, di_1.Service)()
40
- ], PassportSerializerService);
41
- exports.PassportSerializerService = PassportSerializerService;
42
- //# sourceMappingURL=PassportSerializerService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PassportSerializerService.js","sourceRoot":"","sources":["../../../src/services/PassportSerializerService.ts"],"names":[],"mappings":";;;;AACA,iCAA2C;AAC3C,mDAAyD;AACzD,uDAA+C;AAE/C;;GAEG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAIpC,SAAS,CAAC,IAAc,EAAE,IAAS;QACjC,IAAI;YACF,MAAM,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAC,CAAC,CAAC;YAEhD,yCAAyC;YACzC,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC;YAEzB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;SACjC;QAAC,OAAO,EAAE,EAAE;YACX,uBAAuB;YACvB,IAAI,CAAC,EAAE,CAAC,CAAC;SACV;IACH,CAAC;IAED,WAAW,CAAC,GAAQ,EAAE,IAAS;QAC7B,IAAI;YACF,MAAM,IAAI,GAAG,IAAA,yBAAW,EAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAC,CAAC,CAAC;YAE9D,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAClB;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,CAAC,EAAE,CAAC,CAAC;SACV;IACH,CAAC;CACF,CAAA;AA1BC;IAAC,IAAA,aAAQ,EAAC,wBAAwB,EAAE,sBAAQ,CAAC;;wDACL;AAF7B,yBAAyB;IADrC,IAAA,YAAO,GAAE;GACG,yBAAyB,CA2BrC;AA3BY,8DAAyB"}
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProtocolsService = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const core_1 = require("@tsed/core");
7
- const di_1 = require("@tsed/di");
8
- const exceptions_1 = require("@tsed/exceptions");
9
- const passport_1 = tslib_1.__importStar(require("passport"));
10
- const util_1 = require("util");
11
- const constants_js_1 = require("../contants/constants.js");
12
- const PassportException_js_1 = require("../errors/PassportException.js");
13
- const PassportMessage_js_1 = require("../errors/PassportMessage.js");
14
- /**
15
- * @ignore
16
- */
17
- let ProtocolsService = class ProtocolsService {
18
- constructor() {
19
- this.strategies = new Map();
20
- }
21
- getProtocols() {
22
- return this.injector.getProviders(constants_js_1.PROVIDER_TYPE_PROTOCOL);
23
- }
24
- getProtocolsNames() {
25
- return Array.from(this.strategies.keys());
26
- }
27
- /**
28
- * Invoke provider and bind it to passport.
29
- * @param provider
30
- */
31
- async invoke(provider) {
32
- let { name, useStrategy: strategy, settings } = this.getOptions(provider);
33
- const protocol = this.injector.get(provider.provide);
34
- if (protocol.$beforeInstall) {
35
- settings = (await protocol.$beforeInstall(settings)) || settings;
36
- }
37
- const instance = new strategy(settings, this.createHandler(provider));
38
- this.strategies.set(name, instance);
39
- passport_1.default.use(name, instance);
40
- if (protocol.$onInstall) {
41
- await protocol.$onInstall(instance);
42
- }
43
- protocol.$strategy = instance;
44
- return protocol;
45
- }
46
- /**
47
- * Call authenticate passport method.
48
- * @param protocols
49
- * @param options
50
- * @param ctx
51
- */
52
- authenticate(protocols, options, ctx) {
53
- return this.call("authenticate", protocols, options, ctx);
54
- }
55
- /**
56
- * Call authorize passport method.
57
- * @param protocols
58
- * @param options
59
- * @param ctx
60
- */
61
- authorize(protocols, options, ctx) {
62
- return this.call("authorize", protocols, options, ctx);
63
- }
64
- /**
65
- * Call passport authenticate or authorize depending on the chosen method.
66
- * @param method
67
- * @param protocols
68
- * @param options
69
- * @param ctx
70
- * @private
71
- */
72
- async call(method, protocols, options, ctx) {
73
- const request = ctx.getRequest();
74
- const response = ctx.getResponse();
75
- protocols = [].concat(protocols);
76
- if (protocols.length === 0) {
77
- throw new exceptions_1.Unauthorized("Not authorized");
78
- }
79
- try {
80
- options.failWithError = true;
81
- // @ts-ignore
82
- const fn = (0, util_1.promisify)(passport_1.default[method](protocols.length === 1 ? protocols[0] : protocols, options));
83
- await fn(request, response);
84
- }
85
- catch (er) {
86
- if (!(0, core_1.ancestorsOf)(er).includes(Error)) {
87
- throw new PassportException_js_1.PassportException(er);
88
- }
89
- throw er;
90
- }
91
- }
92
- /**
93
- * Create strategy options based on decorator metadata and global configuration
94
- * @param provider
95
- * @private
96
- */
97
- getOptions(provider) {
98
- const { name } = provider.store.get("protocol");
99
- const { useStrategy = passport_1.Strategy, settings = {} } = this.injector.settings.get(`passport.protocols.${name}`) || {};
100
- return {
101
- name,
102
- useStrategy,
103
- settings: {
104
- ...settings,
105
- passReqToCallback: true
106
- }
107
- };
108
- }
109
- /**
110
- * Create the verifier handler for passport
111
- * @param provider
112
- * @private
113
- */
114
- createHandler(provider) {
115
- const middleware = this.platformHandler.createCustomHandler(provider, "$onVerify");
116
- return async (req, ...args) => {
117
- const done = args[args.length - 1];
118
- if (req.$ctx) {
119
- req.$ctx.set("PROTOCOL_ARGS", args.slice(0, -1));
120
- try {
121
- await middleware(req.$ctx);
122
- done(null, ...[].concat(req.$ctx.data));
123
- }
124
- catch (err) {
125
- if (err instanceof PassportMessage_js_1.PassportMessage) {
126
- done(null, false, { ...err.opts, message: err.message });
127
- }
128
- else {
129
- done(err, false, { message: err.message });
130
- }
131
- }
132
- }
133
- else {
134
- done(new Error("Headers already sent"), false, { message: "Headers already sent" });
135
- }
136
- };
137
- }
138
- };
139
- tslib_1.__decorate([
140
- (0, di_1.Inject)(),
141
- tslib_1.__metadata("design:type", common_1.PlatformHandler)
142
- ], ProtocolsService.prototype, "platformHandler", void 0);
143
- tslib_1.__decorate([
144
- (0, di_1.Inject)(),
145
- tslib_1.__metadata("design:type", di_1.InjectorService)
146
- ], ProtocolsService.prototype, "injector", void 0);
147
- ProtocolsService = tslib_1.__decorate([
148
- (0, di_1.Injectable)()
149
- ], ProtocolsService);
150
- exports.ProtocolsService = ProtocolsService;
151
- //# sourceMappingURL=ProtocolsService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProtocolsService.js","sourceRoot":"","sources":["../../../src/services/ProtocolsService.ts"],"names":[],"mappings":";;;;AAAA,yCAA8D;AAC9D,qCAAuC;AACvC,iCAAuE;AACvE,iDAA8C;AAC9C,6DAA4C;AA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AAC,CAAC,CAAC;qBACxD;yBAAM;wBACL,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAC,CAAC,CAAC;qBAC1C;iBACF;aACF;iBAAM;gBACL,IAAI,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,EAAE,KAAK,EAAE,EAAC,OAAO,EAAE,sBAAsB,EAAC,CAAC,CAAC;aACnF;QACH,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAnJC;IAAC,IAAA,WAAM,GAAE;sCACkB,wBAAe;yDAAC;AAE3C;IAAC,IAAA,WAAM,GAAE;sCACS,oBAAe;kDAAC;AAPvB,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAsJ5B;AAtJY,4CAAgB"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProtocolsFromRequest = void 0;
4
- const core_1 = require("@tsed/core");
5
- /**
6
- * @ignore
7
- */
8
- function getProtocolName(req) {
9
- const { query = {}, params = {}, body = {} } = req;
10
- return params.protocol || query.protocol || body.protocol;
11
- }
12
- /**
13
- * @ignore
14
- */
15
- function getProtocolsFromRequest(req, protocol, defaultProtocols) {
16
- if (!(0, core_1.isArray)(protocol)) {
17
- if (protocol === "*") {
18
- return defaultProtocols;
19
- }
20
- const protocolReq = getProtocolName(req);
21
- if (protocol === ":protocol") {
22
- return [protocolReq].filter(Boolean);
23
- }
24
- if (protocolReq && protocolReq !== protocol) {
25
- return [];
26
- }
27
- return [protocol];
28
- }
29
- const protocols = protocol;
30
- if (protocols.includes("*")) {
31
- return defaultProtocols;
32
- }
33
- return protocols;
34
- }
35
- exports.getProtocolsFromRequest = getProtocolsFromRequest;
36
- //# sourceMappingURL=getProtocolsFromRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProtocolsFromRequest.js","sourceRoot":"","sources":["../../../src/utils/getProtocolsFromRequest.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC;;GAEG;AACH,SAAS,eAAe,CAAC,GAAQ;IAC/B,MAAM,EAAC,KAAK,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC;IAEjD,OAAO,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,GAAQ,EAAE,QAA2B,EAAE,gBAA0B;IACvG,IAAI,CAAC,IAAA,cAAO,EAAC,QAAQ,CAAC,EAAE;QACtB,IAAI,QAAQ,KAAK,GAAG,EAAE;YACpB,OAAO,gBAAgB,CAAC;SACzB;QAED,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QAEzC,IAAI,QAAQ,KAAK,WAAW,EAAE;YAC5B,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACtC;QAED,IAAI,WAAW,IAAI,WAAW,KAAK,QAAQ,EAAE;YAC3C,OAAO,EAAE,CAAC;SACX;QAED,OAAO,CAAC,QAAQ,CAAC,CAAC;KACnB;IAED,MAAM,SAAS,GAAa,QAAQ,CAAC;IAErC,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC3B,OAAO,gBAAgB,CAAC;KACzB;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AA1BD,0DA0BC"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,19 +0,0 @@
1
- import { BeforeRoutesInit, OnInit, PlatformApplication, Logger } from "@tsed/common";
2
- import { PassportSerializerService } from "./services/PassportSerializerService.js";
3
- import { ProtocolsService } from "./services/ProtocolsService.js";
4
- /**
5
- * @ignore
6
- */
7
- export declare class PassportModule implements OnInit, BeforeRoutesInit {
8
- private app;
9
- private protocolsService;
10
- private passportSerializer;
11
- userProperty: string;
12
- pauseStream: boolean;
13
- disableSession: boolean;
14
- platformName: string;
15
- logger: Logger;
16
- constructor(app: PlatformApplication, protocolsService: ProtocolsService, passportSerializer: PassportSerializerService);
17
- $onInit(): Promise<any>;
18
- $beforeRoutesInit(): void | Promise<any>;
19
- }
@@ -1 +0,0 @@
1
- export declare const PROVIDER_TYPE_PROTOCOL = "protocol";
@@ -1,6 +0,0 @@
1
- /**
2
- * Inject args resolve by the passport strategy on verify method.
3
- * @decorator
4
- */
5
- export declare function Args(): any;
6
- export declare function Arg(index: number): any;
@@ -1,6 +0,0 @@
1
- import { AuthenticateOptions as PassportAuthenticateOptions } from "passport";
2
- export interface AuthenticateOptions extends PassportAuthenticateOptions {
3
- security?: Record<string, string[]>;
4
- originalUrl?: boolean;
5
- }
6
- export declare function Authenticate(protocol?: string | string[], options?: AuthenticateOptions): Function;
@@ -1,6 +0,0 @@
1
- import { AuthenticateOptions } from "passport";
2
- export interface AuthorizeOptions extends AuthenticateOptions {
3
- security?: Record<string, string[]>;
4
- originalUrl?: boolean;
5
- }
6
- export declare function Authorize(protocol?: string | string[], options?: AuthorizeOptions): Function;
@@ -1,11 +0,0 @@
1
- import { ProtocolOptions } from "../interfaces/ProtocolOptions.js";
2
- /**
3
- * Declare a new Protocol base on a Passport Strategy
4
- *
5
- * @decorator
6
- * @class
7
- */
8
- export declare function Protocol<T = any>(options: ProtocolOptionsDecorator<T>): any;
9
- export type ProtocolOptionsDecorator<T = any> = {
10
- name: string;
11
- } & Partial<ProtocolOptions<T>>;
@@ -1,5 +0,0 @@
1
- export declare class UserInfo {
2
- id: string;
3
- email: string;
4
- password: string;
5
- }
@@ -1,4 +0,0 @@
1
- import { Exception } from "@tsed/exceptions";
2
- export declare class PassportException extends Exception {
3
- constructor(error: any);
4
- }
@@ -1,5 +0,0 @@
1
- import { Unauthorized } from "@tsed/exceptions";
2
- export declare class PassportMessage extends Unauthorized {
3
- opts: Record<string, unknown>;
4
- constructor(message: string, opts?: Record<string, unknown>);
5
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * @file Automatically generated by @tsed/barrels.
3
- */
4
- export * from "./contants/constants.js";
5
- export * from "./decorators/args.js";
6
- export * from "./decorators/authenticate.js";
7
- export * from "./decorators/authorize.js";
8
- export * from "./decorators/protocol.js";
9
- export * from "./domain/UserInfo.js";
10
- export * from "./errors/PassportException.js";
11
- export * from "./errors/PassportMessage.js";
12
- export * from "./interfaces/BeforeInstall.js";
13
- export * from "./interfaces/interfaces.js";
14
- export * from "./interfaces/OnInstall.js";
15
- export * from "./interfaces/OnVerify.js";
16
- export * from "./interfaces/ProtocolMethods.js";
17
- export * from "./interfaces/ProtocolOptions.js";
18
- export * from "./middlewares/PassportMiddleware.js";
19
- export * from "./PassportModule.js";
20
- export * from "./services/PassportSerializerService.js";
21
- export * from "./services/ProtocolsService.js";
22
- export * from "./utils/getProtocolsFromRequest.js";
@@ -1,3 +0,0 @@
1
- export interface BeforeInstall<Settings = any> {
2
- $beforeInstall(setting: Settings): Promise<Settings> | Settings | void;
3
- }
@@ -1,4 +0,0 @@
1
- import { Strategy } from "passport";
2
- export interface OnInstall {
3
- $onInstall(strategy: Strategy): void | Promise<void>;
4
- }
@@ -1,3 +0,0 @@
1
- export interface OnVerify {
2
- $onVerify(...args: any[]): Promise<any | any[]> | any | any[];
3
- }
@@ -1,5 +0,0 @@
1
- import { OnInstall } from "./OnInstall.js";
2
- import { OnVerify } from "./OnVerify.js";
3
- import { BeforeInstall } from "./BeforeInstall.js";
4
- export interface ProtocolMethods<Settings = any> extends OnVerify, OnInstall, BeforeInstall<Settings> {
5
- }
@@ -1,7 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { Strategy } from "passport";
3
- export interface ProtocolOptions<Settings = any> {
4
- name: string;
5
- useStrategy: Type<Strategy>;
6
- settings: Settings;
7
- }
@@ -1,19 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { PassportStatic } from "passport";
3
- import { ProtocolOptions } from "./ProtocolOptions.js";
4
- declare global {
5
- namespace TsED {
6
- interface Configuration {
7
- passport: {
8
- userProperty?: string;
9
- pauseStream?: string;
10
- disableSession?: boolean;
11
- userInfoModel?: Type<any> | false;
12
- module?: PassportStatic;
13
- protocols?: {
14
- [protocolName: string]: Partial<ProtocolOptions>;
15
- };
16
- };
17
- }
18
- }
19
- }
@@ -1,7 +0,0 @@
1
- import { Context } from "@tsed/common";
2
- import { ProtocolsService } from "../services/ProtocolsService.js";
3
- export declare class PassportMiddleware {
4
- protocolsService: ProtocolsService;
5
- shouldSkip(ctx: Context): any;
6
- use(ctx: Context): Promise<void>;
7
- }
@@ -1,9 +0,0 @@
1
- import { UserInfo } from "../domain/UserInfo.js";
2
- /**
3
- * @ignore
4
- */
5
- export declare class PassportSerializerService {
6
- private model;
7
- serialize(user: UserInfo, done: any): void;
8
- deserialize(obj: any, done: any): void;
9
- }
@@ -1,54 +0,0 @@
1
- import { PlatformContext, PlatformHandler } from "@tsed/common";
2
- import { Provider } from "@tsed/di";
3
- import { Strategy } from "passport";
4
- import type { ProtocolMethods } from "../interfaces/ProtocolMethods.js";
5
- /**
6
- * @ignore
7
- */
8
- export declare class ProtocolsService {
9
- readonly strategies: Map<string, Strategy>;
10
- protected platformHandler: PlatformHandler;
11
- private injector;
12
- getProtocols(): Provider[];
13
- getProtocolsNames(): string[];
14
- /**
15
- * Invoke provider and bind it to passport.
16
- * @param provider
17
- */
18
- invoke(provider: Provider): Promise<ProtocolMethods<any> & Record<string, any>>;
19
- /**
20
- * Call authenticate passport method.
21
- * @param protocols
22
- * @param options
23
- * @param ctx
24
- */
25
- authenticate(protocols: string | string[], options: Record<string, any>, ctx: PlatformContext): Promise<void>;
26
- /**
27
- * Call authorize passport method.
28
- * @param protocols
29
- * @param options
30
- * @param ctx
31
- */
32
- authorize(protocols: string | string[], options: Record<string, any>, ctx: PlatformContext): Promise<void>;
33
- /**
34
- * Call passport authenticate or authorize depending on the chosen method.
35
- * @param method
36
- * @param protocols
37
- * @param options
38
- * @param ctx
39
- * @private
40
- */
41
- private call;
42
- /**
43
- * Create strategy options based on decorator metadata and global configuration
44
- * @param provider
45
- * @private
46
- */
47
- private getOptions;
48
- /**
49
- * Create the verifier handler for passport
50
- * @param provider
51
- * @private
52
- */
53
- private createHandler;
54
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export declare function getProtocolsFromRequest(req: any, protocol: string | string[], defaultProtocols: string[]): string[];