@signiant/media-shuttle-sdk
Version:
The SDK for supporting file transfer to and from Media Shuttle
74 lines • 3.03 kB
TypeScript
import Credentials from './Credentials';
/**
* Required parameters to construct an instance of {@link RefreshingCredentials}.
*/
export interface RefreshingCredentialsConstructorProperties {
refreshToken: string;
clientId: string;
domain: string;
}
/**
* This is the initial login response, returned when the user first logs in with their credentials.
* It contains the refresh token and other information needed to create an instance of {@link RefreshingCredentials}.
*/
export interface LoginResponse {
idToken: string;
refreshToken: string;
domain: string;
clientId: string;
expiresInSeconds: number;
}
/**
* The refresh credentials is used to get new auth token to make REST call for Upload and Download requests.
* This class will use the refresh token generated in a previous interaction with {@link LoginCredentials} to get new auth tokens.
* Also will automatically get a new auth token when the current auth token expires using the refresh token.
*
* It also has a logout function which will revoke the refresh token.
*
* Most callers are recommended to use the {@link LoginCredentials} class to get the initial credentials which will return an instance of this class,
* instead of directly instantiating this class.
*/
declare class RefreshingCredentials implements Credentials {
/**
* A token which will be used to get a new authorization token.
*/
private readonly _refreshToken;
/**
* ClientId associated with the refresh token.
*/
private readonly _clientId;
/**
* Domain/endpoint where the refreshToken will be used to get the next token from.
*/
private readonly _domain;
/**
* Token obtained using refreshToken.
*/
_token: string;
/**
* Sort of a debounce mechanism when getAuthToken is called in quick succession.
*/
_tokenFetchPromise: Promise<void>;
_currentTokenExpiryTime: Number;
/**
* @param {object} options Options for this constructor.
*/
constructor({ refreshToken, clientId, domain }: RefreshingCredentialsConstructorProperties);
getAuthToken(): Promise<string>;
static fromAuthenticationResponse(response: LoginResponse): RefreshingCredentials;
private static getCurrentTokenExpiryTime;
private checkIfTokenNeedsRefresh;
private getNewToken;
private reFetchToken;
logout(): Promise<any>;
/**
* Returns the credentials attributes.
* This can be used to persist the credentials for later use, for example in a database or a file,
* including session/localstorage in a browser environment and then use those persisted credentials
* to create a new instance of {@link RefreshingCredentials} without having to go through the login process again.
* @returns An object containing refreshToken, clientId, domain, and token.
*/
getCredentials(): RefreshingCredentialsConstructorProperties;
}
export default RefreshingCredentials;
//# sourceMappingURL=RefreshingCredentials.d.ts.map