@grabjs/superapp-sdk
    Preparing search index...

    Class ScopeModule

    JSBridge module for checking and refreshing API access permissions.

    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.

    ES Module:

    import { ScopeModule } from '@grabjs/superapp-sdk';
    const scope = new ScopeModule();

    CDN (UMD):

    <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
    <script>
    const scope = new SuperAppSDK.ScopeModule();
    </script>

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Checks if the current client has access to a specific JSBridge API method.

      Parameters

      • module: string

        The name of the bridge module to check access for (e.g., 'CameraModule').

      • method: string

        The method name within the module to check access for (e.g., 'scanQRCode').

      Returns Promise<HasAccessToResponse>

      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.

      Returns Promise<ReloadScopesResponse>

      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');
      }