@tsed/passport 7.0.0-alpha.1 → 7.0.0-beta.3
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/{PassportModule.js → cjs/PassportModule.js} +16 -16
- package/lib/cjs/PassportModule.js.map +1 -0
- package/lib/{contants → cjs/contants}/index.js +0 -0
- package/lib/cjs/contants/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/args.js +2 -2
- package/lib/cjs/decorators/args.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/authenticate.js +2 -2
- package/lib/cjs/decorators/authenticate.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/authorize.js +2 -2
- package/lib/cjs/decorators/authorize.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/protocol.js +2 -2
- package/lib/cjs/decorators/protocol.js.map +1 -0
- package/lib/cjs/domain/UserInfo.js +22 -0
- package/lib/cjs/domain/UserInfo.js.map +1 -0
- package/lib/{errors → cjs/errors}/PassportException.js +0 -0
- package/lib/cjs/errors/PassportException.js.map +1 -0
- package/lib/cjs/index.js +20 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/IProtocol.js +0 -0
- package/lib/cjs/interfaces/IProtocol.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnInstall.js +0 -0
- package/lib/cjs/interfaces/OnInstall.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnVerify.js +0 -0
- package/lib/cjs/interfaces/OnVerify.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/ProtocolOptions.js +0 -0
- package/lib/cjs/interfaces/ProtocolOptions.js.map +1 -0
- package/lib/cjs/interfaces/index.js +8 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/PassportMiddleware.js +11 -11
- package/lib/cjs/middlewares/PassportMiddleware.js.map +1 -0
- package/lib/{services → cjs/services}/PassportSerializerService.js +7 -7
- package/lib/cjs/services/PassportSerializerService.js.map +1 -0
- package/lib/{services → cjs/services}/ProtocolsService.js +6 -6
- package/lib/cjs/services/ProtocolsService.js.map +1 -0
- package/lib/{utils → cjs/utils}/getProtocolsFromRequest.js +1 -1
- package/lib/cjs/utils/getProtocolsFromRequest.js.map +1 -0
- package/lib/esm/PassportModule.js +58 -0
- package/lib/esm/PassportModule.js.map +1 -0
- package/lib/esm/contants/index.js +2 -0
- package/lib/esm/contants/index.js.map +1 -0
- package/lib/esm/decorators/args.js +13 -0
- package/lib/esm/decorators/args.js.map +1 -0
- package/lib/esm/decorators/authenticate.js +15 -0
- package/lib/esm/decorators/authenticate.js.map +1 -0
- package/lib/esm/decorators/authorize.js +15 -0
- package/lib/esm/decorators/authorize.js.map +1 -0
- package/lib/esm/decorators/protocol.js +21 -0
- package/lib/esm/decorators/protocol.js.map +1 -0
- package/lib/esm/domain/UserInfo.js +18 -0
- package/lib/esm/domain/UserInfo.js.map +1 -0
- package/lib/esm/errors/PassportException.js +8 -0
- package/lib/esm/errors/PassportException.js.map +1 -0
- package/lib/esm/index.js +17 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/IProtocol.js +2 -0
- package/lib/esm/interfaces/IProtocol.js.map +1 -0
- package/lib/esm/interfaces/OnInstall.js +2 -0
- package/lib/esm/interfaces/OnInstall.js.map +1 -0
- package/lib/esm/interfaces/OnVerify.js +2 -0
- package/lib/esm/interfaces/OnVerify.js.map +1 -0
- package/lib/esm/interfaces/ProtocolOptions.js +2 -0
- package/lib/esm/interfaces/ProtocolOptions.js.map +1 -0
- package/lib/esm/interfaces/index.js +5 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/middlewares/PassportMiddleware.js +41 -0
- package/lib/esm/middlewares/PassportMiddleware.js.map +1 -0
- package/lib/esm/services/PassportSerializerService.js +39 -0
- package/lib/esm/services/PassportSerializerService.js.map +1 -0
- package/lib/esm/services/ProtocolsService.js +129 -0
- package/lib/esm/services/ProtocolsService.js.map +1 -0
- package/lib/esm/utils/getProtocolsFromRequest.js +32 -0
- package/lib/esm/utils/getProtocolsFromRequest.js.map +1 -0
- package/lib/{PassportModule.d.ts → types/PassportModule.d.ts} +0 -0
- package/lib/{contants → types/contants}/index.d.ts +0 -0
- package/lib/{decorators → types/decorators}/args.d.ts +0 -0
- package/lib/{decorators → types/decorators}/authenticate.d.ts +0 -0
- package/lib/{decorators → types/decorators}/authorize.d.ts +0 -0
- package/lib/{decorators → types/decorators}/protocol.d.ts +0 -0
- package/lib/{domain → types/domain}/UserInfo.d.ts +0 -0
- package/lib/{errors → types/errors}/PassportException.d.ts +0 -0
- package/lib/{index.d.ts → types/index.d.ts} +0 -0
- package/lib/{interfaces → types/interfaces}/IProtocol.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnInstall.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnVerify.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/ProtocolOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/index.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/PassportMiddleware.d.ts +0 -0
- package/lib/{services → types/services}/PassportSerializerService.d.ts +0 -0
- package/lib/{services → types/services}/ProtocolsService.d.ts +0 -0
- package/lib/{utils → types/utils}/getProtocolsFromRequest.d.ts +0 -0
- package/package.json +28 -24
- package/tsconfig.compile.esm.json +23 -0
- package/lib/PassportModule.js.map +0 -1
- package/lib/contants/index.js.map +0 -1
- package/lib/decorators/args.js.map +0 -1
- package/lib/decorators/authenticate.js.map +0 -1
- package/lib/decorators/authorize.js.map +0 -1
- package/lib/decorators/protocol.js.map +0 -1
- package/lib/domain/UserInfo.js +0 -22
- package/lib/domain/UserInfo.js.map +0 -1
- package/lib/errors/PassportException.js.map +0 -1
- package/lib/index.js +0 -20
- package/lib/index.js.map +0 -1
- package/lib/interfaces/IProtocol.js.map +0 -1
- package/lib/interfaces/OnInstall.js.map +0 -1
- package/lib/interfaces/OnVerify.js.map +0 -1
- package/lib/interfaces/ProtocolOptions.js.map +0 -1
- package/lib/interfaces/index.js +0 -8
- package/lib/interfaces/index.js.map +0 -1
- package/lib/middlewares/PassportMiddleware.js.map +0 -1
- package/lib/services/PassportSerializerService.js.map +0 -1
- package/lib/services/ProtocolsService.js.map +0 -1
- package/lib/utils/getProtocolsFromRequest.js.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Format, Property } from "@tsed/schema";
|
|
3
|
+
export class UserInfo {
|
|
4
|
+
}
|
|
5
|
+
__decorate([
|
|
6
|
+
Property(),
|
|
7
|
+
__metadata("design:type", String)
|
|
8
|
+
], UserInfo.prototype, "id", void 0);
|
|
9
|
+
__decorate([
|
|
10
|
+
Property(),
|
|
11
|
+
Format("email"),
|
|
12
|
+
__metadata("design:type", String)
|
|
13
|
+
], UserInfo.prototype, "email", void 0);
|
|
14
|
+
__decorate([
|
|
15
|
+
Property(),
|
|
16
|
+
__metadata("design:type", String)
|
|
17
|
+
], UserInfo.prototype, "password", void 0);
|
|
18
|
+
//# sourceMappingURL=UserInfo.js.map
|
|
@@ -0,0 +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;CAUpB;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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PassportException.js","sourceRoot":"","sources":["../../../src/errors/PassportException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C,MAAM,OAAO,iBAAkB,SAAQ,SAAS;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","sourcesContent":["import {Exception} from \"@tsed/exceptions\";\n\nexport class PassportException extends Exception {\n constructor(error: any) {\n super(error.status || 500, error.message);\n this.name = error.name || this.name;\n }\n}\n"]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "./PassportModule";
|
|
2
|
+
// Decorator
|
|
3
|
+
export * from "./decorators/authenticate";
|
|
4
|
+
export * from "./decorators/authorize";
|
|
5
|
+
export * from "./decorators/protocol";
|
|
6
|
+
export * from "./decorators/args";
|
|
7
|
+
// Interfaces
|
|
8
|
+
export * from "./interfaces";
|
|
9
|
+
export * from "./domain/UserInfo";
|
|
10
|
+
export * from "./errors/PassportException";
|
|
11
|
+
// Registries and Services
|
|
12
|
+
export * from "./contants";
|
|
13
|
+
export * from "./services/ProtocolsService";
|
|
14
|
+
export * from "./services/PassportSerializerService";
|
|
15
|
+
// Middlewares
|
|
16
|
+
export * from "./middlewares/PassportMiddleware";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,YAAY;AACZ,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAElC,aAAa;AACb,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAE3C,0BAA0B;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AAErD,cAAc;AACd,cAAc,kCAAkC,CAAC","sourcesContent":["import \"./PassportModule\";\n\n// Decorator\nexport * from \"./decorators/authenticate\";\nexport * from \"./decorators/authorize\";\nexport * from \"./decorators/protocol\";\nexport * from \"./decorators/args\";\n\n// Interfaces\nexport * from \"./interfaces\";\nexport * from \"./domain/UserInfo\";\nexport * from \"./errors/PassportException\";\n\n// Registries and Services\nexport * from \"./contants\";\nexport * from \"./services/ProtocolsService\";\nexport * from \"./services/PassportSerializerService\";\n\n// Middlewares\nexport * from \"./middlewares/PassportMiddleware\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IProtocol.js","sourceRoot":"","sources":["../../../src/interfaces/IProtocol.ts"],"names":[],"mappings":"","sourcesContent":["import {OnInstall} from \"./OnInstall\";\nimport {OnVerify} from \"./OnVerify\";\n\nexport interface IProtocol extends OnVerify, OnInstall {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnInstall.js","sourceRoot":"","sources":["../../../src/interfaces/OnInstall.ts"],"names":[],"mappings":"","sourcesContent":["import {Strategy} from \"passport\";\n\nexport interface OnInstall {\n $onInstall(strategy: Strategy): void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnVerify.js","sourceRoot":"","sources":["../../../src/interfaces/OnVerify.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnVerify {\n $onVerify(...args: any[]): Promise<any | any[]> | any | any[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtocolOptions.js","sourceRoot":"","sources":["../../../src/interfaces/ProtocolOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Strategy} from \"passport\";\n\nexport interface ProtocolOptions<T = any> {\n name: string;\n useStrategy: Type<Strategy>;\n settings: T;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAkBA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ProtocolOptions} from \"./ProtocolOptions\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n passport: {\n userProperty?: string;\n pauseStream?: string;\n userInfoModel?: Type<any> | false;\n protocols?: {\n [protocolName: string]: Partial<ProtocolOptions>;\n };\n };\n }\n }\n}\n\nexport * from \"./ProtocolOptions\";\nexport * from \"./IProtocol\";\nexport * from \"./OnInstall\";\nexport * from \"./OnVerify\";\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var PassportMiddleware_1;
|
|
2
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
+
import { Context, Inject, Middleware } from "@tsed/common";
|
|
4
|
+
import { ProtocolsService } from "../services/ProtocolsService";
|
|
5
|
+
import { getProtocolsFromRequest } from "../utils/getProtocolsFromRequest";
|
|
6
|
+
let PassportMiddleware = PassportMiddleware_1 = class PassportMiddleware {
|
|
7
|
+
shouldSkip(ctx) {
|
|
8
|
+
const request = ctx.getRequest();
|
|
9
|
+
return request.user && request.isAuthenticated();
|
|
10
|
+
}
|
|
11
|
+
async use(ctx) {
|
|
12
|
+
const endpoint = ctx.endpoint;
|
|
13
|
+
const request = ctx.getRequest();
|
|
14
|
+
if (this.shouldSkip(ctx)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const { options, protocol, method, originalUrl = true } = endpoint.store.get(PassportMiddleware_1);
|
|
18
|
+
const protocols = getProtocolsFromRequest(request, protocol, this.protocolsService.getProtocolsNames());
|
|
19
|
+
if (originalUrl) {
|
|
20
|
+
request.url = request.originalUrl;
|
|
21
|
+
}
|
|
22
|
+
await (method === "authenticate"
|
|
23
|
+
? this.protocolsService.authenticate(protocols, options, ctx)
|
|
24
|
+
: this.protocolsService.authorize(protocols, options, ctx));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
__decorate([
|
|
28
|
+
Inject(ProtocolsService),
|
|
29
|
+
__metadata("design:type", ProtocolsService)
|
|
30
|
+
], PassportMiddleware.prototype, "protocolsService", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
__param(0, Context()),
|
|
33
|
+
__metadata("design:type", Function),
|
|
34
|
+
__metadata("design:paramtypes", [Object]),
|
|
35
|
+
__metadata("design:returntype", Promise)
|
|
36
|
+
], PassportMiddleware.prototype, "use", null);
|
|
37
|
+
PassportMiddleware = PassportMiddleware_1 = __decorate([
|
|
38
|
+
Middleware()
|
|
39
|
+
], PassportMiddleware);
|
|
40
|
+
export { PassportMiddleware };
|
|
41
|
+
//# sourceMappingURL=PassportMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PassportMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PassportMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,uBAAuB,EAAC,MAAM,kCAAkC,CAAC;AAGzE,IAAa,kBAAkB,0BAA/B,MAAa,kBAAkB;IAI7B,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,uBAAuB,CAAC,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,MAAM,CAAC,gBAAgB,CAAC;8BACP,gBAAgB;4DAAC;AAOnC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;6CAiBnB;AA1BU,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CA2B9B;SA3BY,kBAAkB","sourcesContent":["import {Context, Inject, Middleware} 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"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Constant, Service } from "@tsed/di";
|
|
3
|
+
import { deserialize, serialize } from "@tsed/json-mapper";
|
|
4
|
+
import { UserInfo } from "../domain/UserInfo";
|
|
5
|
+
/**
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
let PassportSerializerService = class PassportSerializerService {
|
|
9
|
+
serialize(user, done) {
|
|
10
|
+
try {
|
|
11
|
+
const obj = serialize(user, { type: this.model });
|
|
12
|
+
// remove password from serialized object
|
|
13
|
+
delete obj.password;
|
|
14
|
+
done(null, JSON.stringify(obj));
|
|
15
|
+
}
|
|
16
|
+
catch (er) {
|
|
17
|
+
// istanbul ignore next
|
|
18
|
+
done(er);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
deserialize(obj, done) {
|
|
22
|
+
try {
|
|
23
|
+
const user = deserialize(JSON.parse(obj), { type: this.model });
|
|
24
|
+
done(null, user);
|
|
25
|
+
}
|
|
26
|
+
catch (er) {
|
|
27
|
+
done(er);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
__decorate([
|
|
32
|
+
Constant("passport.userInfoModel", UserInfo),
|
|
33
|
+
__metadata("design:type", Object)
|
|
34
|
+
], PassportSerializerService.prototype, "model", void 0);
|
|
35
|
+
PassportSerializerService = __decorate([
|
|
36
|
+
Service()
|
|
37
|
+
], PassportSerializerService);
|
|
38
|
+
export { PassportSerializerService };
|
|
39
|
+
//# sourceMappingURL=PassportSerializerService.js.map
|
|
@@ -0,0 +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;IAIpC,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,OAAO,GAAG,CAAC,QAAQ,CAAC;YAEpB,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 delete obj.password;\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"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { PlatformHandler } from "@tsed/common";
|
|
3
|
+
import { ancestorsOf } from "@tsed/core";
|
|
4
|
+
import { Injectable, InjectorService } from "@tsed/di";
|
|
5
|
+
import { Unauthorized } from "@tsed/exceptions";
|
|
6
|
+
import Passport, { Strategy } from "passport";
|
|
7
|
+
import { PassportException } from "../errors/PassportException";
|
|
8
|
+
import { PROVIDER_TYPE_PROTOCOL } from "../contants";
|
|
9
|
+
import { promisify } from "util";
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
let ProtocolsService = class ProtocolsService {
|
|
14
|
+
constructor(injector) {
|
|
15
|
+
this.injector = injector;
|
|
16
|
+
this.strategies = new Map();
|
|
17
|
+
}
|
|
18
|
+
getProtocols() {
|
|
19
|
+
return Array.from(this.injector.getProviders(PROVIDER_TYPE_PROTOCOL));
|
|
20
|
+
}
|
|
21
|
+
getProtocolsNames() {
|
|
22
|
+
return Array.from(this.strategies.keys());
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Invoke provider and bind it to passport.
|
|
26
|
+
* @param provider
|
|
27
|
+
*/
|
|
28
|
+
invoke(provider) {
|
|
29
|
+
const { name, useStrategy: strategy, settings } = this.getOptions(provider);
|
|
30
|
+
const protocol = this.injector.get(provider.provide);
|
|
31
|
+
const instance = new strategy(settings, this.createHandler(provider));
|
|
32
|
+
this.strategies.set(name, instance);
|
|
33
|
+
Passport.use(name, instance);
|
|
34
|
+
if (protocol.$onInstall) {
|
|
35
|
+
protocol.$onInstall(instance);
|
|
36
|
+
}
|
|
37
|
+
protocol.$strategy = instance;
|
|
38
|
+
return protocol;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Call authenticate passport method.
|
|
42
|
+
* @param protocols
|
|
43
|
+
* @param options
|
|
44
|
+
* @param ctx
|
|
45
|
+
*/
|
|
46
|
+
async authenticate(protocols, options, ctx) {
|
|
47
|
+
return this.call("authenticate", protocols, options, ctx);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Call authorize passport method.
|
|
51
|
+
* @param protocols
|
|
52
|
+
* @param options
|
|
53
|
+
* @param ctx
|
|
54
|
+
*/
|
|
55
|
+
async authorize(protocols, options, ctx) {
|
|
56
|
+
return this.call("authorize", protocols, options, ctx);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Call passport authenticate or authorize depending on the chosen method.
|
|
60
|
+
* @param method
|
|
61
|
+
* @param protocols
|
|
62
|
+
* @param options
|
|
63
|
+
* @param ctx
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
async call(method, protocols, options, ctx) {
|
|
67
|
+
const request = ctx.getRequest();
|
|
68
|
+
const response = ctx.getResponse();
|
|
69
|
+
protocols = [].concat(protocols);
|
|
70
|
+
if (protocols.length === 0) {
|
|
71
|
+
throw new Unauthorized("Not authorized");
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
options.failWithError = true;
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
const fn = promisify(Passport[method](protocols.length === 1 ? protocols[0] : protocols, options));
|
|
77
|
+
await fn(request, response);
|
|
78
|
+
}
|
|
79
|
+
catch (er) {
|
|
80
|
+
if (!ancestorsOf(er).includes(Error)) {
|
|
81
|
+
throw new PassportException(er);
|
|
82
|
+
}
|
|
83
|
+
throw er;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create strategy options based on decorator metadata and global configuration
|
|
88
|
+
* @param provider
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
getOptions(provider) {
|
|
92
|
+
const { name } = provider.store.get("protocol");
|
|
93
|
+
const { useStrategy = Strategy, settings = {} } = this.injector.settings.get(`passport.protocols.${name}`) || {};
|
|
94
|
+
return {
|
|
95
|
+
name,
|
|
96
|
+
useStrategy,
|
|
97
|
+
settings: {
|
|
98
|
+
...settings,
|
|
99
|
+
passReqToCallback: true
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Create the verifier handler for passport
|
|
105
|
+
* @param provider
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
createHandler(provider) {
|
|
109
|
+
const platformHandler = this.injector.get(PlatformHandler);
|
|
110
|
+
const middleware = platformHandler.createCustomHandler(provider, "$onVerify");
|
|
111
|
+
return async (req, ...args) => {
|
|
112
|
+
const done = args[args.length - 1];
|
|
113
|
+
req.$ctx.set("PROTOCOL_ARGS", args.slice(0, -1));
|
|
114
|
+
try {
|
|
115
|
+
await middleware(req.$ctx);
|
|
116
|
+
done(null, ...[].concat(req.$ctx.data));
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
done(err, false, { message: err.message });
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
ProtocolsService = __decorate([
|
|
125
|
+
Injectable(),
|
|
126
|
+
__metadata("design:paramtypes", [InjectorService])
|
|
127
|
+
], ProtocolsService);
|
|
128
|
+
export { ProtocolsService };
|
|
129
|
+
//# sourceMappingURL=ProtocolsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtocolsService.js","sourceRoot":"","sources":["../../../src/services/ProtocolsService.ts"],"names":[],"mappings":"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","sourcesContent":["import {PlatformContext, PlatformHandler} from \"@tsed/common\";\nimport {ancestorsOf} from \"@tsed/core\";\nimport {Injectable, InjectorService, Provider} from \"@tsed/di\";\nimport {Unauthorized} from \"@tsed/exceptions\";\nimport Passport, {Strategy} from \"passport\";\nimport {PassportException} from \"../errors/PassportException\";\nimport {IProtocol, ProtocolOptions} from \"../interfaces\";\nimport {PROVIDER_TYPE_PROTOCOL} from \"../contants\";\nimport {promisify} from \"util\";\n\n/**\n * @ignore\n */\n@Injectable()\nexport class ProtocolsService {\n readonly strategies: Map<string, Strategy> = new Map();\n\n constructor(private injector: InjectorService) {}\n\n public getProtocols(): Provider[] {\n return Array.from(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 public invoke(provider: Provider): any {\n const {name, useStrategy: strategy, settings} = this.getOptions(provider);\n const protocol = this.injector.get<IProtocol & any>(provider.provide)!;\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 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<any>) {\n const platformHandler = this.injector.get<PlatformHandler>(PlatformHandler)!;\n const middleware = platformHandler.createCustomHandler(provider, \"$onVerify\");\n\n return async (req: any, ...args: any[]) => {\n const done = args[args.length - 1];\n req.$ctx.set(\"PROTOCOL_ARGS\", args.slice(0, -1));\n\n try {\n await middleware(req.$ctx);\n done(null, ...[].concat(req.$ctx.data));\n } catch (err) {\n done(err, false, {message: err.message});\n }\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isArray } from "@tsed/core";
|
|
2
|
+
/**
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
function getProtocolName(req) {
|
|
6
|
+
const { query = {}, params = {}, body = {} } = req;
|
|
7
|
+
return params.protocol || query.protocol || body.protocol;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
export function getProtocolsFromRequest(req, protocol, defaultProtocols) {
|
|
13
|
+
if (!isArray(protocol)) {
|
|
14
|
+
if (protocol === "*") {
|
|
15
|
+
return defaultProtocols;
|
|
16
|
+
}
|
|
17
|
+
const protocolReq = getProtocolName(req);
|
|
18
|
+
if (protocol === ":protocol") {
|
|
19
|
+
return [protocolReq].filter(Boolean);
|
|
20
|
+
}
|
|
21
|
+
if (protocolReq && protocolReq !== protocol) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
return [protocol];
|
|
25
|
+
}
|
|
26
|
+
const protocols = protocol;
|
|
27
|
+
if (protocols.includes("*")) {
|
|
28
|
+
return defaultProtocols;
|
|
29
|
+
}
|
|
30
|
+
return protocols;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=getProtocolsFromRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getProtocolsFromRequest.js","sourceRoot":"","sources":["../../../src/utils/getProtocolsFromRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;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,MAAM,UAAU,uBAAuB,CAAC,GAAQ,EAAE,QAA2B,EAAE,gBAA0B;IACvG,IAAI,CAAC,OAAO,CAAC,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","sourcesContent":["import {isArray} from \"@tsed/core\";\n\n/**\n * @ignore\n */\nfunction getProtocolName(req: any) {\n const {query = {}, params = {}, body = {}} = req;\n\n return params.protocol || query.protocol || body.protocol;\n}\n\n/**\n * @ignore\n */\nexport function getProtocolsFromRequest(req: any, protocol: string | string[], defaultProtocols: string[]): string[] {\n if (!isArray(protocol)) {\n if (protocol === \"*\") {\n return defaultProtocols;\n }\n\n const protocolReq = getProtocolName(req);\n\n if (protocol === \":protocol\") {\n return [protocolReq].filter(Boolean);\n }\n\n if (protocolReq && protocolReq !== protocol) {\n return [];\n }\n\n return [protocol];\n }\n\n const protocols: string[] = protocol;\n\n if (protocols.includes(\"*\")) {\n return defaultProtocols;\n }\n\n return protocols;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/passport",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-beta.3",
|
|
4
4
|
"description": "Passport package for Ts.ED framework",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
5
|
+
"source": "./src/index.ts",
|
|
6
|
+
"main": "./lib/cjs/index.js",
|
|
7
|
+
"typings": "./lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./lib/types/index.d.ts",
|
|
10
|
+
"import": "./lib/esm/index.js",
|
|
11
|
+
"require": "./lib/cjs/index.js",
|
|
12
|
+
"default": "./lib/esm/index.js"
|
|
11
13
|
},
|
|
12
14
|
"scripts": {
|
|
13
|
-
"build": "
|
|
15
|
+
"build": "yarn run build:esm && yarn run build:cjs",
|
|
16
|
+
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
17
|
+
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
14
18
|
"start": "ts-node src/index.ts"
|
|
15
19
|
},
|
|
16
20
|
"dependencies": {
|
|
17
21
|
"tslib": "2.2.0"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@tsed/common": "7.0.0-
|
|
21
|
-
"@tsed/core": "7.0.0-
|
|
22
|
-
"@tsed/di": "7.0.0-
|
|
24
|
+
"@tsed/common": "7.0.0-beta.3",
|
|
25
|
+
"@tsed/core": "7.0.0-beta.3",
|
|
26
|
+
"@tsed/di": "7.0.0-beta.3",
|
|
23
27
|
"@types/passport": "1.0.4",
|
|
24
28
|
"@types/passport-http": "0.3.8",
|
|
25
|
-
"@types/passport-local": "1.0.
|
|
29
|
+
"@types/passport-local": "1.0.34",
|
|
26
30
|
"@types/passport-strategy": "0.2.35",
|
|
27
31
|
"passport": "0.4.1",
|
|
28
32
|
"passport-http": "0.3.0",
|
|
@@ -30,23 +34,23 @@
|
|
|
30
34
|
"passport-strategy": "1.0.0"
|
|
31
35
|
},
|
|
32
36
|
"peerDependencies": {
|
|
33
|
-
"@tsed/common": "^7.0.0-
|
|
34
|
-
"@tsed/core": "^7.0.0-
|
|
35
|
-
"@tsed/di": "^7.0.0-
|
|
36
|
-
"@tsed/json-mapper": "^7.0.0-
|
|
37
|
-
"@tsed/logger": "
|
|
38
|
-
"@tsed/openspec": "^7.0.0-
|
|
39
|
-
"@tsed/schema": "^7.0.0-
|
|
40
|
-
"passport": "
|
|
41
|
-
"passport-http": "
|
|
42
|
-
"passport-local": "
|
|
43
|
-
"passport-strategy": "
|
|
37
|
+
"@tsed/common": "^7.0.0-beta.3",
|
|
38
|
+
"@tsed/core": "^7.0.0-beta.3",
|
|
39
|
+
"@tsed/di": "^7.0.0-beta.3",
|
|
40
|
+
"@tsed/json-mapper": "^7.0.0-beta.3",
|
|
41
|
+
"@tsed/logger": ">=6.0.0",
|
|
42
|
+
"@tsed/openspec": "^7.0.0-beta.3",
|
|
43
|
+
"@tsed/schema": "^7.0.0-beta.3",
|
|
44
|
+
"passport": ">=0.4.1",
|
|
45
|
+
"passport-http": ">=0.3.0",
|
|
46
|
+
"passport-local": ">=1.0.0",
|
|
47
|
+
"passport-strategy": ">=1.0.0"
|
|
44
48
|
},
|
|
45
49
|
"repository": "https://github.com/tsedio/tsed",
|
|
46
50
|
"bugs": {
|
|
47
51
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
48
52
|
},
|
|
49
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
53
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/security/passport",
|
|
50
54
|
"author": "Romain Lenzotti",
|
|
51
55
|
"license": "MIT"
|
|
52
56
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.compile.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"module": "ES2020",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "./lib/esm",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./lib/types"
|
|
10
|
+
},
|
|
11
|
+
"exclude": [
|
|
12
|
+
"node_modules",
|
|
13
|
+
"test",
|
|
14
|
+
"lib",
|
|
15
|
+
"benchmark",
|
|
16
|
+
"coverage",
|
|
17
|
+
"spec",
|
|
18
|
+
"**/*.benchmark.ts",
|
|
19
|
+
"**/*.spec.ts",
|
|
20
|
+
"keys",
|
|
21
|
+
"jest.config.js"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
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;IAazB,YACU,GAAwB,EACxB,gBAAkC,EAClC,kBAA6C;QAF7C,QAAG,GAAH,GAAG,CAAqB;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,uBAAkB,GAAlB,kBAAkB,CAA2B;IACpD,CAAC;IAEJ,OAAO;QACL,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,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,QAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAElH,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,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,kBAAQ,CAAC,OAAO,CAAC,EAAC,WAAW,EAAC,CAAC,CAAC,CAAC;gBAE9C,OAAO;YAET;gBACE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,YAAY,mCAAmC,CAAC,CAAC;SACvF;IACH,CAAC;CACF,CAAA;AAvCC;IADC,iBAAQ,CAAC,uBAAuB,CAAC;;oDACb;AAGrB;IADC,iBAAQ,CAAC,sBAAsB,CAAC;;mDACZ;AAGrB;IADC,iBAAQ,CAAC,eAAe,CAAC;;oDACL;AAGrB;IADC,eAAM,EAAE;sCACD,eAAM;8CAAC;AAXJ,cAAc;IAH1B,eAAM,CAAC;QACN,KAAK,EAAE,sBAAa,CAAC,SAAS;KAC/B,CAAC;6CAee,4BAAmB;QACN,mCAAgB;QACd,qDAAyB;GAhB5C,cAAc,CAyC1B;AAzCY,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(\"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 $onInit(): Promise<any> | void {\n Passport.serializeUser(this.passportSerializer.serialize.bind(this.passportSerializer));\n Passport.deserializeUser(this.passportSerializer.deserialize.bind(this.passportSerializer));\n\n this.protocolsService.getProtocols().forEach((provider: Provider<any>) => this.protocolsService.invoke(provider));\n\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.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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,UAAU,CAAC","sourcesContent":["export const PROVIDER_TYPE_PROTOCOL = \"protocol\";\n"]}
|
|
@@ -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,oBAAa,CAAC,gBAAO,CAAC,eAAe,CAAC,CAAC,CAAC;AACjD,CAAC;AAFD,oBAEC;AAED,SAAgB,GAAG,CAAC,KAAa;IAC/B,OAAO,oBAAa,CAAC,gBAAO,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAFD,kBAEC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {useDecorators} from \"@tsed/core\";\n\n/**\n * Inject args resolve by the passport strategy on verify method.\n * @decorator\n */\nexport function Args() {\n return useDecorators(Context(\"PROTOCOL_ARGS\"));\n}\n\nexport function Arg(index: number) {\n return useDecorators(Context(`PROTOCOL_ARGS.${index}`));\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/decorators/authenticate.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAErC,0EAAqE;AACrE,qCAAyC;AACzC,yCAAsC;AAOtC,SAAgB,YAAY,CAAC,WAA8B,GAAG,EAAE,UAA+B,EAAE;IAC/F,OAAO,oBAAa,CAClB,gBAAO,CAAC,uCAAkB,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,iBAAQ,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,oCAYC","sourcesContent":["import {UseAuth} from \"@tsed/common\";\nimport {AuthenticateOptions as PassportAuthenticateOptions} from \"passport\";\nimport {PassportMiddleware} from \"../middlewares/PassportMiddleware\";\nimport {useDecorators} from \"@tsed/core\";\nimport {Security} from \"@tsed/schema\";\n\nexport interface AuthenticateOptions extends PassportAuthenticateOptions {\n security?: Record<string, string[]>;\n originalUrl?: boolean;\n}\n\nexport function Authenticate(protocol: string | string[] = \"*\", options: AuthenticateOptions = {}): Function {\n return useDecorators(\n UseAuth(PassportMiddleware, {\n protocol,\n method: \"authenticate\",\n originalUrl: options.originalUrl === undefined ? true : options.originalUrl,\n options\n }),\n ...Object.entries(options.security || {}).map(([key, value]) => {\n return Security(key, ...value);\n })\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/decorators/authorize.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAErC,0EAAqE;AACrE,qCAAyC;AACzC,yCAAsC;AAOtC,SAAgB,SAAS,CAAC,WAA8B,GAAG,EAAE,UAA4B,EAAE;IACzF,OAAO,oBAAa,CAClB,gBAAO,CAAC,uCAAkB,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,iBAAQ,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,8BAYC","sourcesContent":["import {UseAuth} from \"@tsed/common\";\nimport {AuthenticateOptions} from \"passport\";\nimport {PassportMiddleware} from \"../middlewares/PassportMiddleware\";\nimport {useDecorators} from \"@tsed/core\";\nimport {Security} from \"@tsed/schema\";\n\nexport interface AuthorizeOptions extends AuthenticateOptions {\n security?: Record<string, string[]>;\n originalUrl?: boolean;\n}\n\nexport function Authorize(protocol: string | string[] = \"*\", options: AuthorizeOptions = {}): Function {\n return useDecorators(\n UseAuth(PassportMiddleware, {\n protocol,\n method: \"authorize\",\n originalUrl: options.originalUrl === undefined ? true : options.originalUrl,\n options\n }),\n ...Object.entries(options.security || {}).map(([key, value]) => {\n return Security(key, ...value);\n })\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/decorators/protocol.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAAmD;AAEnD,0CAAmD;AAEnD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAU,OAAoC;IACpE,OAAO,oBAAa,CAClB,eAAU,CAAC;QACT,IAAI,EAAE,iCAAsB;KAC7B,CAAC,EACF,eAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,EAC7B,kBAAa,CAAC;QACZ,QAAQ,EAAE;YACR,SAAS,EAAE;gBACT,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO;aACxB;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAdD,4BAcC","sourcesContent":["import {StoreSet, useDecorators} from \"@tsed/core\";\nimport {Configuration, Injectable} from \"@tsed/di\";\nimport {ProtocolOptions} from \"../interfaces/ProtocolOptions\";\nimport {PROVIDER_TYPE_PROTOCOL} from \"../contants\";\n\n/**\n * Declare a new Protocol base on a Passport Strategy\n *\n * @decorator\n * @class\n */\nexport function Protocol<T = any>(options: ProtocolOptionsDecorator<T>) {\n return useDecorators(\n Injectable({\n type: PROVIDER_TYPE_PROTOCOL\n }),\n StoreSet(\"protocol\", options),\n Configuration({\n passport: {\n protocols: {\n [options.name]: options\n }\n }\n })\n );\n}\n\nexport type ProtocolOptionsDecorator<T = any> = {name: string} & Partial<ProtocolOptions<T>>;\n"]}
|
package/lib/domain/UserInfo.js
DELETED
|
@@ -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
|
-
schema_1.Property(),
|
|
10
|
-
tslib_1.__metadata("design:type", String)
|
|
11
|
-
], UserInfo.prototype, "id", void 0);
|
|
12
|
-
tslib_1.__decorate([
|
|
13
|
-
schema_1.Property(),
|
|
14
|
-
schema_1.Format("email"),
|
|
15
|
-
tslib_1.__metadata("design:type", String)
|
|
16
|
-
], UserInfo.prototype, "email", void 0);
|
|
17
|
-
tslib_1.__decorate([
|
|
18
|
-
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;AARC;IADC,iBAAQ,EAAE;;oCACA;AAIX;IAFC,iBAAQ,EAAE;IACV,eAAM,CAAC,OAAO,CAAC;;uCACF;AAGd;IADC,iBAAQ,EAAE;;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"]}
|
|
@@ -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","sourcesContent":["import {Exception} from \"@tsed/exceptions\";\n\nexport class PassportException extends Exception {\n constructor(error: any) {\n super(error.status || 500, error.message);\n this.name = error.name || this.name;\n }\n}\n"]}
|