node-hue-api
Version:
Philips Hue API Library for Node.js
62 lines (60 loc) • 2.86 kB
TypeScript
import { Tokens } from './OAuthTokens';
export declare class RemoteApi {
private _config;
private _tokens;
constructor(clientId: string, clientSecret: string);
get clientId(): string;
get clientSecret(): string;
get baseUrl(): string;
get accessToken(): string | undefined;
get accessTokenExpiry(): number | undefined;
get refreshToken(): string | undefined;
get refreshTokenExpiry(): number | undefined;
setAccessToken(token: string, expiry?: number): RemoteApi;
setRefreshToken(token: string, expiry?: number): RemoteApi;
/**
* Builds the digest response to pass to the remote API for the provided request details.
*/
getDigestResponse(realm: string, nonce: string, method: string, path: string): string;
/**
* Constructs the digest authorization header value from the provided details.
* @returns {string} The value to be used for the "Authorization" Header.
*/
getAuthorizationHeaderDigest(realm: string, nonce: string, method: string, path: string): string;
/**
* Constructs the basic authorization header value from the provided details.
*
* This is really poor for security, it is only included to complete the implementation of the APIs, you are strongly
* advised to use the digest authorization instead.
* @returns {string} The value to be used for the "Authorization" Header.
*/
getAuthorizationHeaderBasic(): string;
/**
* Exchanges the code for OAuth tokens.
* @param code The authorization code that is provided as part of the OAuth flow.
* @returns The OAuth Tokens obtained from the remote portal.
*/
getToken(code: string): Promise<Tokens>;
/**
* Refreshes the existing tokens by exchanging the current refresh token for new access and refresh tokens.
*
* After calling this the old tokens will no longer be valid. The new tokens obtained will be injected back into the
* API for future calls.
*
* You should ensure you save the new tokens in place of the previous ones that you used to establish the original
* remote connection.
*
* @param refreshToken The refresh token to exchange for new tokens.
* @returns Promise<Tokens> The new refreshed tokens.
*/
refreshTokens(refreshToken: string): Promise<Tokens>;
/**
* Creates a new remote user
* @param remoteBridgeId The id of the hue bridge in the remote portal, usually 0.
* @param deviceType The user device type identifier (this is shown to the end users on the remote access portal). If not specified will default to 'node-hue-api-remote'.
* @returns The new remote username.
*/
createRemoteUsername(remoteBridgeId?: number | string, deviceType?: string): Promise<string>;
private _respondWithDigest;
private _processTokens;
}