
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
@appboxo/js-sdk
Advanced tools
Appboxo JS SDK is a connection bridge between miniapp and native app, that has a rich API features that make your miniapp feel like a native. Using Appboxo JS SDK, host app can pass the user email to miniapp, to register the user automatically in the miniapp.
import appboxoSdk from '@appboxo/js-sdk';
// Sends event to client
appboxoSdk.send('AppBoxoWebAppInit');
// Subscribes to event, sended by client
appboxoSdk.subscribe(e => console.log(e));
For use in a browser, include the file dist/index.umd.js
and use as follows
<script src="dist/index.umd.js"></script>
<script>
// Sends event to client
appboxoSdk.send('AppBoxoWebAppInit');
</script>
Native clients (both Android and iOS) should call this to pass data to mini apps:
window.dispatchEvent(new window.CustomEvent('AppBoxoWebAppEvent', {
bubbles: false,
cancelable: false,
detail: {
type: 'AppBoxoWebAppGetInitData',
data: {
app_id: 234234,
client_id: 344343,
payload: 'asdlj2323ljaoiw',
token: 'qerljljqwerqwe',
request_id: 1
}
}
}))
Important
If an event triggered from mini app has request_id
inside data
(like on the example above), than it means that sendPromise
has been called and same event with request_id
and event type
should be returned to resolve this promise.
appboxoSdk.login(optionalProps)
Sends a message to native client to open confirm modal with default confirmation message. Upon confirmation it sends request to platform and returns resolved authentication token promise to miniapp.
Parameters
optionalProps
optional Props to extend default login behaviorExample
try {
const token = await appboxoSdk.login({
confirmModalText: 'This is my custom confirmation message',
postConfirmCallback: (isConfirmed) => { console.log('Confirmation status: ', isConfirmed) }
});
} catch (error) {
// Handling an error
}
appboxoSdk.logout()
Sends a message to native client to clear authentication tokens.
appboxoSdk.sendPromise(method[, params])
Sends a message to native client and returns the Promise
object with response data
Parameters
method
required The AppBoxo js sdk methodparams
optional Message data objectExample
// Sending event to client
appboxoSdk
.sendPromise('AppBoxoWebAppGetInitData')
.then(data => {
// Handling received data
console.log(data.email);
})
.catch(error => {
// Handling an error
});
You can also use imperative way
try {
const data = await appboxoSdk.sendPromise('AppBoxoWebAppGetInitData');
// Handling received data
console.log(data.email);
} catch (error) {
// Handling an error
}
appboxoSdk.send(method[, params])
Sends a message to native client
Parameters
method
required The AppBoxo js sdk methodparams
optional Message data objectExample
// App initialization
appboxoSdk.send('AppBoxoWebAppInit');
// Opening images
appboxoSdk.send('AppBoxoWebAppShowImages', {
images: [
"https://pp.userapi.com/c639229/v639229113/31b31/KLVUrSZwAM4.jpg",
"https://pp.userapi.com/c639229/v639229113/31b94/mWQwkgDjav0.jpg",
"https://pp.userapi.com/c639229/v639229113/31b3a/Lw2it6bdISc.jpg"
]
}
appboxoSdk.subscribe(fn)
Subscribes a function to events listening
Parameters
fn
required Function to be subscribed to eventsExample
// Subscribing to receiving events
appboxoSdk.subscribe(event => {
if (!event.detail) {
return;
}
const { type, data } = event.detail;
if (type === 'AppBoxoWebAppOpenCodeReaderResult') {
// Reading result of the Code Reader
console.log(data.code_data);
}
if (type === 'AppBoxoWebAppOpenCodeReaderFailed') {
// Catching the error
console.log(data.error_type, data.error_data);
}
});
// Sending method
appboxoSdk.send('AppBoxoWebAppOpenCodeReader', {});
appboxoSdk.unsubscribe(fn)
Unsubscribes a function from events listening
Parameters
fn
required Event subscribed functionExample
const fn = event => {
// ...
};
// Subscribing
appboxoSdk.subscribe(fn);
// Unsubscribing
appboxoSdk.unsubscribe(fn);
appboxoSdk.supports(method)
Checks if an event is available on the current device
Parameters
method
required The AppBoxo js sdk methodappboxoSdk.isWebView()
Returns true
if AppBoxo js sdk is running in mobile app, or false
if not
FAQs
JavaScript SDK for AppBoxo mini-app platform
The npm package @appboxo/js-sdk receives a total of 284 weekly downloads. As such, @appboxo/js-sdk popularity was classified as not popular.
We found that @appboxo/js-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.