UNPKG

@basetime/a2w-api-ts

Version:

Client library that communicates with the addtowallet API.

47 lines (46 loc) 1.26 kB
import { Logger } from '../Logger'; import { Authed } from '../types/Authed'; import { AuthProvider } from './AuthProvider'; /** * Authenticates with the a2w API using an oauth code. */ export default class OAuthProvider implements AuthProvider { private app; private code; /** * The successful last authentication. */ private authed?; /** * The logger. */ private logger; /** * Constructor. * * @param app The ID of the app requesting authentication. * @param code The code that was received from the oauth. * @param logger The logger to use. */ constructor(app: string, code?: string, logger?: Logger); /** * @inheritdoc */ setLogger: (logger: Logger) => void; /** * @inheritdoc */ getAuthed: () => Authed | undefined; /** * Returns a URL to get an oauth code. * * @param redirectUrl The URL to redirect to after the oauth code is received. * @param scopes The requested scopes. * @param state Any value, it will be returned in the redirect. */ getCodeUrl: (redirectUrl: string, scopes: string[], state: string) => string; /** * @inheritdoc */ authenticate: () => Promise<string>; }