Checks if the current client has access to a specific JSBridge API method.
The name of the bridge module to check access for (e.g., 'CameraModule').
The method name within the module to check access for (e.g., 'scanQRCode').
Whether the MiniApp has permission to access the specified method.
Simple usage
import { ScopeModule, isSuccess, isErrorResponse } from '@grabjs/superapp-sdk';
// Initialize the scope module
const scope = new ScopeModule();
// Check access to CameraModule.scanQRCode
const response = await scope.hasAccessTo('CameraModule', 'scanQRCode');
// Handle the response
if (isSuccess(response)) {
console.log('Has access:', response.result.hasAccess);
} else if (isErrorResponse(response)) {
console.error(`Error ${response.status_code}: ${response.error}`);
} else {
console.error('Unhandled response');
}
Requests to reload the consented OAuth scopes for the current client. This refreshes the permissions from the server.
Confirmation that the scopes have been reloaded from the server.
Simple usage
import { ScopeModule, isSuccess, isErrorResponse } from '@grabjs/superapp-sdk';
// Initialize the scope module
const scope = new ScopeModule();
// Reload scopes
const response = await scope.reloadScopes();
// Handle the response
if (isSuccess(response)) {
console.log('Scopes reloaded successfully');
} else if (isErrorResponse(response)) {
console.error(`Error ${response.status_code}: ${response.error}`);
} else {
console.error('Unhandled response');
}
JSBridge module for checking and refreshing API access permissions.
Remarks
Manages OAuth scope permissions, allowing the MiniApp to check access rights and reload scopes from the server. This code must run on the Grab SuperApp's WebView to function correctly.
Example
ES Module:
Example
CDN (UMD):