UNPKG

dop-sdk

Version:

Mini App SDK for JavaScript by VTB

97 lines (96 loc) 4.09 kB
import { Contact } from '../types/contact'; import { MiniAppError } from '../types/error-types'; import { Points } from '../types/point'; import { AccessTokenData } from '../types/token-data'; /** * Interfaces to retrieve User profile related information. */ export interface UserInfoProvider { /** * Fetches the username from host app. * You should request the {@link CustomPermissionName.USER_NAME} permission before using this method. * @returns Username saved in the host app user profile. */ getUserName(): Promise<string>; /** * Fetches the profile photo URI from host app. * You should request the {@link CustomPermissionName.PROFILE_PHOTO} permission before using this method. * @returns Profile photo saved in the host app user profile. */ getProfilePhoto(): Promise<string>; /** * Fetches the contact list from host app. * You should request the {@link CustomPermissionName.CONTACT_LIST} permission before using this method. * @returns Contact list in the host app user profile. */ getContacts(): Promise<Contact[]>; /** * Fetches the access token from host app. * @param audience one of the audiences provided in MiniApp manifest * @param scopes scopes array associated to the audience * @returns Access token from native host app. */ getAccessToken(audience: string, scopes: string[]): Promise<AccessTokenData | MiniAppError>; /** * Fetches the points from host app. * @returns Points from native host app. */ getPoints(): Promise<Points | MiniAppError>; /** * Fetches the Phone number of the user. * @returns Phone number saved in the host app user profile. */ getPhoneNumber(): Promise<string>; /** * Fetches the current login status of the user */ isLoggedIn(): Promise<boolean>; } /** @internal */ export declare class UserInfo implements UserInfoProvider { /** * Associating getUserName function to MiniAppBridge object. * This function returns username from the user profile * (provided the rakuten.miniapp.user.USER_NAME custom permission is allowed by the user) * It returns error info if user had denied the custom permission */ getUserName(): Promise<string>; /** * Associating getProfilePhoto function to MiniAppBridge object. * This function returns username from the user profile. * (provided the rakuten.miniapp.user.PROFILE_PHOTO is allowed by the user) * It returns error info if user had denied the custom permission */ getProfilePhoto(): Promise<string>; /** * Associating getContacts function to MiniAppBridge object. * This function returns contact list from the user profile. * (provided the rakuten.miniapp.user.CONTACT_LIST is allowed by the user) * It returns error info if user had denied the custom permission */ getContacts(): Promise<Contact[]>; /** * Associating getAccessToken function to MiniAppBridge object. * This function returns access token details from the host app. * (provided the rakuten.miniapp.user.ACCESS_TOKEN is allowed by the user) * It returns error info if user had denied the custom permission * @param {string} audience the audience the MiniApp requests for the token * @param {string[]} scopes the associated scopes with the requested audience */ getAccessToken(audience: string, scopes: string[]): Promise<AccessTokenData | MiniAppError>; /** * Associating get point balance function to MiniAppBridge object. * (provided rakuten.miniapp.user.POINTS is allowed by the user) */ getPoints(): Promise<Points | MiniAppError>; /** * Associating getPhoneNumber function to MiniAppBridge object. * This function returns phone number of the User */ getPhoneNumber(): Promise<string>; /** * This interface is used to know if the user login status * @returns true/false based on the user profile status */ isLoggedIn(): Promise<boolean>; }