tickethead-sdk
Version:
SDK for the Tickethead API
95 lines • 3.65 kB
TypeScript
import { AxiosInstance } from 'axios';
import { Jwt, Nonce, UserPassword, RefreshToken, RefreshableJwt, SignedWalletChallenge, WalletChallengeRequest, ServiceAccessData, ThirdPartyAuth, ThirdPartyAuthResponse, ImpersonateRequest } from './types';
import { KeyPair } from '..';
/**
* Service class for account API calls.
*/
export declare class AuthService {
readonly client: AxiosInstance;
readonly version: string;
constructor(client: AxiosInstance, version: string);
/**
* Returns a JWT and its refresh token.
*
* @param refreshToken refresh token object
* @param credentials specify if you want to use non-default credentials
* @returns JWT and refresh token
* @throws `NotFoundError`, `UnauthorizedError`
*/
refreshToken(refreshToken: RefreshToken, credentials?: Jwt): Promise<RefreshableJwt>;
/**
* Returns a JWT and its refresh token.
* Enables accessing secured BAM endpoints.
* Username can also be the user's email.
*
* @param credentials username/email and password
* @returns JWT and refresh token
* @throws `NotFoundError`, `UnauthorizedError`
*/
login(credentials: UserPassword): Promise<RefreshableJwt>;
/**
* Returns a JWT for a newly-created anonymous user.
* This user has no permissions.
*
* @returns JWT for an generated user
*/
guestLogin(): Promise<Jwt>;
/**
* Returns a nonce which has to be signed with the user's wallet to obtain a JWT.
* Enables accessing secured BAM endpoints.
* After signing you need to call walletLogin.
*
* @param req enroll
* @returns nonce to sign
* @throws `BadRequestError`
*/
getWalletChallenge(req: WalletChallengeRequest): Promise<Nonce>;
/**
* Returns a JWT and its refresh token.
* Enables accessing secured BAM endpoints.
* Requires the device ID header to be set.
*
* @param signedChallenge contains a nonce signed by the users wallet
* @returns JWT and refresh token
* @throws `NotFoundError`, `BadRequestError`
*/
walletLogin(signedChallenge: SignedWalletChallenge): Promise<RefreshableJwt>;
/**
* Returns a JWT and its refresh token.
* Enables accessing secured BAM endpoints.
*
* @param keyPair contains a nonce signed by the users wallet
* @returns JWT and refresh token
* @throws `NotFoundError`, `BadRequestError`
*/
loginWithCertificate(wallet: KeyPair, organizerId?: string): Promise<RefreshableJwt>;
/**
* Returns a JWT for a service.
* Enables accessing secured BAM endpoints.
*
* @param credentials service name, org and password
* @returns JWT
* @throws `NotFoundError`, `UnauthorizedError`
*/
serviceLogin(credentials: ServiceAccessData): Promise<Jwt>;
/**
* Returns a JWT for a service.
* Enables external login via OAuth.
* Token is provided by the third party.
*
* @param req User data for login
* @returns JWT and refresh token
*/
externalLogin(req: ThirdPartyAuth): Promise<ThirdPartyAuthResponse>;
/**
* Returns an impersonated JWT, if you have the permissions to get it.
* If you specify an organizerId, the requested JWT will contain the permissions
* that the userId user has for that organizerId
*
* @param req Impersonated user data
* @param adminCredentials if provided, this token will be used for the request
* @returns Impersonation JWT
*/
impersonate(req: ImpersonateRequest, adminCredentials?: Jwt): Promise<Jwt>;
}
//# sourceMappingURL=service.d.ts.map