import { Jwt } from '..' import { AuthService } from '../auth' import { RefreshableJwt } from '../auth/types' import { ICredential, CredentialType } from './credential' /** * This class is used to authenticate with an api key. * This method is currently only used on the NFT service. * Be aware that, consequently, it will not work on other services. */ export class ApiKeyCredentials implements ICredential { readonly type: CredentialType.ApiKey private jwt?: Jwt constructor(apiKey: string) { this.jwt = { token: apiKey } } getToken(): Jwt | RefreshableJwt { return this.jwt } async authorize(_authService: AuthService): Promise { return this.jwt } async refreshToken(): Promise { // You can't refresh an api key return this.jwt } }