UNPKG

298 kBSource Map (JSON)View Raw
1{"version":3,"file":"identity.js","sources":["../es2017/errors/errors/NoOpenIDError.ts","../es2017/errors/errors/AuthenticationError.ts","../es2017/errors/errors/OIDCError.ts","../es2017/errors/errors/InvalidToken.ts","../es2017/errors/errors/InvalidRequest.ts","../es2017/errors/errors/InternalOAuthError.ts","../es2017/errors/errors/index.ts","../es2017/middlewares/middlewares/SessionMiddleware.ts","../es2017/passports/passports/IAuthenticator.ts","../es2017/passports/results/passports/results/ValidationResult.ts","../es2017/passports/results/passports/results/FailResult.ts","../es2017/passports/results/passports/results/PassResult.ts","../es2017/passports/results/passports/results/RedirectResult.ts","../es2017/passports/results/passports/results/SuccessResult.ts","../es2017/passports/results/passports/results/index.ts","../es2017/passports/passports/Strategy.ts","../es2017/passports/passports/SessionStrategy.ts","../es2017/passports/passports/LocalStrategy.ts","../es2017/passports/passports/JwtStrategy.ts","../es2017/passports/passports/ContextExtends.ts","../es2017/passports/passports/Authenticator.ts","../es2017/passports/passports/StrategySelectorHandle.ts","../es2017/services/services/SerializeUser.ts","../es2017/services/services/DeserializeUser.ts","../es2017/services/services/TransformAuthInfo.ts","../es2017/services/services/index.ts","../es2017/passports/passports/PassportBuildService.ts","../es2017/passports/passports/oauth2.ts","../es2017/stores/stores/utils.ts","../es2017/stores/stores/StateStore.ts","../es2017/stores/stores/SessionStore.ts","../es2017/stores/stores/index.ts","../es2017/passports/passports/OAuth2Strategy.ts","../es2017/passports/passports/OIDCStrategy.ts","../es2017/passports/passports/index.ts","../es2017/middlewares/middlewares/AuthMiddleware.ts","../es2017/middlewares/middlewares/AuthFlowService.ts","../es2017/middlewares/middlewares/index.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/Advice.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/Aspect.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/After.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/AfterReturning.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/AfterThrowing.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/Around.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/Before.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/Pointcut.ts","../../../node_modules/@tsdi/aop/src/decorators/decorators/NonePointcut.ts","../../../node_modules/@tsdi/aop/src/joinpoints/joinpoints/JoinpointState.ts","../../../node_modules/@tsdi/aop/src/joinpoints/joinpoints/Joinpoint.ts","../../../node_modules/@tsdi/aop/src/advices/advices/Advices.ts","../../../node_modules/@tsdi/aop/src/IAdvisor.ts","../../../node_modules/@tsdi/aop/src/regexps.ts","../../../node_modules/@tsdi/aop/src/proceeding/proceeding/ProceedingScope.ts","../../../node_modules/@tsdi/aop/src/Advisor.ts","../../../node_modules/@tsdi/aop/src/AdviceMatcher.ts","../../../node_modules/@tsdi/aop/src/IAdviceMatcher.ts","../../../node_modules/@tsdi/aop/src/actions/actions/aop-actions.ts","../../../node_modules/@tsdi/aop/src/AopModule.ts","../../../node_modules/@tsdi/aop/src/index.ts","../es2017/vaildates/vaildates/AuthenticatedVaildate.ts","../es2017/vaildates/vaildates/RoleVaildate.ts","../es2017/vaildates/vaildates/index.ts","../es2017/registers/registers/ControllerAuthRegisterAction.ts","../es2017/IdentityStartupService.ts","../es2017/IdentityModule.ts","../es2017/index.ts"],"sourcesContent":["import { HttpError } from '@mvx/mvc';\n\nexport class NoOpenIDError extends HttpError {\n constructor(message, public response) {\n super(400, message);\n }\n\n static d0Ann(): any {\n return {\"name\":\"NoOpenIDError\"};\n }\n }\n","import { lang } from '@tsdi/ioc';\nimport { HttpError } from '@mvx/mvc';\n\n/**\n * error.\n *\n * @export\n * @class OIDCError\n * @extends {HttpError}\n */\nexport class AuthenticationError extends HttpError {\n error: string;\n expose: boolean;\n // tslint:disable-next-line: variable-name\n constructor(status: number, message: string, public error_description?: string) {\n super(status, message);\n this.name = lang.getClassName(this);\n this.error = message;\n this.expose = status < 500;\n }\n\n static d0Ann(): any {\n return {\"name\":\"AuthenticationError\"};\n }\n }\n","import { AuthenticationError } from './AuthenticationError';\n\n/**\n * error.\n *\n * @export\n * @class OIDCError\n * @extends {HttpError}\n */\nexport class OIDCError extends AuthenticationError {\n\n constructor(message: string, public code: string, public uri?: string, status?: number) {\n super(status, message);\n if (!status) {\n switch (code) {\n case 'access_denied': status = 403; break;\n case 'server_error': status = 502; break;\n case 'temporarily_unavailable': status = 503; break;\n }\n }\n this.expose = status < 500;\n }\n\n static d0Ann(): any {\n return {\"name\":\"OIDCError\"};\n }\n }\n","import { AuthenticationError } from './AuthenticationError';\n\n\n/**\n * invalid token.\n *\n * @export\n * @class InvalidToken\n * @extends {AuthenticationError}\n */\nexport class InvalidToken extends AuthenticationError {\n // tslint:disable-next-line:variable-name\n public error_detail: string;\n constructor(detail: string) {\n super(401, 'invalid_token', 'invalid token provided')\n this.error_detail = detail;\n }\n\n static d0Ann(): any {\n return {\"name\":\"InvalidToken\"};\n }\n }\n","import { AuthenticationError } from './AuthenticationError';\n\n/**\n * invaild request error.\n *\n * @export\n * @class InvalidRequest\n * @extends {HttpError}\n */\nexport class InvalidRequest extends AuthenticationError {\n constructor(description?: string, status = 400) {\n super(status, '', description || 'request is invalid')\n }\n\n static d0Ann(): any {\n return {\"name\":\"InvalidRequest\"};\n }\n }\n","import { AuthenticationError } from './AuthenticationError';\n\n/**\n * internal oauth error.\n *\n * @export\n * @class InternalOAuthError\n * @extends {AuthenticationError}\n */\nexport class InternalOAuthError extends AuthenticationError {\n constructor(message: string, public oauthError: Error) {\n super(400, message)\n }\n\n static d0Ann(): any {\n return {\"name\":\"InternalOAuthError\"};\n }\n }\n","export * from './NoOpenIDError';\nexport * from './AuthenticationError';\nexport * from './OIDCError';\nexport * from './InvalidToken';\nexport * from './InvalidRequest';\nexport * from './InternalOAuthError';\n","import { Abstract } from '@tsdi/ioc';\nimport { MvcMiddleware, Middleware, MiddlewareTypes, IContext, MvcContext, MiddlewareFunc } from '@mvx/mvc';\nconst session = require('koa-session');\nimport { stores, Session } from 'koa-session';\n\n/**\n * Session storage.\n */\n@Abstract()\nexport abstract class SessionStorage implements stores {\n\n constructor() {\n\n }\n\n abstract get(key: string, maxAge: number | 'session', data: { rolling: boolean; });\n\n abstract set(key: string, sess: Partial<Session> & { _expire?: number; _maxAge?: number; }, maxAge: number | 'session', data: { changed: boolean; rolling: boolean; });\n\n abstract destroy(key: string);\n\n static d0Ann(): any {\n return {\"name\":\"SessionStorage\",\"params\":{\"constructor\":[],\"get\":[\"key\",\"maxAge\",\"data\"],\"set\":[\"key\",\"sess\",\"maxAge\",\"data\"],\"destroy\":[\"key\"]}};\n }\n }\n\n/**\n * session middleware.\n *\n * @export\n * @class SessionMiddleware\n * @extends {MvcMiddleware}\n */\n@Middleware({\n name: MiddlewareTypes.Session,\n before: MiddlewareTypes.BodyParser\n})\nexport class SessionMiddleware extends MvcMiddleware {\n\n private middleware: MiddlewareFunc;\n private hasInit = false;\n getMiddleware(context: MvcContext, koa: any) {\n if (!this.hasInit && !this.middleware) {\n let sessCfg = context.getConfiguration().session;\n this.hasInit = true;\n if (sessCfg) {\n sessCfg = Object.assign({\n key: 'typemvc:sess', /** (string) cookie key (default is koa:sess) */\n /** (number || 'session') maxAge in ms (default is 1 days) */\n /** 'session' will result in a cookie that expires when session/browser is closed */\n /** Warning: If a session cookie is stolen, this cookie will never expire */\n maxAge: 36000000,\n overwrite: true, /** (boolean) can overwrite or not (default true) */\n httpOnly: true, /** (boolean) httpOnly or not (default true) */\n signed: true, /** (boolean) signed or not (default true) */\n rolling: false/** (boolean) Force a session identifier cookie to be set on every response. The expiration is reset to the original maxAge, resetting the expiration countdown. default is false **/\n }, sessCfg);\n if (!sessCfg.store) {\n let storage = context.getContainer().getService(SessionStorage);\n if (storage) {\n sessCfg.store = storage;\n }\n }\n\n this.middleware = session(sessCfg, koa);\n } else {\n this.middleware = session(koa);\n }\n }\n return this.middleware;\n }\n\n execute(ctx: IContext, next: () => Promise<void>): Promise<void> {\n let middleware = this.getMiddleware(ctx.mvcContext, ctx.app);\n return middleware(ctx, next);\n }\n\n static d0Ann(): any {\n return {\"name\":\"SessionMiddleware\",\"params\":{\"getMiddleware\":[\"context\",\"koa\"],\"execute\":[\"ctx\",\"next\"]}};\n }\n }\n","import { InjectToken, ObjectMap, Type } from '@tsdi/ioc';\nimport { MvcContext, IContext, MvcConfiguration } from '@mvx/mvc';\nimport { Middleware, Context } from 'koa';\nimport { IStrategy } from './IStrategy';\n\n\n/**\n * deserialize user interface.\n *\n * @export\n * @interface IDeserializeUser\n */\nexport interface IDeserializeUser {\n deserializeUser(obj: any, ctx?: IContext): Promise<any>;\n}\n\nexport type DeserializeUserOption = Type<IDeserializeUser> | ((obj: any, ctx?: IContext) => Promise<any>)\n\nexport interface ISerializeUser {\n serializeUser(user: any, ctx: IContext): Promise<any>;\n}\n\nexport type SerializeUserOption = Type<ISerializeUser> | ((user: any, ctx: IContext) => Promise<any>);\n\nexport interface ITransformAuthInfo {\n authInfo(info, ctx: IContext): Promise<any>;\n}\n\nexport type TransformAuthInfoOption = Type<ITransformAuthInfo> | ((info, ctx: IContext) => Promise<any>);\n\nexport interface IAuthFlowOption {\n strategy: string | string[];\n options: any;\n}\n\n/**\n * strategy option.\n *\n * @export\n * @interface IStrategyOption\n */\nexport interface IStrategyOption extends ObjectMap {\n strategy: string;\n name?: string;\n verify?: Function\n}\n\nexport interface PassportConfigure {\n default?: IAuthFlowOption;\n initialize?: { userProperty?: string, rolesProperty?: string }\n strategies: IStrategyOption[];\n serializers?: SerializeUserOption[];\n deserializers?: DeserializeUserOption[];\n authInfos?: TransformAuthInfoOption[];\n}\n\n/**\n * authenticate option.\n *\n * @export\n * @interface AuthenticateOption\n */\nexport interface AuthenticateOption {\n session?: boolean;\n successRedirect?: string;\n successReturnToOrRedirect?: string;\n failureRedirect?: string;\n assignProperty?: any;\n failureFlash?: string | { type: string, message: string };\n failureMessage?: string | boolean;\n failWithError?: boolean;\n successFlash?: string | { type: string, message: string };\n successMessage?: string | boolean;\n authInfo?: boolean;\n}\n\n\nexport interface VaildFailure {\n challenge: string | any;\n status: number;\n}\n\n\ndeclare module '@mvx/mvc' {\n interface IConfiguration extends MvcConfiguration {\n /**\n * passports config.\n *\n * @memberof IConfiguration\n */\n passports?: PassportConfigure;\n }\n}\n\n\ndeclare module 'koa' {\n interface Context {\n passport: IAuthenticator;\n failures: VaildFailure[],\n mvcContext: MvcContext;\n connection?: any;\n hasRole(...role: string[]): boolean;\n login(user: any, options?: any): Promise<void>;\n logIn(user, options, done);\n logout(): void;\n logOut(): void;\n isAuthenticated(): boolean;\n isUnauthenticated(): boolean;\n }\n}\n\n/**\n * IAuthenticator token.\n */\nexport const AuthenticatorToken = new InjectToken<IAuthenticator>('Authenticator');\n\n/**\n * `Authenticator` constructor.\n *\n */\nexport interface IAuthenticator {\n\n /**\n * user property.\n *\n * @type {string}\n * @memberof IAuthenticator\n */\n readonly userProperty: string;\n\n /**\n * user roles property.\n *\n * @type {string}\n * @memberof IAuthenticator\n */\n readonly rolesProperty: string;\n\n /**\n * get strategy.\n *\n * @param {string} name\n * @returns {IStrategy}\n * @memberof IAuthenticator\n */\n get(name: string): IStrategy;\n /**\n * Utilize the given `strategy` with optional `name`, overridding the strategy's\n * default name.\n *\n * Examples:\n *\n * passport.use(new TwitterStrategy(...));\n *\n * passport.use('api', new http.BasicStrategy(...));\n *\n */\n use(strategy: IStrategy): any;\n use(name: string, strategy: IStrategy): any;\n /**\n * Un-utilize the `strategy` with given `name`.\n *\n * In typical applications, the necessary authentication strategies are static,\n * configured once and always available. As such, there is often no need to\n * invoke this function.\n *\n * However, in certain situations, applications may need dynamically configure\n * and de-configure authentication strategies. The `use()`/`unuse()`\n * combination satisfies these scenarios.\n *\n * Examples:\n *\n * passport.unuse('legacy-api');\n *\n */\n unuse(name: string): this;\n /**\n * Passport's primary initialization middleware.\n *\n * Intializes Passport for incoming requests, allowing\n * authentication strategies to be applied.\n *\n * If sessions are being utilized, applications must set up Passport with\n * functions to serialize a user into and out of a session. For example, a\n * common pattern is to serialize just the user ID into the session (due to the\n * fact that it is desirable to store the minimum amount of data in a session).\n * When a subsequent request arrives for the session, the full User object can\n * be loaded from the database by ID.\n *\n * Note that additional middleware is required to persist login state, so we\n * must use the `connect.session()` middleware _before_ `passport.initialize()`.\n *\n * If sessions are being used, this middleware must be in use by the\n * Koa application for Passport to operate. If the application is\n * entirely stateless (not using sessions), this middleware is not necessary,\n * but its use will not have any adverse impact.\n *\n * Options:\n * - `userProperty` Property to set on `ctx.state` upon login, defaults to _user_\n *\n * Examples:\n * app.use(connect.cookieParser());\n *\n * app.use(connect.session({ secret: 'keyboard cat' }));\n * app.use(passport.initialize());\n * app.use(passport.initialize({ userProperty: 'currentUser' }));\n * app.use(passport.session());\n *\n * passport.serializeUser(function(user, done) {\n * done(null, user.id);\n * });\n *\n * passport.deserializeUser(function(id, done) {\n * User.findById(id, function (err, user) {\n * done(err, user);\n * });\n * });\n *\n */\n initialize(options?: { userProperty?: string, rolesProperty?: string }): Middleware;\n /**\n * Authenticates requests.\n *\n * Applies the `name`ed strategy (or strategies) to the incoming request, in\n * order to authenticate the request. If authentication is successful, the user\n * will be logged in and populated at `ctx.request.state.user` and a session will be\n * established by default. If authentication fails, an unauthorized response\n * will be sent.\n *\n * Options:\n * - `session` Save login state in session, defaults to _true_\n * - `successRedirect` After successful login, redirect to given URL\n * - `failureRedirect` After failed login, redirect to given URL\n * - `assignProperty` Assign the object provided by the verify callback to given property\n *\n * An optional `callback` can be supplied to allow the application to overrride\n * the default manner in which authentication attempts are handled. The\n * callback has the following signature, where `user` will be set to the\n * authenticated user on a successful authentication attempt, or `false`\n * otherwise. An optional `info` argument will be passed, containing additional\n * details provided by the strategy's verify callback.\n *\n * app.get('/protected', function(ctx, next) {\n * passport.authenticate('local', function(err, user, info) {\n * if (err) { return next(err) }\n * if (!user) { return ctx.redirect('/signin') }\n * ctx.redirect('/account');\n * })(ctx, next);\n * });\n *\n * Note that if a callback is supplied, it becomes the application's\n * responsibility to log-in the user, establish a session, and otherwise perform\n * the desired operations.\n * Examples:\n *\n * passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login' })(ctx);\n *\n * passport.authenticate('local', function(err, user) {\n * if (!user) { return ctx.redirect('/login'); }\n * ctx.end('Authenticated!');\n * })(ctx);\n *\n * passport.authenticate('basic', { session: false })(ctx);\n *\n * app.get('/auth/twitter', passport.authenticate('twitter'), function(ctx) {\n * // request will be redirected to Twitter\n * });\n */\n authenticate(strategyNames: string | string[], callback?: (this: void, err: Error, user?: any, info?: any, status?: any) => void): Middleware;\n authenticate(strategyNames: string | string[], options: AuthenticateOption, callback?: (this: void, err: Error, user?: any, info?: any, status?: any) => void): Middleware;\n /**\n * Middleware that will authorize a third-party account using the given\n * `strategy` name, with optional `options`.\n *\n * If authorization is successful, the result provided by the strategy's verify\n * callback will be assigned to `ctx.state.account`. The existing login session and\n * `ctx.state.user` will be unaffected.\n *\n * This function is particularly useful when connecting third-party accounts\n * to the local account of a user that is currently authenticated.\n *\n * Examples:\n *\n * passport.authorize('twitter-authz', { failureRedirect: '/account' });\n */\n authorize(strategy: string | string[], options?: AuthenticateOption, callback?: any): Middleware;\n /**\n * Middleware that will restore login state from a session.\n *\n * Web applications typically use sessions to maintain login state between\n * requests. For example, a user will authenticate by entering credentials into\n * a form which is submitted to the server. If the credentials are valid, a\n * login session is established by setting a cookie containing a session\n * identifier in the user's web browser. The web browser will send this cookie\n * in subsequent requests to the server, allowing a session to be maintained.\n *\n * If sessions are being utilized, and a login session has been established,\n * this middleware will populate `req.user` with the current user.\n *\n * Note that sessions are not strictly required for Passport to operate.\n * However, as a general rule, most web applications will make use of sessions.\n * An exception to this rule would be an API server, which expects each HTTP\n * request to provide credentials in an Authorization header.\n *\n * Examples:\n *\n * app.use(connect.cookieParser());\n * app.use(connect.session({ secret: 'keyboard cat' }));\n * app.use(passport.initialize());\n * app.use(passport.session());\n *\n * Options:\n * - `pauseStream` Pause the request stream before deserializing the user\n * object from the session. Defaults to _false_. Should\n * be set to true in cases where middleware consuming the\n * request body is configured after passport and the\n * deserializeUser method is asynchronous.\n *\n * @api public\n */\n session(options?: AuthenticateOption): Middleware;\n /**\n * Registers a function used to serialize user objects into the session.\n *\n * Examples:\n *\n * passport.serializeUser(function(user, done) {\n * done(null, user.id);\n * });\n *\n * @api public\n */\n serializeUser(fn: (user: any, ctx: Context) => Promise<any>): any;\n serializeUser(user: object, ctx?: Context): Promise<any>;\n /**\n * Registers a function used to deserialize user objects out of the session.\n *\n * Examples:\n *\n * passport.deserializeUser(function(id, done) {\n * User.findById(id, function (err, user) {\n * done(err, user);\n * });\n * });\n *\n * @api public\n */\n deserializeUser(fn: (obj: any, ctx: Context) => Promise<any>): any;\n deserializeUser(obj: any, ctx?: Context): Promise<any>;\n /**\n * Registers a function used to transform auth info.\n *\n * In some circumstances authorization details are contained in authentication\n * credentials or loaded as part of verification.\n *\n * For example, when using bearer tokens for API authentication, the tokens may\n * encode (either directly or indirectly in a database), details such as scope\n * of access or the client to which the token was issued.\n *\n * Such authorization details should be enforced separately from authentication.\n * Because Passport deals only with the latter, this is the responsiblity of\n * middleware or routes further along the chain. However, it is not optimal to\n * decode the same data or execute the same database query later. To avoid\n * this, Passport accepts optional `info` along with the authenticated `user`\n * in a strategy's `success()` action. This info is set at `req.authInfo`,\n * where said later middlware or routes can access it.\n *\n * Optionally, applications can register transforms to proccess this info,\n * which take effect prior to `req.authInfo` being set. This is useful, for\n * example, when the info contains a client ID. The transform can load the\n * client from the database and include the instance in the transformed info,\n * allowing the full set of client properties to be convieniently accessed.\n *\n * If no transforms are registered, `info` supplied by the strategy will be left\n * unmodified.\n *\n * Examples:\n *\n * passport.transformAuthInfo(function(info, done) {\n * Client.findById(info.clientID, function (err, client) {\n * info.client = client;\n * done(err, info);\n * });\n * });\n *\n * @api public\n */\n transformAuthInfo(fn: (info: any, ctx: Context) => Promise<any>): void;\n transformAuthInfo(info: {\n type: string;\n message: string;\n }, ctx: Context): any;\n}\n","import { Context } from 'koa';\nimport '../IAuthenticator';\n\n/**\n * auth action\n *\n * @export\n * @class AuthAction\n */\nexport abstract class ValidationResult {\n\n constructor() {\n\n }\n\n /**\n * execute result.\n *\n * @abstract\n * @param {Context} ctx\n * @param {() => Promise<void>} next\n * @param {Function} [callback]\n * @returns {Promise<void>}\n * @memberof ValidationResult\n */\n abstract execute(ctx: Context, next: () => Promise<void>, callback?: Function): Promise<void>;\n\n static d0Ann(): any {\n return {\"name\":\"ValidationResult\"};\n }\n }\n","import { ValidationResult } from './ValidationResult';\nimport { Context } from 'koa';\n\n/**\n * Fail authentication, with optional `challenge` and `status`, defaulting\n * to 401.\n *\n * Strategies should return this action to fail an authentication attempt.\n *\n * @param {String} challenge\n * @param {Number} status\n * @api public\n */\nexport class FailResult extends ValidationResult {\n\n constructor(private challenge: string, private status: number) {\n super();\n }\n\n async execute(ctx: Context, next: () => Promise<void>): Promise<void> {\n ctx.failures.push({ challenge: this.challenge, status: this.status });\n }\n\n static d0Ann(): any {\n return {\"name\":\"FailResult\"};\n }\n }\n","import { ValidationResult } from './ValidationResult';\nimport { Context } from 'koa';\n\n\n/**\n * Pass without making a success or fail decision.\n *\n * Under most circumstances, Strategies should not need to call this\n * function. It exists primarily to allow previous authentication state\n * to be restored, for example from an HTTP session.\n *\n */\nexport class PassResult extends ValidationResult {\n execute(ctx: Context, next: () => Promise<void>): Promise<void> {\n return next();\n }\n\n static d0Ann(): any {\n return {\"name\":\"PassResult\"};\n }\n }\n","import { ValidationResult } from './ValidationResult';\nimport { Context } from 'koa';\n\n\n/**\n * Redirect to `url` with optional `status`, defaulting to 302.\n *\n * Strategies should return this function to redirect the user (via their\n * user agent) to a third-party website for authentication.\n *\n * @param {String} url\n * @param {Number} status\n * @api public\n */\nexport class RedirectResult extends ValidationResult {\n\n constructor(public url: string, public status = 302) {\n super();\n }\n\n /**\n * execute.\n *\n * @param {Context} ctx\n * @param {() => Promise<void>} next\n * @returns {Promise<void>}\n * @memberof RedirectResult\n */\n async execute(ctx: Context, next: () => Promise<void>): Promise<void> {\n ctx.status = this.status;\n ctx.redirect(this.url);\n }\n\n\n static d0Ann(): any {\n return {\"name\":\"RedirectResult\"};\n }\n }\n","import { Context } from 'koa';\nimport { ValidationResult } from './ValidationResult';\nimport { AuthenticateOption } from '../IAuthenticator';\n\n/**\n * Authenticate `user`, with optional `info`.\n *\n * Strategies should return this action to successfully authenticate a\n * user. `user` should be an object supplied by the application after it\n * has been given an opportunity to verify credentials. `info` is an\n * optional argument containing additional user information. This is\n * useful for third-party authentication strategies to pass profile\n * details.\n *\n * @param {Object} user\n * @param {Object} info\n * @api public\n */\nexport class SuccessResult extends ValidationResult {\n\n constructor(private options: AuthenticateOption, private user: object, private info: { type: string, message: string }) {\n super();\n }\n\n async execute(ctx: Context, next: () => Promise<void>, callback?: Function): Promise<void> {\n\n let user = this.user;\n let info = this.info || <any>{};\n if (callback) {\n return callback(null, user, info);\n }\n let msg;\n let options = this.options;\n if (options.successFlash) {\n var flash = options.successFlash;\n if (typeof flash === 'string') {\n flash = { type: 'success', message: flash };\n }\n flash.type = flash.type || 'success';\n var type = flash.type || info.type || 'success';\n msg = flash.message || info.message || info;\n if (typeof msg === 'string') {\n ctx.session.flash = { type: type, message: msg };\n }\n }\n\n if (options.successMessage) {\n if (!(info.type in ctx.session.message)) {\n ctx.session.message[info.type] = [];\n }\n ctx.session.message[info.type].push(info.message);\n }\n if (options.assignProperty) {\n ctx.state[options.assignProperty] = user;\n }\n\n await ctx.login(user);\n if (options.authInfo !== false) {\n ctx.state.authInfo = await ctx.passport.transformAuthInfo(info, ctx);\n }\n\n if (options.successReturnToOrRedirect) {\n let url = options.successReturnToOrRedirect;\n if (ctx.session && ctx.session.returnTo) {\n url = ctx.session.returnTo;\n delete ctx.session.returnTo;\n }\n return ctx.redirect(url);\n }\n if (options.successRedirect) {\n return ctx.redirect(options.successRedirect);\n }\n }\n\n static d0Ann(): any {\n return {\"name\":\"SuccessResult\"};\n }\n }\n","export * from './ValidationResult';\nexport * from './FailResult';\nexport * from './PassResult';\nexport * from './RedirectResult';\nexport * from './SuccessResult';\nexport * from './ValidationResult';\n","import { Abstract, Inject } from '@tsdi/ioc';\nimport { Input } from '@tsdi/components';\nimport { IStrategy } from './IStrategy';\nimport { IAuthenticator, AuthenticatorToken } from './IAuthenticator';\nimport { ValidationResult } from './results';\nimport { Context } from 'koa';\n\n@Abstract()\nexport abstract class Strategy implements IStrategy {\n\n @Input()\n name: string;\n\n @Inject(AuthenticatorToken)\n protected authenticator: IAuthenticator;\n\n abstract authenticate(ctx: Context, options?: any): Promise<ValidationResult>;\n\n static d0Ann(): any {\n return {\"name\":\"Strategy\",\"params\":{\"authenticate\":[\"ctx\",\"options\"]}};\n }\n }\n","import { Strategy } from './Strategy';\nimport { Context } from 'koa';\nimport { ValidationResult, PassResult } from './results';\n\n/**\n * session.\n *\n * @export\n * @class SessionStrategy\n * @extends {Strategy}\n */\nexport class SessionStrategy extends Strategy {\n\n /**\n * `SessionStrategy` constructor.\n *\n */\n constructor() {\n super();\n this.name = 'session';\n }\n\n /**\n * Authenticate request based on the current session state.\n *\n * The session authentication strategy uses the session to restore any login\n * state across requests. If a login session has been established, `req.user`\n * will be populated with the current user.\n *\n * This strategy is registered automatically by Passport.\n *\n */\n public async authenticate(ctx: Context, options = {}): Promise<ValidationResult> {\n if (!ctx.passport) {\n throw new Error('passport.initialize() middleware not in use');\n }\n\n let su;\n if (ctx.session.passport) {\n su = ctx.session.passport.user;\n }\n\n if (su || su === 0) {\n // NOTE: Stream pausing is desirable in the case where later middleware is\n // listening for events emitted from request. For discussion on the\n // matter, refer to: https://github.com/jaredhanson/passport/pull/106\n const user = await ctx.passport.deserializeUser(su, ctx);\n if (!user) {\n ctx.session.passport.user = undefined;\n return new PassResult();\n }\n const property = ctx.passport.userProperty;\n ctx.state[property] = user;\n }\n return new PassResult();\n }\n\n static d0Ann(): any {\n return {\"name\":\"SessionStrategy\"};\n }\n }\n","import { Component, Input, AfterInit } from '@tsdi/components';\nimport { IContext } from '@mvx/mvc';\nimport { Strategy } from './Strategy';\nimport { IStrategyOption } from './IAuthenticator';\nimport { Context } from 'koa';\nimport { ValidationResult, FailResult, SuccessResult } from './results';\n\n\n/**\n * local verify.\n */\nexport type LocalVerify = (username: string, password: string, ctx: IContext) => Promise<{ user, info }>;\n\n/**\n * LocalStrategy Option\n *\n * @export\n * @interface LocalStrategyOption\n * @extends {IStrategyOption}\n */\nexport interface LocalStrategyOption extends IStrategyOption {\n usernameField?: string;\n passwordField?: string;\n verify: LocalVerify\n}\n\n\n/**\n * Local authenticate strategy\n *\n * @export\n * @class LocalStrategy\n * @extends {Strategy}\n * @implements {AfterInit}\n */\n@Component({\n selector: 'local'\n})\nexport class LocalStrategy extends Strategy implements AfterInit {\n\n @Input() protected verify: LocalVerify;\n @Input() protected usernameField;\n @Input() protected passwordField;\n\n async onAfterInit(): Promise<void> {\n if (!this.name) {\n this.name = 'local';\n }\n if (!this.usernameField) {\n this.usernameField = 'username';\n }\n if (!this.passwordField) {\n this.passwordField = 'password';\n }\n }\n\n async authenticate(ctx: Context, options?: any): Promise<ValidationResult> {\n let username = ctx.request.body[this.usernameField] || ctx.query[this.usernameField];\n let password = ctx.request.body[this.passwordField] || ctx.query[this.passwordField];\n\n let { user, info } = await this.verify(username, password, ctx as IContext);\n\n if (!user) {\n // TODO, not sure 401 is the correct meaning\n return new FailResult(info, 401);\n }\n return new SuccessResult(options, user, info);\n }\n\n\n static d0Ann(): any {\n return {\"name\":\"LocalStrategy\",\"params\":{\"onAfterInit\":[],\"authenticate\":[\"ctx\",\"options\"]}};\n }\n }\n","import { PromiseUtil } from '@tsdi/ioc';\nimport { Component, Input, AfterInit } from '@tsdi/components';\nimport { IContext } from '@mvx/mvc';\nimport { Strategy } from './Strategy';\nimport { IStrategyOption } from './IAuthenticator';\nimport { Context, Request } from 'koa';\nimport { ValidationResult, FailResult, SuccessResult } from './results';\nimport * as url from 'url';\nimport * as jwt from 'jsonwebtoken';\n\n\nexport type JwtVerify = (payload: any, ctx?: IContext) => Promise<{ user, info }>;\n\n/**\n * JwtStrategyOption Option\n *\n * @export\n * @interface JwtStrategyOption\n * @extends {IStrategyOption}\n */\nexport interface JwtStrategyOption extends IStrategyOption {\n secretOrKey?: string | Buffer;\n secretOrKeyProvider?: (request: Request, rawJwtToken) => Promise<string | Buffer>;\n jwtFromRequest: (request: Request) => any;\n verify: JwtVerify;\n // If defined issuer will be verified against this value\n issuer: string;\n\n audience: string | string[];\n algorithms: jwt.Algorithm[];\n ignoreExpiration?: boolean;\n passReqToCallback?\n}\n\n/**\n * Jwt authenticate strategy\n */\n@Component({\n selector: 'jwt'\n})\nexport class JwtStrategy extends Strategy implements AfterInit {\n\n @Input() protected verify: JwtVerify;\n @Input() issuer: string;\n @Input() audience: string | string[];\n @Input() algorithms: jwt.Algorithm[];\n @Input() ignoreExpiration?: boolean;\n @Input() secretOrKey: string | Buffer;\n @Input() secretOrKeyProvider: (request: Request, rawJwtToken) => Promise<string | Buffer>;\n @Input() jwtFromRequest: (request: Request) => any;\n\n async onAfterInit(): Promise<void> {\n if (!this.name) {\n this.name = 'jwt';\n }\n\n if (this.secretOrKey) {\n if (this.secretOrKeyProvider) {\n throw new TypeError('JwtStrategy has been given both a secretOrKey and a secretOrKeyProvider');\n }\n this.secretOrKeyProvider = async (request, rawJwtToken) => {\n return this.secretOrKey;\n };\n }\n\n if (!this.secretOrKeyProvider) {\n throw new TypeError('JwtStrategy requires a secret or key');\n }\n\n if (!this.verify) {\n throw new TypeError('JwtStrategy requires a verify');\n }\n if (!this.jwtFromRequest) {\n throw new TypeError('JwtStrategy requires a function to retrieve jwt from requests (see option jwtFromRequest)');\n }\n }\n\n async authenticate(ctx: Context, options?: any): Promise<ValidationResult> {\n let token = this.jwtFromRequest(ctx.request);\n if (!token) {\n return new FailResult('No auth token', 401);\n }\n let secretOrKey = this.secretOrKey = await this.secretOrKeyProvider(ctx.request, token)\n\n let payload = await new Promise((r, j) => {\n jwt.verify(token, secretOrKey, {\n audience: this.audience,\n issuer: this.issuer,\n algorithms: this.algorithms,\n ignoreExpiration: this.ignoreExpiration\n }, (err, decoded) => {\n if (err) {\n j(err);\n } else {\n r(decoded);\n }\n });\n });\n\n let { user, info } = await this.verify(payload, ctx as IContext);\n\n if (!user) {\n // TODO, not sure 401 is the correct meaning\n return new FailResult(info, 401);\n }\n return new SuccessResult(options, user, info);\n }\n\n sign(payload: string | object | Buffer, secretOrKey?: jwt.Secret, options?: jwt.SignOptions): Promise<string> {\n let defer = PromiseUtil.defer<string>();\n jwt.sign(payload, secretOrKey || this.secretOrKey, {\n audience: this.audience,\n issuer: this.issuer,\n // algorithm: 'HS256',\n ...(options || {})\n // ignoreExpiration: this.ignoreExpiration\n }, (err, decoded) => {\n if (err) {\n defer.reject(err);\n } else {\n defer.resolve(decoded);\n }\n });\n return defer.promise;\n }\n\n\n static d0Ann(): any {\n return {\"name\":\"JwtStrategy\",\"params\":{\"onAfterInit\":[],\"authenticate\":[\"ctx\",\"options\"],\"sign\":[\"payload\",\"secretOrKey\",\"options\"]}};\n }\n }\n\n\nconst matcExp = /(\\S+)\\s+(\\S+)/;\nfunction parseAuthHeader(hdrValue) {\n if (typeof hdrValue !== 'string') {\n return null;\n }\n var matches = hdrValue.match(matcExp);\n return matches && { scheme: matches[1], value: matches[2] };\n}\n\n\n// Note: express http converts all headers\n// to lower case.\nconst AUTH_HEADER = 'authorization',\n LEGACY_AUTH_SCHEME = 'JWT',\n BEARER_AUTH_SCHEME = 'bearer';\n\nexport namespace JwtRequest {\n\n\n export function fromHeader(headerName: string) {\n return function (request) {\n var token = null;\n if (request.headers[headerName]) {\n token = request.headers[headerName];\n }\n return token;\n };\n }\n\n export function fromBodyField(fieldName) {\n return function (request) {\n var token = null;\n if (request.body && Object.prototype.hasOwnProperty.call(request.body, fieldName)) {\n token = request.body[fieldName];\n }\n return token;\n };\n }\n\n export function fromUrlQueryParameter(paramName) {\n return function (request) {\n let token = null,\n parsedUrl = url.parse(request.url, true);\n if (parsedUrl.query && Object.prototype.hasOwnProperty.call(parsedUrl.query, paramName)) {\n token = parsedUrl.query[paramName];\n }\n return token;\n };\n }\n\n export function fromAuthHeaderWithScheme(authScheme) {\n var authSchemeLower = authScheme.toLowerCase();\n return function (request) {\n\n var token = null;\n if (request.headers[AUTH_HEADER]) {\n var authParams = parseAuthHeader(request.headers[AUTH_HEADER]);\n if (authParams && authSchemeLower === authParams.scheme.toLowerCase()) {\n token = authParams.value;\n }\n }\n return token;\n };\n }\n\n export function fromAuthHeaderAsBearerToken() {\n return fromAuthHeaderWithScheme(BEARER_AUTH_SCHEME);\n }\n\n export function fromExtractors(extractors) {\n if (!Array.isArray(extractors)) {\n throw new TypeError('export function fromExtractors expects an array')\n }\n\n return function (request) {\n var token = null;\n var index = 0;\n while (!token && index < length) {\n token = extractors[index].call(this, request);\n index++;\n }\n return token;\n }\n }\n\n\n /**\n * This extractor mimics the behavior of the v1.*.* extraction logic.\n *\n * This extractor exists only to provide an easy transition from the v1.*.* API to the v2.0.0\n * API.\n *\n * This extractor first checks the auth header, if it doesn't find a token there then it checks the\n * specified body field and finally the url query parameters.\n *\n * @param options\n * authScheme: Expected scheme when JWT can be found in HTTP Authorize header. Default is JWT.\n * tokenBodyField: Field in request body containing token. Default is auth_token.\n * tokenQueryParameterName: Query parameter name containing the token. Default is auth_token.\n */\n export function versionOneCompatibility(options) {\n var authScheme = options.authScheme || LEGACY_AUTH_SCHEME,\n bodyField = options.tokenBodyField || 'auth_token',\n queryParam = options.tokenQueryParameterName || 'auth_token';\n\n return function (request) {\n var authHeaderExtractor = fromAuthHeaderWithScheme(authScheme);\n var token = authHeaderExtractor(request);\n\n if (!token) {\n var bodyExtractor = fromBodyField(bodyField);\n token = bodyExtractor(request);\n }\n\n if (!token) {\n var queryExtractor = fromUrlQueryParameter(queryParam);\n token = queryExtractor(request);\n }\n\n return token;\n };\n }\n}\n","import { BaseContext, Context } from 'koa';\nimport './IAuthenticator';\n\n/**\n * Intiate a login session for `user`.\n *\n * Options:\n * - `session` Save login state in session, defaults to `true`\n *\n * Examples:\n *\n * await req.logIn(user, { session: false });\n *\n * @api public\n */\nasync function login(this: Context, user): Promise<void> {\n if (!this.passport) {\n throw new Error('passport.initialize() middleware not in use');\n }\n const property = (this.passport && this.passport.userProperty);\n this.state[property] = user;\n let obj;\n try {\n obj = await this.passport.serializeUser(user, this);\n } catch (err) {\n this.state[property] = null;\n throw err;\n }\n if (!this.session) {\n throw new Error('Should use session middleware before passport middleware');\n }\n this.session.passport.user = obj;\n}\n\n/**\n * Terminate an existing login session.\n *\n * @api public\n */\nfunction logout(this: Context): void {\n if (!this.passport || !this.session) {\n return;\n }\n const property = this.passport.userProperty;\n delete this.state[property];\n delete this.session.passport.user;\n}\n\n/**\n * Test if request is authenticated.\n *\n * @api public\n */\nfunction isAuthenticated(this: Context): boolean {\n if (!this.passport) {\n return false;\n }\n const property = this.passport.userProperty;\n return (this.state[property]) ? true : false;\n}\n\n/**\n * Test if request is unauthenticated.\n *\n * @api public\n */\nfunction isUnauthenticated(): boolean {\n return !this.isAuthenticated();\n}\n\nfunction hasRole(this: Context, ...roles: string[]): boolean {\n if (!this.passport) {\n return false;\n }\n if (!roles.length) {\n return true;\n }\n const property = this.passport.rolesProperty;\n if ((this.state[property])) {\n return this.state[property].some(role => roles.indexOf(role) > 0);\n }\n return false;\n}\n\n/**\n * context extends.\n *\n * @export\n * @param {BaseContext} ctx\n * @returns {void}\n */\nexport function contextExtends(ctx: BaseContext): void {\n // add passport http.IncomingMessage extensions\n if (ctx.hasOwnProperty('login') || ctx.hasOwnProperty('logout') ||\n ctx.hasOwnProperty('isAuthenticated') || ctx.hasOwnProperty('isUnauthenticated')) {\n return;\n }\n\n Object.defineProperties(ctx, {\n login: {\n value: login,\n writable: false,\n enumerable: false,\n },\n logout: {\n value: logout,\n writable: false,\n enumerable: false,\n },\n isAuthenticated: {\n value: isAuthenticated,\n writable: false,\n enumerable: false,\n },\n isUnauthenticated: {\n value: isUnauthenticated,\n writable: false,\n enumerable: false,\n },\n hasRole: {\n value: hasRole,\n writable: false,\n enumerable: false,\n }\n });\n}\n","import { Singleton, isFunction, isString } from '@tsdi/ioc';\nimport { Middleware, Context } from 'koa';\nimport * as http from 'http';\nimport { contextExtends } from './ContextExtends';\nimport { FailResult } from './results';\nimport { IStrategy } from './IStrategy';\nimport { Strategy } from './Strategy';\nimport { SessionStrategy } from './SessionStrategy';\nimport { AuthenticationError } from '../errors';\nimport { IAuthenticator, AuthenticatorToken, AuthenticateOption } from './IAuthenticator';\n\n\n/**\n * `Authenticator` constructor.\n *\n */\n@Singleton(AuthenticatorToken)\nexport class Authenticator implements IAuthenticator {\n private strategies: Map<string, Strategy>;\n private serializers;\n private deserializers;\n private infoTransformers: Array<(info, ctx: Context) => Promise<any>>;\n private _userProperty = 'user';\n private _rolesProperty = 'roles';\n get userProperty() {\n return this._userProperty;\n }\n\n get rolesProperty() {\n return this._rolesProperty;\n }\n\n constructor() {\n this.strategies = new Map();\n this.serializers = [];\n this.deserializers = [];\n this.infoTransformers = [];\n this.use(new SessionStrategy());\n }\n\n /**\n * get strategy.\n *\n * @param {string} name\n * @returns {IStrategy}\n * @memberof IAuthenticator\n */\n get(name: string): IStrategy {\n return this.strategies.get(name);\n }\n /**\n * Utilize the given `strategy` with optional `name`, overridding the strategy's\n * default name.\n *\n * Examples:\n *\n * passport.use(new TwitterStrategy(...));\n *\n * passport.use('api', new http.BasicStrategy(...));\n *\n */\n public use(strategy: Strategy);\n public use(name: string, strategy: Strategy);\n public use(name: any, strategy?: Strategy) {\n if (strategy === undefined) {\n strategy = name;\n name = strategy.name;\n }\n if (!name) {\n throw new Error('Authentication strategies must have a name');\n }\n\n this.strategies.set(name, strategy);\n\n return this;\n }\n\n /**\n * Un-utilize the `strategy` with given `name`.\n *\n * In typical applications, the necessary authentication strategies are static,\n * configured once and always available. As such, there is often no need to\n * invoke this function.\n *\n * However, in certain situations, applications may need dynamically configure\n * and de-configure authentication strategies. The `use()`/`unuse()`\n * combination satisfies these scenarios.\n *\n * Examples:\n *\n * passport.unuse('legacy-api');\n *\n */\n public unuse(name: string) {\n this.strategies.delete(name);\n return this;\n }\n\n /**\n * Passport's primary initialization middleware.\n *\n * Intializes Passport for incoming requests, allowing\n * authentication strategies to be applied.\n *\n * If sessions are being utilized, applications must set up Passport with\n * functions to serialize a user into and out of a session. For example, a\n * common pattern is to serialize just the user ID into the session (due to the\n * fact that it is desirable to store the minimum amount of data in a session).\n * When a subsequent request arrives for the session, the full User object can\n * be loaded from the database by ID.\n *\n * Note that additional middleware is required to persist login state, so we\n * must use the `connect.session()` middleware _before_ `passport.initialize()`.\n *\n * If sessions are being used, this middleware must be in use by the\n * Koa application for Passport to operate. If the application is\n * entirely stateless (not using sessions), this middleware is not necessary,\n * but its use will not have any adverse impact.\n *\n * Options:\n * - `userProperty` Property to set on `ctx.state` upon login, defaults to _user_\n *\n * Examples:\n * app.use(connect.cookieParser());\n *\n * app.use(connect.session({ secret: 'keyboard cat' }));\n * app.use(passport.initialize());\n * app.use(passport.initialize({ userProperty: 'currentUser' }));\n * app.use(passport.session());\n *\n * passport.serializeUser(function(user, done) {\n * done(null, user.id);\n * });\n *\n * passport.deserializeUser(function(id, done) {\n * User.findById(id, function (err, user) {\n * done(err, user);\n * });\n * });\n *\n */\n public initialize(options: { userProperty?: string, rolesProperty?: string } = {}): Middleware {\n this._userProperty = options.userProperty || 'user';\n this._rolesProperty = options.rolesProperty || 'roles';\n\n return async (ctx: Context, next) => {\n ctx.passport = this;\n const session = ctx.session;\n if (!session) {\n throw new Error('Session middleware is needed with passport middleware!');\n }\n if (!('passport' in session)) {\n ctx.session.passport = { user: undefined };\n }\n if (!('message' in session)) {\n session.message = {};\n }\n ctx.session = session;\n contextExtends(ctx);\n await next();\n };\n }\n\n /**\n * Authenticates requests.\n *\n * Applies the `name`ed strategy (or strategies) to the incoming request, in\n * order to authenticate the request. If authentication is successful, the user\n * will be logged in and populated at `ctx.request.state.user` and a session will be\n * established by default. If authentication fails, an unauthorized response\n * will be sent.\n *\n * Options:\n * - `session` Save login state in session, defaults to _true_\n * - `successRedirect` After successful login, redirect to given URL\n * - `failureRedirect` After failed login, redirect to given URL\n * - `assignProperty` Assign the object provided by the verify callback to given property\n *\n * An optional `callback` can be supplied to allow the application to overrride\n * the default manner in which authentication attempts are handled. The\n * callback has the following signature, where `user` will be set to the\n * authenticated user on a successful authentication attempt, or `false`\n * otherwise. An optional `info` argument will be passed, containing additional\n * details provided by the strategy's verify callback.\n *\n * app.get('/protected', function(ctx, next) {\n * passport.authenticate('local', function(err, user, info) {\n * if (err) { return next(err) }\n * if (!user) { return ctx.redirect('/signin') }\n * ctx.redirect('/account');\n * })(ctx, next);\n * });\n *\n * Note that if a callback is supplied, it becomes the application's\n * responsibility to log-in the user, establish a session, and otherwise perform\n * the desired operations.\n * Examples:\n *\n * return passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login' });\n *\n * passport.authenticate('local', function(err, user) {\n * if (!user) { return ctx.redirect('/login'); }\n * ctx.end('Authenticated!');\n * });\n *\n * passport.authenticate('basic', { session: false });\n *\n *\n */\n public authenticate(strategyNames: string | string[],\n callback?: (this: void, err: Error, user?, info?, status?) => void): Middleware;\n public authenticate(strategyNames: string | string[],\n options: AuthenticateOption,\n callback?: (this: void, err: Error, user?, info?, status?) => void): Middleware;\n public authenticate(strategyNames: string | string[],\n options: any = {},\n callback?: (this: void, err: Error, user?, info?, status?) => void): Middleware {\n if (isFunction(options)) {\n callback = options;\n options = {};\n }\n\n let multi = true;\n // Cast `strategy` to an array, allowing authentication to pass through a chain of\n // strategies. The first strategy to succeed, redirect, or error will halt\n // the chain. Authentication failures will proceed through each strategy in\n // series, ultimately failing if all strategies fail.\n //\n // This is typically used on API endpoints to allow clients to authenticate\n // using their preferred choice of Basic, Digest, token-based schemes, etc.\n // It is not feasible to construct a chain of multiple strategies that involve\n // redirection (for example both Facebook and Twitter), since the first one to\n // redirect will halt the chain.\n if (isString(strategyNames)) {\n strategyNames = [strategyNames];\n multi = false;\n }\n\n return async (ctx: Context, next) => {\n\n // accumulator for failures from each strategy in the chain\n const failures = ctx.failures = [];\n\n function allFailed() {\n if (callback) {\n if (!multi) {\n return callback(null, false, failures[0].challenge, failures[0].status);\n } else {\n const challenges = failures.map(f => f.challenge);\n const statuses = failures.map(f => f.status);\n return callback(null, false, challenges, statuses);\n }\n }\n\n // Strategies are ordered by priority. For the purpose of flashing a\n // message, the first failure will be displayed.\n // const challenge = (failures[0] || {}).challenge || {};\n if (options.failureMessage && failures[0].challenge.type) {\n const challenge = failures[0].challenge;\n if (!(challenge.type in ctx.session.message)) {\n ctx.session.message[challenge.type] = [];\n }\n ctx.session.message[challenge.type].push(challenge.messages);\n }\n if (options.failureRedirect) {\n return ctx.redirect(options.failureRedirect);\n }\n\n // When failure handling is not delegated to the application, the default\n // is to respond with 401 Unauthorized. Note that the WWW-Authenticate\n // header will be set according to the strategies in use (see\n // actions#fail). If multiple strategies failed, each of their challenges\n // will be included in the response.\n\n const rchallenge = [];\n let rstatus;\n let status;\n for (const failure of failures) {\n status = failure.status;\n rstatus = rstatus || status;\n if (isString(failure.challenge)) {\n rchallenge.push(failure.challenge);\n }\n }\n\n ctx.status = rstatus || 401;\n if (ctx.status === 401 && rchallenge.length) {\n ctx.set('WWW-Authenticate', rchallenge);\n }\n if (options.failWithError) {\n throw new AuthenticationError(rstatus, http.STATUS_CODES[ctx.status]);\n }\n // ctx.res.statusMessage = http.STATUS_CODES[ctx.status];\n ctx.response.message = http.STATUS_CODES[ctx.status];\n ctx.res.end(http.STATUS_CODES[ctx.status]);\n }\n\n for (const strategyName of strategyNames) {\n const strategy = this.strategies.get(strategyName);\n if (!strategy) {\n throw new Error(`Unknown authentication strategy \"${strategyName}\"`);\n }\n try {\n const res = await strategy.authenticate(ctx, options);\n if (res instanceof FailResult) {\n await res.execute(ctx, next);\n } else {\n return await res.execute(ctx, next, callback);\n }\n } catch (error) {\n if (callback) {\n return callback(error);\n }\n throw error;\n }\n }\n return allFailed();\n };\n }\n\n /**\n * Middleware that will authorize a third-party account using the given\n * `strategy` name, with optional `options`.\n *\n * If authorization is successful, the result provided by the strategy's verify\n * callback will be assigned to `ctx.state.account`. The existing login session and\n * `ctx.state.user` will be unaffected.\n *\n * This function is particularly useful when connecting third-party accounts\n * to the local account of a user that is currently authenticated.\n *\n * Examples:\n *\n * passport.authorize('twitter-authz', { failureRedirect: '/account' });\n */\n public authorize(strategy: string | string[], options: AuthenticateOption = {}, callback?) {\n options.assignProperty = 'account';\n return this.authenticate(strategy, options, callback);\n }\n\n /**\n * Middleware that will restore login state from a session.\n *\n * Web applications typically use sessions to maintain login state between\n * requests. For example, a user will authenticate by entering credentials into\n * a form which is submitted to the server. If the credentials are valid, a\n * login session is established by setting a cookie containing a session\n * identifier in the user's web browser. The web browser will send this cookie\n * in subsequent requests to the server, allowing a session to be maintained.\n *\n * If sessions are being utilized, and a login session has been established,\n * this middleware will populate `req.user` with the current user.\n *\n * Note that sessions are not strictly required for Passport to operate.\n * However, as a general rule, most web applications will make use of sessions.\n * An exception to this rule would be an API server, which expects each HTTP\n * request to provide credentials in an Authorization header.\n *\n * Examples:\n *\n * app.use(connect.cookieParser());\n * app.use(connect.session({ secret: 'keyboard cat' }));\n * app.use(passport.initialize());\n * app.use(passport.session());\n *\n * Options:\n * - `pauseStream` Pause the request stream before deserializing the user\n * object from the session. Defaults to _false_. Should\n * be set to true in cases where middleware consuming the\n * request body is configured after passport and the\n * deserializeUser method is asynchronous.\n *\n * @api public\n */\n public session(options?: AuthenticateOption): Middleware {\n return this.authenticate('session', options);\n }\n\n /**\n * Registers a function used to serialize user objects into the session.\n *\n * Examples:\n *\n * passport.serializeUser(function(user, done) {\n * done(null, user.id);\n * });\n *\n * @api public\n */\n public serializeUser(fn: (user: any, ctx: Context) => Promise<any>);\n public async serializeUser(user: object, ctx: Context);\n public async serializeUser(user, ctx?) {\n if (typeof user === 'function') {\n return this.serializers.push(user);\n }\n\n for (const layer of this.serializers) {\n const obj = await layer(user, ctx);\n if (obj || obj === 0) {\n return obj;\n }\n }\n throw new Error('Failed to serialize user into session');\n }\n\n /**\n * Registers a function used to deserialize user objects out of the session.\n *\n * Examples:\n *\n * passport.deserializeUser(function(id, done) {\n * User.findById(id, function (err, user) {\n * done(err, user);\n * });\n * });\n *\n * @api public\n */\n public deserializeUser(fn: (obj: any, ctx: Context) => Promise<any>);\n public async deserializeUser(obj: any, ctx: Context): Promise<any>;\n public async deserializeUser(obj, ctx?): Promise<any> {\n if (isFunction(obj)) {\n return this.deserializers.push(obj);\n }\n\n for (const layer of this.deserializers) {\n const user = await layer(obj, ctx);\n if (user) {\n return user;\n } else if (user === null || user === false) {\n return false;\n }\n }\n throw new Error('Failed to deserialize user out of session');\n }\n\n /**\n * Registers a function used to transform auth info.\n *\n * In some circumstances authorization details are contained in authentication\n * credentials or loaded as part of verification.\n *\n * For example, when using bearer tokens for API authentication, the tokens may\n * encode (either directly or indirectly in a database), details such as scope\n * of access or the client to which the token was issued.\n *\n * Such authorization details should be enforced separately from authentication.\n * Because Passport deals only with the latter, this is the responsiblity of\n * middleware or routes further along the chain. However, it is not optimal to\n * decode the same data or execute the same database query later. To avoid\n * this, Passport accepts optional `info` along with the authenticated `user`\n * in a strategy's `success()` action. This info is set at `req.authInfo`,\n * where said later middlware or routes can access it.\n *\n * Optionally, applications can register transforms to proccess this info,\n * which take effect prior to `req.authInfo` being set. This is useful, for\n * example, when the info contains a client ID. The transform can load the\n * client from the database and include the instance in the transformed info,\n * allowing the full set of client properties to be convieniently accessed.\n *\n * If no transforms are registered, `info` supplied by the strategy will be left\n * unmodified.\n *\n * Examples:\n *\n * passport.transformAuthInfo(function(info, done) {\n * Client.findById(info.clientID, function (err, client) {\n * info.client = client;\n * done(err, info);\n * });\n * });\n *\n * @api public\n */\n public transformAuthInfo(fn: (info, ctx: Context) => Promise<any>): void;\n public transformAuthInfo(info: { type: string, message: string }, ctx: Context): Promise<any>;\n public async transformAuthInfo(info, ctx?): Promise<any> {\n if (isFunction(info)) {\n return this.infoTransformers.push(info);\n }\n\n // private implementation that traverses the chain of transformers,\n // attempting to transform auth info\n\n for (const layer of this.infoTransformers) {\n const tinfo = await layer(info, ctx);\n if (tinfo) {\n return tinfo;\n }\n }\n return info;\n }\n\n static d0Ann(): any {\n return {\"name\":\"Authenticator\",\"params\":{\"constructor\":[],\"get\":[\"name\"],\"use\":[\"name\",\"strategy\"],\"unuse\":[\"name\"],\"initialize\":[\"options\"],\"authenticate\":[\"strategyNames\",\"options\",\"callback\"],\"authorize\":[\"strategy\",\"options\",\"callback\"],\"session\":[\"options\"],\"serializeUser\":[\"user\",\"ctx\"],\"deserializeUser\":[\"obj\",\"ctx\"],\"transformAuthInfo\":[\"info\",\"ctx\"]}};\n }\n }\n\n\n\n","import { isMetadataObject } from '@tsdi/ioc';\nimport { ComponentSelectorHandle, ComponentProvider } from '@tsdi/components';\n\nexport class StrategySelectorHandle extends ComponentSelectorHandle {\n protected getSelector(template: any, compdr?: ComponentProvider): any {\n return isMetadataObject(template) ? template.strategy : null;\n }\n\n static d0Ann(): any {\n return {\"name\":\"StrategySelectorHandle\"};\n }\n }\n","import { Abstract } from '@tsdi/ioc';\nimport { Context } from 'koa';\nimport { ISerializeUser } from '../passports';\n\n@Abstract()\nexport abstract class SerializeUser implements ISerializeUser {\n abstract serializeUser(user: any, ctx: Context): Promise<any>;\n\n static d0Ann(): any {\n return {\"name\":\"SerializeUser\",\"params\":{\"serializeUser\":[\"user\",\"ctx\"]}};\n }\n }\n","\nimport { Abstract } from '@tsdi/ioc';\nimport { Context } from 'koa';\nimport { IDeserializeUser } from '../passports';\n\n@Abstract()\nexport abstract class DeserializeUser implements IDeserializeUser {\n abstract deserializeUser(obj: any, ctx: Context): Promise<any>;\n\n static d0Ann(): any {\n return {\"name\":\"DeserializeUser\",\"params\":{\"deserializeUser\":[\"obj\",\"ctx\"]}};\n }\n }\n","import { Abstract } from '@tsdi/ioc';\nimport { Context } from 'koa';\nimport { ITransformAuthInfo } from '../passports';\n\n@Abstract()\nexport abstract class TransformAuthInfo implements ITransformAuthInfo {\n abstract authInfo(user: any, ctx: Context): Promise<any>;\n\n static d0Ann(): any {\n return {\"name\":\"TransformAuthInfo\",\"params\":{\"authInfo\":[\"user\",\"ctx\"]}};\n }\n }\n","export * from './SerializeUser';\nexport * from './DeserializeUser';\nexport * from './TransformAuthInfo';\n","import { Abstract, Inject, Injectable, isClass, isFunction, INJECTOR, ActionInjectorToken } from '@tsdi/ioc';\nimport { ICoreInjector } from '@tsdi/core';\nimport { StartupDecoratorRegisterer } from '@tsdi/boot';\nimport { ComponentBuilder, Component, ComponentSelectorHandle } from '@tsdi/components';\nimport { IConfiguration, IContext } from '@mvx/mvc';\nimport { IStrategy } from './IStrategy';\nimport { Strategy } from './Strategy';\nimport { StrategySelectorHandle } from './StrategySelectorHandle';\nimport { IStrategyOption, IAuthenticator } from './IAuthenticator';\nimport { SerializeUser, DeserializeUser, TransformAuthInfo } from '../services';\n\n/**\n * PassportBuildService\n *\n * @export\n * @abstract\n * @class PassportBuildService\n */\n@Abstract()\nexport abstract class PassportBuildService {\n\n @Inject(INJECTOR)\n protected injector: ICoreInjector;\n\n @Inject()\n private builder: ComponentBuilder;\n\n abstract build(passport: IAuthenticator, configuration: IConfiguration): Promise<void>;\n\n async createStrategy(option: IStrategyOption): Promise<IStrategy> {\n return await this.builder.resolveTemplate({ template: option, injector: this.injector });\n }\n\n static d0Ann(): any {\n return {\"name\":\"PassportBuildService\",\"params\":{\"build\":[\"passport\",\"configuration\"],\"createStrategy\":[\"option\"]}};\n }\n }\n\n\n/**\n * register passport strategy in configuare.\n *\n * @export\n * @class ConfigurePassportBuildService\n * @extends {PassportBuildService}\n */\n@Injectable()\nexport class ConfigurePassportBuildService extends PassportBuildService {\n\n async build(passport: IAuthenticator, configuration: IConfiguration): Promise<void> {\n let actInj = this.injector.getInstance(ActionInjectorToken);\n let register = actInj.getInstance(StartupDecoratorRegisterer).getRegisterer('TranslateTemplate');\n if (!register.has(StrategySelectorHandle)) {\n register.registerBefore(Component, ComponentSelectorHandle, StrategySelectorHandle);\n }\n if (configuration.passports) {\n let { strategies, serializers, deserializers, authInfos } = configuration.passports;\n if (strategies.length) {\n await Promise.all(strategies.map(async p => {\n let strategy = await this.createStrategy(p);\n if (strategy instanceof Strategy) {\n passport.use(strategy);\n }\n }));\n }\n\n if (serializers && serializers.length) {\n serializers.forEach(ser => {\n if (isClass(ser)) {\n if (!this.injector.has(ser)) {\n this.injector.register(ser);\n }\n passport.serializeUser((user, ctx) => this.injector.resolve(ser).serializeUser(user, ctx as IContext));\n } else if (isFunction(ser)) {\n passport.serializeUser(ser);\n }\n });\n } else {\n this.injector.getServices(SerializeUser)\n .forEach(ser => {\n passport.serializeUser((user, ctx) => ser.serializeUser(user, ctx as IContext))\n });\n }\n\n if (deserializers && deserializers.length) {\n deserializers.forEach(desr => {\n if (isClass(desr)) {\n if (!this.injector.has(desr)) {\n this.injector.register(desr);\n }\n passport.deserializeUser((obj, ctx) => this.injector.resolve(desr).deserializeUser(obj, ctx as IContext));\n } else if (isFunction(desr)) {\n passport.deserializeUser(desr);\n }\n });\n } else {\n this.injector.getServices(DeserializeUser)\n .forEach(desr => {\n passport.deserializeUser((obj, ctx) => desr.deserializeUser(obj, ctx as IContext))\n });\n }\n\n if (authInfos && authInfos.length) {\n authInfos.forEach(trans => {\n if (isClass(trans)) {\n if (!this.injector.has(trans)) {\n this.injector.register(trans);\n }\n passport.transformAuthInfo((info, ctx) => this.injector.resolve(trans).authInfo(info, ctx as IContext));\n } else if (isFunction(trans)) {\n passport.transformAuthInfo(trans);\n }\n });\n } else {\n this.injector.getServices(TransformAuthInfo)\n .forEach(ser => {\n passport.transformAuthInfo((info, ctx) => ser.authInfo(info, ctx))\n });\n }\n }\n }\n\n static d0Ann(): any {\n return {\"name\":\"ConfigurePassportBuildService\",\"params\":{\"build\":[\"passport\",\"configuration\"]}};\n }\n }\n","import * as http from 'http';\nimport * as https from 'https';\nimport * as querystring from 'querystring';\nimport { parse } from 'url';\nimport { AuthenticationError } from '../errors';\n\n/**\n * oauth2 error.\n *\n * @export\n * @class OAuth2Error\n * @extends {AuthenticationError}\n */\nexport class OAuth2Error extends AuthenticationError {\n // tslint:disable-next-line:variable-name\n constructor(status: number, message: string, error_description?: string) {\n super(status, message, error_description);\n }\n\n static d0Ann(): any {\n return {\"name\":\"OAuth2Error\"};\n }\n }\n\n/**\n * oauth2\n *\n * @export\n * @class OAuth2\n */\nexport class OAuth2 {\n private accessTokenName: string;\n private authMethod: string;\n private useAuthorizationHeaderForGET: boolean;\n private agent; // our agent\n\n // Allows you to set an agent to use instead of the default HTTP or\n // HTTPS agents. Useful when dealing with your own certificates.\n public set Agent(agent: http.Agent) {\n this.agent = agent;\n }\n public get Agent(): http.Agent {\n return this.agent;\n }\n\n // This 'hack' method is required for sites that don't use\n // 'access_token' as the name of the access token (for requests).\n // ( http://tools.ietf.org/html/draft-ietf-oauth-v2-16#section-7 )\n // it isn't clear what the correct value should be atm, so allowing\n // for specific (temporary?) override for now.\n public set AccessTokenName(name: string) {\n this.accessTokenName = name;\n }\n public get AccessTokenName(): string {\n return this.accessTokenName;\n }\n\n // Sets the authorization method for Authorization header.\n // e.g. Authorization: Bearer <token> # \"Bearer\" is the authorization method.\n public set AuthMethod(authMethod: string) {\n this.authMethod = authMethod;\n }\n public get AuthMethod(): string {\n return this.authMethod;\n }\n\n // If you use the OAuth2 exposed 'get' method (and don't construct your own _request call )\n // this will specify whether to use an 'Authorize' header instead of passing the access_token as a query parameter\n public set UseAuthorizationHeaderForGET(useIt) {\n this.useAuthorizationHeaderForGET = useIt;\n }\n public get UseAuthorizationHeaderForGET() {\n return this.useAuthorizationHeaderForGET;\n }\n\n public get ClientId(): string {\n return this.clientId;\n }\n\n public get AuthorizeUrl(): string {\n return this.authorizeUrl;\n }\n\n private get AccessTokenUrl() {\n return `${this.baseSite}${this.accessTokenUrl}`; /* + \"?\" + querystring.stringify(params); */\n }\n\n constructor(private clientId: string,\n private clientSecret: string,\n private baseSite: string,\n private authorizeUrl = '/oauth/authorize',\n private accessTokenUrl = '/oauth/access_token',\n private customHeader: any = {}) {\n this.accessTokenName = 'access_token';\n this.authMethod = 'Bearer';\n this.useAuthorizationHeaderForGET = false;\n this.agent = undefined;\n }\n\n // Build the authorization header. In particular, build the part after the colon.\n // e.g. Authorization: Bearer <token> # Build \"Bearer <token>\"\n public buildAuthHeader(token: string): string {\n return `${this.authMethod} ${token}`;\n }\n\n public getAuthorizeUrl(params: any = {}) {\n params.client_id = this.clientId;\n return `${this.baseSite}${this.authorizeUrl}?${querystring.stringify(params)}`;\n }\n\n public async getOAuthAccessToken(code, params: any = {}) {\n params.client_id = this.clientId;\n params.client_secret = this.clientSecret;\n const codeParam = (params.grant_type === 'refresh_token') ? 'refresh_token' : 'code';\n params[codeParam] = code;\n\n const postData = querystring.stringify(params);\n const postHeaders = {\n 'Content-Type': 'application/x-www-form-urlencoded',\n };\n\n const { result } = await this.request('POST', this.AccessTokenUrl, postHeaders, postData, null);\n let data;\n try {\n // As of http://tools.ietf.org/html/draft-ietf-oauth-v2-07\n // responses should be in JSON\n data = JSON.parse(result);\n } catch (error) {\n // .... However both Facebook + Github currently use rev05 of the spec\n // and neither seem to specify a content-type correctly in their response headers :(\n // clients of these services will suffer a *minor* performance cost of the exception\n // being thrown\n data = querystring.parse(result);\n }\n\n const accessToken = data[this.AccessTokenName];\n if (!accessToken) {\n throw new OAuth2Error(400, JSON.stringify(params));\n }\n const refreshToken = data.refresh_token;\n delete data.refresh_token;\n return {\n accessToken,\n refreshToken,\n result: data,\n };\n }\n\n public async get(url: string, accessToken: string) {\n let headers = {};\n if (this.useAuthorizationHeaderForGET) {\n headers = { Authorization: this.buildAuthHeader(accessToken) };\n accessToken = null;\n }\n return await this.request('GET', url, headers, '', accessToken);\n }\n\n public request(method: string, url: string, headers: any = {},\n postBody?: string | Buffer, accessToken?: string): Promise<{ result: string, response: any }> {\n\n const parsedUrl = parse(url, true);\n if (parsedUrl.protocol === 'https:' && !parsedUrl.port) {\n parsedUrl.port = '443';\n }\n const realHeaders = Object.assign({}, this.customHeader, headers);\n realHeaders.Host = parsedUrl.host;\n\n if (!realHeaders['User-Agent']) {\n realHeaders['User-Agent'] = 'Node-oauth';\n }\n\n realHeaders['Content-Length'] = 0;\n if (postBody) {\n realHeaders['Content-Length'] = Buffer.isBuffer(postBody) ? postBody.length :\n Buffer.byteLength(postBody);\n }\n\n if (accessToken && !('Authorization' in realHeaders)) {\n // It seems that the default value of .query return by URL.parse is {}.\n // if (!parsedUrl.query) {\n // parsedUrl.query = {};\n // }\n parsedUrl.query[this.accessTokenName] = accessToken;\n }\n\n let queryStr = querystring.stringify(parsedUrl.query);\n if (queryStr) {\n queryStr = '?' + queryStr;\n }\n const options = {\n protocol: parsedUrl.protocol,\n host: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname + queryStr,\n method,\n headers: realHeaders,\n };\n return new Promise((resolve, reject) => {\n this.executeRequest(options, postBody,\n (err, result, response) => err ? reject(err) : resolve({ result, response }));\n });\n }\n\n private executeRequest(options, postBody, callback) {\n let callbackCalled = false;\n\n let result = '';\n // set the agent on the request options\n if (this.agent) {\n options.agent = this.agent;\n }\n\n const request = options.protocol !== 'https:' ? http.request(options) : https.request(options);\n request.on('response', (response) => {\n response.on('data', (chunk) => {\n result += chunk;\n });\n response.addListener('end', () => {\n if (!callbackCalled) {\n callbackCalled = true;\n if (!(response.statusCode >= 200 && response.statusCode <= 299) &&\n (response.statusCode !== 301) && (response.statusCode !== 302)) {\n callback(new OAuth2Error(response.statusCode, result));\n } else {\n callback(null, result, response);\n }\n }\n });\n });\n request.on('error', (e) => {\n callbackCalled = true;\n callback(e);\n });\n\n if ((options.method === 'POST' || options.method === 'PUT') && postBody) {\n request.write(postBody);\n }\n request.end();\n }\n\n static d0Ann(): any {\n return {\"name\":\"OAuth2\"};\n }\n }\n","import * as crypto from 'crypto';\nimport { Context } from 'koa';\n\n\n\nexport namespace OIDCUtils {\n\n /**\n * Reconstructs the original URL of the request.\n *\n * This function builds a URL that corresponds the original URL requested by the\n * client, including the protocol (http or https) and host.\n *\n * If the request passed through any proxies that terminate SSL, the\n * `X-Forwarded-Proto` header is used to detect if the request was encrypted to\n * the proxy.\n *\n * @return {String}\n * @api private\n */\n export function originalURL(ctx: Context, options) {\n options = options || {};\n var app = ctx.app;\n if (app && ctx.get && ctx.get('trust proxy')) {\n options.proxy = true;\n }\n var trustProxy = options.proxy;\n\n var proto = (ctx.headers['x-forwarded-proto'] || '').toLowerCase()\n , tls = ctx.connection.encrypted || (trustProxy && 'https' === proto.split(/\\s*,\\s*/)[0])\n , host = (trustProxy && ctx.headers['x-forwarded-host']) || ctx.headers.host\n , protocol = tls ? 'https' : 'http'\n , path = ctx.url || '';\n return protocol + '://' + host + path;\n };\n\n /**\n * Merge object b with object a.\n *\n * var a = { foo: 'bar' }\n * , b = { bar: 'baz' };\n *\n * utils.merge(a, b);\n * // => { foo: 'bar', bar: 'baz' }\n *\n * @param {Object} a\n * @param {Object} b\n * @return {Object}\n * @api private\n */\n\n export function merge(a, b) {\n if (a && b) {\n for (var key in b) {\n a[key] = b[key];\n }\n }\n return a;\n }\n\n /**\n * Return a unique identifier with the given `len`.\n *\n * utils.uid(10);\n * // => \"FDaS435D2z\"\n *\n * CREDIT: Connect -- utils.uid\n * https://github.com/senchalabs/connect/blob/2.7.2/lib/utils.js\n *\n * @param {Number} len\n * @return {String}\n * @api private\n */\n\n export function uid(len) {\n return crypto.randomBytes(Math.ceil(len * 3 / 4))\n .toString('base64')\n .slice(0, len);\n }\n}\n","import { Context } from 'koa';\n\n/**\n * store metadata.\n *\n * @export\n * @interface StoreMeta\n */\nexport interface StoreMeta {\n timestamp?: number;\n params?: any;\n grant_type?: string;\n\n identifierField?: string;\n scope?: string | string[];\n issuer?: any;\n authorizationURL?: string;\n tokenURL?: string;\n clientID?: string;\n clientSecret?: string;\n callbackURL?: string;\n customHeaders?: any;\n skipUserProfile?: boolean;\n userInfoURL?: string;\n}\n\nexport interface VerifyResult {\n state?: StoreMeta;\n /**\n * verify result.\n *\n * @type {boolean}\n * @memberof VerifyResult\n */\n result: boolean;\n /**\n * message.\n *\n * @type {string}\n * @memberof VerifyResult\n */\n message: string;\n}\n\n/**\n * state store.\n *\n * @export\n * @interface IStateStore\n */\nexport interface IStateStore {\n /**\n * Store request state.\n *\n * This implementation simply generates a random string and stores the value in\n * the session, where it will be used for verification when the user is\n * redirected back to the application.\n *\n * @param {Context} ctx\n * @param {StoreMeta} [meta]\n * @returns {Promise<string>}\n * @memberof IStateStore\n */\n store(ctx: Context, meta?: StoreMeta): Promise<string>;\n /**\n * Verify request state.\n *\n * This implementation simply compares the state parameter in the request to the\n * value generated earlier and stored in the session.\n *\n * @param {Context} ctx\n * @param {string} providedState\n * @returns {Promise<VerifyResult>}\n * @memberof IStateStore\n */\n verify(ctx: Context, providedState: string): Promise<VerifyResult>;\n}\n\nexport abstract class StateStore implements IStateStore {\n\n constructor() {\n\n }\n\n abstract store(ctx: Context, meta?: StoreMeta): Promise<string>;\n abstract verify(ctx: Context, providedState: string): Promise<VerifyResult>;\n\n static d0Ann(): any {\n return {\"name\":\"StateStore\"};\n }\n }\n","import { StateStore, StoreMeta, VerifyResult } from './StateStore';\nimport { Context } from 'koa';\nimport { OIDCUtils } from './utils';\n\n/**\n * Creates an instance of `SessionStore`.\n *\n * This is the state store implementation for the OAuth2Strategy used when\n * the `state` option is enabled. It generates a random state and stores it in\n * `req.session` and verifies it when the service provider redirects the user\n * back to the application.\n *\n * This state store requires session support. If no session exists, an error\n * will be thrown.\n *\n */\nexport class SessionStore extends StateStore {\n\n constructor(private key: string) {\n super();\n }\n\n /**\n * Store request state.\n *\n * This implementation simply generates a random string and stores the value in\n * the session, where it will be used for verification when the user is\n * redirected back to the application.\n *\n */\n public async store(ctx: Context, meta?: StoreMeta): Promise<string> {\n if (!ctx.session) {\n throw new Error(`OAuth 2.0 authentication requires session support\n when using state. Did you forget to use session middleware?`);\n }\n\n const key = this.key;\n const state = OIDCUtils.uid(24);\n if (!ctx.session[key]) {\n ctx.session[key] = {};\n }\n ctx.session[key].state = state;\n return state;\n }\n\n /**\n * Verify request state.\n *\n * This implementation simply compares the state parameter in the request to the\n * value generated earlier and stored in the session.\n *\n */\n public async verify(ctx: Context, providedState: string): Promise<VerifyResult> {\n if (!ctx.session) {\n throw new Error(`OAuth 2.0 authentication requires session support\n when using state. Did you forget to use koa-session middleware?`);\n }\n\n const key = this.key;\n if (!ctx.session[key]) {\n return {\n result: false,\n message: 'Unable to verify authorization request state.',\n };\n }\n\n const state = ctx.session[key].state;\n if (!state) {\n return {\n result: false,\n message: 'Unable to verify authorization request state.',\n };\n }\n\n delete ctx.session[key].state;\n if (Object.keys(ctx.session[key]).length === 0) {\n delete ctx.session[key];\n }\n\n if (state !== providedState) {\n return {\n result: false,\n message: 'Invalid authorization request state.',\n };\n }\n\n return { result: true, state: state, message: '' };\n }\n\n static d0Ann(): any {\n return {\"name\":\"SessionStore\"};\n }\n }\n","export * from './utils';\nexport * from './StateStore';\nexport * from './SessionStore';\n","import { Input, Component, AfterInit } from '@tsdi/components';\nimport { InternalOAuthError, AuthenticationError } from '../errors';\nimport { OAuth2Error, OAuth2 } from './oauth2';\nimport { Strategy } from './Strategy';\nimport { IStrategyOption } from './IAuthenticator';\nimport { StateStore, SessionStore } from '../stores';\nimport { parse, resolve, format } from 'url';\nimport { Context } from 'koa';\nimport { FailResult, SuccessResult, RedirectResult } from './results';\n\n\nexport type VerifyFunction = (accessToken: string, refreshToken: string, params, profile: object)\n => Promise<{ user, info }>;\n\n\n/**\n * oauth2 option.\n *\n * @export\n * @interface OAuth2Option\n * @extends {IStrategyOption}\n */\nexport interface OAuth2Option extends IStrategyOption {\n authorizationURL: string;\n tokenURL: string;\n verify: VerifyFunction;\n skipUserProfile: boolean;\n scopeSeparator: string;\n callbackURL?: string,\n scope?: string | string[],\n sessionKey?: string;\n // private trustProxy?: string,\n clientSecret: string;\n customHeaders?: any;\n stateStore?: object | boolean;\n /**\n * Retrieve user profile from service provider.\n *\n * OAuth 2.0-based authentication strategies can overrride this function in\n * order to load the user's profile from the service provider. This assists\n * applications (and users of those applications) in the initial registration\n * process by automatically submitting required information.\n */\n userProfile?: (accessToken: string) => Promise<any>;\n /**\n * Return extra parameters to be included in the token request.\n *\n * Some OAuth 2.0 providers allow additional, non-standard parameters to be\n * included when requesting an access token. Since these parameters are not\n * standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication\n * strategies can overrride this function in order to populate these parameters\n * as required by the provider.\n *\n */\n tokenParams: (options) => any;\n /**\n * Return extra parameters to be included in the authorization request.\n *\n * Some OAuth 2.0 providers allow additional, non-standard parameters to be\n * included when requesting authorization. Since these parameters are not\n * standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication\n * strategies can overrride this function in order to populate these parameters\n * as required by the provider.\n *\n */\n authorizationParams(options): any\n}\n\n/**\n* Creates an instance of `OAuth2Strategy`.\n*\n* The OAuth 2.0 authentication strategy authenticates requests using the OAuth\n* 2.0 framework.\n*\n* OAuth 2.0 provides a facility for delegated authentication, whereby users can\n* authenticate using a third-party service such as Facebook. Delegating in\n* this manner involves a sequence of events, including redirecting the user to\n* the third-party service for authorization. Once authorization has been\n* granted, the user is redirected back to the application and an authorization\n* code can be used to obtain credentials.\n*\n* Applications must supply a `verify` callback, for which the function\n* signature is:\n*\n* function(accessToken, refreshToken, profile, done) { ... }\n*\n* The verify callback is responsible for finding or creating the user, and\n* invoking `done` with the following arguments:\n*\n* done(err, user, info);\n*\n* `user` should be set to `false` to indicate an authentication failure.\n* Additional `info` can optionally be passed as a third argument, typically\n* used to display informational messages. If an exception occured, `err`\n* should be set.\n*\n* Params:\n*\n* - `authorizationURL` URL used to obtain an authorization grant\n* - `tokenURL` URL used to obtain an access token\n* - `clientId` identifies client to service provider\n* - `clientSecret` secret used to establish ownership of the client identifer\n* - `callbackURL` URL to which the service provider will redirect the user after obtaining authorization\n* - `passReqToCallback` when `true`, `req` is the first argument to the verify callback (default: `false`)\n*\n* Examples:\n*\n* passport.use(new OAuth2Strategy({\n* authorizationURL: 'https://www.example.com/oauth2/authorize',\n* tokenURL: 'https://www.example.com/oauth2/token',\n* clientId: '123-456-789',\n* clientSecret: 'shhh-its-a-secret'\n* callbackURL: 'https://www.example.net/auth/example/callback'\n* },\n* function(accessToken, refreshToken, profile, done) {\n* User.findOrCreate(..., function (err, user) {\n* done(err, user);\n* });\n* }\n* ));\n*\n*/\n@Component({\n selector: 'oauth2'\n})\nexport class OAuth2Strategy extends Strategy implements AfterInit {\n\n protected oauth2: OAuth2;\n\n @Input() protected stateStore: StateStore;\n @Input() protected clientId: string;\n @Input() protected authorizationURL: string;\n @Input() protected tokenURL: string;\n @Input() protected verify: VerifyFunction;\n @Input({ defaultValue: false }) protected skipUserProfile: boolean;\n @Input({ defaultValue: ' ' }) protected scopeSeparator: string;\n @Input() protected callbackURL?: string;\n @Input() protected scope?: string | string[];\n @Input() protected sessionKey?: string;\n // private trustProxy?: string;\n @Input({ defaultValue: '' }) clientSecret: string;\n @Input() customHeaders?: any;\n\n /**\n * Retrieve user profile from service provider.\n *\n * OAuth 2.0-based authentication strategies can overrride this function in\n * order to load the user's profile from the service provider. This assists\n * applications (and users of those applications) in the initial registration\n * process by automatically submitting required information.\n */\n @Input() protected userProfile: (accessToken: string) => Promise<any>;\n /**\n * Return extra parameters to be included in the token request.\n *\n * Some OAuth 2.0 providers allow additional, non-standard parameters to be\n * included when requesting an access token. Since these parameters are not\n * standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication\n * strategies can overrride this function in order to populate these parameters\n * as required by the provider.\n *\n */\n @Input() protected tokenParams: (options) => any;\n\n /**\n * Return extra parameters to be included in the authorization request.\n *\n * Some OAuth 2.0 providers allow additional, non-standard parameters to be\n * included when requesting authorization. Since these parameters are not\n * standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication\n * strategies can overrride this function in order to populate these parameters\n * as required by the provider.\n *\n */\n @Input() protected authorizationParams: (options) => any;\n\n\n async onAfterInit(): Promise<void> {\n if (!this.name) {\n this.name = 'oauth2';\n }\n // NOTE: The _oauth2 property is considered \"protected\". Subclasses are\n // allowed to use it when making protected resource requests to retrieve\n // the user profile.\n this.oauth2 = new OAuth2(this.clientId, this.clientSecret,\n '', this.authorizationURL, this.tokenURL, this.customHeaders);\n\n if (!this.sessionKey) {\n this.sessionKey = ('oauth2:' + parse(this.authorizationURL).hostname);\n }\n\n if (!this.stateStore) { // if stateStore is `true`, use default session stateStore\n this.stateStore = new SessionStore(this.sessionKey);\n }\n\n if (!this.userProfile) {\n this.userProfile = (accessToken: string) => new Object() as any;\n }\n\n if (!this.tokenParams) {\n this.tokenParams = (options) => new Object() as any;\n }\n\n if (!this.authorizationParams) {\n this.authorizationParams = (options) => new Object() as any;\n }\n\n }\n\n public async authenticate(ctx: Context, options: any = {}) {\n\n if (ctx.query && ctx.query.error) {\n if (ctx.query.error === 'access_denied') {\n return new FailResult(ctx.query.error_description, 401);\n }\n throw new AuthenticationError(ctx.query.error_description, ctx.query.error_uri, ctx.query.error);\n }\n\n let callbackURL = options.callbackURL || this.callbackURL;\n if (callbackURL) {\n const parsed = parse(callbackURL);\n if (!parsed.protocol) {\n // The callback URL is relative, resolve a fully qualified URL from the\n // URL of the originating request.\n callbackURL = resolve(ctx.request.origin, callbackURL);\n }\n }\n\n const meta = {\n authorizationURL: this.authorizationURL,\n tokenURL: this.tokenURL,\n clientId: this.clientId,\n };\n if (ctx.query && ctx.query.code) {\n const state = ctx.query.state;\n const { result: verifiedResult, message: verifiedMsg } = await this.stateStore.verify(ctx, state);\n if (!verifiedResult) {\n return new FailResult(verifiedMsg, 403);\n }\n\n const code = ctx.query.code;\n const params = this.tokenParams(options);\n params.grant_type = 'authorization_code';\n if (callbackURL) {\n params.redirect_uri = callbackURL;\n }\n\n let accessToken;\n let refreshToken;\n let accessTokenResult;\n try {\n ({\n accessToken,\n refreshToken,\n result: accessTokenResult,\n } = await this.oauth2.getOAuthAccessToken(code, params));\n } catch (err) {\n throw this.parseOAuthError(err);\n }\n const profile = await this.loadUserProfile(accessToken);\n const { user, info } = await this.verify(accessToken, refreshToken, accessTokenResult, profile);\n if (!user) {\n // TODO, not sure 401 is the correct meaning\n return new FailResult(info, 401);\n }\n return new SuccessResult(options, user, info);\n } else {\n const params = this.authorizationParams(options);\n params.response_type = 'code';\n if (callbackURL) {\n params.redirect_uri = callbackURL;\n }\n let scope = options.scope || this.scope;\n if (scope) {\n if (Array.isArray(scope)) {\n scope = scope.join(this.scopeSeparator);\n }\n params.scope = scope;\n }\n\n let state: string = options.state;\n if (state) {\n params.state = state;\n } else {\n state = await this.stateStore.store(ctx, meta);\n if (state) {\n params.state = state;\n }\n }\n const parsed = parse(this.oauth2.AuthorizeUrl, true);\n parsed.query = Object.assign({}, parsed.query, params);\n (parsed.query as any).client_id = this.oauth2.ClientId;\n delete parsed.search;\n const location = format(parsed);\n return new RedirectResult(location);\n }\n }\n\n /**\n * Parse error response from OAuth 2.0 endpoint.\n *\n * OAuth 2.0-based authentication strategies can overrride this function in\n * order to parse error responses received from the token endpoint, allowing the\n * most informative message to be displayed.\n *\n * If this function is not overridden, the body will be parsed in accordance\n * with RFC 6749, section 5.2.\n *\n */\n private parseOAuthError(err: Error | OAuth2Error) {\n let e;\n if (err instanceof OAuth2Error) {\n try {\n const json = JSON.parse(err.message);\n if (json.error) {\n e = new InternalOAuthError(`Failed to obtain access token:${json.error_description}`, json.error);\n }\n } catch (_) {\n // console.warn('============This error can be ignored==============');\n // console.warn(_);\n // console.warn('===================================================');\n }\n }\n if (!e) {\n err.message = `Failed to obtain access token:${err.message}`;\n e = err;\n }\n return e;\n }\n\n /**\n * Load user profile, contingent upon options.\n *\n */\n private async loadUserProfile(accessToken: string) {\n if (this.skipUserProfile) {\n return Promise.resolve(null);\n }\n return await this.userProfile(accessToken);\n }\n\n\n static d0Ann(): any {\n return {\"name\":\"OAuth2Strategy\",\"params\":{\"onAfterInit\":[],\"authenticate\":[\"ctx\",\"options\"],\"parseOAuthError\":[\"err\"],\"loadUserProfile\":[\"accessToken\"]}};\n }\n }\n","import { isArray, isFunction, Inject, Singleton, PromiseUtil, INJECTOR } from '@tsdi/ioc';\nimport { AfterInit, Input, Component, TemplateOptionToken } from '@tsdi/components';\nimport { Strategy } from './Strategy';\nimport { IStrategyOption } from './IAuthenticator';\nimport { Context } from 'koa';\nimport { stringify } from 'querystring';\nimport { OIDCError, InternalOAuthError, NoOpenIDError } from '../errors';\nimport { SessionStore, StateStore, OIDCUtils } from '../stores';\nimport { parse, resolve, format } from 'url';\nimport { OAuth2, OAuth2Error } from './oauth2';\nimport { RedirectResult, FailResult, ValidationResult, SuccessResult } from './results';\nimport { ICoreInjector } from '@tsdi/core';\nconst webfinger = require('webfinger').webfinger;\nconst request = require('request');\n\nexport type OIDCVerifyFunction = (ctx: Context, iss: string, sub: string, profile: any, jwtClaims?: string, accessToken?: string, refreshToken?: string, params?: any)\n => Promise<{ user, info }>;\n\nexport interface OIDCConfigure {\n issuer?: string;\n authorizationURL?: string;\n tokenURL?: string;\n userInfoURL?: string;\n clientID: string;\n clientSecret: string;\n callbackURL?: string;\n registrationURL?: string\n _raw?: any;\n nonce?: any;\n display?: string;\n prompt?: string;\n timestamp?: number;\n params?: any;\n}\n\nexport interface OIDCOption extends IStrategyOption, OIDCConfigure {\n sessionKey?: string;\n identifierField?: string;\n scope: string | string[];\n store?: SessionStore;\n customHeaders?: any;\n skipUserProfile?: boolean | ((issuer: string, subject: string) => Promise<any>);\n passReqToCallback?: string;\n verify: OIDCVerifyFunction;\n getClient?: (issuer: string) => Promise<any>;\n /**\n * Return extra parameters to be included in the authorization request.\n *\n * Some OAuth 2.0 providers allow additional, non-standard parameters to be\n * included when requesting authorization. Since these parameters are not\n * standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication\n * strategies can overrride this function in order to populate these parameters\n * as required by the provider.\n *\n */\n authorizationParams: (options) => any;\n}\n\n/**\n * OIDC authenticate strategy\n *\n * @export\n * @class OIDCStrategy\n * @extends {Strategy}\n * @implements {AfterInit}\n */\n@Component({\n selector: 'oidc'\n})\nexport class OIDCStrategy extends Strategy implements AfterInit {\n\n @Input('store') protected stateStore: StateStore;\n @Input() protected scope: string | string[];\n @Input() protected identifierField: string;\n\n @Input() protected issuer: string;\n @Input() protected sessionKey: string;\n @Input() protected tokenURL: string;\n @Input() protected authorizationURL: string;\n @Input() protected clientID: string;\n @Input() protected clientSecret: string;\n @Input() protected callbackURL?: string;\n @Input() protected userInfoURL?: string;\n @Input() protected customHeaders?: any;\n @Input() protected verify: OIDCVerifyFunction;\n @Input() protected passReqToCallback: string;\n @Input() protected skipUserProfile?: boolean | ((issuer: string, subject: string) => Promise<any>);\n\n /**\n * Return extra parameters to be included in the authorization request.\n *\n * Some OAuth 2.0 providers allow additional, non-standard parameters to be\n * included when requesting authorization. Since these parameters are not\n * standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication\n * strategies can overrride this function in order to populate these parameters\n * as required by the provider.\n *\n */\n @Input() protected authorizationParams: (options) => any;\n\n @Inject(TemplateOptionToken)\n options: OIDCOption;\n\n\n @Inject(INJECTOR) injector: ICoreInjector;\n\n async onAfterInit(): Promise<void> {\n if (!this.name) {\n this.name = 'openidconnect';\n }\n if (!this.identifierField) {\n this.identifierField = 'openid_identifier';\n }\n\n if (!this.sessionKey) {\n this.sessionKey = ('oauth2:' + parse(this.authorizationURL).hostname)\n }\n\n if (this.stateStore) {\n this.stateStore = new SessionStore(this.sessionKey);\n }\n\n if (!(this.authorizationURL && this.tokenURL) && this.options.getClient) {\n throw new Error('OpenID Connect authentication requires getClientCallback option')\n }\n\n }\n\n\n async authenticate(ctx: Context, options?: any): Promise<ValidationResult> {\n options = options || {};\n if (ctx.query && ctx.query.error) {\n if (ctx.query.error === 'access_denied') {\n return new FailResult(ctx.query.error_description, 403);\n } else {\n throw new OIDCError(ctx.query.error_description, ctx.query.error, ctx.query.error_uri);\n }\n }\n\n if (ctx.query && ctx.query.code) {\n let state = ctx.query.state;\n const { result: verifiedResult, state: meta, message: verifiedMsg } = await this.stateStore.verify(ctx, state);\n if (!verifiedResult) {\n return new FailResult(verifiedMsg, 403);\n }\n const code = ctx.query.code;\n let callbackURL = meta.callbackURL;\n\n let oauth2 = new OAuth2(meta.clientID, meta.clientSecret,\n '', meta.authorizationURL, meta.tokenURL, meta.customHeaders);\n let accessToken;\n let refreshToken;\n let accessTokenResult;\n try {\n ({\n accessToken,\n refreshToken,\n result: accessTokenResult,\n } = await oauth2.getOAuthAccessToken(code, { grant_type: 'authorization_code', redirect_uri: callbackURL }));\n } catch (err) {\n throw this.parseOAuthError(err);\n }\n\n var idToken = accessTokenResult['id_token'];\n if (!idToken) {\n throw new Error('ID Token not present in token response');\n }\n\n let idTokenSegments = idToken.split('.')\n , jwtClaimsStr\n , jwtClaims;\n\n try {\n jwtClaimsStr = new Buffer(idTokenSegments[1], 'base64').toString();\n jwtClaims = JSON.parse(jwtClaimsStr);\n } catch (ex) {\n throw ex;\n }\n\n var missing = ['iss', 'sub', 'aud', 'exp', 'iat'].filter(param => !jwtClaims[param]);\n if (missing.length) {\n throw new Error('id token is missing required parameter(s) - ' + missing.join(', '));\n }\n\n // https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation - check 1.\n if (jwtClaims.iss !== meta.issuer) {\n throw new Error('id token not issued by correct OpenID provider - ' +\n 'expected: ' + meta.issuer + ' | from: ' + jwtClaims.iss);\n }\n\n // https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation - checks 2 and 3.\n if (typeof jwtClaims.aud === 'string') {\n if (jwtClaims.aud !== meta.clientID) {\n throw new Error('aud parameter does not include this client - is: '\n + jwtClaims.aud + '| expected: ' + meta.clientID);\n }\n } else if (isArray(jwtClaims.aud)) {\n if (jwtClaims.aud.indexOf(meta.clientID) === -1) {\n throw new Error('aud parameter does not include this client - is: ' +\n jwtClaims.aud + ' | expected to include: ' + meta.clientID);\n }\n if (jwtClaims.length > 1 && !jwtClaims.azp) {\n throw new Error('azp parameter required with multiple audiences');\n }\n } else {\n throw new Error('Invalid aud parameter type');\n }\n\n // https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation - check 4.\n if (jwtClaims.azp && jwtClaims.azp !== meta.clientID) {\n throw new Error('this client is not the authorized party - ' +\n 'expected: ' + meta.clientID + ' | is: ' + jwtClaims.azp);\n }\n\n // Possible TODO: Add accounting for some clock skew.\n // https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation - check 5.\n if (jwtClaims.exp < (Date.now() / 1000)) {\n throw new Error('id token has expired');\n }\n\n // Note: https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation - checks 6 and 7 are out of scope of this library.\n\n // https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation - check 8.\n if (meta.params.max_age && (!jwtClaims.auth_time || ((meta.timestamp - meta.params.max_age) > jwtClaims.auth_time))) {\n throw new Error('auth_time in id_token not included or too old');\n }\n\n if (meta.params.nonce && (!jwtClaims.nonce || jwtClaims.nonce !== meta.params.nonce)) {\n throw new Error('Invalid nonce in id_token');\n }\n\n var iss = jwtClaims.iss;\n var sub = jwtClaims.sub;\n // Prior to OpenID Connect Basic Client Profile 1.0 - draft 22, the\n // \"sub\" claim was named \"user_id\". Many providers still issue the\n // claim under the old field, so fallback to that.\n if (!sub) {\n sub = jwtClaims.user_id;\n }\n\n let load = await this.shouldLoadUserProfile(iss, sub);\n let profile: any = undefined;\n if (load) {\n var parsed = parse(meta.userInfoURL, true);\n parsed.query['schema'] = 'openid';\n delete parsed.search;\n var userInfoURL = format(parsed);\n\n // NOTE: We are calling node-oauth's internal `_request` function (as\n // opposed to `get`) in order to send the access token in the\n // `Authorization` header rather than as a query parameter.\n //\n // Additionally, the master branch of node-oauth (as of\n // 2013-02-16) will include the access token in *both* headers\n // and query parameters, which is a violation of the spec.\n // Setting the fifth argument of `_request` to `null` works\n // around this issue. I've noted this in comments here:\n // https://github.com/ciaranj/node-oauth/issues/117\n\n const { result: body, response: res } = await oauth2.request('GET', userInfoURL, { 'Authorization': 'Bearer ' + accessToken, 'Accept': 'application/json' }, null, null);\n\n profile = {};\n try {\n var json = JSON.parse(body);\n profile.id = json.sub;\n // Prior to OpenID Connect Basic Client Profile 1.0 - draft 22, the\n // \"sub\" key was named \"user_id\". Many providers still use the old\n // key, so fallback to that.\n if (!profile.id) {\n profile.id = json.user_id;\n }\n\n profile.displayName = json.name;\n profile.name = {\n familyName: json.family_name,\n givenName: json.given_name,\n middleName: json.middle_name\n };\n\n profile._raw = body;\n profile._json = json;\n } catch (ex) {\n throw ex;\n }\n }\n\n const { user, info } = await this.verify(ctx, this.passReqToCallback ? iss : undefined, sub, profile, jwtClaims, accessToken, refreshToken, accessTokenResult);\n\n if (!user) {\n // TODO, not sure 401 is the correct meaning\n return new FailResult(info, 401);\n }\n return new SuccessResult(options, user, info);\n\n } else {\n // The request being authenticated is initiating OpenID Connect\n // authentication. Prior to redirecting to the provider, configuration will\n // be loaded. The configuration is typically either pre-configured or\n // discovered dynamically. When using dynamic discovery, a user supplies\n // their identifer as input.\n\n let identifier;\n let idfield = this.identifierField;\n if (ctx.request.body && ctx.request.body[idfield]) {\n identifier = ctx.request.body[idfield];\n } else if (ctx.query && ctx.query[idfield]) {\n identifier = ctx.query[idfield];\n }\n\n let meta = await this.getConfigure(identifier);\n let callbackURL = options.callbackURL || this.callbackURL;\n if (callbackURL) {\n const parsed = parse(callbackURL);\n if (!parsed.protocol) {\n // The callback URL is relative, resolve a fully qualified URL from the\n // URL of the originating request.\n callbackURL = resolve(ctx.request.origin, callbackURL);\n }\n }\n meta.callbackURL = callbackURL;\n\n\n let params = await this.authorizationParams(options);\n params['response_type'] = 'code';\n params['client_id'] = meta.clientID;\n if (callbackURL) { params.redirect_uri = callbackURL; }\n let scope = options.scope || this.scope;\n if (isArray(scope)) { scope = scope.join(' '); }\n if (scope) {\n params.scope = 'openid ' + scope;\n } else {\n params.scope = 'openid';\n }\n\n // Optional Parameters\n\n ['max_age', 'ui_locals', 'id_token_hint', 'login_hint', 'acr_values']\n .filter(x => { return x in meta })\n .forEach(y => { params[y] = meta[y] });\n\n if (meta.display && ['page', 'popup', 'touch', 'wap'].indexOf(meta.display) !== -1) {\n params.display = meta.display;\n }\n if (meta.prompt && ['none', 'login', 'consent', 'select_account'].indexOf(meta.prompt) !== -1) {\n params.prompt = meta.prompt;\n }\n\n if (meta.nonce && typeof meta.nonce === 'boolean') { params.nonce = OIDCUtils.uid(20); }\n if (meta.nonce && typeof meta.nonce === 'number') { params.nonce = OIDCUtils.uid(meta.nonce); }\n if (meta.nonce && typeof meta.nonce === 'string') { params.nonce = meta.nonce; }\n\n if (params.max_age) {\n meta.timestamp = Math.floor(Date.now() / 1000);\n }\n\n meta.params = params;\n for (let param in params) {\n if (meta[param]) {\n delete meta[param]; // Remove redundant information.\n }\n }\n\n // State Storage/Management\n try {\n let state = await this.stateStore.store(ctx, meta);\n params.state = state;\n var location = meta.authorizationURL + '?' + stringify(params);\n return new RedirectResult(location);\n } catch (ex) {\n throw ex;\n }\n\n }\n }\n\n private async shouldLoadUserProfile(issuer: string, subject: string): Promise<boolean> {\n if (this.skipUserProfile) {\n return isFunction(this.skipUserProfile) ? await this.skipUserProfile(issuer, subject) : false;\n }\n return true;\n }\n\n private parseOAuthError(err: Error | OAuth2Error) {\n let e;\n if (err instanceof OAuth2Error) {\n try {\n const json = JSON.parse(err.message);\n if (json.error) {\n e = new InternalOAuthError(`Failed to obtain access token:${json.error_description}`, json.error);\n }\n } catch (_) {\n // console.warn('============This error can be ignored==============');\n // console.warn(_);\n // console.warn('===================================================');\n }\n }\n if (!e) {\n err.message = `Failed to obtain access token:${err.message}`;\n e = err;\n }\n return e;\n }\n\n\n protected async getConfigure(identifier: string): Promise<OIDCConfigure> {\n if (this.authorizationURL && this.tokenURL) {\n return await this.manualConfigure(identifier);\n } else {\n return await this.dynamicConfigure(identifier);\n }\n }\n\n protected async dynamicConfigure(identifier: string): Promise<OIDCConfigure> {\n let issuer = await this.injector.getInstance(Resolver).resolve(identifier);\n let url = issuer + '/.well-known/openid-configuration';\n let defer = PromiseUtil.defer<OIDCConfigure>();\n request.get(url, async (err, res, body) => {\n if (err) { return defer.reject(err); }\n if (res.statusCode !== 200) {\n return defer.reject(new Error('Unexpected status code from OpenID provider configuration: ' + res.statusCode));\n }\n\n var config = {} as OIDCConfigure;\n\n try {\n var json = JSON.parse(body);\n\n config.issuer = json.issuer;\n config.authorizationURL = json.authorization_endpoint;\n config.tokenURL = json.token_endpoint;\n config.userInfoURL = json.userinfo_endpoint;\n config.registrationURL = json.registration_endpoint;\n\n config._raw = json;\n\n } catch (ex) {\n return defer.reject(new Error('Failed to parse OpenID provider configuration'));\n }\n\n\n // TODO: Pass registrationURL here.\n let client = await this.options.getClient(config.issuer);\n config.clientID = client.id;\n config.clientSecret = client.secret;\n if (client.redirectURIs) {\n config.callbackURL = client.redirectURIs[0];\n }\n return defer.resolve(config);\n });\n\n return defer.promise;\n }\n\n protected async manualConfigure(identifier: string): Promise<OIDCConfigure> {\n let missing = ['issuer', 'authorizationURL', 'tokenURL', 'clientID', 'clientSecret'].filter(opt => !this.options[opt]);\n if (missing.length) {\n throw new Error('Manual OpenID configuration is missing required parameter(s) - ' + missing.join(', '));\n }\n\n let params = {\n issuer: this.issuer,\n authorizationURL: this.authorizationURL,\n tokenURL: this.tokenURL,\n userInfoURL: this.userInfoURL,\n clientID: this.clientID,\n clientSecret: this.clientSecret,\n callbackURL: this.callbackURL\n } as OIDCConfigure\n\n Object.keys(this.options).map(opt => {\n if (['nonce', 'display', 'prompt', 'max_age', 'ui_locals', 'id_token_hint', 'login_hint', 'acr_values'].indexOf(opt) !== -1) {\n params[opt] = this.options[opt];\n }\n });\n\n return params;\n }\n\n static d0Ann(): any {\n return {\"name\":\"OIDCStrategy\",\"params\":{\"onAfterInit\":[],\"authenticate\":[\"ctx\",\"options\"],\"shouldLoadUserProfile\":[\"issuer\",\"subject\"],\"parseOAuthError\":[\"err\"],\"getConfigure\":[\"identifier\"],\"dynamicConfigure\":[\"identifier\"],\"manualConfigure\":[\"identifier\"]}};\n }\n }\n\n\nconst REL = 'http://openid.net/specs/connect/1.0/issuer';\n\n@Singleton()\nexport class Resolver {\n\n resolve(identifier): Promise<string> {\n let defer = PromiseUtil.defer<string>();\n webfinger(identifier, REL, { webfingerOnly: true }, (err, jrd) => {\n if (err) {\n return defer.reject(err);\n }\n if (!jrd.links) {\n return defer.reject(new NoOpenIDError('No links in resource descriptor', jrd));\n }\n\n let issuer;\n for (let i = 0; i < jrd.links.length; i++) {\n let link = jrd.links[i];\n if (link.rel === REL) {\n issuer = link.href;\n break;\n }\n }\n\n if (!issuer) {\n return defer.reject(new NoOpenIDError('No OpenID Connect issuer in resource descriptor', jrd));\n }\n return defer.resolve(issuer);\n });\n\n return defer.promise;\n }\n\n static d0Ann(): any {\n return {\"name\":\"Resolver\",\"params\":{\"resolve\":[\"identifier\"]}};\n }\n }\n","export * from './IAuthenticator';\nexport * from './IStrategy';\nexport * from './results';\nexport * from './Strategy';\nexport * from './SessionStrategy';\nexport * from './LocalStrategy';\nexport * from './JwtStrategy';\nexport * from './ContextExtends';\nexport * from './Authenticator';\nexport * from './PassportBuildService';\nexport * from './oauth2';\nexport * from './OAuth2Strategy';\nexport * from './OIDCStrategy';\nexport * from './StrategySelectorHandle';\n","import { Inject } from '@tsdi/ioc';\nimport { Middleware, CompositeMiddleware, MiddlewareTypes, IContext, MvcContext, RouteChecker, IConfiguration } from '@mvx/mvc';\nimport { AuthenticatorToken, IAuthenticator } from '../passports';\nimport '../passports/IAuthenticator';\n\n/**\n * authentication middleware.\n *\n * @export\n * @class AuthMiddleware\n * @extends {CompositeMiddleware}\n */\n@Middleware({\n name: 'auth',\n before: MiddlewareTypes.View\n})\nexport class AuthMiddleware extends CompositeMiddleware {\n\n private hasInit = false;\n\n @Inject(AuthenticatorToken)\n passport: IAuthenticator;\n\n private checker: RouteChecker;\n getChecker() {\n if (!this.checker) {\n this.checker = this.injector.get(RouteChecker);\n }\n return this.checker;\n }\n\n\n async execute(ctx: IContext, next?: () => Promise<void>): Promise<void> {\n if (!this.hasInit) {\n await this.setup(ctx.mvcContext);\n this.hasInit = true;\n }\n await super.execute(ctx);\n ctx.passport = this.passport;\n return await next();\n }\n\n protected async setup(context: MvcContext) {\n let configuration: IConfiguration = context.getConfiguration();\n this.use(this.passport.initialize(configuration.passports.initialize || {}));\n this.use(this.passport.session());\n }\n\n static d0Ann(): any {\n return {\"name\":\"AuthMiddleware\",\"params\":{\"getChecker\":[],\"execute\":[\"ctx\",\"next\"],\"setup\":[\"context\"]}};\n }\n }\n\n\n// @Middleware({\n// name: 'authcheck',\n// scope: 'route'\n// })\n// export class AuthCheckMiddleware extends MvcMiddleware {\n// @Inject(AuthenticatorToken)\n// passport: IAuthenticator;\n\n// async execute(ctx: IContext, next: () => Promise<void>): Promise<void> {\n// let configuration: IConfiguration = ctx.mvcContext.configuration;\n// if (configuration.passports.default) {\n// let flowOption = configuration.passports.default;\n// await this.passport.authenticate(flowOption.strategy, flowOption.options)(ctx, next);\n// }\n// await next();\n// }\n// }\n","import { Type, Singleton, Inject } from '@tsdi/ioc';\nimport { AuthorizationService, IContext, MiddlewareType, Authorization, IConfiguration } from '@mvx/mvc';\nimport { AuthenticatorToken, IAuthenticator } from '../passports';\n\n@Singleton()\nexport class AuthFlowService extends AuthorizationService {\n @Inject(AuthenticatorToken)\n passport: IAuthenticator;\n\n getAuthMiddlewares(ctx: IContext, controller: Type<any>): MiddlewareType[];\n getAuthMiddlewares(ctx: IContext, controller: Type<any>, propertyKey: string): MiddlewareType[];\n getAuthMiddlewares(ctx: IContext, controller: Type<any>, propertyKey?: any) {\n let middlewares = [];\n let mvcCtx = ctx.mvcContext;\n let configuration: IConfiguration = mvcCtx.getConfiguration();\n let flowOption = configuration.passports.default;\n if (!flowOption) {\n return middlewares;\n }\n\n let refl = mvcCtx.reflects;\n if (propertyKey) {\n if (refl.hasMethodMetadata(Authorization, controller, propertyKey)) {\n middlewares.push(this.passport.authenticate(flowOption.strategy, flowOption.options));\n }\n } else if (refl.hasMetadata(Authorization, controller)) {\n middlewares.push(this.passport.authenticate(flowOption.strategy, flowOption.options));\n }\n\n return middlewares;\n }\n\n\n static d0Ann(): any {\n return {\"name\":\"AuthFlowService\",\"params\":{\"getAuthMiddlewares\":[\"ctx\",\"controller\",\"propertyKey\"]}};\n }\n }\n","export * from './SessionMiddleware';\nexport * from './AuthMiddleware';\nexport * from './AuthFlowService';\n","import { createMethodDecorator, IMethodDecorator, MetadataExtends, isString, isRegExp, ArgsIteratorAction, isArray } from '@tsdi/ioc';\nimport { AdviceMetadata } from '../metadatas/AdviceMetadata';\nimport { AdviceTypes } from '../AdviceTypes';\n\n\n/**\n * advice decorator for method.\n *\n * @export\n * @interface IAdviceDecorator\n * @extends {IMethodDecorator<T>}\n * @template T\n */\nexport interface IAdviceDecorator<T extends AdviceMetadata> extends IMethodDecorator<T> {\n /**\n * define advice with params.\n *\n * ### Usage\n * - path or module name, match express.\n * - `execution(moduelName.*.*(..)) || @annotation(DecortorName) || @within(ClassName)`\n * - `execution(moduelName.*.*(..)) && @annotation(DecortorName) && @within(ClassName)`\n *\n * ```\n * @Aspect()\n * class AspectClass {\n * @Advice('\"execution(moduelName.*.*(..)\")')\n * process(joinPoint: JointPoint){\n * }\n * }\n * ```\n *\n * - match method with a decorator annotation.\n *\n * ```\n * @Aspect()\n * class AspectClass {\n * @Advice('@annotation(DecoratorName)')\n * process(joinPoint: JointPoint){\n * }\n * }\n * ```\n *\n * @param {(string | RegExp)} [pointcut] define advice match express for pointcut.\n * @param { string } [annotation] annotation name, special annotation metadata for annotation advices.\n */\n (pointcut?: string | RegExp, annotation?: string): MethodDecorator;\n\n /**\n * define advice with metadata map.\n * @param {T} [metadata]\n */\n (metadata?: T): MethodDecorator;\n}\n\nexport function createAdviceDecorator<T extends AdviceMetadata>(adviceName: string,\n actions?: ArgsIteratorAction<T>[],\n afterPointcutActions?: ArgsIteratorAction<T> | ArgsIteratorAction<T>[],\n metadataExtends?: MetadataExtends<T>): IAdviceDecorator<T> {\n actions = actions || [];\n\n actions.push((ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg) || isRegExp(arg)) {\n ctx.metadata.pointcut = arg;\n ctx.next(next);\n }\n });\n if (afterPointcutActions) {\n if (isArray(afterPointcutActions)) {\n actions.push(...afterPointcutActions);\n } else {\n actions.push(afterPointcutActions);\n }\n }\n\n actions.push(\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg) && ctx.args.indexOf(arg) === 1) {\n ctx.metadata.annotationArgName = arg;\n ctx.next(next);\n }\n },\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg)) {\n ctx.metadata.annotationName = arg;\n ctx.next(next);\n }\n }\n );\n\n return createMethodDecorator<AdviceMetadata>('Advice',\n actions,\n metadata => {\n if (metadataExtends) {\n metadataExtends(metadata as T);\n }\n metadata.adviceName = adviceName as AdviceTypes;\n return metadata;\n }) as IAdviceDecorator<T>;\n}\n\n/**\n * aop advice decorator.\n *\n * @Advice\n */\nexport const Advice: IAdviceDecorator<AdviceMetadata> = createAdviceDecorator('Advice');\n","import { createClassDecorator, ITypeDecorator, Registration, isString, isClass, isArray, ClassType } from '@tsdi/ioc';\nimport { AspectMetadata } from '../metadatas/AspectMetadata';\n\n/**\n * Aspect decorator\n *\n * @export\n * @interface IAspectDecorator\n * @extends {ITypeDecorator<AspectMetadata>}\n */\nexport interface IAspectDecorator extends ITypeDecorator<AspectMetadata> {\n /**\n * Aspect decorator, define for class. use to define class as aspect. it can setting provider to some token, singleton or not.\n *\n * @Aspect\n *\n * @param {string} annotation set pointcut in the class with the annotation decorator only.\n * @param {(ClassType | ClassType[])>} [within] set pointcut in the class with the annotation decorator only.\n * @param {(Registration | symbol | string)} [provide] define this class provider for provide.\n * @param {string} [alias] define this class provider with alias for provide.\n * @param {boolean} [singlton] define this class as singlton.\n * @param {number} [cache] define class cahce expris when is not singlton.\n */\n (annotation: string, within?: ClassType | ClassType[], provide?: Registration | symbol | string, alias?: string, singlton?: boolean, cache?: number): ClassDecorator;\n\n /**\n * Aspect decorator, define for class. use to define the class. it can setting provider to some token, singleton or not.\n *\n * @Aspect\n *\n * @param {AspectMetadata} [metadata] metadata map.\n */\n (metadata?: AspectMetadata): ClassDecorator;\n}\n\n\n/**\n * Aspect decorator. define aspect service.\n *\n * @Aspect\n */\nexport const Aspect: IAspectDecorator = createClassDecorator<AspectMetadata>('Aspect',\n [\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg)) {\n ctx.metadata.annotation = arg;\n ctx.next(next);\n }\n },\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isArray(arg) || isClass(arg)) {\n ctx.metadata.within = arg;\n ctx.next(next);\n }\n }\n ], true) as IAspectDecorator;\n\n","import { AdviceMetadata } from '../metadatas/AdviceMetadata';\nimport { IAdviceDecorator, createAdviceDecorator } from './Advice';\n\n/**\n * aop after advice decorator.\n *\n * @After\n */\nexport const After: IAdviceDecorator<AdviceMetadata> = createAdviceDecorator<AdviceMetadata>('After') as IAdviceDecorator<AdviceMetadata>;\n","import { isString } from '@tsdi/ioc';\nimport { IAdviceDecorator, createAdviceDecorator } from './Advice';\nimport { AfterReturningMetadata } from '../metadatas/AfterReturningMetadata';\n\n/**\n * aop after returning decorator.\n *\n * @export\n * @interface IAfterReturningDecorator\n * @extends {IAdviceDecorator<T>}\n * @template T\n */\nexport interface IAfterReturningDecorator<T extends AfterReturningMetadata> extends IAdviceDecorator<T> {\n /**\n * define aop after returning advice.\n *\n * @param {(string | RegExp)} [pointcut] define advice match express for pointcut.\n * @param {string} [returning] set name provider of pointcut returing data for advices.\n * @param { string } [annotation] annotation name, special annotation metadata for annotation advices.\n */\n (pointcut?: string | RegExp, returning?: string, annotation?: string): MethodDecorator;\n}\n\n/**\n * aop after returning advice decorator.\n *\n * @AfterReturning\n */\nexport const AfterReturning: IAfterReturningDecorator<AfterReturningMetadata> =\n createAdviceDecorator<AfterReturningMetadata>(\n 'AfterReturning',\n null,\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg)) {\n ctx.metadata.returning = arg;\n ctx.next(next);\n }\n }\n ) as IAfterReturningDecorator<AfterReturningMetadata>;\n","import { isString } from '@tsdi/ioc';\nimport { IAdviceDecorator, createAdviceDecorator } from './Advice';\nimport { AfterThrowingMetadata } from '../metadatas/AfterThrowingMetadata';\n/**\n * aop after throwing decorator.\n *\n * @export\n * @interface IAfterThrowingDecorator\n * @extends {IAdviceDecorator<T>}\n * @template T\n */\nexport interface IAfterThrowingDecorator<T extends AfterThrowingMetadata> extends IAdviceDecorator<T> {\n /**\n * define aop after throwing advice.\n *\n * @param {(string | RegExp)} [pointcut] define advice match express for pointcut.\n * @param {string} [throwing] set name provider of pointcut throwing error for advices.\n * @param { string } [annotation] annotation name, special annotation metadata for annotation advices.\n */\n (pointcut?: string | RegExp, throwing?: string, annotation?: string): MethodDecorator\n}\n\n/**\n * aop after throwing advice decorator.\n *\n * @AfterThrowing\n */\nexport const AfterThrowing: IAfterThrowingDecorator<AfterThrowingMetadata> =\n createAdviceDecorator<AfterThrowingMetadata>(\n 'AfterThrowing',\n null,\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg)) {\n ctx.metadata.throwing = arg;\n ctx.next(next);\n }\n }\n ) as IAfterThrowingDecorator<AfterThrowingMetadata>;\n","import { isString } from '@tsdi/ioc';\nimport { AroundMetadata } from '../metadatas/AroundMetadata';\nimport { IAdviceDecorator, createAdviceDecorator } from './Advice';\n\n/**\n * aop around decorator.\n *\n * @export\n * @interface IAroundDecorator\n * @extends {IAdviceDecorator<T>}\n * @template T\n */\nexport interface IAroundDecorator<T extends AroundMetadata> extends IAdviceDecorator<T> {\n /**\n * define aop around advice.\n *\n * @param {(string | RegExp)} [pointcut] define advice match express for pointcut.\n * @param {string} [returning] set name provider of pointcut returing data for advices.\n * @param {string} [throwing] set name provider of pointcut throwing error for advices.\n * @param {string} [annotation] annotation name, special annotation metadata for annotation advices.\n */\n (pointcut?: string | RegExp, args?: string, returning?: string, throwing?: string, annotation?: string): MethodDecorator\n}\n\n/**\n * aop Around advice decorator.\n *\n * @Around\n */\nexport const Around: IAroundDecorator<AroundMetadata> =\n createAdviceDecorator<AroundMetadata>(\n 'Around',\n null,\n [\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg)) {\n ctx.metadata.args = arg;\n ctx.next(next);\n }\n },\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg)) {\n ctx.metadata.returning = arg;\n ctx.next(next);\n }\n },\n (ctx, next) => {\n let arg = ctx.currArg;\n if (isString(arg)) {\n ctx.metadata.throwing = arg;\n ctx.next(next);\n }\n }\n ]) as IAroundDecorator<AroundMetadata>;\n","import { AdviceMetadata } from '../metadatas/AdviceMetadata';\nimport { IAdviceDecorator, createAdviceDecorator } from './Advice';\n\n/**\n * aop Before advice decorator.\n *\n * @Before\n */\nexport const Before: IAdviceDecorator<AdviceMetadata> = createAdviceDecorator<AdviceMetadata>('Before') as IAdviceDecorator<AdviceMetadata>;\n","import { AdviceMetadata } from '../metadatas/AdviceMetadata';\nimport { IAdviceDecorator, createAdviceDecorator } from './Advice';\n\n/**\n * aop Pointcut advice decorator.\n *\n * @Pointcut\n */\nexport const Pointcut: IAdviceDecorator<AdviceMetadata> =\n createAdviceDecorator<AdviceMetadata>('Pointcut') as IAdviceDecorator<AdviceMetadata>;\n","import { createClassDecorator, ClassMetadata, ITypeDecorator, Type } from '@tsdi/ioc';\n\n/**\n * none pointcut decorator.\n *\n * @export\n * @interface INonePointcutDecorator\n * @extends {ITypeDecorator<ClassMetadata>}\n */\nexport interface INonePointcutDecorator extends ITypeDecorator<ClassMetadata> {\n /**\n * NonePointcut decorator, define class not work with aop.\n *\n * @NonePointcut\n *\n */\n (): ClassDecorator;\n /**\n * NonePointcut decorator, define class not work with aop.\n *\n * @NonePointcut\n */\n (target: Type): void;\n}\n\n/**\n * NonePointcut decorator, define class not work with aop.\n *\n * @NonePointcut\n */\nexport const NonePointcut: INonePointcutDecorator = createClassDecorator<ClassMetadata>('NonePointcut');\n","export enum JoinpointState {\n Before = 'Before',\n Pointcut = 'Pointcut',\n After = 'After',\n AfterReturning = 'AfterReturning',\n AfterThrowing = 'AfterThrowing'\n}\n","import {\n Type, MethodMetadata, IParameter, ClassMetadata, IProviders, TypeMetadata, tokenId, Token,\n isNullOrUndefined, IocContext, ActCtxOption, IInjector, createContext, PROVIDERS\n} from '@tsdi/ioc';\nimport { JoinpointState } from './JoinpointState';\nimport { Advices } from '../advices/Advices';\n\n\nexport interface JoinpointOption extends ActCtxOption {\n provJoinpoint?: Joinpoint;\n name: string;\n fullName: string;\n params: IParameter[];\n originMethod?: Function;\n args: any[];\n state?: JoinpointState;\n advices: Advices;\n annotations?: (ClassMetadata | MethodMetadata)[];\n target?: any;\n targetType: Type;\n providers?: IProviders;\n}\n\nexport const AOP_METHOD_NAME = tokenId<string>('AOP_METHOD_NAME');\nexport const AOP_METHOD_FULLNAME = tokenId<string>('AOP_METHOD_FULLNAME');\nexport const AOP_METHOD_ORIGIN = tokenId<Function>('AOP_METHOD_ORIGIN');\nexport const AOP_METHOD_PARAMS = tokenId<IParameter[]>('AOP_METHOD_PARAMS');\nexport const AOP_METHOD_ANNOTATIONS = tokenId<(ClassMetadata | MethodMetadata)[]>('AOP_METHOD_ANNOTATIONS');\nexport const AOP_METHOD_PROVIDERS = tokenId<IProviders>('AOP_METHOD_PROVIDERS');\nexport const AOP_PROV_JOINPOINT = tokenId<Joinpoint>('AOP_PROV_JOINPOINT');\nexport const AOP_ARGS = tokenId<any[]>('AOP_ARGS');\nexport const AOP_TARGET = tokenId<any>('AOP_TARGET');\nexport const AOP_TARGET_TYPE = tokenId<Type>('AOP_TARGET_TYPE');\nexport const AOP_RETURNING = tokenId<any>('AOP_RETURNING');\nexport const AOP_THROWING = tokenId<Error>('AOP_THROWING');\nexport const AOP_STATE = tokenId<JoinpointState>('AOP_STATE');\nexport const AOP_ADVICES = tokenId<Advices>('AOP_ADVICES');\n\n\n/**\n * Join point data.\n *\n * @export\n * @class Joinpoint\n * @implements {IJoinpoint}\n */\nexport class Joinpoint extends IocContext {\n /**\n * method name\n *\n * @type {string}\n * @memberof Joinpoint\n */\n get name(): string {\n return this.getValue(AOP_METHOD_NAME);\n }\n\n /**\n * prov joinpoint.\n *\n * @type {IJoinpoint}\n * @memberof Joinpoint\n */\n get provJoinpoint(): Joinpoint {\n return this.getValue(AOP_PROV_JOINPOINT);\n }\n\n routeValue<T>(token: Token<T>): T {\n let value: T;\n let currj: Joinpoint = this;\n let key = this.injector.getTokenKey(token);\n while (isNullOrUndefined(value) && currj) {\n value = currj.getValue(key);\n currj = currj.provJoinpoint;\n }\n return value;\n }\n\n /**\n * full name.\n *\n * @type {string}\n * @memberof Joinpoint\n */\n get fullName(): string {\n return this.getValue(AOP_METHOD_FULLNAME);\n }\n\n get originMethod(): Function {\n return this.getValue(AOP_METHOD_ORIGIN);\n }\n\n /**\n * join point state.\n *\n * @type {JoinpointState}\n * @memberof Joinpoint\n */\n get state(): JoinpointState {\n return this.getValue(AOP_STATE);\n }\n\n /**\n * params of pointcut.\n *\n * @type {IParameter[]}\n * @memberof Joinpoint\n */\n get params(): IParameter[] {\n return this.getValue(AOP_METHOD_PARAMS);\n }\n\n /**\n * args of pointcut.\n *\n * @type {any[]}\n * @memberof Joinpoint\n */\n get args(): any[] {\n return this.getValue(AOP_ARGS) ?? [];\n }\n /**\n * pointcut returing\n *\n * @type {*}\n * @memberof Joinpoint\n */\n get returning(): any {\n return this.getValue(AOP_RETURNING);\n }\n\n /**\n * pointcut throwing error.\n *\n * @type {*}\n * @memberof Joinpoint\n */\n get throwing(): Error {\n return this.getValue(AOP_THROWING);\n }\n\n /**\n * advicer of joinpoint\n *\n * @type {Advicer}\n * @memberof Joinpoint\n */\n get advices(): Advices {\n return this.getValue(AOP_ADVICES);\n }\n\n /**\n * orgin pointcut method metadatas.\n *\n * @type {TypeMetadata[]}\n * @memberof Joinpoint\n */\n get annotations(): TypeMetadata[] {\n return this.routeValue(AOP_METHOD_ANNOTATIONS);\n }\n\n /**\n * pointcut target instance\n *\n * @type {*}\n * @memberof Joinpoint\n */\n get target(): any {\n return this.getValue(AOP_TARGET);\n }\n\n /**\n * pointcut target type.\n *\n * @type {Type}\n * @memberof Joinpoint\n */\n get targetType(): Type {\n return this.getValue(AOP_TARGET_TYPE);\n }\n\n get providers(): IProviders {\n if (!this.hasValue(AOP_METHOD_PROVIDERS)) {\n this.setValue(AOP_METHOD_PROVIDERS, this.injector.getInstance(PROVIDERS));\n }\n return this.getValue(AOP_METHOD_PROVIDERS)\n }\n\n getProvProviders(): IProviders[] {\n let pdrs: IProviders[] = [];\n let currj: Joinpoint = this.provJoinpoint;\n while (currj) {\n let pdr = currj.hasValue(AOP_METHOD_PROVIDERS) ? currj.providers : null;\n if (pdr && pdr.size) {\n pdrs.push(pdr);\n }\n currj = currj.provJoinpoint;\n }\n return pdrs;\n }\n\n setOptions(options: JoinpointOption) {\n if (!options) {\n return this;\n }\n super.setOptions(options);\n this.setValue(AOP_TARGET_TYPE, options.targetType);\n options.target && this.setValue(AOP_TARGET, options.target)\n options.originMethod && this.setValue(AOP_METHOD_ORIGIN, options.originMethod);\n this.setValue(AOP_METHOD_NAME, options.name);\n this.setValue(AOP_METHOD_FULLNAME, options.fullName);\n this.setValue(AOP_METHOD_PARAMS, options.params);\n this.setValue(AOP_ARGS, options.args);\n this.setValue(AOP_ADVICES, options.advices);\n options.state && this.setValue(AOP_STATE, options.state);\n options.providers && this.setValue(AOP_METHOD_PROVIDERS, options.providers);\n options.annotations && this.setValue(AOP_METHOD_ANNOTATIONS, options.annotations);\n options.provJoinpoint && this.setValue(AOP_PROV_JOINPOINT, options.provJoinpoint);\n }\n\n /**\n * create resolve context via options.\n *\n * @static\n * @param {IInjector} injector\n * @param {ResolveActionOption} options\n * @returns {ResolveActionContext}\n * @memberof ResolveActionContext\n */\n static parse<T>(injector: IInjector, options: JoinpointOption): Joinpoint {\n return createContext<Joinpoint>(injector, Joinpoint, options);\n }\n}\n","import { Advicer } from './Advicer';\nimport { tokenId } from '@tsdi/ioc';\n\n/**\n * advices of target.\n *\n * @export\n * @interface Advices\n */\nexport interface Advices {\n Pointcut: Advicer[];\n Before: Advicer[];\n After: Advicer[];\n Around: Advicer[];\n AfterThrowing: Advicer[];\n AfterReturning: Advicer[];\n}\n\n\nexport const AdvicesToken = tokenId<Advices>('AOP_ADVICES');\n","import { Type, ObjectMap, ParamProviders, tokenId } from '@tsdi/ioc';\nimport { Advices } from './advices/Advices';\nimport { AdviceMetadata } from './metadatas/AdviceMetadata';\n\n\nexport const AOP_EXTEND_TARGET_TOKEN = tokenId<(target: any) => void>('AOP_EXTEND_TARGET_TOKEN')\n/**\n * Aop IAdvisor interface token.\n * it is a token id, you can register yourself IAdvisor for this.\n */\nexport const AdvisorToken = tokenId<IAdvisor>('DI_IAdvisor');\n\n/**\n * aspect and advices manager.\n *\n * @export\n * @interface IAdvisor\n */\nexport interface IAdvisor {\n /**\n * aspects\n *\n * @type {Map<Type, ObjectMap<AdviceMetadata[]>>}\n * @memberof IAdvisor\n */\n aspects: Map<Type, ObjectMap<AdviceMetadata[]>>;\n /**\n * advices\n *\n * @type {Map<Type, Map<string, Advices>>}\n * @memberof IAdvisor\n */\n advices: Map<Type, Map<string, Advices>>;\n\n /**\n * set advices.\n *\n * @param {Type} type\n * @param {string} key\n * @param {Advices} advices\n * @memberof IAdvisor\n */\n setAdvices(type: Type, key: string, advices: Advices);\n\n /**\n * the type has advices or not.\n * @param type\n */\n hasAdvices(type: Type): boolean;\n /**\n * get advices.\n *\n * @param {Type} type\n * @returns {Advices}\n * @memberof IAdvisor\n */\n getAdviceMap(type: Type): Map<string, Advices>;\n /**\n * get advices.\n *\n * @param {Type} type\n * @param {string} key\n * @returns {Advices}\n * @memberof IAdvisor\n */\n getAdvices(type: Type, key: string): Advices;\n\n /**\n * add aspect.\n *\n * @param {Type} aspect\n * @param {IIocContainer} raiseContainer\n * @memberof IAdvisor\n */\n add(aspect: Type);\n\n /**\n * resolve aspect.\n *\n * @template T\n * @param {Type<T>} aspect\n * @param {...ParamProviders[]} providers\n * @returns {T}\n * @memberof IAdvisor\n */\n resolve<T>(aspect: Type<T>, ...providers: ParamProviders[]): T;\n}\n","export const aExp = /^@/;\nexport const annPreChkExp = /^\\^?@\\w+/;\nexport const annContentExp = /^@annotation\\(.*\\)$/;\nexport const executionChkExp = /^execution\\(\\S+\\)$/;\nexport const execContentExp = /^execution\\(.*\\)$/;\nexport const mthNameExp = /^\\w+(\\((\\s*\\w+\\s*,)*\\s*\\w*\\))?$/;\nexport const tgMthChkExp = /^([\\w\\*]+\\.)+[\\w\\*]+(\\((\\s*\\w+\\s*,)*\\s*\\w*\\))?$/;\nexport const preParam = /^\\(/;\nexport const endParam = /\\)$/;\nexport const withInChkExp = /^@within\\(\\s*\\w+/;\nexport const targetChkExp = /^@target\\(\\s*\\w+/;\nexport const replAny = /\\*\\*/gi;\nexport const replAny1 = /\\*/gi;\nexport const replDot = /\\./gi;\nexport const replNav = /\\//gi;\n","import {\n Type, isFunction, lang, IProviders, InvokedProviders, ITypeReflects, TypeReflectsToken, IocCompositeAction, IParameter, IActionSetup, isArray, isDefined, tokenId, isPromise, PromiseUtil\n} from '@tsdi/ioc';\nimport { Advices } from '../advices/Advices';\nimport { IPointcut } from '../joinpoints/IPointcut';\nimport { Joinpoint, AOP_RETURNING, AOP_STATE, AOP_THROWING } from '../joinpoints/Joinpoint';\nimport { JoinpointState } from '../joinpoints/JoinpointState';\nimport { AdvisorToken } from '../IAdvisor';\nimport { aExp } from '../regexps';\nimport { Advicer } from '../advices/Advicer';\n\nconst proxyFlag = '_proxy';\nconst ctor = 'constructor';\nexport const AOP_ADVICE_INVOKER = tokenId<(joinPoint: Joinpoint, advicer: Advicer) => any>('AOP_ADVICE_INVOKER');\n\n/**\n * Proxy method.\n *\n * @export\n * @class ProxyMethod\n * @implements {IProxyMethod}\n */\nexport class ProceedingScope extends IocCompositeAction<Joinpoint> implements IActionSetup {\n\n execute(ctx: Joinpoint, next?: () => void) {\n ctx.providers.inject({ provide: Joinpoint, useValue: ctx });\n ctx.setValue(AOP_ADVICE_INVOKER, (j, a) => this.invokeAdvice(j, a, this.reflects));\n super.execute(ctx, next);\n }\n\n private _reflects: ITypeReflects;\n get reflects(): ITypeReflects {\n if (!this._reflects) {\n this._reflects = this.actInjector.getInstance(TypeReflectsToken);\n }\n return this._reflects;\n }\n\n beforeConstr(targetType: Type, params: IParameter[], args: any[], providers: IProviders) {\n let propertykey = ctor;\n let advices = this.actInjector.getInstance(AdvisorToken).getAdvices(targetType, propertykey);\n if (!advices) {\n return;\n }\n\n let className = lang.getClassName(targetType);\n let joinPoint = Joinpoint.parse(this.reflects.getInjector(targetType), {\n name: ctor,\n state: JoinpointState.Before,\n advices: advices,\n fullName: className + '.' + ctor,\n args: args,\n params: params,\n targetType: targetType,\n providers: providers\n });\n this.execute(joinPoint);\n }\n\n afterConstr(target: any, targetType: Type, params: IParameter[], args: any[], providers: IProviders) {\n let propertykey = ctor;\n let advices = this.actInjector.getInstance(AdvisorToken).getAdvices(targetType, propertykey);\n if (!advices) {\n return;\n }\n\n let className = lang.getClassName(targetType);\n let joinPoint = Joinpoint.parse(this.reflects.getInjector(targetType), {\n name: ctor,\n state: JoinpointState.After,\n advices: advices,\n fullName: className + '.' + ctor,\n args: args,\n params: params,\n target: target,\n targetType: targetType,\n providers: providers\n });\n this.execute(joinPoint);\n }\n\n /**\n * proceed the proxy method.\n *\n * @param {*} target\n * @param {Type} targetType\n * @param {IPointcut} pointcut\n * @param {Joinpoint} [provJoinpoint]\n * @memberof ProxyMethod\n */\n proceed(target: any, targetType: Type, advices: Advices, pointcut: IPointcut, provJoinpoint?: Joinpoint) {\n let methodName = pointcut.name;\n if (advices && pointcut) {\n if (pointcut.descriptor && (pointcut.descriptor.get || pointcut.descriptor.set)) {\n if (pointcut.descriptor.get && !pointcut.descriptor.get[proxyFlag]) {\n let getMethod = pointcut.descriptor.get.bind(target);\n pointcut.descriptor.get = this.proxy(getMethod, advices, target, targetType, pointcut, provJoinpoint);\n pointcut.descriptor.get[proxyFlag] = true;\n }\n if (pointcut.descriptor.set && !pointcut.descriptor.set[proxyFlag]) {\n let setMethod = pointcut.descriptor.set.bind(target);\n pointcut.descriptor.set = this.proxy(setMethod, advices, target, targetType, pointcut, provJoinpoint);\n pointcut.descriptor.set[proxyFlag] = true;\n }\n Reflect.defineProperty(target, methodName, pointcut.descriptor);\n } else if (isFunction(target[methodName]) && !target[methodName][proxyFlag]) {\n let propertyMethod = target[methodName].bind(target);\n target[methodName] = this.proxy(propertyMethod, advices, target, targetType, pointcut, provJoinpoint);\n target[methodName][proxyFlag] = true;\n }\n }\n }\n\n proxy(propertyMethod: Function, advices: Advices, target: any, targetType: Type, pointcut: IPointcut, provJoinpoint?: Joinpoint) {\n let fullName = pointcut.fullName;\n let methodName = pointcut.name;\n let reflects = this.reflects;\n let self = this;\n return (...args: any[]) => {\n let larg = lang.last(args);\n let cuurPrd: IProviders = null;\n if (larg instanceof InvokedProviders) {\n args = args.slice(0, args.length - 1);\n cuurPrd = larg;\n }\n let joinPoint = Joinpoint.parse(reflects.getInjector(targetType), {\n name: methodName,\n fullName: fullName,\n params: reflects.getParameters(targetType, target, methodName),\n args: args,\n target: target,\n targetType: targetType,\n advices: advices,\n originMethod: propertyMethod,\n provJoinpoint: provJoinpoint,\n annotations: reflects.getMetadatas(targetType, methodName, 'method'),\n providers: cuurPrd\n });\n\n self.execute(joinPoint);\n let returning = joinPoint.returning;\n return returning;\n }\n }\n\n setup() {\n this.use(CtorAdvicesScope)\n .use(MethodAdvicesScope);\n }\n\n protected invokeAdvice(joinPoint: Joinpoint, advicer: Advicer, reflects: ITypeReflects) {\n let metadata: any = advicer.advice;\n let providers = joinPoint.providers;\n if (isDefined(joinPoint.args) && metadata.args) {\n providers.inject({ provide: metadata.args, useValue: joinPoint.args })\n }\n\n if (metadata.annotationArgName) {\n providers.inject({\n provide: metadata.annotationArgName,\n useFactory: () => {\n let curj = joinPoint;\n let annotations = curj.annotations;\n\n if (isArray(annotations)) {\n if (metadata.annotationName) {\n let d: string = metadata.annotationName;\n d = aExp.test(d) ? d : `@${d}`;\n return annotations.filter(a => a.decorator === d);\n }\n return annotations;\n } else {\n return [];\n }\n }\n });\n }\n\n if (joinPoint.hasValue(AOP_RETURNING) && metadata.returning) {\n providers.inject({ provide: metadata.returning, useValue: joinPoint.returning })\n }\n\n if (joinPoint.throwing && metadata.throwing) {\n providers.inject({ provide: metadata.throwing, useValue: joinPoint.throwing });\n }\n return reflects.getInjector(advicer.aspectType).invoke(advicer.aspectType, advicer.advice.propertyKey, providers);\n }\n\n}\n\n\nexport class CtorAdvicesScope extends IocCompositeAction<Joinpoint> implements IActionSetup {\n execute(ctx: Joinpoint, next?: () => void) {\n if (ctx.name === ctor) {\n super.execute(ctx);\n } else {\n next();\n }\n }\n setup() {\n this.use(CtorBeforeAdviceAction)\n .use(CtorAfterAdviceAction);\n }\n}\n\nexport const CtorBeforeAdviceAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.state === JoinpointState.Before) {\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n advices.Before.forEach(advicer => {\n invoker(ctx, advicer);\n });\n\n advices.Pointcut.forEach(advicer => {\n invoker(ctx, advicer);\n });\n\n advices.Around.forEach(advicer => {\n invoker(ctx, advicer);\n });\n }\n next();\n\n}\n\n\nexport const CtorAfterAdviceAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.state === JoinpointState.After) {\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n advices.After.forEach(advicer => {\n invoker(ctx, advicer);\n });\n\n advices.Around.forEach(advicer => {\n invoker(ctx, advicer);\n });\n }\n next();\n}\n\nexport class MethodAdvicesScope extends IocCompositeAction<Joinpoint> implements IActionSetup {\n\n execute(ctx: Joinpoint, next?: () => void) {\n ctx.providers.inject(...ctx.getProvProviders());\n super.execute(ctx, next);\n }\n setup() {\n this.use(BeforeAdvicesAction)\n .use(PointcutAdvicesAction)\n .use(ExecuteOriginMethodAction)\n .use(AfterAdvicesAction)\n .use(AfterAsyncReturningAdvicesAction)\n .use(AfterReturningAdvicesAction)\n .use(AfterThrowingAdvicesAction);\n }\n\n}\n\n\nexport const BeforeAdvicesAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.throwing) {\n return next();\n }\n ctx.setValue(AOP_STATE, JoinpointState.Before);\n\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n advices.Around.forEach(advicer => {\n invoker(ctx, advicer);\n });\n\n advices.Before.forEach(advicer => {\n invoker(ctx, advicer);\n });\n next();\n}\n\nexport const PointcutAdvicesAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.throwing) {\n return next();\n }\n ctx.setValue(AOP_STATE, JoinpointState.Pointcut);\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n advices.Pointcut.forEach(advicer => {\n invoker(ctx, advicer);\n });\n next();\n}\n\nexport const ExecuteOriginMethodAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.throwing) {\n return next();\n }\n try {\n let val = ctx.originMethod(...ctx.args);\n ctx.setValue(AOP_RETURNING, val);\n } catch (err) {\n ctx.setValue(AOP_THROWING, err);\n }\n next();\n}\n\nexport const AfterAdvicesAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.throwing) {\n return next();\n }\n ctx.setValue(AOP_STATE, JoinpointState.After);\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n advices.Around.forEach(advicer => {\n invoker(ctx, advicer);\n });\n advices.After.forEach(advicer => {\n invoker(ctx, advicer);\n });\n next();\n}\n\nexport const AfterAsyncReturningAdvicesAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.throwing || !isPromise(ctx.returning)) {\n return next();\n }\n\n ctx.setValue(AOP_STATE, JoinpointState.AfterReturning);\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n ctx.setValue(AOP_RETURNING, PromiseUtil.step([\n ctx.returning,\n ...advices.Around.map(a => () => invoker(ctx, a)),\n ...advices.AfterReturning.map(a => () => invoker(ctx, a)),\n ctx.returning\n ]));\n\n}\n\nexport const AfterReturningAdvicesAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.throwing) {\n return next();\n }\n if (ctx.hasValue(AOP_RETURNING)) {\n ctx.setValue(AOP_STATE, JoinpointState.AfterReturning);\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n advices.Around.forEach(advicer => {\n invoker(ctx, advicer);\n });\n advices.AfterReturning.forEach(advicer => {\n invoker(ctx, advicer);\n });\n }\n}\n\nexport const AfterThrowingAdvicesAction = function (ctx: Joinpoint, next: () => void): void {\n if (ctx.throwing) {\n ctx.setValue(AOP_STATE, JoinpointState.AfterThrowing);\n }\n let advices = ctx.advices;\n let invoker = ctx.getValue(AOP_ADVICE_INVOKER);\n advices.Around.forEach(advicer => {\n invoker(ctx, advicer);\n });\n advices.AfterThrowing.forEach(advicer => {\n invoker(ctx, advicer);\n });\n}\n","import {\n Type, ObjectMap, ParamProviders, Inject, TypeReflectsToken, ITypeReflects\n} from '@tsdi/ioc';\nimport { Advices } from './advices/Advices';\nimport { Advice } from './decorators/Advice';\nimport { AdviceMetadata } from './metadatas/AdviceMetadata';\nimport { IAdvisor } from './IAdvisor';\n\n/**\n * for global aop advisor.\n *\n * @export\n * @class Advisor\n */\nexport class Advisor implements IAdvisor {\n /**\n * aspects.\n *\n * @type {Map<Type, ObjectMap<AdviceMetadata[]>>}\n * @memberof AspectManager\n */\n aspects: Map<Type, ObjectMap<AdviceMetadata[]>>;\n /**\n * method advices.\n *\n * @type {Map<Type, Map<string, Advices>>}\n * @memberof AspectManager\n */\n advices: Map<Type, Map<string, Advices>>;\n\n constructor(@Inject(TypeReflectsToken) private reflects: ITypeReflects) {\n this.aspects = new Map();\n this.advices = new Map();\n }\n\n /**\n * set advices.\n *\n * @param {string} key\n * @param {Advices} advices\n * @memberof Advisor\n */\n setAdvices(type: Type, key: string, advices: Advices) {\n if (!this.advices.has(type)) {\n this.advices.set(type, new Map());\n }\n this.advices.get(type).set(key, advices);\n }\n\n hasAdvices(type: Type): boolean {\n return this.advices.has(type);\n }\n\n /**\n * get advices.\n *\n * @param {string} key\n * @returns\n * @memberof Advisor\n */\n getAdvices(type: Type, key: string) {\n return this.advices.get(type)?.get(key) || null;\n }\n\n /**\n * get advices.\n *\n * @param {string} key\n * @returns {Advices}\n * @memberof IAdvisor\n */\n getAdviceMap(type: Type): Map<string, Advices> {\n return this.advices.get(type);\n }\n\n /**\n * add aspect.\n *\n * @param {Type} aspect\n * @param {IInjector} injector\n * @memberof Advisor\n */\n add(aspect: Type) {\n if (!this.aspects.has(aspect)) {\n let metas = this.reflects.getMethodMetadata<AdviceMetadata>(Advice, aspect);\n this.aspects.set(aspect, metas);\n }\n }\n\n /**\n * resolve aspect.\n *\n * @template T\n * @param {Type<T>} aspect\n * @param {...ParamProviders[]} providers\n * @returns {T}\n * @memberof Advisor\n */\n resolve<T>(aspect: Type<T>, ...providers: ParamProviders[]): T {\n return this.reflects.getInjector(aspect).resolve(aspect, ...providers);\n }\n}\n","import {\n Inject, isString, isRegExp, isDefined, Type, ObjectMap, lang, isArray,\n isFunction, TypeReflectsToken, ITypeReflects\n} from '@tsdi/ioc';\nimport { IAdviceMatcher } from './IAdviceMatcher';\nimport { AdviceMetadata } from './metadatas/AdviceMetadata';\nimport { AspectMetadata } from './metadatas/AspectMetadata';\nimport { IPointcut } from './joinpoints/IPointcut';\nimport { MatchPointcut } from './joinpoints/MatchPointcut';\nimport { Advice } from './decorators/Advice';\nimport { Aspect } from './decorators/Aspect';\nimport {\n annPreChkExp, executionChkExp, preParam, endParam, annContentExp, aExp, execContentExp,\n mthNameExp, tgMthChkExp, replAny, replAny1, replDot, replNav, withInChkExp, targetChkExp\n} from './regexps';\n\n/**\n * match express.\n */\nexport type MatchExpress = (method: string, fullName: string, targetType?: Type, target?: any, pointcut?: IPointcut) => boolean;\n\n\n\n/**\n * advice matcher, use to match advice when a registered create instance.\n *\n * @export\n * @class AdviceMatcher\n * @implements {IAdviceMatcher}\n */\nexport class AdviceMatcher implements IAdviceMatcher {\n\n constructor(@Inject(TypeReflectsToken) private reflects: ITypeReflects) {\n\n }\n\n match(aspectType: Type, targetType: Type, adviceMetas?: ObjectMap<AdviceMetadata[]>, target?: any): MatchPointcut[] {\n let refs = this.reflects;\n let aspectMeta = lang.first(refs.getMetadata<AspectMetadata>(Aspect, aspectType));\n if (aspectMeta) {\n if (aspectMeta.without) {\n let outs = isArray(aspectMeta.without) ? aspectMeta.without : [aspectMeta.without];\n if (outs.some(t => refs.isExtends(targetType, t))) {\n return [];\n }\n }\n if (aspectMeta.within) {\n let ins = isArray(aspectMeta.within) ? aspectMeta.within : [aspectMeta.within];\n if (!ins.some(t => refs.isExtends(targetType, t))) {\n if (!aspectMeta.annotation) {\n return [];\n }\n }\n }\n if (aspectMeta.annotation) {\n let annotation = isFunction(aspectMeta.annotation) ? aspectMeta.annotation.toString() : aspectMeta.annotation;\n let anno = (annPreChkExp.test(annotation) ? '' : '@') + annotation;\n if (!refs.hasMetadata(anno, targetType)) {\n return [];\n }\n }\n }\n\n let className = lang.getClassName(targetType);\n adviceMetas = adviceMetas || refs.getMethodMetadata<AdviceMetadata>(Advice, targetType);\n let matched: MatchPointcut[] = [];\n\n if (targetType === aspectType) {\n let adviceNames = Object.keys(adviceMetas);\n if (adviceNames.length > 1) {\n let advices: AdviceMetadata[] = [];\n adviceNames.forEach(n => {\n advices = advices.concat(adviceMetas[n]);\n });\n\n adviceNames.forEach(n => {\n advices.forEach(adv => {\n if (adv.propertyKey !== n) {\n if (this.matchAspectSelf(n, adv)) {\n matched.push({\n name: n,\n fullName: `${className}.${n}`,\n advice: adv\n });\n }\n }\n })\n });\n }\n } else {\n let points: IPointcut[] = [];\n let decorators = refs.create(targetType).defines.getPropertyDescriptors();\n // match method.\n for (let name in decorators) {\n // if (name !== 'constructor') {\n points.push({\n name: name,\n fullName: `${className}.${name}`\n });\n // }\n }\n\n Object.getOwnPropertyNames(adviceMetas).forEach(name => {\n let advices = adviceMetas[name];\n advices.forEach(metadata => {\n matched = matched.concat(this.filterPointcut(targetType, points, metadata));\n });\n });\n }\n\n return matched;\n\n }\n\n protected matchAspectSelf(name: string, metadata: AdviceMetadata): boolean {\n if (metadata.pointcut) {\n let pointcut = metadata.pointcut;\n\n if (isString(pointcut)) {\n if (executionChkExp.test(pointcut)) {\n pointcut = pointcut.substring(10, pointcut.length - 1);\n }\n return pointcut.startsWith(name);\n } else if (isRegExp(pointcut)) {\n return pointcut.test(name);\n }\n }\n return false;\n }\n\n filterPointcut(type: Type, points: IPointcut[], metadata: AdviceMetadata, target?: any): MatchPointcut[] {\n if (!metadata.pointcut) {\n return [];\n }\n let matchedPointcut;\n if (metadata.pointcut) {\n let match = this.matchTypeFactory(type, metadata);\n matchedPointcut = points.filter(p => match(p.name, p.fullName, type, target, p))\n }\n\n matchedPointcut = matchedPointcut || [];\n return matchedPointcut.map(p => {\n return Object.assign({}, p, { advice: metadata });\n });\n }\n\n protected matchTypeFactory(type: Type, metadata: AdviceMetadata): MatchExpress {\n let pointcut = metadata.pointcut;\n let expresses: (MatchExpress | string)[] = [];\n if (metadata.within) {\n expresses.push((method: string, fullName: string, targetType?: Type) => {\n if (isArray(metadata.within)) {\n return metadata.within.some(t => this.reflects.isExtends(targetType, t));\n } else {\n return this.reflects.isExtends(targetType, metadata.within);\n }\n });\n expresses.push('&&')\n }\n if (metadata.target) {\n expresses.push((method: string, fullName: string, targetType?: Type, target?: any) => {\n return metadata.target = target;\n });\n expresses.push('&&')\n }\n\n if (metadata.annotation) {\n expresses.push((method: string, fullName: string, targetType?: Type, target?: any) => {\n return this.reflects.hasMethodMetadata(metadata.annotation, targetType, method);\n });\n expresses.push('&&')\n }\n if (isString(pointcut)) {\n let pointcuts = (pointcut || '').trim();\n expresses.push(this.tranlateExpress(type, pointcuts));\n } else if (isRegExp(pointcut)) {\n let pointcutReg = pointcut;\n if (annPreChkExp.test(pointcutReg.source)) {\n expresses.push((name: string, fullName: string, targetType?: Type) => {\n let decName = Reflect.getMetadataKeys(type, name);\n return decName.some(n => isString(n) && pointcutReg.test(n));\n });\n\n } else {\n expresses.push((name: string, fullName: string) => pointcutReg.test(fullName));\n }\n }\n return this.mergeExpress(...expresses);\n }\n\n protected spiltBrace(strExp: string) {\n strExp = strExp.trim();\n\n if (preParam.test(strExp) && endParam.test(strExp)) {\n strExp = strExp.substring(1, strExp.length - 1).trim();\n }\n\n if (preParam.test(strExp) && endParam.test(strExp)) {\n return this.spiltBrace(strExp);\n } else {\n return strExp;\n }\n }\n\n protected expressToFunc(type: Type, strExp: string): MatchExpress {\n if (annContentExp.test(strExp)) {\n let exp = strExp.substring(12, strExp.length - 1);\n let annotation = aExp.test(exp) ? exp : ('@' + exp);\n return (name: string, fullName: string) => {\n if (name === 'constructor') {\n return this.reflects.hasMetadata(annotation, type);\n }\n return this.reflects.hasMethodMetadata(annotation, type, name);\n }\n\n } else if (execContentExp.test(strExp)) {\n let exp = strExp.substring(10, strExp.length - 1);\n if (exp === '*' || exp === '*.*') {\n return (name: string, fullName: string) => !!name && !this.reflects.hasMetadata(Aspect, type);\n } else if (mthNameExp.test(exp)) {\n // if is method name, will match aspect self only.\n return () => false;\n } else if (tgMthChkExp.test(exp)) {\n exp = exp.replace(replAny, '(\\\\\\w+(\\\\\\.|\\\\\\/)){0,}\\\\\\w+')\n .replace(replAny1, '\\\\\\w+')\n .replace(replDot, '\\\\\\.')\n .replace(replNav, '\\\\\\/');\n\n let matcher = new RegExp(exp + '$');\n return (name: string, fullName: string) => matcher.test(fullName);\n } else {\n return () => false;\n }\n } else if (withInChkExp.test(strExp)) {\n let classnames = strExp.substring(strExp.indexOf('(') + 1, strExp.length - 1).split(',').map(n => n.trim());\n return (name: string, fullName: string, targetType?: Type) => classnames.indexOf(lang.getClassName(targetType)) >= 0;\n } else if (targetChkExp.test(strExp)) {\n let torken = strExp.substring(strExp.indexOf('(') + 1, strExp.length - 1).trim();\n return (name: string, fullName: string, targetType?: Type) => this.reflects.getInjector(type).getTokenProvider(torken) === targetType;\n } else {\n return () => false;\n }\n }\n\n protected tranlateExpress(type: Type, strExp: string): MatchExpress {\n let expresses: ((MatchExpress) | string)[] = [];\n\n let idxOr = strExp.indexOf('||');\n let idxAd = strExp.indexOf('&&');\n if (idxAd < 0 && idxOr < 0) {\n expresses.push(this.expressToFunc(type, this.spiltBrace(strExp)))\n } else {\n if (idxOr > idxAd) {\n let leftExp = this.spiltBrace(strExp.substring(0, idxOr));\n if (leftExp) {\n expresses.push(this.tranlateExpress(type, leftExp));\n }\n let rightExp = this.spiltBrace(strExp.substring(idxOr + 2));\n if (rightExp) {\n expresses.push('||');\n expresses.push(this.tranlateExpress(type, rightExp));\n }\n } else if (idxAd > idxOr) {\n let leftExp = this.spiltBrace(strExp.substring(0, idxAd));\n if (leftExp) {\n expresses.push(this.tranlateExpress(type, leftExp));\n }\n let rightExp = this.spiltBrace(strExp.substring(idxAd + 2));\n if (rightExp) {\n expresses.push('&&');\n expresses.push(this.tranlateExpress(type, rightExp));\n }\n }\n }\n\n return this.mergeExpress(...expresses);\n }\n\n\n protected mergeExpress(...expresses: (MatchExpress | string)[]): MatchExpress {\n return (method: string, fullName: string, targetType?: Type, pointcut?: IPointcut) => {\n let flag;\n expresses.forEach((express, idx) => {\n if (isDefined(flag)) {\n return;\n }\n if (isFunction(express)) {\n let rel = express(method, fullName, targetType, pointcut);\n if (idx < expresses.length - 2) {\n if (!rel && express[idx + 1] === '&&') {\n flag = false;\n }\n if (rel && express[idx + 1] === '||') {\n flag = true;\n }\n } else {\n flag = rel;\n }\n }\n\n });\n return flag;\n }\n }\n}\n","import { Type, ObjectMap, tokenId } from '@tsdi/ioc';\nimport { AdviceMetadata } from './metadatas/AdviceMetadata';\nimport { MatchPointcut } from './joinpoints/MatchPointcut';\n\n/**\n * Aop advice matcher interface token.\n * it is a token id, you can register yourself IActionBuilder for this.\n */\nexport const AdviceMatcherToken = tokenId<IAdviceMatcher>('DI_IAdviceMatcher');\n\n/**\n * advice match interface, use to match advice when a registered create instance.\n *\n * @export\n * @interface IAdviceMatcher\n */\nexport interface IAdviceMatcher {\n\n /**\n * match pointcuts of type.\n *\n * @param {Type} aspectType\n * @param {Type} type\n * @param {ObjectMap<AdviceMetadata[]>} [adviceMetas]\n * @param {*} [instance]\n * @returns {MatchPointcut[]}\n * @memberof IAdviceMatcher\n */\n match(aspectType: Type, type: Type, adviceMetas?: ObjectMap<AdviceMetadata[]>, instance?: any): MatchPointcut[]\n}\n","import {\n RuntimeContext, lang, isClass, Type, isBaseType, DesignContext,\n ITypeReflects, ActionInjectorToken, CTX_PARAMS, CTX_ARGS\n} from '@tsdi/ioc';\nimport { AdvisorToken } from '../IAdvisor';\nimport { ProceedingScope } from '../proceeding/ProceedingScope';\nimport { NonePointcut } from '../decorators/NonePointcut';\nimport { Advicer } from '../advices/Advicer';\nimport { Advices } from '../advices/Advices';\nimport { AdviceMatcherToken } from '../IAdviceMatcher';\n\n\n/**\n * execute bind method pointcut action.\n */\nexport const BindMthPointcutAction = function (ctx: RuntimeContext, next: () => void): void {\n // aspect class do nothing.\n let reflects = ctx.reflects;\n if (!ctx.target || !isValAspectTag(ctx.type, reflects)) {\n return next();\n }\n\n let scope = reflects.getActionInjector().getInstance(ProceedingScope);\n\n let target = ctx.target;\n let targetType = ctx.type;\n\n let className = lang.getClassName(targetType);\n let decorators = ctx.targetReflect.defines.getPropertyDescriptors();\n let advisor = reflects.getActionInjector().getInstance(AdvisorToken);\n let advicesMap = advisor.getAdviceMap(targetType);\n\n if (advicesMap && advicesMap.size) {\n advicesMap.forEach((advices, name) => {\n if (name === 'constructor') {\n return;\n }\n let pointcut = {\n name: name,\n fullName: `${className}.${name}`,\n descriptor: decorators[name]\n }\n scope.proceed(target, targetType, advices, pointcut)\n });\n }\n\n next();\n};\n\n\n/**\n * before constructor advice actions.\n *\n * @export\n */\nexport const BeforeCtorAdviceAction = function (ctx: RuntimeContext, next: () => void): void {\n // aspect class do nothing.\n let reflects = ctx.reflects;\n if (!isValAspectTag(ctx.type, reflects)) {\n return next();\n }\n\n reflects.getActionInjector().getInstance(ActionInjectorToken)\n .getInstance(ProceedingScope)\n .beforeConstr(ctx.type, ctx.getValue(CTX_PARAMS), ctx.getValue(CTX_ARGS), ctx.providers);\n\n next();\n\n};\n\n\n/**\n * after constructor advice actions.\n *\n * @export\n */\nexport const AfterCtorAdviceAction = function (ctx: RuntimeContext, next: () => void): void {\n // aspect class do nothing.\n let reflects = ctx.reflects;\n if (!ctx.target || !isValAspectTag(ctx.type, reflects)) {\n return next();\n }\n\n reflects.getActionInjector().getInstance(ActionInjectorToken)\n .getInstance(ProceedingScope)\n .afterConstr(ctx.target, ctx.type, ctx.getValue(CTX_PARAMS), ctx.getValue(CTX_ARGS), ctx.providers);\n\n next();\n};\n\n/**\n * regist aspect action.\n *\n * @export\n */\nexport const RegistAspectAction = function (ctx: DesignContext, next: () => void): void {\n let type = ctx.type;\n let aspectMgr = ctx.reflects.getActionInjector().getInstance(AdvisorToken);\n aspectMgr.add(type);\n next();\n};\n\n/**\n * match pointcut action.\n *\n * @export\n */\nexport const MatchPointcutAction = function (ctx: RuntimeContext, next: () => void): void {\n // aspect class do nothing.\n let reflects = ctx.reflects;\n if (!isValAspectTag(ctx.type, reflects)) {\n return next();\n }\n\n let advisor = reflects.getActionInjector().getInstance(AdvisorToken);\n let matcher = reflects.getActionInjector().getInstance(AdviceMatcherToken);\n let targetType = ctx.type;\n\n advisor.aspects.forEach((adviceMetas, type) => {\n let matchpoints = matcher.match(type, targetType, adviceMetas, ctx.target);\n matchpoints.forEach(mpt => {\n let name = mpt.name;\n let advice = mpt.advice;\n\n let advices = advisor.getAdvices(targetType, name);\n if (!advices) {\n advices = {\n Before: [],\n Pointcut: [],\n After: [],\n Around: [],\n AfterThrowing: [],\n AfterReturning: []\n } as Advices;\n advisor.setAdvices(targetType, name, advices);\n }\n let advicer = Object.assign(mpt, {\n aspectType: type\n }) as Advicer;\n\n if (advice.adviceName === 'Before') {\n if (!advices.Before.some(a => equals(a, advicer))) {\n advices.Before.push(advicer);\n }\n } else if (advice.adviceName === 'Pointcut') {\n if (!advices.Pointcut.some(a => equals(a, advicer))) {\n advices.Pointcut.push(advicer);\n }\n } else if (advice.adviceName === 'Around') {\n if (!advices.Around.some(a => equals(a, advicer))) {\n advices.Around.push(advicer);\n }\n } else if (advice.adviceName === 'After') {\n if (!advices.After.some(a => equals(a, advicer))) {\n advices.After.push(advicer);\n }\n } else if (advice.adviceName === 'AfterThrowing') {\n if (!advices.AfterThrowing.some(a => equals(a, advicer))) {\n advices.AfterThrowing.push(advicer);\n }\n } else if (advice.adviceName === 'AfterReturning') {\n if (!advices.AfterReturning.some(a => equals(a, advicer))) {\n advices.AfterReturning.push(advicer);\n }\n }\n });\n });\n next();\n}\n\nfunction equals(a: Advicer, b: Advicer) {\n return a.aspectType === b.aspectType && a.advice.propertyKey === b.advice.propertyKey;\n}\n\n\n\n/**\n * is target can aspect or not.\n *\n * @export\n * @param {Type} targetType\n * @returns {boolean}\n */\nfunction isValAspectTag(targetType: Type, reflects: ITypeReflects): boolean {\n if (!isClass(targetType) || isBaseType(targetType)) {\n return false;\n }\n if (targetType.d0NPT) {\n return false;\n }\n return !reflects.hasMetadata(NonePointcut, targetType)\n}\n","import {\n Inject, BeforeCtorScope, AfterCtorScope, IocContainerToken, IIocContainer,\n RuntimeMthScope, TypeProviderAction, RegSingletionAction, RuntimeLifeScope,\n CtorArgsAction, ActionInjector, DesignRegisterer, RuntimeRegisterer, IocExt, TypeReflectsToken\n} from '@tsdi/ioc';\nimport { Aspect } from './decorators/Aspect';\nimport { Advisor } from './Advisor';\nimport { AdviceMatcher } from './AdviceMatcher';\nimport {\n RegistAspectAction, BeforeCtorAdviceAction, AfterCtorAdviceAction,\n BindMthPointcutAction, MatchPointcutAction\n} from './actions/aop-actions';\nimport { ProceedingScope } from './proceeding/ProceedingScope';\nimport { AdvisorToken } from './IAdvisor';\nimport { AdviceMatcherToken } from './IAdviceMatcher';\n\n\n\n/**\n * aop ext for ioc. auto run setup after registered.\n * @export\n * @class AopModule\n */\n@IocExt()\nexport class AopModule {\n\n constructor() {\n\n }\n\n /**\n * register aop for container.\n *\n * @memberof AopModule\n */\n setup(@Inject(IocContainerToken) container: IIocContainer) {\n\n const actInjector = container.getSingleton(ActionInjector);\n const reflects = container.getSingleton(TypeReflectsToken);\n\n actInjector\n .setSingleton(AdvisorToken, new Advisor(reflects), Advisor)\n .setSingleton(AdviceMatcherToken, new AdviceMatcher(reflects), AdviceMatcher);\n\n actInjector.regAction(ProceedingScope);\n\n actInjector.getInstance(BeforeCtorScope)\n .useBefore(BeforeCtorAdviceAction);\n\n actInjector.getInstance(AfterCtorScope)\n // .use(ExetndsInstanceAction)\n .use(AfterCtorAdviceAction);\n\n actInjector.getInstance(RuntimeMthScope)\n .useBefore(BindMthPointcutAction);\n\n actInjector.getInstance(RuntimeLifeScope)\n .useBefore(MatchPointcutAction, CtorArgsAction);\n\n actInjector.getInstance(DesignRegisterer)\n .register(Aspect, 'Class', TypeProviderAction, RegistAspectAction);\n\n actInjector.getInstance(RuntimeRegisterer)\n .register(Aspect, 'Class', RegSingletionAction);\n\n }\n}\n","// decorators\nexport * from './decorators/Advice';\nexport * from './decorators/Aspect';\nexport * from './decorators/After';\nexport * from './decorators/AfterReturning';\nexport * from './decorators/AfterThrowing';\nexport * from './decorators/Around';\nexport * from './decorators/Before';\nexport * from './decorators/Pointcut';\nexport * from './decorators/NonePointcut';\n\n// metadatas\nexport * from './metadatas/AdviceMetadata';\nexport * from './metadatas/AfterReturningMetadata';\nexport * from './metadatas/AfterThrowingMetadata';\nexport * from './metadatas/PointcutMetadata';\nexport * from './metadatas/AroundMetadata';\nexport * from './metadatas/AspectMetadata';\n\n\n// joinpoints\nexport * from './joinpoints/JoinpointState';\nexport * from './joinpoints/IPointcut';\nexport * from './joinpoints/Joinpoint';\nexport * from './joinpoints/MatchPointcut';\n\n\n// advices\nexport * from './advices/Advicer';\nexport * from './advices/Advices';\n\nexport * from './proceeding/ProceedingScope';\n\nexport * from './AdviceTypes';\nexport * from './IAdvisor';\nexport * from './Advisor';\nexport * from './AdviceMatcher';\nexport * from './AopModule';\n\n// actions\nexport * from './actions/aop-actions';\n","import { Inject, isFunction } from '@tsdi/ioc';\nimport { Aspect, Joinpoint, Before } from '@tsdi/aop';\nimport { AuthorizationMetadata, ContextToken, UnauthorizedError, AuthorizationPointcut, IContext } from '@mvx/mvc'\n\n@Aspect()\nexport class AuthenticatedVaildate {\n\n @Before(AuthorizationPointcut, 'authAnnotation')\n vaildate(@Inject(ContextToken) ctx: IContext, authAnnotation: AuthorizationMetadata[], joinPoint: Joinpoint) {\n if (!isFunction(ctx.isAuthenticated)) {\n return;\n }\n if (!ctx.isAuthenticated()) {\n throw new UnauthorizedError();\n }\n }\n\n static d0Ann(): any {\n return {\"name\":\"AuthenticatedVaildate\",\"params\":{\"vaildate\":[\"ctx\",\"authAnnotation\",\"joinPoint\"]}};\n }\n }\n","import { Inject, isFunction } from '@tsdi/ioc';\nimport { Aspect, Joinpoint, Before } from '@tsdi/aop';\nimport { AuthorizationMetadata, ContextToken, ForbiddenError, AuthorizationPointcut, IContext } from '@mvx/mvc';\n\n@Aspect()\nexport class RoleVaildate {\n\n @Before(AuthorizationPointcut, 'authAnnotation')\n vaildate(@Inject(ContextToken) ctx: IContext, authAnnotation: AuthorizationMetadata[], joinPoint: Joinpoint) {\n if (isFunction(ctx.hasRole) && authAnnotation && authAnnotation.length) {\n if (!ctx.hasRole(...authAnnotation.map(a => a.role).filter(a => a))) {\n throw new ForbiddenError();\n }\n }\n }\n\n static d0Ann(): any {\n return {\"name\":\"RoleVaildate\",\"params\":{\"vaildate\":[\"ctx\",\"authAnnotation\",\"joinPoint\"]}};\n }\n }\n","export * from './AuthenticatedVaildate';\nexport * from './RoleVaildate';\n","import { DesignContext, hasOwnClassMetadata, getTypeMetadata, InjectToken, hasMethodMetadata } from '@tsdi/ioc';\nimport { Authorization, ControllerMetadata, Controller } from '@mvx/mvc';\n\n/**\n * the routes need to auth.\n */\nexport const AuthRoutesToken = new InjectToken<Set<string>>('identify_auth_routes');\n\nexport const ControllerAuthRegisterAction = (ctx: DesignContext, next: () => void) => {\n if (hasOwnClassMetadata(Authorization, ctx.type) || hasMethodMetadata(Authorization, ctx.type)) {\n let ctrlmetadatas = getTypeMetadata<ControllerMetadata>(Controller, ctx.type);\n let routers = ctx.injector.get(AuthRoutesToken);\n ctrlmetadatas.forEach(ctlmeta => {\n if (!ctlmeta) {\n return;\n }\n let prefix = ctlmeta.routePrefix;\n if (prefix && !/^\\//.test(prefix)) {\n prefix = '/' + prefix;\n }\n routers.add(prefix);\n });\n }\n next();\n}\n","import { Injectable, Singleton } from '@tsdi/ioc';\nimport { BeforeMidddlewareStartupService, MvcMiddlewares, MvcContext } from '@mvx/mvc';\nimport { PassportBuildService, ConfigurePassportBuildService, AuthenticatorToken } from './passports';\n\n@Singleton\nexport class IdentityStartupService extends BeforeMidddlewareStartupService {\n\n async startup(ctx: MvcContext, middlewares?: MvcMiddlewares): Promise<void> {\n let passport = ctx.injector.get(AuthenticatorToken);\n let services = ctx.injector.getServices(PassportBuildService);\n // config build first.\n let cfs = services.find(s => s instanceof ConfigurePassportBuildService);\n if (cfs && services.indexOf(cfs) > 0) {\n services.splice(services.indexOf(cfs), 1);\n services.unshift(cfs);\n }\n await Promise.all(services.map(s => s.build(passport, ctx.getConfiguration())));\n }\n\n\n static d0Ann(): any {\n return {\"name\":\"IdentityStartupService\",\"params\":{\"startup\":[\"ctx\",\"middlewares\"]}};\n }\n }\n","import { IocExt, Inject, ActionInjectorToken, DesignRegisterer } from '@tsdi/ioc';\nimport { ContainerToken, IContainer } from '@tsdi/core';\nimport { ComponentsModule, ElementModule } from '@tsdi/components';\nimport { Controller } from '@mvx/mvc';\nimport * as vaildates from './vaildates';\nimport * as middlewares from './middlewares';\nimport * as passports from './passports';\nimport { ControllerAuthRegisterAction, AuthRoutesToken } from './registers/ControllerAuthRegisterAction';\nimport { IdentityStartupService } from './IdentityStartupService';\nimport { DIModule } from '@tsdi/boot';\n\n\n@IocExt()\nclass IdentitySetupModule {\n\n constructor() {\n\n }\n\n setup(@Inject(ContainerToken) container: IContainer) {\n container.bindProvider(AuthRoutesToken, new Set());\n let actjtr = container.getInstance(ActionInjectorToken);\n actjtr.register(ControllerAuthRegisterAction);\n\n let dreger = actjtr.getInstance(DesignRegisterer);\n dreger.register(Controller, 'Class', ControllerAuthRegisterAction);\n\n }\n\n static d0Ann(): any {\n return {\"name\":\"IdentitySetupModule\",\"params\":{\"constructor\":[],\"setup\":[\"container\"]}};\n }\n }\n\n\n\n@DIModule({\n regIn: 'root',\n imports: [\n IdentitySetupModule,\n ComponentsModule,\n ElementModule\n ],\n providers: [\n IdentityStartupService,\n [passports, vaildates, middlewares]\n ]\n})\nexport class IdentityModule {\n\n\n static d0Ann(): any {\n return {\"name\":\"IdentityModule\",\"params\":{}};\n }\n }\n\n","export * from './errors';\nexport * from './middlewares';\nexport * from './passports';\nexport * from './stores';\nexport * from './vaildates';\nexport * from './IdentityModule';\nexport * from './services';\nexport * from './registers/ControllerAuthRegisterAction';\n"],"names":["mvc_1","ioc_1","tslib_1","session","components_1","IAuthenticator_1","results_1","jwt","ContextExtends_1","errors_1","boot_1","services_1","url","url_1","utils_1","oauth2_1","stores_1","webfinger","require$$0","oauth2","querystring_1","passports_1","Advice_1","IAdvisor_1","regexps_1","Aspect_1","IAdviceMatcher_1","NonePointcut_1","aop_actions_1","aop_1","ControllerAuthRegisterAction_1","core_1"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAqC;AAErC,MAAa,aAAc,SAAQA,aAAS;IAC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