Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
0b576c3170 | |||
df96f08038 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/sdk",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/sdk",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"private": false,
|
||||
"description": "an sdk package for api.global",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -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<any> {
|
||||
slug: 'testapi';
|
||||
public async handleRequest(request: ISimpleRequest) {
|
||||
public async handleRequest(authInfo: sdk.AuthInfo<any>, request: ISimpleRequest) {
|
||||
// this.authenticationHandler
|
||||
let response: any;
|
||||
return response;
|
||||
|
@ -1 +1,2 @@
|
||||
export * from './sdk.classes.aghandler';
|
||||
export * from './sdk.classes.aghandler';
|
||||
export * from './sdk.classes.authinfo';
|
||||
|
@ -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<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>;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
import * as plugins from './sdk.plugins';
|
||||
|
||||
export abstract class AAuthenticationHandler {}
|
19
ts/sdk.classes.authinfo.ts
Normal file
19
ts/sdk.classes.authinfo.ts
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user