@appboxo/web-sdk 1.4.0 → 1.4.2
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 +2 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,13 +16,7 @@ const sdk = new AppboxoWebSDK({
|
|
|
16
16
|
const authCode = await fetch('/api/auth-code').then(r => r.json());
|
|
17
17
|
sdk.setAuthCode(authCode);
|
|
18
18
|
|
|
19
|
-
// Mount miniapp
|
|
20
|
-
await sdk.mount({
|
|
21
|
-
container: document.getElementById("miniapp"),
|
|
22
|
-
url: "https://your-miniapp.com"
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Or let SDK fetch URL from API automatically
|
|
19
|
+
// Mount miniapp (SDK will automatically fetch URL from API)
|
|
26
20
|
await sdk.mount({
|
|
27
21
|
container: document.getElementById("miniapp")
|
|
28
22
|
});
|
|
@@ -47,7 +41,6 @@ const sdk = new AppboxoWebSDK({
|
|
|
47
41
|
sandboxMode?: boolean; // Optional, default: false
|
|
48
42
|
debug?: boolean; // Optional, default: false. When true, enables all console logs for debugging. When false, no console logs are output.
|
|
49
43
|
locale?: string; // Optional, locale/language code (e.g., 'en', 'en-US', 'ru', 'zh-CN')
|
|
50
|
-
isDesktop?: boolean; // Optional, default: false. When true, API calls to fetch miniapp settings will include is_desktop=true parameter
|
|
51
44
|
onGetAuthCode?: () => Promise<string>; // Optional, for automatic auth code retrieval
|
|
52
45
|
onGetAuthTokens?: () => Promise<LoginResponse>; // Optional, for direct auth tokens
|
|
53
46
|
onPaymentRequest?: (params: PaymentRequest) => Promise<PaymentResponse>; // Optional, for handling payment requests
|
|
@@ -180,23 +173,6 @@ The locale is passed to the miniapp via `InitData.data.locale` on the next `AppB
|
|
|
180
173
|
- If you call `setLocale()` after the miniapp has already loaded, the locale will be included in the next InitData request. The miniapp may need to reload or request InitData again to receive the updated locale.
|
|
181
174
|
- To ensure the locale is available immediately, set it during SDK initialization or before calling `mount()`.
|
|
182
175
|
|
|
183
|
-
### Desktop Mode
|
|
184
|
-
|
|
185
|
-
When `isDesktop: true` is set, the SDK will include `is_desktop=true` parameter when fetching miniapp settings from the API. This allows the backend to return desktop-specific configurations.
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
const sdk = new AppboxoWebSDK({
|
|
189
|
-
clientId: "your-client-id",
|
|
190
|
-
appId: "your-app-id",
|
|
191
|
-
isDesktop: true // Enable desktop mode
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
When enabled, API calls to `/miniapps/{appId}/settings/` will include the `is_desktop=true` query parameter:
|
|
196
|
-
```
|
|
197
|
-
GET /miniapps/{appId}/settings/?client_id={clientId}&is_desktop=true
|
|
198
|
-
```
|
|
199
|
-
|
|
200
176
|
### Logout
|
|
201
177
|
|
|
202
178
|
The `logout()` method clears the host app's storage and SDK's internal authentication data.
|
|
@@ -331,14 +307,7 @@ function App() {
|
|
|
331
307
|
### Using mount helper
|
|
332
308
|
|
|
333
309
|
```typescript
|
|
334
|
-
//
|
|
335
|
-
await sdk.mount({
|
|
336
|
-
container: '#miniapp-container',
|
|
337
|
-
url: 'https://miniapp.com',
|
|
338
|
-
className: 'miniapp-iframe'
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
// Or fetch URL from API automatically
|
|
310
|
+
// SDK will automatically fetch miniapp URL from API
|
|
342
311
|
await sdk.mount({
|
|
343
312
|
container: '#miniapp-container',
|
|
344
313
|
className: 'miniapp-iframe'
|