@tsed/passport 7.0.0-beta.11 → 7.0.0-beta.14
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/lib/cjs/PassportModule.js +8 -0
- package/lib/cjs/PassportModule.js.map +1 -1
- package/lib/cjs/domain/UserInfo.js +3 -0
- package/lib/cjs/domain/UserInfo.js.map +1 -1
- package/lib/cjs/middlewares/PassportMiddleware.js +1 -0
- package/lib/cjs/middlewares/PassportMiddleware.js.map +1 -1
- package/lib/cjs/services/PassportSerializerService.js +2 -1
- package/lib/cjs/services/PassportSerializerService.js.map +1 -1
- package/lib/cjs/services/ProtocolsService.js +20 -14
- package/lib/cjs/services/ProtocolsService.js.map +1 -1
- package/lib/esm/PassportModule.js +8 -0
- package/lib/esm/PassportModule.js.map +1 -1
- package/lib/esm/domain/UserInfo.js +3 -0
- package/lib/esm/domain/UserInfo.js.map +1 -1
- package/lib/esm/middlewares/PassportMiddleware.js +1 -0
- package/lib/esm/middlewares/PassportMiddleware.js.map +1 -1
- package/lib/esm/services/PassportSerializerService.js +2 -1
- package/lib/esm/services/PassportSerializerService.js.map +1 -1
- package/lib/esm/services/ProtocolsService.js +21 -15
- package/lib/esm/services/ProtocolsService.js.map +1 -1
- package/lib/types/services/ProtocolsService.d.ts +4 -4
- package/package.json +11 -7
- package/readme.md +2 -1
|
@@ -10,6 +10,14 @@ const ProtocolsService_1 = require("./services/ProtocolsService");
|
|
|
10
10
|
* @ignore
|
|
11
11
|
*/
|
|
12
12
|
let PassportModule = class PassportModule {
|
|
13
|
+
app;
|
|
14
|
+
protocolsService;
|
|
15
|
+
passportSerializer;
|
|
16
|
+
userProperty;
|
|
17
|
+
pauseStream;
|
|
18
|
+
disableSession;
|
|
19
|
+
platformName;
|
|
20
|
+
logger;
|
|
13
21
|
constructor(app, protocolsService, passportSerializer) {
|
|
14
22
|
this.app = app;
|
|
15
23
|
this.protocolsService = protocolsService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PassportModule.js","sourceRoot":"","sources":["../../src/PassportModule.ts"],"names":[],"mappings":";;;;AAAA,yCAAsI;AACtI,gEAAgC;AAChC,oFAA+E;AAC/E,kEAA6D;AAE7D;;GAEG;AAIH,IAAa,cAAc,GAA3B,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"PassportModule.js","sourceRoot":"","sources":["../../src/PassportModule.ts"],"names":[],"mappings":";;;;AAAA,yCAAsI;AACtI,gEAAgC;AAChC,oFAA+E;AAC/E,kEAA6D;AAE7D;;GAEG;AAIH,IAAa,cAAc,GAA3B,MAAa,cAAc;IAiBf;IACA;IACA;IAjBV,YAAY,CAAS;IAGrB,WAAW,CAAU;IAGrB,cAAc,CAAU;IAGxB,YAAY,CAAS;IAGrB,MAAM,CAAS;IAEf,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;AA3CC;IADC,IAAA,iBAAQ,EAAC,uBAAuB,CAAC;;oDACb;AAGrB;IADC,IAAA,iBAAQ,EAAC,sBAAsB,CAAC;;mDACZ;AAGrB;IADC,IAAA,iBAAQ,EAAC,yBAAyB,EAAE,KAAK,CAAC;;sDACnB;AAGxB;IADC,IAAA,iBAAQ,EAAC,eAAe,CAAC;;oDACL;AAGrB;IADC,IAAA,eAAM,GAAE;sCACD,eAAM;8CAAC;AAdJ,cAAc;IAH1B,IAAA,eAAM,EAAC;QACN,KAAK,EAAE,sBAAa,CAAC,SAAS;KAC/B,CAAC;6CAkBe,4BAAmB;QACN,mCAAgB;QACd,qDAAyB;GAnB5C,cAAc,CA6C1B;AA7CY,wCAAc","sourcesContent":["import {BeforeRoutesInit, Constant, Inject, Module, OnInit, PlatformApplication, Provider, ProviderScope, Logger} from \"@tsed/common\";\nimport Passport from \"passport\";\nimport {PassportSerializerService} from \"./services/PassportSerializerService\";\nimport {ProtocolsService} from \"./services/ProtocolsService\";\n\n/**\n * @ignore\n */\n@Module({\n scope: ProviderScope.SINGLETON\n})\nexport class PassportModule implements OnInit, BeforeRoutesInit {\n @Constant(\"passport.userProperty\")\n userProperty: string;\n\n @Constant(\"passport.pauseStream\")\n pauseStream: boolean;\n\n @Constant(\"passport.disableSession\", false)\n disableSession: boolean;\n\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\n\n @Inject()\n logger: Logger;\n\n constructor(\n private app: PlatformApplication,\n private protocolsService: ProtocolsService,\n private passportSerializer: PassportSerializerService\n ) {}\n\n async $onInit(): Promise<any> {\n Passport.serializeUser(this.passportSerializer.serialize.bind(this.passportSerializer));\n Passport.deserializeUser(this.passportSerializer.deserialize.bind(this.passportSerializer));\n\n const promises = this.protocolsService.getProtocols().map((provider: Provider) => this.protocolsService.invoke(provider));\n\n await Promise.all(promises);\n return undefined;\n }\n\n $beforeRoutesInit(): void | Promise<any> {\n const {userProperty, pauseStream} = this;\n switch (this.platformName) {\n case \"express\":\n this.app.use(Passport.initialize({userProperty}));\n !this.disableSession && this.app.use(Passport.session({pauseStream}));\n\n return;\n\n default:\n this.logger.warn(`Platform \"${this.platformName}\" not supported by @tsed/passport`);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserInfo.js","sourceRoot":"","sources":["../../../src/domain/UserInfo.ts"],"names":[],"mappings":";;;;AAAA,yCAA8C;AAE9C,MAAa,QAAQ;
|
|
1
|
+
{"version":3,"file":"UserInfo.js","sourceRoot":"","sources":["../../../src/domain/UserInfo.ts"],"names":[],"mappings":";;;;AAAA,yCAA8C;AAE9C,MAAa,QAAQ;IAEnB,EAAE,CAAS;IAIX,KAAK,CAAS;IAGd,QAAQ,CAAS;CAClB;AARC;IADC,IAAA,iBAAQ,GAAE;;oCACA;AAIX;IAFC,IAAA,iBAAQ,GAAE;IACV,IAAA,eAAM,EAAC,OAAO,CAAC;;uCACF;AAGd;IADC,IAAA,iBAAQ,GAAE;;0CACM;AATnB,4BAUC","sourcesContent":["import {Format, Property} from \"@tsed/schema\";\n\nexport class UserInfo {\n @Property()\n id: string;\n\n @Property()\n @Format(\"email\")\n email: string;\n\n @Property()\n password: string;\n}\n"]}
|
|
@@ -9,6 +9,7 @@ const common_1 = require("@tsed/common");
|
|
|
9
9
|
const ProtocolsService_1 = require("../services/ProtocolsService");
|
|
10
10
|
const getProtocolsFromRequest_1 = require("../utils/getProtocolsFromRequest");
|
|
11
11
|
let PassportMiddleware = PassportMiddleware_1 = class PassportMiddleware {
|
|
12
|
+
protocolsService;
|
|
12
13
|
shouldSkip(ctx) {
|
|
13
14
|
const request = ctx.getRequest();
|
|
14
15
|
return request.user && request.isAuthenticated();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PassportMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PassportMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,iCAAgC;AAChC,qEAAsD;AACtD,yCAAqC;AACrC,mEAA8D;AAC9D,8EAAyE;AAGzE,IAAa,kBAAkB,0BAA/B,MAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"PassportMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PassportMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,iCAAgC;AAChC,qEAAsD;AACtD,yCAAqC;AACrC,mEAA8D;AAC9D,8EAAyE;AAGzE,IAAa,kBAAkB,0BAA/B,MAAa,kBAAkB;IAE7B,gBAAgB,CAAmB;IAEnC,UAAU,CAAC,GAAY;QACrB,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO;SACR;QACD,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,EAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAkB,CAAC,CAAC;QAC/F,MAAM,SAAS,GAAG,IAAA,iDAAuB,EAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAExG,IAAI,WAAW,EAAE;YACf,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC;SACnC;QAED,MAAM,CAAC,MAAM,KAAK,cAAc;YAC9B,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC;YAC7D,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AAzBC;IADC,IAAA,WAAM,EAAC,mCAAgB,CAAC;sCACP,mCAAgB;4DAAC;AAOnC;IAAW,mBAAA,IAAA,gBAAO,GAAE,CAAA;;;;6CAiBnB;AA1BU,kBAAkB;IAD9B,IAAA,iCAAU,GAAE;GACA,kBAAkB,CA2B9B;AA3BY,gDAAkB","sourcesContent":["import {Inject} from \"@tsed/di\";\nimport {Middleware} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/common\";\nimport {ProtocolsService} from \"../services/ProtocolsService\";\nimport {getProtocolsFromRequest} from \"../utils/getProtocolsFromRequest\";\n\n@Middleware()\nexport class PassportMiddleware {\n @Inject(ProtocolsService)\n protocolsService: ProtocolsService;\n\n shouldSkip(ctx: Context) {\n const request = ctx.getRequest();\n return request.user && request.isAuthenticated();\n }\n\n async use(@Context() ctx: Context) {\n const endpoint = ctx.endpoint;\n const request = ctx.getRequest();\n\n if (this.shouldSkip(ctx)) {\n return;\n }\n const {options, protocol, method, originalUrl = true} = endpoint.store.get(PassportMiddleware);\n const protocols = getProtocolsFromRequest(request, protocol, this.protocolsService.getProtocolsNames());\n\n if (originalUrl) {\n request.url = request.originalUrl;\n }\n\n await (method === \"authenticate\"\n ? this.protocolsService.authenticate(protocols, options, ctx)\n : this.protocolsService.authorize(protocols, options, ctx));\n }\n}\n"]}
|
|
@@ -9,11 +9,12 @@ const UserInfo_1 = require("../domain/UserInfo");
|
|
|
9
9
|
* @ignore
|
|
10
10
|
*/
|
|
11
11
|
let PassportSerializerService = class PassportSerializerService {
|
|
12
|
+
model;
|
|
12
13
|
serialize(user, done) {
|
|
13
14
|
try {
|
|
14
15
|
const obj = (0, json_mapper_1.serialize)(user, { type: this.model });
|
|
15
16
|
// remove password from serialized object
|
|
16
|
-
|
|
17
|
+
obj.password = undefined;
|
|
17
18
|
done(null, JSON.stringify(obj));
|
|
18
19
|
}
|
|
19
20
|
catch (er) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PassportSerializerService.js","sourceRoot":"","sources":["../../../src/services/PassportSerializerService.ts"],"names":[],"mappings":";;;;AACA,iCAA2C;AAC3C,mDAAyD;AACzD,iDAA4C;AAE5C;;GAEG;AAEH,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;
|
|
1
|
+
{"version":3,"file":"PassportSerializerService.js","sourceRoot":"","sources":["../../../src/services/PassportSerializerService.ts"],"names":[],"mappings":";;;;AACA,iCAA2C;AAC3C,mDAAyD;AACzD,iDAA4C;AAE5C;;GAEG;AAEH,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;IAE5B,KAAK,CAA2B;IAExC,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;AAzBC;IADC,IAAA,aAAQ,EAAC,wBAAwB,EAAE,mBAAQ,CAAC;;wDACL;AAF7B,yBAAyB;IADrC,IAAA,YAAO,GAAE;GACG,yBAAyB,CA2BrC;AA3BY,8DAAyB","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Constant, Service} from \"@tsed/di\";\nimport {deserialize, serialize} from \"@tsed/json-mapper\";\nimport {UserInfo} from \"../domain/UserInfo\";\n\n/**\n * @ignore\n */\n@Service()\nexport class PassportSerializerService {\n @Constant(\"passport.userInfoModel\", UserInfo)\n private model: Type<UserInfo> | boolean;\n\n serialize(user: UserInfo, done: any) {\n try {\n const obj = serialize(user, {type: this.model});\n\n // remove password from serialized object\n obj.password = undefined;\n\n done(null, JSON.stringify(obj));\n } catch (er) {\n // istanbul ignore next\n done(er);\n }\n }\n\n deserialize(obj: any, done: any) {\n try {\n const user = deserialize(JSON.parse(obj), {type: this.model});\n\n done(null, user);\n } catch (er) {\n done(er);\n }\n }\n}\n"]}
|
|
@@ -7,17 +7,16 @@ const core_1 = require("@tsed/core");
|
|
|
7
7
|
const di_1 = require("@tsed/di");
|
|
8
8
|
const exceptions_1 = require("@tsed/exceptions");
|
|
9
9
|
const passport_1 = tslib_1.__importStar(require("passport"));
|
|
10
|
-
const PassportException_1 = require("../errors/PassportException");
|
|
11
|
-
const constants_1 = require("../contants/constants");
|
|
12
10
|
const util_1 = require("util");
|
|
11
|
+
const constants_1 = require("../contants/constants");
|
|
12
|
+
const PassportException_1 = require("../errors/PassportException");
|
|
13
13
|
/**
|
|
14
14
|
* @ignore
|
|
15
15
|
*/
|
|
16
16
|
let ProtocolsService = class ProtocolsService {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
strategies = new Map();
|
|
18
|
+
platformHandler;
|
|
19
|
+
injector;
|
|
21
20
|
getProtocols() {
|
|
22
21
|
return this.injector.getProviders(constants_1.PROVIDER_TYPE_PROTOCOL);
|
|
23
22
|
}
|
|
@@ -112,15 +111,15 @@ let ProtocolsService = class ProtocolsService {
|
|
|
112
111
|
* @private
|
|
113
112
|
*/
|
|
114
113
|
createHandler(provider) {
|
|
115
|
-
const
|
|
116
|
-
const middleware = platformHandler.createCustomHandler(provider, "$onVerify");
|
|
114
|
+
const middleware = this.platformHandler.createCustomHandler(provider, "$onVerify");
|
|
117
115
|
return async (req, ...args) => {
|
|
116
|
+
const $ctx = (0, di_1.getContext)();
|
|
118
117
|
const done = args[args.length - 1];
|
|
119
|
-
if (
|
|
120
|
-
|
|
118
|
+
if ($ctx) {
|
|
119
|
+
$ctx.set("PROTOCOL_ARGS", args.slice(0, -1));
|
|
121
120
|
try {
|
|
122
|
-
await middleware(
|
|
123
|
-
done(null, ...[].concat(
|
|
121
|
+
await middleware($ctx);
|
|
122
|
+
done(null, ...[].concat($ctx.data));
|
|
124
123
|
}
|
|
125
124
|
catch (err) {
|
|
126
125
|
done(err, false, { message: err.message });
|
|
@@ -132,9 +131,16 @@ let ProtocolsService = class ProtocolsService {
|
|
|
132
131
|
};
|
|
133
132
|
}
|
|
134
133
|
};
|
|
134
|
+
tslib_1.__decorate([
|
|
135
|
+
(0, di_1.Inject)(),
|
|
136
|
+
tslib_1.__metadata("design:type", common_1.PlatformHandler)
|
|
137
|
+
], ProtocolsService.prototype, "platformHandler", void 0);
|
|
138
|
+
tslib_1.__decorate([
|
|
139
|
+
(0, di_1.Inject)(),
|
|
140
|
+
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
141
|
+
], ProtocolsService.prototype, "injector", void 0);
|
|
135
142
|
ProtocolsService = tslib_1.__decorate([
|
|
136
|
-
(0, di_1.Injectable)()
|
|
137
|
-
tslib_1.__metadata("design:paramtypes", [di_1.InjectorService])
|
|
143
|
+
(0, di_1.Injectable)()
|
|
138
144
|
], ProtocolsService);
|
|
139
145
|
exports.ProtocolsService = ProtocolsService;
|
|
140
146
|
//# sourceMappingURL=ProtocolsService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProtocolsService.js","sourceRoot":"","sources":["../../../src/services/ProtocolsService.ts"],"names":[],"mappings":";;;;AAAA,yCAA8D;AAC9D,qCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"ProtocolsService.js","sourceRoot":"","sources":["../../../src/services/ProtocolsService.ts"],"names":[],"mappings":";;;;AAAA,yCAA8D;AAC9D,qCAAuC;AACvC,iCAAmF;AACnF,iDAA8C;AAC9C,6DAA4C;AAC5C,+BAA+B;AAC/B,qDAA6D;AAC7D,mEAA8D;AAI9D;;GAEG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAClB,UAAU,GAA0B,IAAI,GAAG,EAAE,CAAC;IAG7C,eAAe,CAAkB;IAGnC,QAAQ,CAAkB;IAE3B,YAAY;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,kCAAsB,CAAC,CAAC;IAC5D,CAAC;IAEM,iBAAiB;QACtB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,QAAkB;QAC7B,IAAI,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC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AAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAEnF,OAAO,KAAK,EAAE,GAAQ,EAAE,GAAG,IAAW,EAAE,EAAE;YACxC,MAAM,IAAI,GAAG,IAAA,eAAU,GAAmB,CAAC;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAEnC,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE7C,IAAI;oBACF,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;oBAEvB,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;iBACrC;gBAAC,OAAO,GAAG,EAAE;oBACZ,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAC,CAAC,CAAC;iBAC1C;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;AA/IC;IADC,IAAA,WAAM,GAAE;sCACkB,wBAAe;yDAAC;AAG3C;IADC,IAAA,WAAM,GAAE;sCACS,oBAAe;kDAAC;AAPvB,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAmJ5B;AAnJY,4CAAgB","sourcesContent":["import {PlatformContext, PlatformHandler} from \"@tsed/common\";\nimport {ancestorsOf} from \"@tsed/core\";\nimport {getContext, Inject, Injectable, InjectorService, Provider} from \"@tsed/di\";\nimport {Unauthorized} from \"@tsed/exceptions\";\nimport Passport, {Strategy} from \"passport\";\nimport {promisify} from \"util\";\nimport {PROVIDER_TYPE_PROTOCOL} from \"../contants/constants\";\nimport {PassportException} from \"../errors/PassportException\";\nimport type {ProtocolMethods} from \"../interfaces/ProtocolMethods\";\nimport type {ProtocolOptions} from \"../interfaces/ProtocolOptions\";\n\n/**\n * @ignore\n */\n@Injectable()\nexport class ProtocolsService {\n readonly strategies: Map<string, Strategy> = new Map();\n\n @Inject()\n protected platformHandler: PlatformHandler;\n\n @Inject()\n private injector: InjectorService;\n\n public getProtocols(): Provider[] {\n return this.injector.getProviders(PROVIDER_TYPE_PROTOCOL);\n }\n\n public getProtocolsNames(): string[] {\n return Array.from(this.strategies.keys());\n }\n\n /**\n * Invoke provider and bind it to passport.\n * @param provider\n */\n async invoke(provider: Provider) {\n let {name, useStrategy: strategy, settings} = this.getOptions(provider);\n const protocol = this.injector.get<ProtocolMethods & Record<string, any>>(provider.provide)!;\n\n if (protocol.$beforeInstall) {\n settings = (await protocol.$beforeInstall(settings)) || settings;\n }\n\n const instance = new strategy(settings, this.createHandler(provider));\n\n this.strategies.set(name, instance);\n\n Passport.use(name, instance);\n\n if (protocol.$onInstall) {\n await protocol.$onInstall(instance);\n }\n\n protocol.$strategy = instance;\n\n return protocol;\n }\n\n /**\n * Call authenticate passport method.\n * @param protocols\n * @param options\n * @param ctx\n */\n public async authenticate(protocols: string | string[], options: Record<string, any>, ctx: PlatformContext) {\n return this.call(\"authenticate\", protocols, options, ctx);\n }\n\n /**\n * Call authorize passport method.\n * @param protocols\n * @param options\n * @param ctx\n */\n public async authorize(protocols: string | string[], options: Record<string, any>, ctx: PlatformContext) {\n return this.call(\"authorize\", protocols, options, ctx);\n }\n\n /**\n * Call passport authenticate or authorize depending on the chosen method.\n * @param method\n * @param protocols\n * @param options\n * @param ctx\n * @private\n */\n private async call(\n method: \"authenticate\" | \"authorize\",\n protocols: string | string[],\n options: Record<string, any>,\n ctx: PlatformContext\n ) {\n const request = ctx.getRequest();\n const response = ctx.getResponse();\n protocols = ([] as string[]).concat(protocols);\n\n if (protocols.length === 0) {\n throw new Unauthorized(\"Not authorized\");\n }\n\n try {\n options.failWithError = true;\n // @ts-ignore\n const fn = promisify(Passport[method](protocols.length === 1 ? protocols[0] : protocols, options));\n\n await fn(request, response);\n } catch (er) {\n if (!ancestorsOf(er).includes(Error)) {\n throw new PassportException(er);\n }\n\n throw er;\n }\n }\n\n /**\n * Create strategy options based on decorator metadata and global configuration\n * @param provider\n * @private\n */\n private getOptions(provider: Provider<any>): ProtocolOptions {\n const {name} = provider.store.get(\"protocol\");\n const {useStrategy = Strategy, settings = {}}: ProtocolOptions = this.injector.settings.get(`passport.protocols.${name}`) || {};\n\n return {\n name,\n useStrategy,\n settings: {\n ...settings,\n passReqToCallback: true\n }\n };\n }\n\n /**\n * Create the verifier handler for passport\n * @param provider\n * @private\n */\n private createHandler(provider: Provider) {\n const middleware = this.platformHandler.createCustomHandler(provider, \"$onVerify\");\n\n return async (req: any, ...args: any[]) => {\n const $ctx = getContext<PlatformContext>();\n const done = args[args.length - 1];\n\n if ($ctx) {\n $ctx.set(\"PROTOCOL_ARGS\", args.slice(0, -1));\n\n try {\n await middleware($ctx);\n\n done(null, ...[].concat($ctx.data));\n } catch (err) {\n done(err, false, {message: err.message});\n }\n } else {\n done(new Error(\"Headers already sent\"), false, {message: \"Headers already sent\"});\n }\n };\n }\n}\n"]}
|
|
@@ -7,6 +7,14 @@ import { ProtocolsService } from "./services/ProtocolsService.js";
|
|
|
7
7
|
* @ignore
|
|
8
8
|
*/
|
|
9
9
|
let PassportModule = class PassportModule {
|
|
10
|
+
app;
|
|
11
|
+
protocolsService;
|
|
12
|
+
passportSerializer;
|
|
13
|
+
userProperty;
|
|
14
|
+
pauseStream;
|
|
15
|
+
disableSession;
|
|
16
|
+
platformName;
|
|
17
|
+
logger;
|
|
10
18
|
constructor(app, protocolsService, passportSerializer) {
|
|
11
19
|
this.app = app;
|
|
12
20
|
this.protocolsService = protocolsService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PassportModule.js","sourceRoot":"","sources":["../../src/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esInit, Constant, Inject, Module, OnInit, PlatformApplication, Provider, ProviderScope, Logger} from \"@tsed/common\";\nimport Passport from \"passport\";\nimport {PassportSerializerService} from \"./services/PassportSerializerService\";\nimport {ProtocolsService} from \"./services/ProtocolsService\";\n\n/**\n * @ignore\n */\n@Module({\n scope: ProviderScope.SINGLETON\n})\nexport class PassportModule implements OnInit, BeforeRoutesInit {\n @Constant(\"passport.userProperty\")\n userProperty: string;\n\n @Constant(\"passport.pauseStream\")\n pauseStream: boolean;\n\n @Constant(\"passport.disableSession\", false)\n disableSession: boolean;\n\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\n\n @Inject()\n logger: Logger;\n\n constructor(\n private app: PlatformApplication,\n private protocolsService: ProtocolsService,\n private passportSerializer: PassportSerializerService\n ) {}\n\n async $onInit(): Promise<any> {\n Passport.serializeUser(this.passportSerializer.serialize.bind(this.passportSerializer));\n Passport.deserializeUser(this.passportSerializer.deserialize.bind(this.passportSerializer));\n\n const promises = this.protocolsService.getProtocols().map((provider: Provider) => this.protocolsService.invoke(provider));\n\n await Promise.all(promises);\n return undefined;\n }\n\n $beforeRoutesInit(): void | Promise<any> {\n const {userProperty, pauseStream} = this;\n switch (this.platformName) {\n case \"express\":\n this.app.use(Passport.initialize({userProperty}));\n !this.disableSession && this.app.use(Passport.session({pauseStream}));\n\n return;\n\n default:\n this.logger.warn(`Platform \"${this.platformName}\" not supported by @tsed/passport`);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserInfo.js","sourceRoot":"","sources":["../../../src/domain/UserInfo.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE9C,MAAM,OAAO,QAAQ;
|
|
1
|
+
{"version":3,"file":"UserInfo.js","sourceRoot":"","sources":["../../../src/domain/UserInfo.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE9C,MAAM,OAAO,QAAQ;IAEnB,EAAE,CAAS;IAIX,KAAK,CAAS;IAGd,QAAQ,CAAS;CAClB;AARC;IADC,QAAQ,EAAE;;oCACA;AAIX;IAFC,QAAQ,EAAE;IACV,MAAM,CAAC,OAAO,CAAC;;uCACF;AAGd;IADC,QAAQ,EAAE;;0CACM","sourcesContent":["import {Format, Property} from \"@tsed/schema\";\n\nexport class UserInfo {\n @Property()\n id: string;\n\n @Property()\n @Format(\"email\")\n email: string;\n\n @Property()\n password: string;\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { Context } from "@tsed/common";
|
|
|
6
6
|
import { ProtocolsService } from "../services/ProtocolsService.js";
|
|
7
7
|
import { getProtocolsFromRequest } from "../utils/getProtocolsFromRequest.js";
|
|
8
8
|
let PassportMiddleware = PassportMiddleware_1 = class PassportMiddleware {
|
|
9
|
+
protocolsService;
|
|
9
10
|
shouldSkip(ctx) {
|
|
10
11
|
const request = ctx.getRequest();
|
|
11
12
|
return request.user && request.isAuthenticated();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PassportMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PassportMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,uBAAuB,EAAC,MAAM,kCAAkC,CAAC;AAGzE,IAAa,kBAAkB,0BAA/B,MAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"PassportMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PassportMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAA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AC,gBAAgB,CAAC;8BACP,gBAAgB;4DAAC;AAOnC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;6CAiBnB;AA1BU,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CA2B9B;SA3BY,kBAAkB","sourcesContent":["import {Inject} from \"@tsed/di\";\nimport {Middleware} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/common\";\nimport {ProtocolsService} from \"../services/ProtocolsService\";\nimport {getProtocolsFromRequest} from \"../utils/getProtocolsFromRequest\";\n\n@Middleware()\nexport class PassportMiddleware {\n @Inject(ProtocolsService)\n protocolsService: ProtocolsService;\n\n shouldSkip(ctx: Context) {\n const request = ctx.getRequest();\n return request.user && request.isAuthenticated();\n }\n\n async use(@Context() ctx: Context) {\n const endpoint = ctx.endpoint;\n const request = ctx.getRequest();\n\n if (this.shouldSkip(ctx)) {\n return;\n }\n const {options, protocol, method, originalUrl = true} = endpoint.store.get(PassportMiddleware);\n const protocols = getProtocolsFromRequest(request, protocol, this.protocolsService.getProtocolsNames());\n\n if (originalUrl) {\n request.url = request.originalUrl;\n }\n\n await (method === \"authenticate\"\n ? this.protocolsService.authenticate(protocols, options, ctx)\n : this.protocolsService.authorize(protocols, options, ctx));\n }\n}\n"]}
|
|
@@ -6,11 +6,12 @@ import { UserInfo } from "../domain/UserInfo.js";
|
|
|
6
6
|
* @ignore
|
|
7
7
|
*/
|
|
8
8
|
let PassportSerializerService = class PassportSerializerService {
|
|
9
|
+
model;
|
|
9
10
|
serialize(user, done) {
|
|
10
11
|
try {
|
|
11
12
|
const obj = serialize(user, { type: this.model });
|
|
12
13
|
// remove password from serialized object
|
|
13
|
-
|
|
14
|
+
obj.password = undefined;
|
|
14
15
|
done(null, JSON.stringify(obj));
|
|
15
16
|
}
|
|
16
17
|
catch (er) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PassportSerializerService.js","sourceRoot":"","sources":["../../../src/services/PassportSerializerService.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAE5C;;GAEG;AAEH,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;
|
|
1
|
+
{"version":3,"file":"PassportSerializerService.js","sourceRoot":"","sources":["../../../src/services/PassportSerializerService.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAE5C;;GAEG;AAEH,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;IAE5B,KAAK,CAA2B;IAExC,SAAS,CAAC,IAAc,EAAE,IAAS;QACjC,IAAI;YACF,MAAM,GAAG,GAAG,SAAS,CAAC,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,WAAW,CAAC,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;AAzBC;IADC,QAAQ,CAAC,wBAAwB,EAAE,QAAQ,CAAC;;wDACL;AAF7B,yBAAyB;IADrC,OAAO,EAAE;GACG,yBAAyB,CA2BrC;SA3BY,yBAAyB","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Constant, Service} from \"@tsed/di\";\nimport {deserialize, serialize} from \"@tsed/json-mapper\";\nimport {UserInfo} from \"../domain/UserInfo\";\n\n/**\n * @ignore\n */\n@Service()\nexport class PassportSerializerService {\n @Constant(\"passport.userInfoModel\", UserInfo)\n private model: Type<UserInfo> | boolean;\n\n serialize(user: UserInfo, done: any) {\n try {\n const obj = serialize(user, {type: this.model});\n\n // remove password from serialized object\n obj.password = undefined;\n\n done(null, JSON.stringify(obj));\n } catch (er) {\n // istanbul ignore next\n done(er);\n }\n }\n\n deserialize(obj: any, done: any) {\n try {\n const user = deserialize(JSON.parse(obj), {type: this.model});\n\n done(null, user);\n } catch (er) {\n done(er);\n }\n }\n}\n"]}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { PlatformHandler } from "@tsed/common";
|
|
3
3
|
import { ancestorsOf } from "@tsed/core";
|
|
4
|
-
import { Injectable, InjectorService } from "@tsed/di";
|
|
4
|
+
import { getContext, Inject, Injectable, InjectorService } from "@tsed/di";
|
|
5
5
|
import { Unauthorized } from "@tsed/exceptions";
|
|
6
6
|
import Passport, { Strategy } from "passport";
|
|
7
|
-
import { PassportException } from "../errors/PassportException.js";
|
|
8
|
-
import { PROVIDER_TYPE_PROTOCOL } from "../contants/constants.js";
|
|
9
7
|
import { promisify } from "util";
|
|
8
|
+
import { PROVIDER_TYPE_PROTOCOL } from "../contants/constants.js";
|
|
9
|
+
import { PassportException } from "../errors/PassportException.js";
|
|
10
10
|
/**
|
|
11
11
|
* @ignore
|
|
12
12
|
*/
|
|
13
13
|
let ProtocolsService = class ProtocolsService {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
14
|
+
strategies = new Map();
|
|
15
|
+
platformHandler;
|
|
16
|
+
injector;
|
|
18
17
|
getProtocols() {
|
|
19
18
|
return this.injector.getProviders(PROVIDER_TYPE_PROTOCOL);
|
|
20
19
|
}
|
|
@@ -109,15 +108,15 @@ let ProtocolsService = class ProtocolsService {
|
|
|
109
108
|
* @private
|
|
110
109
|
*/
|
|
111
110
|
createHandler(provider) {
|
|
112
|
-
const
|
|
113
|
-
const middleware = platformHandler.createCustomHandler(provider, "$onVerify");
|
|
111
|
+
const middleware = this.platformHandler.createCustomHandler(provider, "$onVerify");
|
|
114
112
|
return async (req, ...args) => {
|
|
113
|
+
const $ctx = getContext();
|
|
115
114
|
const done = args[args.length - 1];
|
|
116
|
-
if (
|
|
117
|
-
|
|
115
|
+
if ($ctx) {
|
|
116
|
+
$ctx.set("PROTOCOL_ARGS", args.slice(0, -1));
|
|
118
117
|
try {
|
|
119
|
-
await middleware(
|
|
120
|
-
done(null, ...[].concat(
|
|
118
|
+
await middleware($ctx);
|
|
119
|
+
done(null, ...[].concat($ctx.data));
|
|
121
120
|
}
|
|
122
121
|
catch (err) {
|
|
123
122
|
done(err, false, { message: err.message });
|
|
@@ -129,9 +128,16 @@ let ProtocolsService = class ProtocolsService {
|
|
|
129
128
|
};
|
|
130
129
|
}
|
|
131
130
|
};
|
|
131
|
+
__decorate([
|
|
132
|
+
Inject(),
|
|
133
|
+
__metadata("design:type", PlatformHandler)
|
|
134
|
+
], ProtocolsService.prototype, "platformHandler", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
Inject(),
|
|
137
|
+
__metadata("design:type", InjectorService)
|
|
138
|
+
], ProtocolsService.prototype, "injector", void 0);
|
|
132
139
|
ProtocolsService = __decorate([
|
|
133
|
-
Injectable()
|
|
134
|
-
__metadata("design:paramtypes", [InjectorService])
|
|
140
|
+
Injectable()
|
|
135
141
|
], ProtocolsService);
|
|
136
142
|
export { ProtocolsService };
|
|
137
143
|
//# sourceMappingURL=ProtocolsService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProtocolsService.js","sourceRoot":"","sources":["../../../src/services/ProtocolsService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,eAAe,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,UAAU,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ProtocolsService.js","sourceRoot":"","sources":["../../../src/services/ProtocolsService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,eAAe,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AACnF,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,QAAQ,EAAE,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAC,sBAAsB,EAAC,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAI9D;;GAEG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAClB,UAAU,GAA0B,IAAI,GAAG,EAAE,CAAC;IAG7C,eAAe,CAAkB;IAGnC,QAAQ,CAAkB;IAE3B,YAAY;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;IAC5D,CAAC;IAEM,iBAAiB;QACtB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAG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iB,EAAE,IAAI;aACxB;SACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACK,aAAa,CAAC,QAAkB;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAEnF,OAAO,KAAK,EAAE,GAAQ,EAAE,GAAG,IAAW,EAAE,EAAE;YACxC,MAAM,IAAI,GAAG,UAAU,EAAmB,CAAC;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAEnC,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE7C,IAAI;oBACF,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;oBAEvB,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;iBACrC;gBAAC,OAAO,GAAG,EAAE;oBACZ,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAC,CAAC,CAAC;iBAC1C;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;AA/IC;IADC,MAAM,EAAE;8BACkB,eAAe;yDAAC;AAG3C;IADC,MAAM,EAAE;8BACS,eAAe;kDAAC;AAPvB,gBAAgB;IAD5B,UAAU,EAAE;GACA,gBAAgB,CAmJ5B;SAnJY,gBAAgB","sourcesContent":["import {PlatformContext, PlatformHandler} from \"@tsed/common\";\nimport {ancestorsOf} from \"@tsed/core\";\nimport {getContext, Inject, Injectable, InjectorService, Provider} from \"@tsed/di\";\nimport {Unauthorized} from \"@tsed/exceptions\";\nimport Passport, {Strategy} from \"passport\";\nimport {promisify} from \"util\";\nimport {PROVIDER_TYPE_PROTOCOL} from \"../contants/constants\";\nimport {PassportException} from \"../errors/PassportException\";\nimport type {ProtocolMethods} from \"../interfaces/ProtocolMethods\";\nimport type {ProtocolOptions} from \"../interfaces/ProtocolOptions\";\n\n/**\n * @ignore\n */\n@Injectable()\nexport class ProtocolsService {\n readonly strategies: Map<string, Strategy> = new Map();\n\n @Inject()\n protected platformHandler: PlatformHandler;\n\n @Inject()\n private injector: InjectorService;\n\n public getProtocols(): Provider[] {\n return this.injector.getProviders(PROVIDER_TYPE_PROTOCOL);\n }\n\n public getProtocolsNames(): string[] {\n return Array.from(this.strategies.keys());\n }\n\n /**\n * Invoke provider and bind it to passport.\n * @param provider\n */\n async invoke(provider: Provider) {\n let {name, useStrategy: strategy, settings} = this.getOptions(provider);\n const protocol = this.injector.get<ProtocolMethods & Record<string, any>>(provider.provide)!;\n\n if (protocol.$beforeInstall) {\n settings = (await protocol.$beforeInstall(settings)) || settings;\n }\n\n const instance = new strategy(settings, this.createHandler(provider));\n\n this.strategies.set(name, instance);\n\n Passport.use(name, instance);\n\n if (protocol.$onInstall) {\n await protocol.$onInstall(instance);\n }\n\n protocol.$strategy = instance;\n\n return protocol;\n }\n\n /**\n * Call authenticate passport method.\n * @param protocols\n * @param options\n * @param ctx\n */\n public async authenticate(protocols: string | string[], options: Record<string, any>, ctx: PlatformContext) {\n return this.call(\"authenticate\", protocols, options, ctx);\n }\n\n /**\n * Call authorize passport method.\n * @param protocols\n * @param options\n * @param ctx\n */\n public async authorize(protocols: string | string[], options: Record<string, any>, ctx: PlatformContext) {\n return this.call(\"authorize\", protocols, options, ctx);\n }\n\n /**\n * Call passport authenticate or authorize depending on the chosen method.\n * @param method\n * @param protocols\n * @param options\n * @param ctx\n * @private\n */\n private async call(\n method: \"authenticate\" | \"authorize\",\n protocols: string | string[],\n options: Record<string, any>,\n ctx: PlatformContext\n ) {\n const request = ctx.getRequest();\n const response = ctx.getResponse();\n protocols = ([] as string[]).concat(protocols);\n\n if (protocols.length === 0) {\n throw new Unauthorized(\"Not authorized\");\n }\n\n try {\n options.failWithError = true;\n // @ts-ignore\n const fn = promisify(Passport[method](protocols.length === 1 ? protocols[0] : protocols, options));\n\n await fn(request, response);\n } catch (er) {\n if (!ancestorsOf(er).includes(Error)) {\n throw new PassportException(er);\n }\n\n throw er;\n }\n }\n\n /**\n * Create strategy options based on decorator metadata and global configuration\n * @param provider\n * @private\n */\n private getOptions(provider: Provider<any>): ProtocolOptions {\n const {name} = provider.store.get(\"protocol\");\n const {useStrategy = Strategy, settings = {}}: ProtocolOptions = this.injector.settings.get(`passport.protocols.${name}`) || {};\n\n return {\n name,\n useStrategy,\n settings: {\n ...settings,\n passReqToCallback: true\n }\n };\n }\n\n /**\n * Create the verifier handler for passport\n * @param provider\n * @private\n */\n private createHandler(provider: Provider) {\n const middleware = this.platformHandler.createCustomHandler(provider, \"$onVerify\");\n\n return async (req: any, ...args: any[]) => {\n const $ctx = getContext<PlatformContext>();\n const done = args[args.length - 1];\n\n if ($ctx) {\n $ctx.set(\"PROTOCOL_ARGS\", args.slice(0, -1));\n\n try {\n await middleware($ctx);\n\n done(null, ...[].concat($ctx.data));\n } catch (err) {\n done(err, false, {message: err.message});\n }\n } else {\n done(new Error(\"Headers already sent\"), false, {message: \"Headers already sent\"});\n }\n };\n }\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { PlatformContext } from "@tsed/common";
|
|
2
|
-
import {
|
|
1
|
+
import { PlatformContext, PlatformHandler } from "@tsed/common";
|
|
2
|
+
import { Provider } from "@tsed/di";
|
|
3
3
|
import { Strategy } from "passport";
|
|
4
4
|
import type { ProtocolMethods } from "../interfaces/ProtocolMethods";
|
|
5
5
|
/**
|
|
6
6
|
* @ignore
|
|
7
7
|
*/
|
|
8
8
|
export declare class ProtocolsService {
|
|
9
|
-
private injector;
|
|
10
9
|
readonly strategies: Map<string, Strategy>;
|
|
11
|
-
|
|
10
|
+
protected platformHandler: PlatformHandler;
|
|
11
|
+
private injector;
|
|
12
12
|
getProtocols(): Provider[];
|
|
13
13
|
getProtocolsNames(): string[];
|
|
14
14
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/passport",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.14",
|
|
4
4
|
"description": "Passport package for Ts.ED framework",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
"start": "ts-node src/index.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"tslib": "2.
|
|
25
|
+
"tslib": "2.4.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tsed/common": "7.0.0-beta.
|
|
29
|
-
"@tsed/core": "7.0.0-beta.
|
|
30
|
-
"@tsed/di": "7.0.0-beta.
|
|
28
|
+
"@tsed/common": "7.0.0-beta.14",
|
|
29
|
+
"@tsed/core": "7.0.0-beta.14",
|
|
30
|
+
"@tsed/di": "7.0.0-beta.14",
|
|
31
|
+
"@tsed/platform-router": "7.0.0-beta.14",
|
|
31
32
|
"@types/passport": "1.0.7",
|
|
32
33
|
"@types/passport-http": "0.3.9",
|
|
33
34
|
"@types/passport-local": "1.0.34",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"passport-strategy": "1.0.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"@tsed/common": "^7.0.0-beta.
|
|
42
|
+
"@tsed/common": "^7.0.0-beta.14",
|
|
42
43
|
"passport": ">=0.4.1"
|
|
43
44
|
},
|
|
44
45
|
"peerDependenciesMeta": {
|
|
@@ -52,5 +53,8 @@
|
|
|
52
53
|
},
|
|
53
54
|
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/security/passport",
|
|
54
55
|
"author": "Romain Lenzotti",
|
|
55
|
-
"license": "MIT"
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"tag": "beta"
|
|
59
|
+
}
|
|
56
60
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|