@microfox/fillout-oauth
Version:
TypeScript OAuth package for Fillout
45 lines (42 loc) • 1.48 kB
TypeScript
interface FilloutOAuthConfig {
clientId: string;
clientSecret: string;
redirectUri: string;
}
interface AccessTokenResponse {
access_token: string;
base_url: string;
}
interface AuthorizationCodeParams {
code: string;
}
interface TokenRequestParams {
code: string;
client_id: string;
client_secret: string;
redirect_uri: string;
}
declare class FilloutOAuthSdk {
private config;
constructor(config: FilloutOAuthConfig);
/**
* Generates the authorization URL for the OAuth flow.
* @param state An optional state parameter for CSRF protection
* @returns The authorization URL
*/
getAuthorizationUrl(state?: string): string;
/**
* Exchanges an authorization code for an access token.
* @param params The parameters required for the token request
* @returns The access token response
*/
getAccessToken(params: AuthorizationCodeParams): Promise<AccessTokenResponse>;
/**
* Validates the access token by making a request to the Fillout API.
* @param accessToken The access token to validate
* @returns A boolean indicating whether the token is valid
*/
validateAccessToken(accessToken: string): Promise<boolean>;
}
declare function createFilloutOAuth(config: FilloutOAuthConfig): FilloutOAuthSdk;
export { type AccessTokenResponse, type AuthorizationCodeParams, type FilloutOAuthConfig, FilloutOAuthSdk, type TokenRequestParams, createFilloutOAuth };