6 Commits

Author SHA1 Message Date
e91131b7ae 1.0.6 2020-07-04 14:38:26 +00:00
4dd5d12a2e fix(core): update 2020-07-04 14:38:25 +00:00
7fd110d56c 1.0.5 2020-03-26 21:45:03 +00:00
bb7e9e75ba fix(fix(AAgHandler): now has mandatory async start and async stop methods): update 2020-03-26 21:45:03 +00:00
0b576c3170 1.0.4 2020-03-25 20:15:47 +00:00
df96f08038 fix(core): update 2020-03-25 20:15:46 +00:00
7 changed files with 51 additions and 17 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@apiglobal/sdk",
"version": "1.0.3",
"version": "1.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@apiglobal/sdk",
"version": "1.0.3",
"version": "1.0.6",
"private": false,
"description": "an sdk package for api.global",
"main": "dist_ts/index.js",
@ -8,9 +8,8 @@
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)",
"format": "(gitzone format)"
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",

View File

@ -3,13 +3,23 @@ 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<any> {
slug: 'testapi';
public async handleRequest(request: ISimpleRequest) {
public async handleRequest(authInfo: sdk.AuthInfo<any>, request: ISimpleRequest) {
// this.authenticationHandler
let response: any;
return response;
}
public async checkReqirements() {
return {
allOk: true,
reason: ''
}
}
public async start() {}
public async stop() {}
}
const myHandlerInstance = new MyHandler();

View File

@ -1 +1,2 @@
export * from './sdk.classes.aghandler';
export * from './sdk.classes.aghandler';
export * from './sdk.classes.authinfo';

View File

@ -1,16 +1,24 @@
import * as plugins from './sdk.plugins';
import { AuthInfo } from './sdk.classes.authinfo';
export abstract class AAgHandler {
public authenticationHandler: any;
export interface IRequirementResult {
allOk: boolean;
reason: string;
}
export abstract class AAgHandler<TClaim> {
/**
* a slug that separates the handler from other handlers
*/
public abstract slug: string;
public abstract handleRequest (request: plugins.tsclass.network.ISimpleRequest): Promise<plugins.tsclass.network.ISimpleResponse>;
public setAuthenticationHandler(authHandler) {
this.authenticationHandler = authHandler;
}
public abstract handleRequest (authInfoArg: AuthInfo<TClaim>, request: plugins.tsclass.network.ISimpleRequest): Promise<plugins.tsclass.network.ISimpleResponse>;
public abstract checkReqirements (): Promise<IRequirementResult>;
/**
* start the ag-handler
*/
public abstract start(): Promise<any>;
public abstract stop(): Promise<any>;
}

View File

@ -1,3 +0,0 @@
import * as plugins from './sdk.plugins';
export abstract class AAuthenticationHandler {}

View File

@ -0,0 +1,19 @@
import * as plugins from './sdk.plugins';
/**
* AuthInfo is created for every single incoming request
*/
export abstract class AuthInfo<TClaim> {
/**
* 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;
}