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().
import { Frame } from '@aspro-cloud/miniapp-jssdk'Properties
Event
Reference to the Event class
static Event: typeof EventModal
Reference to the Modal class
static Modal: typeof ModalSidepanel
Reference to the Sidepanel class
static Sidepanel: typeof SidepanelSwal
Reference to the Swal class
static Swal: typeof SwalToast
Reference to the Toast class
static Toast: typeof Toastdomain
Current Аспро.Cloud account domain
get domain(): stringevents
EventCallbacks<FrameEventName> object with event handlers
get events(): EventCallbacks
set events(value: EventCallbacks)https
HTTPS connection flag
get https(): booleanlanguage
Current platform interface language
get language(): stringoptions
Options instance for managing application settings
get options(): Optionsrest
Rest instance for Rest API calls
get rest(): ResttargetOrigin
Parent window origin, calculated automatically
get targetOrigin(): stringuniqid
Unique identifier of the application embedding placement
get uniqid(): stringuser
User instance for checking current user permissions, managing their settings, etc.
get user(): UseruserOptions
UserOptions instance for managing current user settings
get userOptions(): UserOptionsMethods
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()
static async initialize(params?: FrameParams): Promise<Frame>| Parameter | Type | Description |
|---|---|---|
params | FrameParams | Initialization parameters |
Method events initialize():
| Event | Parameter | Type | Description |
|---|---|---|---|
'onReady' | Fired after iframe content is loaded (DOMContentLoaded), Frame is initialized and context is received, embedded content is displayed | ||
context | FrameContext | Application 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()
static getInstance(): Framedestroy
Removes subscriptions and releases resources
destroy(): voidgetContext
Returns FrameContext — the current application context
async getContext(): Promise<FrameContext>getScopes
Returns an array of Scope strings ('code:access') — scopes of the installed application version available to the current user
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
async hasScope(scope: Scope | Scope[]): Promise<boolean>| Parameter | Type | Description |
|---|---|---|
scope | Scope | 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
async openHomepage(params: FrameOpenHomepageParams): Promise<any>| Parameter | Type | Description |
|---|---|---|
params | FrameOpenHomepageParams | Parameters |
Method events openHomepage():
| Event | Parameter | Type | Description |
|---|---|---|---|
'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
async openUrl(params: FrameOpenUrlParams): Promise<any>| Parameter | Type | Description |
|---|---|---|
params | FrameOpenUrlParams | Parameters |
Method events openUrl():
| Event | Parameter | Type | Description |
|---|---|---|---|
'onOpen' | URL successfully opened | ||
'onCancel' | User cancelled the action |
Example
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')
}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');
}