@grabjs/superapp-sdk 1.8.10 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.json +11473 -0
- package/dist/index.d.ts +1719 -0
- package/dist/index.esm.js +7 -0
- package/dist/index.js +7 -1
- package/package.json +44 -19
- package/docs/CameraModule.md +0 -89
- package/docs/CheckoutModule.md +0 -48
- package/docs/ContainerModule.md +0 -524
- package/docs/IdentityModule.md +0 -192
- package/docs/LocaleModule.md +0 -51
- package/docs/LocationModule.md +0 -172
- package/docs/MediaModule.md +0 -97
- package/docs/PlatformModule.md +0 -33
- package/docs/ProfileModule.md +0 -136
- package/docs/ScopeModule.md +0 -68
- package/docs/StorageModule.md +0 -327
- package/docs/SystemWebViewKitModule.md +0 -41
package/docs/LocaleModule.md
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# LocaleModule
|
|
2
|
-
|
|
3
|
-
## Description
|
|
4
|
-
|
|
5
|
-
Will return current locale information
|
|
6
|
-
|
|
7
|
-
## Supported Languages
|
|
8
|
-
|
|
9
|
-
| Language | Locale |
|
|
10
|
-
| ----------------- | ------ |
|
|
11
|
-
| English | en |
|
|
12
|
-
| Indonesia | id |
|
|
13
|
-
| Chinese | zh |
|
|
14
|
-
| Malaysia | ms |
|
|
15
|
-
| Thai | th |
|
|
16
|
-
| Vietnamese | vi |
|
|
17
|
-
| Burmese (Zawgyi) | zg |
|
|
18
|
-
| Burmese (Unicode) | my |
|
|
19
|
-
| Khmer | km |
|
|
20
|
-
|
|
21
|
-
## Methods
|
|
22
|
-
|
|
23
|
-
### 1. Get language locale
|
|
24
|
-
|
|
25
|
-
**Method name**: `getLanguageLocaleIdentifier`
|
|
26
|
-
|
|
27
|
-
**Arguments**: `None`
|
|
28
|
-
|
|
29
|
-
**Return type**
|
|
30
|
-
|
|
31
|
-
| Type | Description |
|
|
32
|
-
| ------ | -------------------------------------- |
|
|
33
|
-
| String | Locale identifier. Example: "en", "id" |
|
|
34
|
-
|
|
35
|
-
**Code example**
|
|
36
|
-
|
|
37
|
-
```javascript
|
|
38
|
-
import { LocaleModule } from '@grab/superapp-sdk';
|
|
39
|
-
|
|
40
|
-
// Ideally, initialize this only one and reuse across app.
|
|
41
|
-
const localeModule = new LocaleModule()
|
|
42
|
-
|
|
43
|
-
localeModule.getLanguageLocaleIdentifier({})
|
|
44
|
-
.then({ result, error }) => {
|
|
45
|
-
if (!!result) {
|
|
46
|
-
const locale = result;
|
|
47
|
-
} else if (!!error) {
|
|
48
|
-
// Some error happened. Use default language.
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
```
|
package/docs/LocationModule.md
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# LocationModule
|
|
2
|
-
|
|
3
|
-
## Description
|
|
4
|
-
|
|
5
|
-
Will return current user position
|
|
6
|
-
|
|
7
|
-
## Methods
|
|
8
|
-
|
|
9
|
-
### 1. Get current user coordinate
|
|
10
|
-
|
|
11
|
-
**Method name**: `getCoordinate`
|
|
12
|
-
|
|
13
|
-
**Scopes to be requested**: `mobile.geolocation`
|
|
14
|
-
|
|
15
|
-
**Arguments**: `None`
|
|
16
|
-
|
|
17
|
-
**Return type**
|
|
18
|
-
|
|
19
|
-
| Name | Type | Description |
|
|
20
|
-
| --------- | ------ | ----------------------------------------------------------- |
|
|
21
|
-
| latitude | Double | Latitude is horizontal line described for earth coordinates |
|
|
22
|
-
| longitude | Double | Longitude is vertical line described for earth coordinates |
|
|
23
|
-
|
|
24
|
-
**Code example**
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
import { LocationModule } from '@grab/superapp-sdk';
|
|
28
|
-
|
|
29
|
-
// Ideally, initialize this only one and reuse across app.
|
|
30
|
-
const locationModule = new LocationModule()
|
|
31
|
-
|
|
32
|
-
locationModule.getCoordinate({})
|
|
33
|
-
.then({ result, error }) => {
|
|
34
|
-
if (!!result) {
|
|
35
|
-
const { latitude, longitude } = result;
|
|
36
|
-
} else if (!!error) {
|
|
37
|
-
// Some error happened.
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 2. Stream current user coordinates
|
|
43
|
-
|
|
44
|
-
**Method name**: `observeLocationChange`
|
|
45
|
-
|
|
46
|
-
**Scopes to be requested**: `mobile.geolocation`
|
|
47
|
-
|
|
48
|
-
**Arguments**: `None`
|
|
49
|
-
|
|
50
|
-
**Return type**
|
|
51
|
-
|
|
52
|
-
| Name | Type | Description |
|
|
53
|
-
| --------- | ------ | ----------------------------------------------------------- |
|
|
54
|
-
| latitude | Double | Latitude is horizontal line described for earth coordinates |
|
|
55
|
-
| longitude | Double | Longitude is vertical line described for earth coordinates |
|
|
56
|
-
|
|
57
|
-
**Code example**
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
import { LocationModule } from '@grab/superapp-sdk';
|
|
61
|
-
|
|
62
|
-
// Ideally, initialize this only one and reuse across app.
|
|
63
|
-
const locationModule = new LocationModule();
|
|
64
|
-
|
|
65
|
-
// Unsubscribe from this subscription to terminate the stream.
|
|
66
|
-
const subscription = locationModule.observeLocationChange({}).subscribe({
|
|
67
|
-
next: ({ result, error }) => {
|
|
68
|
-
if (!!result) {
|
|
69
|
-
const { latitude, longitude } = result;
|
|
70
|
-
} else if (!!error) {
|
|
71
|
-
// Some error happened.
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
complete: () => {
|
|
75
|
-
// Completion logic for when the stream completes.
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### 3. Get current user country code
|
|
81
|
-
|
|
82
|
-
**Method name**: `getCountryCode`
|
|
83
|
-
|
|
84
|
-
**Scopes to be requested**: `mobile.geolocation`
|
|
85
|
-
|
|
86
|
-
**Arguments**: `None`
|
|
87
|
-
|
|
88
|
-
**Return type**
|
|
89
|
-
|
|
90
|
-
| Name | Type | Description |
|
|
91
|
-
| ----------- | ------ | ------------------------------ |
|
|
92
|
-
| countryCode | String | country code (e.g., "SG", "ID", "MY") |
|
|
93
|
-
|
|
94
|
-
**Code example**
|
|
95
|
-
|
|
96
|
-
```javascript
|
|
97
|
-
import { LocationModule } from '@grab/superapp-sdk';
|
|
98
|
-
|
|
99
|
-
// Ideally, initialize this only one and reuse across app.
|
|
100
|
-
const locationModule = new LocationModule()
|
|
101
|
-
|
|
102
|
-
locationModule.getCountryCode({})
|
|
103
|
-
.then((response) => {
|
|
104
|
-
switch (response.status_code) {
|
|
105
|
-
case 200:
|
|
106
|
-
// Success - country code retrieved
|
|
107
|
-
console.log('Country code:', response.result);
|
|
108
|
-
break;
|
|
109
|
-
case 204:
|
|
110
|
-
// No result - location is undefined or might be uncovered by location service data
|
|
111
|
-
console.log('No result - location is undefined or uncovered by location service');
|
|
112
|
-
break;
|
|
113
|
-
case 403:
|
|
114
|
-
// Permission denied - mobile.geolocation scope not granted
|
|
115
|
-
console.log('Location access denied:', response.error);
|
|
116
|
-
break;
|
|
117
|
-
case 424:
|
|
118
|
-
// Location service has issue/unaccessible
|
|
119
|
-
console.log('Location service unavailable:', response.error);
|
|
120
|
-
break;
|
|
121
|
-
default:
|
|
122
|
-
// Handle other potential status codes
|
|
123
|
-
console.log('Error:', response.error);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Response Format
|
|
129
|
-
|
|
130
|
-
The location methods return an object with different structures based on the result:
|
|
131
|
-
|
|
132
|
-
### Success Response (Status Code 200)
|
|
133
|
-
```javascript
|
|
134
|
-
{
|
|
135
|
-
"status_code": 200,
|
|
136
|
-
"result": "SG" // The country code (e.g., "SG", "ID", "MY")
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### No Result Response (Status Code 204)
|
|
141
|
-
```javascript
|
|
142
|
-
{
|
|
143
|
-
"status_code": 204
|
|
144
|
-
// No result property
|
|
145
|
-
// No error property
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Error Response (Status Code 403)
|
|
150
|
-
```javascript
|
|
151
|
-
{
|
|
152
|
-
"status_code": 403,
|
|
153
|
-
"error": "Location access denied"
|
|
154
|
-
// No result property
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Error Response (Status Code 424)
|
|
159
|
-
```javascript
|
|
160
|
-
{
|
|
161
|
-
"status_code": 424,
|
|
162
|
-
"error": "Determining country code from coordinates fails"
|
|
163
|
-
// No result property
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Status Codes
|
|
168
|
-
|
|
169
|
-
- `200`: Successfully retrieved country code
|
|
170
|
-
- `204`: No result (location is undefined or uncovered by location service or in ocean area)
|
|
171
|
-
- `403`: Location access denied (mobile.geolocation scope not granted)
|
|
172
|
-
- `424`: Location service unavailable/unaccessible
|
package/docs/MediaModule.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# What is MediaModule ?
|
|
2
|
-
|
|
3
|
-
`MediaModule` This module will open a media player
|
|
4
|
-
|
|
5
|
-
## Methods
|
|
6
|
-
|
|
7
|
-
### 1. To play DRM content
|
|
8
|
-
|
|
9
|
-
#### Method name
|
|
10
|
-
|
|
11
|
-
```javascript
|
|
12
|
-
playDRMContent(data);
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
#### Params
|
|
16
|
-
|
|
17
|
-
| Name | Type | Description |
|
|
18
|
-
| ---- | --------- | --------------------- |
|
|
19
|
-
| data | VideoData | Response from backend |
|
|
20
|
-
|
|
21
|
-
#### VideoData
|
|
22
|
-
|
|
23
|
-
| Name | Type | Description |
|
|
24
|
-
| ----------- | ------ | ------------------------ |
|
|
25
|
-
| content | url | Content URL for playback |
|
|
26
|
-
| certificate | url | DRM certificate URL |
|
|
27
|
-
| license | url | DRM licence URL |
|
|
28
|
-
| titleId | string | Playback item identifier |
|
|
29
|
-
|
|
30
|
-
#### Return type
|
|
31
|
-
|
|
32
|
-
A data stream emitting events on the video playback status.
|
|
33
|
-
|
|
34
|
-
| Name | Type | Description |
|
|
35
|
-
| -------- | ------ | ---------------------------------------------- |
|
|
36
|
-
| type | string | Type of the event. Refer to the event types |
|
|
37
|
-
| titleId | string | Playback item identifier |
|
|
38
|
-
| length | int | Length of the video (in seconds) |
|
|
39
|
-
| position | int | The current position of the video (in seconds) |
|
|
40
|
-
|
|
41
|
-
The types of events are as follows:
|
|
42
|
-
|
|
43
|
-
| EventType | Description |
|
|
44
|
-
| ----------------- | ------------------------------------- |
|
|
45
|
-
| START_PLAYBACK | Emitted when the video starts playing |
|
|
46
|
-
| STOP_PLAYBACK | Emitted when the video stops playing |
|
|
47
|
-
| PROGRESS_PLAYBACK | Emitted every 10 seconds |
|
|
48
|
-
|
|
49
|
-
#### Code example
|
|
50
|
-
|
|
51
|
-
```javascript
|
|
52
|
-
import { MediaModule } from '@grabjs/superapp-sdk';
|
|
53
|
-
|
|
54
|
-
const mediaModule = new MediaModule();
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
// This is for backward compatibility, since older app
|
|
58
|
-
// versions do not support this syntax.
|
|
59
|
-
mediaModule
|
|
60
|
-
.playDRMContent({
|
|
61
|
-
content: 'content-url-here',
|
|
62
|
-
certificate: 'certificate-url-here',
|
|
63
|
-
license: 'license-url-here',
|
|
64
|
-
titleId: 'title-id-here'
|
|
65
|
-
})
|
|
66
|
-
.subscribe({
|
|
67
|
-
next: ({ result, error, status_code }) => {
|
|
68
|
-
if (!!result) {
|
|
69
|
-
const { type, titleId, length, position } = result;
|
|
70
|
-
|
|
71
|
-
// Do what we want with the data here.
|
|
72
|
-
} else if (!!error) {
|
|
73
|
-
// Handle error here.
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
complete: () => {
|
|
77
|
-
// Completion logic here when the stream stops.
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
} catch (e) {
|
|
81
|
-
// Fallback to old way to ensure the video still plays.
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
#### Response example
|
|
86
|
-
|
|
87
|
-
```json
|
|
88
|
-
{
|
|
89
|
-
"status_code": 200,
|
|
90
|
-
"result": {
|
|
91
|
-
"type": "PROGRESS_PLAYBACK",
|
|
92
|
-
"titleId": "2o23asdf1asd123",
|
|
93
|
-
"length": 3600,
|
|
94
|
-
"position": 1800
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
package/docs/PlatformModule.md
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# PlatformModule
|
|
2
|
-
## Description
|
|
3
|
-
|
|
4
|
-
PlatformKit provides API to navigate back to host application.
|
|
5
|
-
|
|
6
|
-
## Methods
|
|
7
|
-
### 1. Close the current and go back to host application
|
|
8
|
-
|
|
9
|
-
**Method name**: `back`
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
**Arguments**: `None`
|
|
13
|
-
|
|
14
|
-
**Return type**
|
|
15
|
-
|
|
16
|
-
`None`
|
|
17
|
-
|
|
18
|
-
**Code example**
|
|
19
|
-
```javascript
|
|
20
|
-
import { PlatformModule } from '@grab/superapp-sdk';
|
|
21
|
-
|
|
22
|
-
// Ideally, initialize this only one and reuse across app.
|
|
23
|
-
const platformModule = new PlatformModule()
|
|
24
|
-
|
|
25
|
-
platformModule.back({})
|
|
26
|
-
.then({ result, error }) => {
|
|
27
|
-
if (!!result) {
|
|
28
|
-
// There is a valid result.
|
|
29
|
-
} else if (!!error) {
|
|
30
|
-
// Some error happened.
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
```
|
package/docs/ProfileModule.md
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# ProfileModule
|
|
2
|
-
|
|
3
|
-
## Description
|
|
4
|
-
|
|
5
|
-
The ProfileModule provides functionality related to user profile information.
|
|
6
|
-
|
|
7
|
-
## Methods
|
|
8
|
-
|
|
9
|
-
### 1. Fetch Email
|
|
10
|
-
|
|
11
|
-
**Method name**: `fetchEmail`
|
|
12
|
-
|
|
13
|
-
**Scopes to be requested**: `mobile.profile`
|
|
14
|
-
|
|
15
|
-
**Description**
|
|
16
|
-
|
|
17
|
-
This is used to fetch the verified email of the user. If the user does not have a verified email, the method will return a `status_code` of `204`.
|
|
18
|
-
|
|
19
|
-
**Arguments**
|
|
20
|
-
|
|
21
|
-
None
|
|
22
|
-
|
|
23
|
-
**Return type**
|
|
24
|
-
|
|
25
|
-
| Name | Type | Description |
|
|
26
|
-
| --- | --- | --- |
|
|
27
|
-
| result | Object \| null | Result of the fetch email operation. Returns `null` if no verified email is found (204). |
|
|
28
|
-
| error | String \| null | Error message if the operation fails |
|
|
29
|
-
| status_code | Number | HTTP status code for the operation |
|
|
30
|
-
|
|
31
|
-
**Result Object Properties**
|
|
32
|
-
|
|
33
|
-
When `status_code` is `200`, the result object contains:
|
|
34
|
-
|
|
35
|
-
| Property | Type | Description |
|
|
36
|
-
| --- | --- | --- |
|
|
37
|
-
| email | String | The verified email address of the user |
|
|
38
|
-
|
|
39
|
-
**Status Codes**
|
|
40
|
-
|
|
41
|
-
- **200**: Success, verified email found and returned in `result`
|
|
42
|
-
- **204**: No verified email found for the user
|
|
43
|
-
- **400**: Client error (e.g. invalid request)
|
|
44
|
-
- **500**: Internal server error
|
|
45
|
-
|
|
46
|
-
**Code example**
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
import { ProfileModule } from "@grabjs/superapp-sdk";
|
|
50
|
-
|
|
51
|
-
// Ideally, initialize this only once and reuse across app.
|
|
52
|
-
const profileModule = new ProfileModule();
|
|
53
|
-
|
|
54
|
-
const { result, error, status_code } = await profileModule.fetchEmail();
|
|
55
|
-
|
|
56
|
-
if (status_code === 200 && result) {
|
|
57
|
-
console.log("User email:", result.email);
|
|
58
|
-
} else if (status_code === 204) {
|
|
59
|
-
console.log("User does not have a verified email.");
|
|
60
|
-
} else if (error) {
|
|
61
|
-
console.error("Fetch email error:", error);
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### 2. Verify Email
|
|
66
|
-
|
|
67
|
-
**Method name**: `verifyEmail`
|
|
68
|
-
|
|
69
|
-
**Scopes to be requested**: `mobile.profile`
|
|
70
|
-
|
|
71
|
-
**Description**
|
|
72
|
-
|
|
73
|
-
Trigger email capture bottom sheet and OTP verification. If the user closes the verify OTP bottom sheet, the method will return a `status_code` of `204`.
|
|
74
|
-
|
|
75
|
-
Successful verification will also update the email address for the user on Grab.
|
|
76
|
-
|
|
77
|
-
**Arguments**
|
|
78
|
-
|
|
79
|
-
| Name | Type | Required | Description |
|
|
80
|
-
| --- | --- | --- | --- |
|
|
81
|
-
| request | Object | Yes | Request parameters for email verification |
|
|
82
|
-
|
|
83
|
-
**Request Object Properties**
|
|
84
|
-
|
|
85
|
-
| Property | Type | Required | Description |
|
|
86
|
-
| --- | --- | --- | --- |
|
|
87
|
-
| email | String | No | Email address for verification. Native bottom sheet will be displayed with this email address if not empty (User can edit before proceeding) |
|
|
88
|
-
| skipUserInput | Boolean | No | If set to `true`, and email is not empty, trigger the verify OTP bottom sheet directly. |
|
|
89
|
-
|
|
90
|
-
**Return type**
|
|
91
|
-
|
|
92
|
-
| Name | Type | Description |
|
|
93
|
-
| --- | --- | --- |
|
|
94
|
-
| result | Object \| null | Result of the verify email operation. Returns `null` if the user cancels (204). |
|
|
95
|
-
| error | String \| null | Error message if the operation fails |
|
|
96
|
-
| status_code | Number | HTTP status code for the operation |
|
|
97
|
-
|
|
98
|
-
**Result Object Properties**
|
|
99
|
-
|
|
100
|
-
When `status_code` is `200`, the result object contains:
|
|
101
|
-
|
|
102
|
-
| Property | Type | Description |
|
|
103
|
-
| --- | --- | --- |
|
|
104
|
-
| email | String | The verified email address of the user |
|
|
105
|
-
|
|
106
|
-
**Status Codes**
|
|
107
|
-
|
|
108
|
-
- **200**: Success, email verified and returned in `result`
|
|
109
|
-
- **204**: User closed the native bottom sheet
|
|
110
|
-
- **400**: Client error (e.g. invalid email format)
|
|
111
|
-
- **403**: Unauthorised
|
|
112
|
-
- **500**: Internal server error
|
|
113
|
-
|
|
114
|
-
**Code example**
|
|
115
|
-
|
|
116
|
-
```javascript
|
|
117
|
-
import { ProfileModule } from "@grabjs/superapp-sdk";
|
|
118
|
-
|
|
119
|
-
// Ideally, initialize this only once and reuse across app.
|
|
120
|
-
const profileModule = new ProfileModule();
|
|
121
|
-
|
|
122
|
-
const request = {
|
|
123
|
-
email: "test@example.com",
|
|
124
|
-
skipUserInput: false
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const { result, error, status_code } = await profileModule.verifyEmail(request);
|
|
128
|
-
|
|
129
|
-
if (status_code === 200 && result) {
|
|
130
|
-
console.log("Verified email:", result.email);
|
|
131
|
-
} else if (status_code === 204) {
|
|
132
|
-
console.log("User closed the bottom sheet.");
|
|
133
|
-
} else if (error) {
|
|
134
|
-
console.error("Verify email error:", error);
|
|
135
|
-
}
|
|
136
|
-
```
|
package/docs/ScopeModule.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# ScopeModule
|
|
2
|
-
|
|
3
|
-
## Description
|
|
4
|
-
|
|
5
|
-
Access scope control related API.
|
|
6
|
-
|
|
7
|
-
## Methods
|
|
8
|
-
|
|
9
|
-
### 1. Check if current client has access to specific API
|
|
10
|
-
|
|
11
|
-
**Method name**: `hasAccessTo`
|
|
12
|
-
|
|
13
|
-
**Arguments**
|
|
14
|
-
|
|
15
|
-
| Name | Type | Description |
|
|
16
|
-
| ------ | ------ | ------------------ |
|
|
17
|
-
| module | String | Bridge module name |
|
|
18
|
-
| method | String | Method name |
|
|
19
|
-
|
|
20
|
-
**Return type**
|
|
21
|
-
|
|
22
|
-
`Boolean`
|
|
23
|
-
|
|
24
|
-
**Code example**
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
import { ScopeModule } from '@grab/superapp-sdk';
|
|
28
|
-
|
|
29
|
-
// Ideally, initialize this only one and reuse across app.
|
|
30
|
-
const scopeModule = new ScopeModule()
|
|
31
|
-
|
|
32
|
-
scopeModule.hasAccessTo({ module, method })
|
|
33
|
-
.then({ result, error }) => {
|
|
34
|
-
if (!!result) {
|
|
35
|
-
// There is a valid result.
|
|
36
|
-
} else if (!!error) {
|
|
37
|
-
// Some error happened.
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 2. Request to reload consented scopes for current client
|
|
43
|
-
|
|
44
|
-
**Method name**: `reloadScopes`
|
|
45
|
-
|
|
46
|
-
**Arguments**: `None`
|
|
47
|
-
|
|
48
|
-
**Return type**
|
|
49
|
-
|
|
50
|
-
`Void`
|
|
51
|
-
|
|
52
|
-
**Code example**
|
|
53
|
-
|
|
54
|
-
```javascript
|
|
55
|
-
import { ScopeModule } from '@grab/superapp-sdk';
|
|
56
|
-
|
|
57
|
-
// Ideally, initialize this only one and reuse across app.
|
|
58
|
-
const scopeModule = new ScopeModule()
|
|
59
|
-
|
|
60
|
-
scopeModule.reloadScopes({})
|
|
61
|
-
.then({ status_code, error }) => {
|
|
62
|
-
if (`${status_code}`.startsWith('20')) {
|
|
63
|
-
// The operation succeeded.
|
|
64
|
-
} else if (!!error) {
|
|
65
|
-
// Some error happened.
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
```
|