@kittycad/lib
Version:
Javascript library for KittyCAD API
40 lines • 1.69 kB
TypeScript
import { type AccessContext, type ObjStringDict, OAuth2AuthCodePKCE } from '@kittycad/oauth2-auth-code-pkce';
export interface ClientOptions {
token?: string;
baseUrl?: string;
fetch?: typeof fetch;
clientId?: string;
redirectUrl?: string;
scopes?: string[];
onAccessTokenExpiry?: (refreshAccessToken: () => Promise<AccessContext>) => Promise<AccessContext>;
onInvalidGrant?: (refreshAuthCodeOrRefreshToken: () => Promise<void>) => void;
}
export declare class Client {
token?: string;
baseUrl?: string;
fetch?: typeof fetch;
clientId?: string;
redirectUrl?: string;
scopes?: string[];
onAccessTokenExpiry?: (refreshAccessToken: () => Promise<AccessContext>) => Promise<AccessContext>;
onInvalidGrant?: (refreshAuthCodeOrRefreshToken: () => Promise<void>) => void;
oauth2?: OAuth2AuthCodePKCE;
constructor(tokenOrOpts?: string | ClientOptions);
authorize(oneTimeParams?: ObjStringDict): Promise<void>;
isReturningFromAuthServer(): Promise<boolean>;
getAccessToken(): Promise<AccessContext | undefined>;
resetOAuth2(): void;
private createOAuth2Client;
private updateTokenFromAccessContext;
}
/**
* Build a URL query string from a map of params, skipping undefined values.
* Arrays append multiple entries with the same key. Returns '' when empty.
*/
export declare function buildQuery(params: Record<string, unknown>): string;
/**
* Build an application/x-www-form-urlencoded body from a params map,
* skipping undefined and expanding arrays as repeated keys.
*/
export declare function buildForm(params: Record<string, unknown>): URLSearchParams;
//# sourceMappingURL=client.d.ts.map