@base44/sdk
Version:
JavaScript SDK for Base44 API
56 lines (55 loc) • 2.13 kB
TypeScript
/**
* Utility functions for authentication and token handling
*/
/**
* Retrieves an access token from either localStorage or URL parameters
*
* @param {Object} options - Configuration options
* @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
* @param {string} [options.paramName='access_token'] - The URL parameter name
* @param {boolean} [options.saveToStorage=true] - Whether to save the token to localStorage if found in URL
* @param {boolean} [options.removeFromUrl=true] - Whether to remove the token from URL after retrieval
* @returns {string|null} The access token or null if not found
*/
export declare function getAccessToken(options?: {
storageKey?: string;
paramName?: string;
saveToStorage?: boolean;
removeFromUrl?: boolean;
}): string | null;
/**
* Saves an access token to localStorage
*
* @param {string} token - The access token to save
* @param {Object} options - Configuration options
* @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
* @returns {boolean} Success status
*/
export declare function saveAccessToken(token: string, options: {
storageKey?: string;
}): boolean;
/**
* Removes the access token from localStorage
*
* @param {Object} options - Configuration options
* @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
* @returns {boolean} Success status
*/
export declare function removeAccessToken(options: {
storageKey?: string;
}): boolean;
/**
* Constructs the absolute URL for the login page
*
* @param {string} nextUrl - URL to redirect back to after login
* @param {Object} options - Configuration options
* @param {string} options.serverUrl - Server URL (e.g., 'https://base44.app')
* @param {string|number} options.appId - Application ID
* @param {string} [options.loginPath='/login'] - Path to the login endpoint
* @returns {string} The complete login URL
*/
export declare function getLoginUrl(nextUrl: string, options: {
serverUrl: string;
appId: string;
loginPath?: string;
}): string;