import {AuthenticationExtension, Extension, HttpMethod, IServiceCall, ISession, SessionRequirement} from "@chaosinsight/portalclient" import type {IPortalResponse} from "../index" export default class AuthKey extends AuthenticationExtension { public readonly authenticationType = "AuthKey" protected readonly extensionName = "AuthKey" public loginGet(token: string): IServiceCall> { return this.setAuthenticatedOnSuccess(this.call("Login", {token}, HttpMethod.Get, SessionRequirement.basic)) } public loginPost(token: string): IServiceCall> { return this.setAuthenticatedOnSuccess(this.call("Login", {token}, HttpMethod.Post, SessionRequirement.basic)) } public createPost(name: string ): IServiceCall> { return this.call("Create", {name}, HttpMethod.Post, SessionRequirement.authenticated) } } export interface IAuthKey { Token: string Name: string UserGuid: string } Extension.add(AuthKey, "authKey") declare module "@chaosinsight/portalclient" { // tslint:disable-next-line interface ExtensionHandler { authKey: AuthKey } }