@grabjs/superapp-sdk 2.0.0-beta.23 → 2.0.0-beta.28
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/README.md +55 -55
- package/api-reference/api.json +44309 -0
- package/dist/index.d.ts +2163 -2607
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +14 -9
- package/skills/SKILL.md +368 -0
- package/api-reference/json/api.json +0 -27688
- package/api-reference/markdown/README.md +0 -194
- package/api-reference/markdown/classes/BaseModule.md +0 -123
- package/api-reference/markdown/classes/CameraModule.md +0 -177
- package/api-reference/markdown/classes/CheckoutModule.md +0 -181
- package/api-reference/markdown/classes/ContainerModule.md +0 -751
- package/api-reference/markdown/classes/DeviceCapabilityModule.md +0 -161
- package/api-reference/markdown/classes/FileModule.md +0 -178
- package/api-reference/markdown/classes/IdentityModule.md +0 -299
- package/api-reference/markdown/classes/LocaleModule.md +0 -161
- package/api-reference/markdown/classes/LocationModule.md +0 -239
- package/api-reference/markdown/classes/MediaModule.md +0 -219
- package/api-reference/markdown/classes/PlatformModule.md +0 -162
- package/api-reference/markdown/classes/ProfileModule.md +0 -224
- package/api-reference/markdown/classes/ScopeModule.md +0 -219
- package/api-reference/markdown/classes/StorageModule.md +0 -608
- package/api-reference/markdown/classes/SystemWebViewKitModule.md +0 -177
- package/api-reference/markdown/classes/UserAttributesModule.md +0 -164
- package/api-reference/markdown/functions/isClientError.md +0 -37
- package/api-reference/markdown/functions/isErrorResponse.md +0 -40
- package/api-reference/markdown/functions/isRedirection.md +0 -37
- package/api-reference/markdown/functions/isServerError.md +0 -37
- package/api-reference/markdown/functions/isSuccess.md +0 -39
- package/api-reference/markdown/globals.md +0 -176
- package/api-reference/markdown/interfaces/GrabAppInfo.md +0 -23
- package/api-reference/markdown/interfaces/InvokeOptions.md +0 -63
- package/api-reference/markdown/interfaces/Version.md +0 -23
- package/api-reference/markdown/interfaces/WrappedModule.md +0 -51
- package/api-reference/markdown/type-aliases/AuthorizeRequest.md +0 -79
- package/api-reference/markdown/type-aliases/AuthorizeResponse.md +0 -58
- package/api-reference/markdown/type-aliases/AuthorizeResult.md +0 -33
- package/api-reference/markdown/type-aliases/BackResponse.md +0 -37
- package/api-reference/markdown/type-aliases/BackResult.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeClientError.md +0 -9
- package/api-reference/markdown/type-aliases/BridgeError.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeRedirection.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeResponse.md +0 -40
- package/api-reference/markdown/type-aliases/BridgeServerError.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeStatusCode.md +0 -7
- package/api-reference/markdown/type-aliases/BridgeStream.md +0 -29
- package/api-reference/markdown/type-aliases/BridgeStreamHandlers.md +0 -25
- package/api-reference/markdown/type-aliases/BridgeSuccessResponse.md +0 -14
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResponse.md +0 -18
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResult.md +0 -8
- package/api-reference/markdown/type-aliases/CloseResponse.md +0 -37
- package/api-reference/markdown/type-aliases/CloseResult.md +0 -8
- package/api-reference/markdown/type-aliases/DRMContentConfig.md +0 -34
- package/api-reference/markdown/type-aliases/DRMPlaybackEvent.md +0 -43
- package/api-reference/markdown/type-aliases/DownloadFileRequest.md +0 -32
- package/api-reference/markdown/type-aliases/DownloadFileResponse.md +0 -48
- package/api-reference/markdown/type-aliases/DownloadFileResult.md +0 -11
- package/api-reference/markdown/type-aliases/ErrorResponse.md +0 -32
- package/api-reference/markdown/type-aliases/FetchEmailResponse.md +0 -58
- package/api-reference/markdown/type-aliases/FetchEmailResult.md +0 -21
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResponse.md +0 -42
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResult.md +0 -57
- package/api-reference/markdown/type-aliases/GetBooleanRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetBooleanResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetBooleanResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetCoordinateResponse.md +0 -49
- package/api-reference/markdown/type-aliases/GetCoordinateResult.md +0 -29
- package/api-reference/markdown/type-aliases/GetCountryCodeResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetCountryCodeResult.md +0 -25
- package/api-reference/markdown/type-aliases/GetDoubleRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetDoubleResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetDoubleResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetIntRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetIntResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetIntResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResponse.md +0 -48
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResult.md +0 -31
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResponse.md +0 -48
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResult.md +0 -17
- package/api-reference/markdown/type-aliases/GetSessionParamsResponse.md +0 -40
- package/api-reference/markdown/type-aliases/GetSessionParamsResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetStringRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetStringResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetStringResult.md +0 -27
- package/api-reference/markdown/type-aliases/HasAccessToResponse.md +0 -66
- package/api-reference/markdown/type-aliases/HasAccessToResult.md +0 -27
- package/api-reference/markdown/type-aliases/HideBackButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideBackButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/HideLoaderResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideLoaderResult.md +0 -8
- package/api-reference/markdown/type-aliases/HideRefreshButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideRefreshButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/IsConnectedResponse.md +0 -31
- package/api-reference/markdown/type-aliases/IsConnectedResult.md +0 -27
- package/api-reference/markdown/type-aliases/IsEsimSupportedResponse.md +0 -48
- package/api-reference/markdown/type-aliases/IsEsimSupportedResult.md +0 -17
- package/api-reference/markdown/type-aliases/ObserveDRMPlaybackResponse.md +0 -15
- package/api-reference/markdown/type-aliases/ObserveLocationChangeResponse.md +0 -15
- package/api-reference/markdown/type-aliases/OnContentLoadedResponse.md +0 -37
- package/api-reference/markdown/type-aliases/OnContentLoadedResult.md +0 -8
- package/api-reference/markdown/type-aliases/OnCtaTapRequest.md +0 -13
- package/api-reference/markdown/type-aliases/OnCtaTapResponse.md +0 -37
- package/api-reference/markdown/type-aliases/OnCtaTapResult.md +0 -8
- package/api-reference/markdown/type-aliases/OpenExternalLinkRequest.md +0 -13
- package/api-reference/markdown/type-aliases/OpenExternalLinkResponse.md +0 -46
- package/api-reference/markdown/type-aliases/OpenExternalLinkResult.md +0 -8
- package/api-reference/markdown/type-aliases/Platform.md +0 -7
- package/api-reference/markdown/type-aliases/PlayDRMContentResponse.md +0 -43
- package/api-reference/markdown/type-aliases/PlayDRMContentResult.md +0 -8
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewRequest.md +0 -23
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResponse.md +0 -55
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResult.md +0 -8
- package/api-reference/markdown/type-aliases/ReloadScopesResponse.md +0 -46
- package/api-reference/markdown/type-aliases/ReloadScopesResult.md +0 -8
- package/api-reference/markdown/type-aliases/RemoveAllResponse.md +0 -37
- package/api-reference/markdown/type-aliases/RemoveAllResult.md +0 -8
- package/api-reference/markdown/type-aliases/RemoveResponse.md +0 -46
- package/api-reference/markdown/type-aliases/RemoveResult.md +0 -8
- package/api-reference/markdown/type-aliases/ResponseStatusCode200.md +0 -34
- package/api-reference/markdown/type-aliases/ResponseStatusCode204.md +0 -20
- package/api-reference/markdown/type-aliases/ResponseStatusCode302.md +0 -20
- package/api-reference/markdown/type-aliases/ResponseStatusCode400.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode401.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode403.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode404.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode424.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode426.md +0 -12
- package/api-reference/markdown/type-aliases/ResponseStatusCode500.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode501.md +0 -12
- package/api-reference/markdown/type-aliases/ScanQRCodeRequest.md +0 -27
- package/api-reference/markdown/type-aliases/ScanQRCodeResponse.md +0 -64
- package/api-reference/markdown/type-aliases/ScanQRCodeResult.md +0 -21
- package/api-reference/markdown/type-aliases/SendAnalyticsEventRequest.md +0 -56
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetBackgroundColorRequest.md +0 -13
- package/api-reference/markdown/type-aliases/SetBackgroundColorResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetBackgroundColorResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetBooleanResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetBooleanResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetDoubleResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetDoubleResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetIntResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetIntResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetStringResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetStringResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetTitleRequest.md +0 -13
- package/api-reference/markdown/type-aliases/SetTitleResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetTitleResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowBackButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowBackButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowLoaderResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowLoaderResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/StatusCodeMap.md +0 -80
- package/api-reference/markdown/type-aliases/Subscription.md +0 -12
- package/api-reference/markdown/type-aliases/TriggerCheckoutRequest.md +0 -26
- package/api-reference/markdown/type-aliases/TriggerCheckoutResponse.md +0 -76
- package/api-reference/markdown/type-aliases/TriggerCheckoutResult.md +0 -75
- package/api-reference/markdown/type-aliases/VerifyEmailRequest.md +0 -32
- package/api-reference/markdown/type-aliases/VerifyEmailResponse.md +0 -55
- package/api-reference/markdown/type-aliases/VerifyEmailResult.md +0 -8
- package/api-reference/markdown/variables/ContainerAnalyticsEventData.md +0 -21
- package/api-reference/markdown/variables/ContainerAnalyticsEventName.md +0 -13
- package/api-reference/markdown/variables/ContainerAnalyticsEventState.md +0 -25
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
[@grabjs/superapp-sdk](../globals.md) / DeviceCapabilityModule
|
|
2
|
-
|
|
3
|
-
# Class: DeviceCapabilityModule
|
|
4
|
-
|
|
5
|
-
JSBridge module for querying native device capability information.
|
|
6
|
-
|
|
7
|
-
## Remarks
|
|
8
|
-
|
|
9
|
-
Provides access to device capability checks exposed by the native Grab app bridge.
|
|
10
|
-
This code must run on the Grab SuperApp's webview to function correctly.
|
|
11
|
-
|
|
12
|
-
## Examples
|
|
13
|
-
|
|
14
|
-
**ES Module:**
|
|
15
|
-
```typescript
|
|
16
|
-
import { DeviceCapabilityModule } from '@grabjs/superapp-sdk';
|
|
17
|
-
const deviceCapabilityModule = new DeviceCapabilityModule();
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**CDN (UMD):**
|
|
21
|
-
```html
|
|
22
|
-
<script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
23
|
-
<script>
|
|
24
|
-
const deviceCapabilityModule = new SuperAppSDK.DeviceCapabilityModule();
|
|
25
|
-
</script>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## No Inherit Doc
|
|
29
|
-
|
|
30
|
-
## Extends
|
|
31
|
-
|
|
32
|
-
- [`BaseModule`](BaseModule.md)
|
|
33
|
-
|
|
34
|
-
## Constructors
|
|
35
|
-
|
|
36
|
-
### Constructor
|
|
37
|
-
|
|
38
|
-
> **new DeviceCapabilityModule**(): `DeviceCapabilityModule`
|
|
39
|
-
|
|
40
|
-
#### Returns
|
|
41
|
-
|
|
42
|
-
`DeviceCapabilityModule`
|
|
43
|
-
|
|
44
|
-
#### Overrides
|
|
45
|
-
|
|
46
|
-
[`BaseModule`](BaseModule.md).[`constructor`](BaseModule.md#constructor)
|
|
47
|
-
|
|
48
|
-
## Methods
|
|
49
|
-
|
|
50
|
-
### invoke()
|
|
51
|
-
|
|
52
|
-
> **invoke**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): `Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
53
|
-
|
|
54
|
-
Invokes a JSBridge method with optional app validation and response transformation.
|
|
55
|
-
|
|
56
|
-
#### Type Parameters
|
|
57
|
-
|
|
58
|
-
##### T
|
|
59
|
-
|
|
60
|
-
`T`
|
|
61
|
-
|
|
62
|
-
#### Parameters
|
|
63
|
-
|
|
64
|
-
##### options
|
|
65
|
-
|
|
66
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
67
|
-
|
|
68
|
-
The invoke options including method name, params, validation, and transformation.
|
|
69
|
-
|
|
70
|
-
#### Returns
|
|
71
|
-
|
|
72
|
-
`Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
73
|
-
|
|
74
|
-
A promise resolving to the JSBridge response.
|
|
75
|
-
|
|
76
|
-
#### Remarks
|
|
77
|
-
|
|
78
|
-
- Always checks if running in Grab app (returns 501 if not).
|
|
79
|
-
- When `isSupported` returns false, returns 426 (Upgrade Required).
|
|
80
|
-
- When `transformResponse` is provided, applies it to successful responses.
|
|
81
|
-
- All errors are reported via the `status_code` field; this method never rejects.
|
|
82
|
-
- For streaming methods, use `invokeStream` instead.
|
|
83
|
-
|
|
84
|
-
#### Inherited from
|
|
85
|
-
|
|
86
|
-
[`BaseModule`](BaseModule.md).[`invoke`](BaseModule.md#invoke)
|
|
87
|
-
|
|
88
|
-
***
|
|
89
|
-
|
|
90
|
-
### invokeStream()
|
|
91
|
-
|
|
92
|
-
> **invokeStream**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): [`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
93
|
-
|
|
94
|
-
Invokes a JSBridge streaming method that returns a `BridgeStream`.
|
|
95
|
-
|
|
96
|
-
#### Type Parameters
|
|
97
|
-
|
|
98
|
-
##### T
|
|
99
|
-
|
|
100
|
-
`T`
|
|
101
|
-
|
|
102
|
-
#### Parameters
|
|
103
|
-
|
|
104
|
-
##### options
|
|
105
|
-
|
|
106
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
107
|
-
|
|
108
|
-
The invoke options including method name, params, and validation.
|
|
109
|
-
|
|
110
|
-
#### Returns
|
|
111
|
-
|
|
112
|
-
[`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
113
|
-
|
|
114
|
-
A `BridgeStream` for receiving continuous data from the JSBridge.
|
|
115
|
-
|
|
116
|
-
#### Remarks
|
|
117
|
-
|
|
118
|
-
- Always checks if running in Grab app (returns 501 error response if not).
|
|
119
|
-
- When `isSupported` returns false, returns 426 error response.
|
|
120
|
-
- Returns a `BridgeStream` that can be subscribed to or awaited for the first value.
|
|
121
|
-
- All errors are reported via error responses in the stream; this method never rejects.
|
|
122
|
-
|
|
123
|
-
#### Inherited from
|
|
124
|
-
|
|
125
|
-
[`BaseModule`](BaseModule.md).[`invokeStream`](BaseModule.md#invokestream)
|
|
126
|
-
|
|
127
|
-
***
|
|
128
|
-
|
|
129
|
-
### isEsimSupported()
|
|
130
|
-
|
|
131
|
-
> **isEsimSupported**(): `Promise`\<[`IsEsimSupportedResponse`](../type-aliases/IsEsimSupportedResponse.md)\>
|
|
132
|
-
|
|
133
|
-
Checks whether the current device supports eSIM.
|
|
134
|
-
|
|
135
|
-
#### Returns
|
|
136
|
-
|
|
137
|
-
`Promise`\<[`IsEsimSupportedResponse`](../type-aliases/IsEsimSupportedResponse.md)\>
|
|
138
|
-
|
|
139
|
-
Whether eSIM is supported on the current device.
|
|
140
|
-
|
|
141
|
-
#### Example
|
|
142
|
-
|
|
143
|
-
**Simple usage**
|
|
144
|
-
```typescript
|
|
145
|
-
// Initialize the device capability module
|
|
146
|
-
const deviceCapabilityModule = new DeviceCapabilityModule();
|
|
147
|
-
|
|
148
|
-
// Check eSIM support
|
|
149
|
-
const response = await deviceCapabilityModule.isEsimSupported();
|
|
150
|
-
|
|
151
|
-
switch (response.status_code) {
|
|
152
|
-
case 200:
|
|
153
|
-
console.log('eSIM supported:', response.result);
|
|
154
|
-
break;
|
|
155
|
-
case 501:
|
|
156
|
-
console.log('Not in Grab app:', response.error);
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
console.log('Unexpected status code:', response);
|
|
160
|
-
}
|
|
161
|
-
```
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
[@grabjs/superapp-sdk](../globals.md) / FileModule
|
|
2
|
-
|
|
3
|
-
# Class: FileModule
|
|
4
|
-
|
|
5
|
-
JSBridge module for downloading files to the user's device.
|
|
6
|
-
|
|
7
|
-
## Remarks
|
|
8
|
-
|
|
9
|
-
Initiates native file download handling in the Grab app using a file URL and file name.
|
|
10
|
-
This code must run on the Grab SuperApp's webview to function correctly.
|
|
11
|
-
|
|
12
|
-
## Examples
|
|
13
|
-
|
|
14
|
-
**ES Module:**
|
|
15
|
-
```typescript
|
|
16
|
-
import { FileModule } from '@grabjs/superapp-sdk';
|
|
17
|
-
const fileModule = new FileModule();
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**CDN (UMD):**
|
|
21
|
-
```html
|
|
22
|
-
<script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
23
|
-
<script>
|
|
24
|
-
const fileModule = new SuperAppSDK.FileModule();
|
|
25
|
-
</script>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## No Inherit Doc
|
|
29
|
-
|
|
30
|
-
## Extends
|
|
31
|
-
|
|
32
|
-
- [`BaseModule`](BaseModule.md)
|
|
33
|
-
|
|
34
|
-
## Constructors
|
|
35
|
-
|
|
36
|
-
### Constructor
|
|
37
|
-
|
|
38
|
-
> **new FileModule**(): `FileModule`
|
|
39
|
-
|
|
40
|
-
#### Returns
|
|
41
|
-
|
|
42
|
-
`FileModule`
|
|
43
|
-
|
|
44
|
-
#### Overrides
|
|
45
|
-
|
|
46
|
-
[`BaseModule`](BaseModule.md).[`constructor`](BaseModule.md#constructor)
|
|
47
|
-
|
|
48
|
-
## Methods
|
|
49
|
-
|
|
50
|
-
### downloadFile()
|
|
51
|
-
|
|
52
|
-
> **downloadFile**(`request`: [`DownloadFileRequest`](../type-aliases/DownloadFileRequest.md)): `Promise`\<[`DownloadFileResponse`](../type-aliases/DownloadFileResponse.md)\>
|
|
53
|
-
|
|
54
|
-
Downloads a file via the native bridge.
|
|
55
|
-
|
|
56
|
-
#### Parameters
|
|
57
|
-
|
|
58
|
-
##### request
|
|
59
|
-
|
|
60
|
-
[`DownloadFileRequest`](../type-aliases/DownloadFileRequest.md)
|
|
61
|
-
|
|
62
|
-
File information, including URL and target file name.
|
|
63
|
-
|
|
64
|
-
#### Returns
|
|
65
|
-
|
|
66
|
-
`Promise`\<[`DownloadFileResponse`](../type-aliases/DownloadFileResponse.md)\>
|
|
67
|
-
|
|
68
|
-
Download operation result.
|
|
69
|
-
|
|
70
|
-
#### Example
|
|
71
|
-
|
|
72
|
-
**Simple usage**
|
|
73
|
-
```typescript
|
|
74
|
-
// Initialize the file module
|
|
75
|
-
const fileModule = new FileModule();
|
|
76
|
-
|
|
77
|
-
// Download the file
|
|
78
|
-
const response = await fileModule.downloadFile({
|
|
79
|
-
fileUrl: 'https://example.com/report.pdf',
|
|
80
|
-
fileName: 'report.pdf',
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
switch (response.status_code) {
|
|
84
|
-
case 204:
|
|
85
|
-
console.log('File downloaded successfully');
|
|
86
|
-
break;
|
|
87
|
-
case 400:
|
|
88
|
-
console.log('Bad request:', response.error);
|
|
89
|
-
break;
|
|
90
|
-
case 500:
|
|
91
|
-
console.log('Internal server error:', response.error);
|
|
92
|
-
break;
|
|
93
|
-
case 501:
|
|
94
|
-
console.log('Not in Grab app:', response.error);
|
|
95
|
-
break;
|
|
96
|
-
default:
|
|
97
|
-
console.log('Unexpected status code:', response);
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
***
|
|
102
|
-
|
|
103
|
-
### invoke()
|
|
104
|
-
|
|
105
|
-
> **invoke**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): `Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
106
|
-
|
|
107
|
-
Invokes a JSBridge method with optional app validation and response transformation.
|
|
108
|
-
|
|
109
|
-
#### Type Parameters
|
|
110
|
-
|
|
111
|
-
##### T
|
|
112
|
-
|
|
113
|
-
`T`
|
|
114
|
-
|
|
115
|
-
#### Parameters
|
|
116
|
-
|
|
117
|
-
##### options
|
|
118
|
-
|
|
119
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
120
|
-
|
|
121
|
-
The invoke options including method name, params, validation, and transformation.
|
|
122
|
-
|
|
123
|
-
#### Returns
|
|
124
|
-
|
|
125
|
-
`Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
126
|
-
|
|
127
|
-
A promise resolving to the JSBridge response.
|
|
128
|
-
|
|
129
|
-
#### Remarks
|
|
130
|
-
|
|
131
|
-
- Always checks if running in Grab app (returns 501 if not).
|
|
132
|
-
- When `isSupported` returns false, returns 426 (Upgrade Required).
|
|
133
|
-
- When `transformResponse` is provided, applies it to successful responses.
|
|
134
|
-
- All errors are reported via the `status_code` field; this method never rejects.
|
|
135
|
-
- For streaming methods, use `invokeStream` instead.
|
|
136
|
-
|
|
137
|
-
#### Inherited from
|
|
138
|
-
|
|
139
|
-
[`BaseModule`](BaseModule.md).[`invoke`](BaseModule.md#invoke)
|
|
140
|
-
|
|
141
|
-
***
|
|
142
|
-
|
|
143
|
-
### invokeStream()
|
|
144
|
-
|
|
145
|
-
> **invokeStream**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): [`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
146
|
-
|
|
147
|
-
Invokes a JSBridge streaming method that returns a `BridgeStream`.
|
|
148
|
-
|
|
149
|
-
#### Type Parameters
|
|
150
|
-
|
|
151
|
-
##### T
|
|
152
|
-
|
|
153
|
-
`T`
|
|
154
|
-
|
|
155
|
-
#### Parameters
|
|
156
|
-
|
|
157
|
-
##### options
|
|
158
|
-
|
|
159
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
160
|
-
|
|
161
|
-
The invoke options including method name, params, and validation.
|
|
162
|
-
|
|
163
|
-
#### Returns
|
|
164
|
-
|
|
165
|
-
[`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
166
|
-
|
|
167
|
-
A `BridgeStream` for receiving continuous data from the JSBridge.
|
|
168
|
-
|
|
169
|
-
#### Remarks
|
|
170
|
-
|
|
171
|
-
- Always checks if running in Grab app (returns 501 error response if not).
|
|
172
|
-
- When `isSupported` returns false, returns 426 error response.
|
|
173
|
-
- Returns a `BridgeStream` that can be subscribed to or awaited for the first value.
|
|
174
|
-
- All errors are reported via error responses in the stream; this method never rejects.
|
|
175
|
-
|
|
176
|
-
#### Inherited from
|
|
177
|
-
|
|
178
|
-
[`BaseModule`](BaseModule.md).[`invokeStream`](BaseModule.md#invokestream)
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
[@grabjs/superapp-sdk](../globals.md) / IdentityModule
|
|
2
|
-
|
|
3
|
-
# Class: IdentityModule
|
|
4
|
-
|
|
5
|
-
JSBridge module for authenticating users via GrabID.
|
|
6
|
-
|
|
7
|
-
## Remarks
|
|
8
|
-
|
|
9
|
-
Handles OAuth2/OIDC authentication flows with PKCE support, enabling MiniApps to obtain user identity tokens.
|
|
10
|
-
Supports both native in-app consent and web-based fallback flows.
|
|
11
|
-
This code must run on the Grab SuperApp's webview to function correctly.
|
|
12
|
-
|
|
13
|
-
## Examples
|
|
14
|
-
|
|
15
|
-
**ES Module:**
|
|
16
|
-
```typescript
|
|
17
|
-
import { IdentityModule } from '@grabjs/superapp-sdk';
|
|
18
|
-
const identity = new IdentityModule();
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
**CDN (UMD):**
|
|
22
|
-
```html
|
|
23
|
-
<script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
24
|
-
<script>
|
|
25
|
-
const identity = new SuperAppSDK.IdentityModule();
|
|
26
|
-
</script>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## No Inherit Doc
|
|
30
|
-
|
|
31
|
-
## Extends
|
|
32
|
-
|
|
33
|
-
- [`BaseModule`](BaseModule.md)
|
|
34
|
-
|
|
35
|
-
## Constructors
|
|
36
|
-
|
|
37
|
-
### Constructor
|
|
38
|
-
|
|
39
|
-
> **new IdentityModule**(): `IdentityModule`
|
|
40
|
-
|
|
41
|
-
#### Returns
|
|
42
|
-
|
|
43
|
-
`IdentityModule`
|
|
44
|
-
|
|
45
|
-
#### Overrides
|
|
46
|
-
|
|
47
|
-
[`BaseModule`](BaseModule.md).[`constructor`](BaseModule.md#constructor)
|
|
48
|
-
|
|
49
|
-
## Methods
|
|
50
|
-
|
|
51
|
-
### authorize()
|
|
52
|
-
|
|
53
|
-
> **authorize**(`request`: [`AuthorizeRequest`](../type-aliases/AuthorizeRequest.md)): `Promise`\<[`AuthorizeResponse`](../type-aliases/AuthorizeResponse.md)\>
|
|
54
|
-
|
|
55
|
-
Initiates an OAuth2 authorization flow with PKCE (Proof Key for Code Exchange).
|
|
56
|
-
This method handles both native in-app consent and web-based fallback flows.
|
|
57
|
-
|
|
58
|
-
#### Parameters
|
|
59
|
-
|
|
60
|
-
##### request
|
|
61
|
-
|
|
62
|
-
[`AuthorizeRequest`](../type-aliases/AuthorizeRequest.md)
|
|
63
|
-
|
|
64
|
-
Authorization parameters including client ID, redirect URI, scope, and environment.
|
|
65
|
-
|
|
66
|
-
#### Returns
|
|
67
|
-
|
|
68
|
-
`Promise`\<[`AuthorizeResponse`](../type-aliases/AuthorizeResponse.md)\>
|
|
69
|
-
|
|
70
|
-
The authorization result, containing the authorization code on success or redirect status.
|
|
71
|
-
|
|
72
|
-
#### Remarks
|
|
73
|
-
|
|
74
|
-
**Important Note on redirectUri and responseMode:**
|
|
75
|
-
|
|
76
|
-
The actual `redirectUri` used during authorization may differ from the one you provide,
|
|
77
|
-
depending on the flow:
|
|
78
|
-
|
|
79
|
-
- `responseMode: 'in_place'` when native flow is available: Uses the current page URL
|
|
80
|
-
(normalized) as the `redirectUri`, overriding your provided value
|
|
81
|
-
- `responseMode: 'in_place'` falling back to web flow if native flow is not available:
|
|
82
|
-
Uses your provided `redirectUri`
|
|
83
|
-
- `responseMode: 'redirect'`: Always uses your provided `redirectUri`
|
|
84
|
-
|
|
85
|
-
To ensure successful token exchange (which requires matching `redirectUri` values),
|
|
86
|
-
always retrieve the actual `redirectUri` from `getAuthorizationArtifacts()`
|
|
87
|
-
after authorization completes.
|
|
88
|
-
|
|
89
|
-
**Consent Selection Rules (Native vs Web):**
|
|
90
|
-
|
|
91
|
-
- If the user agent does not match the Grab app pattern, the SDK uses web consent
|
|
92
|
-
- If the app version in the user agent is below 5.396.0 (iOS or Android),
|
|
93
|
-
the SDK uses web consent
|
|
94
|
-
- For supported versions, the SDK attempts native consent first and falls back to
|
|
95
|
-
web on specific native errors (400, 401, 403)
|
|
96
|
-
|
|
97
|
-
#### Example
|
|
98
|
-
|
|
99
|
-
**Simple usage**
|
|
100
|
-
```typescript
|
|
101
|
-
// Initialize the identity module
|
|
102
|
-
const identityModule = new IdentityModule();
|
|
103
|
-
|
|
104
|
-
// Initiate authorization with redirect mode
|
|
105
|
-
const response = await identityModule.authorize({
|
|
106
|
-
clientId: 'your-client-id',
|
|
107
|
-
redirectUri: 'https://your-app.com/callback',
|
|
108
|
-
scope: 'openid profile',
|
|
109
|
-
environment: 'production',
|
|
110
|
-
responseMode: 'redirect'
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
switch (response.status_code) {
|
|
114
|
-
case 200:
|
|
115
|
-
// Authorization successful (in_place mode with native flow)
|
|
116
|
-
console.log('Auth Code:', response.result.code);
|
|
117
|
-
console.log('State:', response.result.state);
|
|
118
|
-
break;
|
|
119
|
-
case 302:
|
|
120
|
-
// Redirect in progress (web flow with responseMode: 'redirect')
|
|
121
|
-
// The page will be redirected to the authorization URL
|
|
122
|
-
console.log('Redirecting to authorization...');
|
|
123
|
-
break;
|
|
124
|
-
case 204:
|
|
125
|
-
// User cancelled or flow completed without result data
|
|
126
|
-
console.log('Authorization cancelled or no content');
|
|
127
|
-
break;
|
|
128
|
-
case 400:
|
|
129
|
-
// Authorization failed
|
|
130
|
-
console.error('Auth error:', response.error);
|
|
131
|
-
break;
|
|
132
|
-
default:
|
|
133
|
-
console.log('Unexpected status code:', response);
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
***
|
|
138
|
-
|
|
139
|
-
### clearAuthorizationArtifacts()
|
|
140
|
-
|
|
141
|
-
> **clearAuthorizationArtifacts**(): `Promise`\<[`ResponseStatusCode204`](../type-aliases/ResponseStatusCode204.md)\>
|
|
142
|
-
|
|
143
|
-
Clears all stored PKCE authorization artifacts from local storage.
|
|
144
|
-
This should be called after a successful token exchange or when you need to
|
|
145
|
-
reset the authorization state (e.g., on error or logout).
|
|
146
|
-
|
|
147
|
-
#### Returns
|
|
148
|
-
|
|
149
|
-
`Promise`\<[`ResponseStatusCode204`](../type-aliases/ResponseStatusCode204.md)\>
|
|
150
|
-
|
|
151
|
-
Confirmation that the authorization artifacts have been cleared.
|
|
152
|
-
|
|
153
|
-
#### Example
|
|
154
|
-
|
|
155
|
-
**Simple usage**
|
|
156
|
-
```typescript
|
|
157
|
-
// Initialize the identity module
|
|
158
|
-
const identityModule = new IdentityModule();
|
|
159
|
-
|
|
160
|
-
// Clear stored authorization artifacts after successful token exchange
|
|
161
|
-
const response = await identityModule.clearAuthorizationArtifacts();
|
|
162
|
-
|
|
163
|
-
if (response.status_code === 204) {
|
|
164
|
-
console.log('Authorization artifacts cleared');
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
***
|
|
169
|
-
|
|
170
|
-
### getAuthorizationArtifacts()
|
|
171
|
-
|
|
172
|
-
> **getAuthorizationArtifacts**(): `Promise`\<[`GetAuthorizationArtifactsResponse`](../type-aliases/GetAuthorizationArtifactsResponse.md)\>
|
|
173
|
-
|
|
174
|
-
Retrieves stored PKCE authorization artifacts from local storage.
|
|
175
|
-
These artifacts are used to complete the OAuth2 authorization code exchange.
|
|
176
|
-
|
|
177
|
-
#### Returns
|
|
178
|
-
|
|
179
|
-
`Promise`\<[`GetAuthorizationArtifactsResponse`](../type-aliases/GetAuthorizationArtifactsResponse.md)\>
|
|
180
|
-
|
|
181
|
-
The stored PKCE artifacts including state, code verifier, nonce, and redirect URI.
|
|
182
|
-
|
|
183
|
-
#### Remarks
|
|
184
|
-
|
|
185
|
-
**Important:** The `redirectUri` returned by this method is the actual redirect URI
|
|
186
|
-
that was sent to the authorization server. This may differ from the `redirectUri`
|
|
187
|
-
you provided to `authorize()` if you used `responseMode: 'in_place'` with native flow.
|
|
188
|
-
You must use this returned `redirectUri` for token exchange to ensure OAuth compliance.
|
|
189
|
-
|
|
190
|
-
#### Example
|
|
191
|
-
|
|
192
|
-
**Simple usage**
|
|
193
|
-
```typescript
|
|
194
|
-
// Initialize the identity module
|
|
195
|
-
const identityModule = new IdentityModule();
|
|
196
|
-
|
|
197
|
-
// Retrieve stored authorization artifacts after authorization redirect
|
|
198
|
-
const response = await identityModule.getAuthorizationArtifacts();
|
|
199
|
-
|
|
200
|
-
switch (response.status_code) {
|
|
201
|
-
case 200:
|
|
202
|
-
// All artifacts present - proceed with token exchange
|
|
203
|
-
const { state, codeVerifier, nonce, redirectUri } = response.result;
|
|
204
|
-
console.log('State:', state);
|
|
205
|
-
console.log('Code Verifier:', codeVerifier);
|
|
206
|
-
console.log('Nonce:', nonce);
|
|
207
|
-
console.log('Redirect URI:', redirectUri);
|
|
208
|
-
break;
|
|
209
|
-
case 204:
|
|
210
|
-
// No artifacts yet - user hasn't authorized
|
|
211
|
-
console.log('No authorization artifacts found. Authorization has not been initiated.');
|
|
212
|
-
break;
|
|
213
|
-
case 400:
|
|
214
|
-
// Inconsistent state - possible data corruption
|
|
215
|
-
console.error('Authorization artifacts error:', response.error);
|
|
216
|
-
break;
|
|
217
|
-
default:
|
|
218
|
-
console.log('Unexpected status code:', response);
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
***
|
|
223
|
-
|
|
224
|
-
### invoke()
|
|
225
|
-
|
|
226
|
-
> **invoke**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): `Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
227
|
-
|
|
228
|
-
Invokes a JSBridge method with optional app validation and response transformation.
|
|
229
|
-
|
|
230
|
-
#### Type Parameters
|
|
231
|
-
|
|
232
|
-
##### T
|
|
233
|
-
|
|
234
|
-
`T`
|
|
235
|
-
|
|
236
|
-
#### Parameters
|
|
237
|
-
|
|
238
|
-
##### options
|
|
239
|
-
|
|
240
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
241
|
-
|
|
242
|
-
The invoke options including method name, params, validation, and transformation.
|
|
243
|
-
|
|
244
|
-
#### Returns
|
|
245
|
-
|
|
246
|
-
`Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
247
|
-
|
|
248
|
-
A promise resolving to the JSBridge response.
|
|
249
|
-
|
|
250
|
-
#### Remarks
|
|
251
|
-
|
|
252
|
-
- Always checks if running in Grab app (returns 501 if not).
|
|
253
|
-
- When `isSupported` returns false, returns 426 (Upgrade Required).
|
|
254
|
-
- When `transformResponse` is provided, applies it to successful responses.
|
|
255
|
-
- All errors are reported via the `status_code` field; this method never rejects.
|
|
256
|
-
- For streaming methods, use `invokeStream` instead.
|
|
257
|
-
|
|
258
|
-
#### Inherited from
|
|
259
|
-
|
|
260
|
-
[`BaseModule`](BaseModule.md).[`invoke`](BaseModule.md#invoke)
|
|
261
|
-
|
|
262
|
-
***
|
|
263
|
-
|
|
264
|
-
### invokeStream()
|
|
265
|
-
|
|
266
|
-
> **invokeStream**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): [`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
267
|
-
|
|
268
|
-
Invokes a JSBridge streaming method that returns a `BridgeStream`.
|
|
269
|
-
|
|
270
|
-
#### Type Parameters
|
|
271
|
-
|
|
272
|
-
##### T
|
|
273
|
-
|
|
274
|
-
`T`
|
|
275
|
-
|
|
276
|
-
#### Parameters
|
|
277
|
-
|
|
278
|
-
##### options
|
|
279
|
-
|
|
280
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
281
|
-
|
|
282
|
-
The invoke options including method name, params, and validation.
|
|
283
|
-
|
|
284
|
-
#### Returns
|
|
285
|
-
|
|
286
|
-
[`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
287
|
-
|
|
288
|
-
A `BridgeStream` for receiving continuous data from the JSBridge.
|
|
289
|
-
|
|
290
|
-
#### Remarks
|
|
291
|
-
|
|
292
|
-
- Always checks if running in Grab app (returns 501 error response if not).
|
|
293
|
-
- When `isSupported` returns false, returns 426 error response.
|
|
294
|
-
- Returns a `BridgeStream` that can be subscribed to or awaited for the first value.
|
|
295
|
-
- All errors are reported via error responses in the stream; this method never rejects.
|
|
296
|
-
|
|
297
|
-
#### Inherited from
|
|
298
|
-
|
|
299
|
-
[`BaseModule`](BaseModule.md).[`invokeStream`](BaseModule.md#invokestream)
|