Skip to content

Frame

Frame — the main SDK object representing the current mini‑application inside the Аспро.Cloud platform iframe. It is a singleton — created once via initialize() or the wrapper App.initializeFrame().

ts
import { Frame } from '@aspro-cloud/miniapp-jssdk'

Properties

Event

Reference to the Event class

ts
static Event: typeof Event

Reference to the Modal class

ts
static Modal: typeof Modal

Sidepanel

Reference to the Sidepanel class

ts
static Sidepanel: typeof Sidepanel

Swal

Reference to the Swal class

ts
static Swal: typeof Swal

Toast

Reference to the Toast class

ts
static Toast: typeof Toast

domain

Current Аспро.Cloud account domain

ts
get domain(): string

events

EventCallbacks<FrameEventName> object with event handlers

ts
get events(): EventCallbacks
set events(value: EventCallbacks)

https

HTTPS connection flag

ts
get https(): boolean

language

Current platform interface language

ts
get language(): string

options

Options instance for managing application settings

ts
get options(): Options

rest

Rest instance for Rest API calls

ts
get rest(): Rest

targetOrigin

Parent window origin, calculated automatically

ts
get targetOrigin(): string

uniqid

Unique identifier of the application embedding placement

ts
get uniqid(): string

user

User instance for checking current user permissions, managing their settings, etc.

ts
get user(): User

userOptions

UserOptions instance for managing current user settings

ts
get userOptions(): UserOptions

Methods

initialize

Initializes a mini‑application inside the Аспро.Cloud platform iframe and returns a singleton instance of Frame. It is recommended to use the wrapper App.initializeFrame()

ts
static async initialize(params?: FrameParams): Promise<Frame>
ParameterTypeDescription
paramsFrameParamsInitialization parameters

Method events initialize():

EventParameterTypeDescription
'onReady'Fired after iframe content is loaded (DOMContentLoaded), Frame is initialized and context is received, embedded content is displayed
contextFrameContextApplication context

Errors

The method will throw an error if:

  • the application is not running in a browser
  • the application is not inside an iframe
  • the platform account domain could not be determined

getInstance

Returns the current singleton instance of Frame. Call only after initialize()

ts
static getInstance(): Frame

destroy

Removes subscriptions and releases resources

ts
destroy(): void

getContext

Returns FrameContext — the current application context

ts
async getContext(): Promise<FrameContext>

getScopes

Returns an array of Scope strings ('code:access') — scopes of the installed application version available to the current user

ts
async getScopes(): Promise<Scope[]>

hasScope

Checks whether the installed application version has at least one of the given scopes in the Scope format ('code:access'). A broader access level includes a narrower one, so it is enough to check the minimum required level. For example, the 'users:read' check returns true if the application was granted the full level for the users code — it covers read. When an array is passed, the method returns true if at least one of the scopes is satisfied

ts
async hasScope(scope: Scope | Scope[]): Promise<boolean>
ParameterTypeDescription
scopeScope | Scope[]A single scope or an array of scopes to check

openHomepage

Opens the application homepage in the platform interface if the homepage is listed in the embedding placements of the manifest for the currently installed application version

ts
async openHomepage(params: FrameOpenHomepageParams): Promise<any>
ParameterTypeDescription
paramsFrameOpenHomepageParamsParameters

Method events openHomepage():

EventParameterTypeDescription
'onOpen'Application homepage opened
'onCancel'Opening cancelled

openUrl

Opens a URL in the platform interface. When navigating to an external resource, the platform will ask the user for confirmation and open the link in a new browser tab

ts
async openUrl(params: FrameOpenUrlParams): Promise<any>
ParameterTypeDescription
paramsFrameOpenUrlParamsParameters

Method events openUrl():

EventParameterTypeDescription
'onOpen'URL successfully opened
'onCancel'User cancelled the action

Example

ts
import { App, Toast } from '@aspro-cloud/miniapp-jssdk'

const frame = await App.initializeFrame({
  events: {
    onReady: (context) => {
      console.log(`Application is ready, received context: ${context}`)
    }
  }
})

// navigate to a page inside the platform
await frame.openUrl({
  url: '/_module/crm/view/account_view/47547'
})

// navigate to an external resource (opens in a new tab with confirmation)
await frame.openUrl({
  url: 'https://aspro.cloud/',
  events: {
    onOpen: () => console.log('Navigation completed'),
    onCancel: () => console.log('User cancelled navigation')
  }
})

// scopes of the installed application version
console.log(`Application scopes: ${await frame.getScopes()}`) // e.g. ['users:full']

// the full level covers read, so the users:read check passes when users:full is granted
if (await frame.hasScope('users:read')) {
  console.log('Read access to users is granted')
}
js
const App = window.ACloudMiniApp;

const frame = await App.initializeFrame({
  events: {
    onReady: (context) => {
      console.log(`Application is ready, received context: ${context}`);
    }
  }
});

// navigate to a page inside the platform
await frame.openUrl({
  url: '/_module/crm/view/account_view/47547'
});

// navigate to an external resource (opens in a new tab with confirmation)
await frame.openUrl({
  url: 'https://aspro.cloud/',
  events: {
    onOpen: () => console.log('Navigation completed'),
    onCancel: () => console.log('User cancelled navigation')
  }
});

// scopes of the installed application version
console.log(`Application scopes: ${await frame.getScopes()}`); // e.g. ['users:full']

// the full level covers read, so the users:read check passes when users:full is granted
if (await frame.hasScope('users:read')) {
  console.log('Read access to users is granted');
}

Published under the MIT license.