UNPKG

@mongodb-js/charts-embed-dom

Version:

JavaScript library for embedding MongoDB Charts

48 lines (47 loc) 1.24 kB
export type StitchAppClient = { auth: { refreshCustomData?(): Promise<void>; refreshAccessToken?(): Promise<void>; authInfo?: { accessToken?: string; }; isLoggedIn: boolean; }; }; export type RealmAppClient = { authenticator: Record<string, any>; currentUser: { accessToken?: string; refreshCustomData?(): Promise<void>; isLoggedIn: boolean; }; }; type AppClient = StitchAppClient | RealmAppClient; /** * A helper utility to support using [Realm Authentication](https://www.mongodb.com/docs/realm/) with MongoDB Charts with two npm packages: * * Using "mongodb-stitch-browser-sdk" * * ```js * const client = Stitch.initializeDefaultAppClient('<your-client-app-id>'); * client.auth.loginWithCredential(...) * * const sdk = new ChartsEmbedSDK({ * getUserToken: () => getRealmUserToken(client) * }) * ``` * * or using "realm-web" * * ```js * const client = new Realm.App({id: '<your-client-app-id>'}); * client.logIn(...) * * const sdk = new ChartsEmbedSDK({ * getUserToken: () => getRealmUserToken(client) * }) * ``` * */ export declare function getRealmUserToken(appClient: AppClient): Promise<string>; export {};