@ledewire/browser 0.4.0 → 0.6.0

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/llms.txt CHANGED
@@ -51,7 +51,7 @@ Token refresh is automatic — never call a refresh method manually.
51
51
 
52
52
  ## localStorageAdapter
53
53
 
54
- Persist sessions across page reloads using `localStorage`:
54
+ Persist sessions across page reloads and browser restarts using `localStorage`:
55
55
 
56
56
  ```ts
57
57
  import { init, localStorageAdapter } from '@ledewire/browser'
@@ -63,6 +63,21 @@ const lw = init({
63
63
  })
64
64
  ```
65
65
 
66
+ ## sessionStorageAdapter
67
+
68
+ Persist sessions within the current tab only (cleared on tab close) using `sessionStorage`.
69
+ Use this to prevent token leakage across tabs — recommended for embedded checkout widgets
70
+ and kiosk-mode UIs:
71
+
72
+ ```ts
73
+ import { init, sessionStorageAdapter } from '@ledewire/browser'
74
+
75
+ const lw = init({
76
+ apiKey: 'your_api_key',
77
+ storage: sessionStorageAdapter(),
78
+ })
79
+ ```
80
+
66
81
  Use `MemoryTokenStorage` (default) for highest security — tokens are never written
67
82
  to disk and are cleared when the page unloads.
68
83
 
@@ -87,18 +102,15 @@ lw.config.getPublic() → Promise<PublicConfigResponse>
87
102
  // Safe to call before authentication — use to get the Google Client ID for sign-in UI.
88
103
  ```
89
104
 
90
- ### lw.auth (buyer and seller auth)
105
+ ### lw.auth (buyer auth)
91
106
 
92
107
  ```ts
93
108
  lw.auth.signup(body) → Promise<AuthenticationResponse>
94
109
  lw.auth.loginWithEmail({ email, password }) → Promise<AuthenticationResponse>
95
110
  lw.auth.loginWithGoogle({ id_token }) → Promise<AuthenticationResponse>
96
- lw.auth.loginWithApiKey({ key, secret? }) → Promise<AuthenticationResponse>
97
- // key-only → view permission (read-only, sufficient for lw.seller.content.*)
98
- // key + secret → full permission (read/write)
99
111
  lw.auth.logout() → Promise<void>
100
- lw.auth.requestPasswordReset({ email }) → Promise<void>
101
- lw.auth.resetPassword({ token, password }) → Promise<void>
112
+ lw.auth.requestPasswordReset({ email }) → Promise<AuthPasswordResetResponse>
113
+ lw.auth.resetPassword({ email, reset_code, password }) → Promise<AuthPasswordResetResponse>
102
114
  ```
103
115
 
104
116
  Tokens are stored automatically after every successful login.
@@ -156,21 +168,26 @@ lw.purchases.get(purchaseId: string) → Promise<PurchaseRespon
156
168
  ### lw.content
157
169
 
158
170
  ```ts
159
- lw.content.getWithAccess(contentId: string, options?) → Promise<ContentWithAccessResponse>
171
+ lw.content.getWithAccess(contentId: string) → Promise<ContentWithAccessResponse>
160
172
  // Returns content payload + access info. Requires a valid buyer session.
161
173
  // content_type: 'markdown' | 'external_ref'
162
- // content_body: base64-encoded string (use atob() to decode markdown)
174
+ // content_body: plain text markdown (SDK decodes base64 automatically)
163
175
  // content_uri: URL for external_ref content (Vimeo, YouTube, PDF, etc.)
164
176
  ```
165
177
 
166
- ### lw.seller.content (requires API key login)
178
+ ### lw.seller
167
179
 
168
- Read-only operations scoped to the authenticated seller's store.
180
+ Operations scoped to the authenticated seller's store.
169
181
  Store identity is derived server-side from the token — no `store_id` needed.
170
182
 
171
183
  ```ts
184
+ // Authenticate first (key-only → view; key + secret → full)
185
+ lw.seller.loginWithApiKey({ key, secret? }) → Promise<AuthenticationResponse>
186
+ // key-only → view permission (read-only, sufficient for lw.seller.content.*)
187
+ // key + secret → full permission (read/write)
188
+
172
189
  // 1. Obtain a view token (key-only is sufficient)
173
- await lw.auth.loginWithApiKey({ key: 'your_api_key' })
190
+ await lw.seller.loginWithApiKey({ key: 'your_api_key' })
174
191
 
175
192
  // 2. List all store content
176
193
  lw.seller.content.list() → Promise<ContentResponse[]>
@@ -208,7 +225,7 @@ switch (checkout_state.next_required_action) {
208
225
  const { content_type, content_body, content_uri } =
209
226
  await lw.content.getWithAccess('article-123')
210
227
  if (content_type === 'markdown') {
211
- renderMarkdown(atob(content_body)) // base64-decode then render
228
+ renderMarkdown(content_body) // plain text — SDK decodes base64 automatically
212
229
  } else {
213
230
  window.location.href = content_uri // redirect to gated video/PDF
214
231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledewire/browser",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "LedeWire SDK for browsers — embed a paywall with a single script tag",
5
5
  "type": "module",
6
6
  "exports": {