@ledewire/browser 0.8.1 → 0.9.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
@@ -117,6 +117,8 @@ lw.auth.resetPassword({ email, reset_code, password }) → Promise<AuthP
117
117
  Tokens are stored automatically after every successful login.
118
118
  `loginWithBuyerApiKey` is useful in buyer dashboards where the user has created a
119
119
  named API key and wants to authenticate headlessly (without email/password).
120
+ `signup` accepts an optional `company_invitation_token` (from a Company
121
+ invitation email) to sign up and join that Company in one step.
120
122
 
121
123
  ### lw.checkout
122
124
 
@@ -149,10 +151,15 @@ switch (checkout_state.next_required_action) {
149
151
 
150
152
  ```ts
151
153
  lw.wallet.balance() → Promise<WalletBalanceResponse>
152
- // { balance_cents: number, spendable_cents: number, held_cents: number, holds: Hold[] }
154
+ // { balance_cents: number | null, spendable_cents: number | null, held_cents: number,
155
+ // holds: Hold[], remaining_cents: number | null, company_name: string | null }
153
156
  // balance_cents always equals spendable_cents. held_cents is committed to active
154
157
  // bulk acquisitions (node-only feature); holds is one entry per such acquisition:
155
158
  // { acquisition_id, held_cents, authorized_at }.
159
+ // COMPANY MEMBERS see no balance: balance_cents/spendable_cents are null,
160
+ // company_name names whose wallet pays, remaining_cents is what they may still
161
+ // spend today. content.getWithAccess().access_info.wallet_balance_cents is null
162
+ // for them too. Handle null before rendering or doing arithmetic.
156
163
 
157
164
  lw.wallet.transactions(params?: PaginationParams) → Promise<{ data: WalletTransactionItem[], pagination: PaginationMeta }>
158
165
 
@@ -160,7 +167,10 @@ lw.wallet.createPaymentSession({ amount_cents: number }) → Promise<WalletPayme
160
167
  // { payment_url: string, session_id: string, ... } — redirect user to payment_url
161
168
 
162
169
  lw.wallet.getPaymentStatus(sessionId: string) → Promise<WalletPaymentStatusResponse>
163
- // Poll after return from payment redirect to confirm funding
170
+ // Poll after return from payment redirect to confirm funding.
171
+ // status: 'pending' | 'awaiting_verification' | 'processing' | 'completed' | 'failed' | 'cancelled'
172
+ // completed/failed/cancelled are terminal; ACH can sit in awaiting_verification
173
+ // (microdeposits) then processing for days. Personal top-ups only.
164
174
  ```
165
175
 
166
176
  ### lw.purchases
@@ -213,6 +223,7 @@ interface UserSpendCap {
213
223
  resets_at: string // ISO 8601
214
224
  spend_window_timezone: string // IANA zone, UTC by default
215
225
  bulk_exempt: boolean
226
+ company_name: string | null // set for a Company member: this is their membership's cap
216
227
  }
217
228
 
218
229
  interface UserSpendCapUpdateRequest {
@@ -222,7 +233,9 @@ interface UserSpendCapUpdateRequest {
222
233
 
223
234
  Exceeding the cap throws `SpendCapReachedError` (402) from
224
235
  `lw.purchases.create()` — funding the wallet does NOT clear it. It clears at
225
- `resetsAt`, or when the cap is raised/removed here.
236
+ `resetsAt`, or when the cap is raised/removed here. A Company member's cap is
237
+ set by a Company admin (`lw.company.members.update()`); `update()` here throws
238
+ `ForbiddenError` for a member.
226
239
 
227
240
  #### lw.user.mcpKeys
228
241
 
@@ -246,6 +259,31 @@ interface McpApiKeyCreateRequest {
246
259
 
247
260
  The `secret` in the create response is shown once — store it alongside `key`.
248
261
 
262
+ ### lw.company
263
+
264
+ A Company is a shared wallet that pays for its members' purchases; each member
265
+ spends under their own daily Spend cap and never sees the Company balance.
266
+ `membership.*` and `invitations.accept()` are for any buyer; everything else is
267
+ Company-admin only (`ForbiddenError` for a plain member, `NotFoundError` when
268
+ not in a Company). List methods return `{ data }`.
269
+
270
+ ```ts
271
+ lw.company.membership.get() / .leave()
272
+ lw.company.invitations.list() / .create({ email, role? }) / .accept({ token })
273
+ lw.company.members.list() / .update(membershipId, { role?, daily_spend_limit_cents? }) / .remove(membershipId)
274
+ lw.company.machineUsers.list() / .create({ name, description? }) / .deactivate(id) // deactivate is permanent
275
+ lw.company.machineUsers.buyerKeys.list(muId) / .create(muId, { name }) / .revoke(muId, keyId)
276
+ lw.company.machineUsers.mcpKeys.list(muId) / .create(muId, { label, scopes }) / .revoke(muId, keyId)
277
+ lw.company.wallet.createPaymentSession({ amount_cents, currency? }) / .listPendingTopUps()
278
+ lw.company.purchases.list({ member?, from?, to?, kind?, page?, per_page? }) // paginated
279
+ lw.company.spend.list({ member?, from?, to? })
280
+ ```
281
+
282
+ `members.*` take the membership id (`CompanyMember.id`), not `user_id`. Key
283
+ `secret`s from `machineUsers.*Keys.create()` are shown once. A Company top-up
284
+ is not found by `lw.wallet.getPaymentStatus()` — track it with
285
+ `listPendingTopUps()`, where it drops off once settled.
286
+
249
287
  ### lw.seller
250
288
 
251
289
  Operations scoped to the authenticated seller's store.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledewire/browser",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "LedeWire SDK for browsers — embed a paywall with a single script tag",
5
5
  "type": "module",
6
6
  "exports": {