diff --git a/test/test.ts b/test/test.ts index 5e4e606..d2b9aeb 100644 --- a/test/test.ts +++ b/test/test.ts @@ -3,9 +3,9 @@ import * as sdk from '../ts/index'; import { ISimpleRequest } from '@tsclass/tsclass/dist_ts/network'; tap.test('should create a valid Handler', async () => { - class MyHandler extends sdk.AAgHandler { + class MyHandler extends sdk.AAgHandler { slug: 'testapi'; - public async handleRequest(request: ISimpleRequest) { + public async handleRequest(authInfo: sdk.AuthInfo, request: ISimpleRequest) { // this.authenticationHandler let response: any; return response; diff --git a/ts/index.ts b/ts/index.ts index 60260f1..77c1249 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1 +1,2 @@ -export * from './sdk.classes.aghandler'; \ No newline at end of file +export * from './sdk.classes.aghandler'; +export * from './sdk.classes.authinfo'; diff --git a/ts/sdk.classes.aghandler.ts b/ts/sdk.classes.aghandler.ts index d24c24c..8cfa6ea 100644 --- a/ts/sdk.classes.aghandler.ts +++ b/ts/sdk.classes.aghandler.ts @@ -1,16 +1,11 @@ import * as plugins from './sdk.plugins'; +import { AuthInfo } from './sdk.classes.authinfo'; -export abstract class AAgHandler { - public authenticationHandler: any; - +export abstract class AAgHandler { /** * a slug that separates the handler from other handlers */ public abstract slug: string; - public abstract handleRequest (request: plugins.tsclass.network.ISimpleRequest): Promise; - - public setAuthenticationHandler(authHandler) { - this.authenticationHandler = authHandler; - } + public abstract handleRequest (authInfoArg: AuthInfo, request: plugins.tsclass.network.ISimpleRequest): Promise; } \ No newline at end of file diff --git a/ts/sdk.classes.authenticationhandler.ts b/ts/sdk.classes.authenticationhandler.ts deleted file mode 100644 index 5203e0a..0000000 --- a/ts/sdk.classes.authenticationhandler.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as plugins from './sdk.plugins'; - -export abstract class AAuthenticationHandler {} \ No newline at end of file diff --git a/ts/sdk.classes.authinfo.ts b/ts/sdk.classes.authinfo.ts new file mode 100644 index 0000000..f4a260c --- /dev/null +++ b/ts/sdk.classes.authinfo.ts @@ -0,0 +1,19 @@ +import * as plugins from './sdk.plugins'; + +/** + * AuthInfo is created for every single incoming request + */ +export abstract class AuthInfo { + /** + * wether the request is generally authenticated + */ + public abstract authenticated: boolean; + + /** + * A heuristic analysis result wether the request might be fishy. + * Note: DDOS attacks should never make it anywhere near your code and are filtered by api.global itself. + */ + public abstract potentiallyMalicious: boolean; + + public abstract claim: TClaim; +}