UNPKG

@vrspace/babylonjs

Version:

vrspace.org babylonjs client

122 lines (121 loc) 4.44 kB
/** * Class to execute REST API calls, singleton. * By default, we're making API calls to the same server that serves the content. * This can be changed by providing different apiBase URL to the constructor. * All methods are asynchronous but blocking calls. */ export class VRSpaceAPI { static instance: any; /** * Returns VRSpaceAPI instance, creates one if required. * @param {String|null} [apiBase] API URL base * @param {String|null} [apiPath] API URL path * @returns {VRSpaceAPI} */ static getInstance(apiBase?: string | null, apiPath?: string | null): VRSpaceAPI; /** * @param apiBase Base URL for all API endpoint, defaults to /vrspace/api */ constructor(apiBase?: string, apiPath?: string); base: string; apiClient: ApiClient; endpoint: { /** @type {WorldsApi} */ worlds: WorldsApi; oauth2: string; files: string; /** @type {UsersApi} */ user: UsersApi; /** @type {GroupsApi} */ groups: GroupsApi; /** @type {WebPushApi} */ webpush: WebPushApi; /** @type {ServerInfoApi} */ server: ServerInfoApi; }; /** * Verify if given user name is valid, i.e. we can create user with that name. * @param name user name * @returns true if user name is available */ verifyName(name: any): Promise<boolean>; /** * Returns current user name associated with the session. * @returns current user name, or null if user is anonymous (not logged in yet) */ getUserName(): Promise<string>; /** * Returns true if the user is authanticated */ getAuthenticated(): Promise<boolean>; /** * Initiates OAuth2 login with the server - opens login form with Oauth provider. * Requires Oauth2 provider id as returned by listOAuthProviders(). * @param providerId Oauth provider as defined on the server * @param userName user name * @param avatarUrl optional Avatar URL */ oauth2login(providerId: any, userName: any, avatarUrl: any): Promise<void>; /** Returns object of provider id: name (e.g. github: GitHub) */ listOAuthProviders(): Promise<any>; /** * Returns User object of the current user, or null for anonymous users */ getUserObject(): Promise<import("./openapi/model/User.js").User>; /** * Create a world from template * @returns token required to access the world * @param worldName unique world name * @param templateName optional template name, a world with this name must exist on the server * @param isPublic default false, i.e. only invited users (having the token) can enter * @param isTemporary default true, i.e. world is deleted once the last user exits */ createWorldFromTemplate(worldName: any, templateName: any, isPublic?: boolean, isTemporary?: boolean): Promise<string>; /** * Internally used helper method */ getJson(url: any): Promise<any>; /** * Internally used helper method */ getText(url: any): Promise<string | void>; /** * Upload a file. * @param file File object * @param position an object containing x,y,z (Vector3) * @param rotation an object containing x,y,z (Vector3) */ upload(file: any, position: any, rotation: any): void; /** * Internal used by webpushSubscribe * @private */ private unregisterSubscription; /** * Internal used by webpushSubscribe * @private */ private registerSubscription; /** * Internal used by webpushSubscribe * @private */ private createSubscription; /** * Internal used by webpushSubscribe * @private */ private urlBase64ToUint8Array; /** * Subcribe to web push, if available on the server. Requires existing service worker, * registered in main html file onload function. Fails silently if the registration does not exist. * @param {String} clientUrl path to serviceworker.js */ webpushSubscribe(clientUrl: string): void; } import { ApiClient } from './openapi/ApiClient.js'; import { WorldsApi } from './openapi/api/WorldsApi.js'; import { UsersApi } from './openapi/api/UsersApi.js'; import { GroupsApi } from './openapi/api/GroupsApi.js'; import { WebPushApi } from './openapi/api/WebPushApi.js'; import { ServerInfoApi } from './openapi/api/ServerInfoApi.js';