@appboxo/web-sdk 1.3.0 → 1.3.1

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.
Files changed (2) hide show
  1. package/README.md +33 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -47,6 +47,7 @@ const sdk = new AppboxoWebSDK({
47
47
  sandboxMode?: boolean; // Optional, default: false
48
48
  debug?: boolean; // Optional, default: false. When true, enables all console logs for debugging. When false, no console logs are output.
49
49
  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
50
51
  onGetAuthCode?: () => Promise<string>; // Optional, for automatic auth code retrieval
51
52
  onGetAuthTokens?: () => Promise<LoginResponse>; // Optional, for direct auth tokens
52
53
  onPaymentRequest?: (params: PaymentRequest) => Promise<PaymentResponse>; // Optional, for handling payment requests
@@ -179,6 +180,37 @@ The locale is passed to the miniapp via `InitData.data.locale` on the next `AppB
179
180
  - 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.
180
181
  - To ensure the locale is available immediately, set it during SDK initialization or before calling `mount()`.
181
182
 
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
+ ### Logout
201
+
202
+ The `logout()` method clears the host app's storage and SDK's internal authentication data.
203
+
204
+ ```typescript
205
+ sdk.logout();
206
+ ```
207
+
208
+ **Important Notes:**
209
+ - This only clears the **host app's** `localStorage` and `sessionStorage`
210
+ - Miniapp's storage is separate (different origin) and cannot be cleared from the host app due to browser security restrictions
211
+ - The SDK will send a logout notification to the miniapp via `postMessage`, allowing the miniapp to clear its own storage if it listens for the event
212
+ - SDK's internal `authCode` and `authTokens` are also cleared
213
+
182
214
  ## Methods
183
215
 
184
216
  | Method | Description |
@@ -194,6 +226,7 @@ The locale is passed to the miniapp via `InitData.data.locale` on the next `AppB
194
226
  | `onEvent(type, handler)` | Register custom event handler |
195
227
  | `onLoginComplete(callback)` | Login completion callback |
196
228
  | `onPaymentComplete(callback)` | Payment completion callback |
229
+ | `logout()` | Clear host app's localStorage, sessionStorage, and SDK's internal auth data |
197
230
  | `destroy()` | Clean up resources |
198
231
 
199
232
  ## Events
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appboxo/web-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Boxo Desktop Host App SDK for handling miniapp events",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",