@ledewire/browser 0.8.1 → 0.10.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/README.md +32 -0
- package/dist/index.d.ts +1195 -33
- package/dist/index.js +134 -16
- package/dist/index.js.map +1 -1
- package/dist/ledewire.min.js +1 -1
- package/dist/ledewire.min.js.map +1 -1
- package/llms.txt +46 -3
- package/package.json +1 -1
package/llms.txt
CHANGED
|
@@ -117,6 +117,13 @@ 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` and `loginWithGoogle` accept an optional `company_invitation_token`
|
|
121
|
+
(Company invitation) and `invitation_token` (store invitation) to create the
|
|
122
|
+
account and join in one step. If an invitation can't be accepted, nothing is
|
|
123
|
+
created and the call throws a 422 `LedewireError` with
|
|
124
|
+
`type === 'invitation_not_accepted'` and `details.reason`. For a Google account
|
|
125
|
+
that already exists the sign-in succeeds and `res.invitations` reports each
|
|
126
|
+
outcome.
|
|
120
127
|
|
|
121
128
|
### lw.checkout
|
|
122
129
|
|
|
@@ -149,10 +156,15 @@ switch (checkout_state.next_required_action) {
|
|
|
149
156
|
|
|
150
157
|
```ts
|
|
151
158
|
lw.wallet.balance() → Promise<WalletBalanceResponse>
|
|
152
|
-
// { balance_cents: number, spendable_cents: number, held_cents: number,
|
|
159
|
+
// { balance_cents: number | null, spendable_cents: number | null, held_cents: number,
|
|
160
|
+
// holds: Hold[], remaining_cents: number | null, company_name: string | null }
|
|
153
161
|
// balance_cents always equals spendable_cents. held_cents is committed to active
|
|
154
162
|
// bulk acquisitions (node-only feature); holds is one entry per such acquisition:
|
|
155
163
|
// { acquisition_id, held_cents, authorized_at }.
|
|
164
|
+
// COMPANY MEMBERS see no balance: balance_cents/spendable_cents are null,
|
|
165
|
+
// company_name names whose wallet pays, remaining_cents is what they may still
|
|
166
|
+
// spend today. content.getWithAccess().access_info.wallet_balance_cents is null
|
|
167
|
+
// for them too. Handle null before rendering or doing arithmetic.
|
|
156
168
|
|
|
157
169
|
lw.wallet.transactions(params?: PaginationParams) → Promise<{ data: WalletTransactionItem[], pagination: PaginationMeta }>
|
|
158
170
|
|
|
@@ -160,7 +172,10 @@ lw.wallet.createPaymentSession({ amount_cents: number }) → Promise<WalletPayme
|
|
|
160
172
|
// { payment_url: string, session_id: string, ... } — redirect user to payment_url
|
|
161
173
|
|
|
162
174
|
lw.wallet.getPaymentStatus(sessionId: string) → Promise<WalletPaymentStatusResponse>
|
|
163
|
-
// Poll after return from payment redirect to confirm funding
|
|
175
|
+
// Poll after return from payment redirect to confirm funding.
|
|
176
|
+
// status: 'pending' | 'awaiting_verification' | 'processing' | 'completed' | 'failed' | 'cancelled'
|
|
177
|
+
// completed/failed/cancelled are terminal; ACH can sit in awaiting_verification
|
|
178
|
+
// (microdeposits) then processing for days. Personal top-ups only.
|
|
164
179
|
```
|
|
165
180
|
|
|
166
181
|
### lw.purchases
|
|
@@ -213,6 +228,7 @@ interface UserSpendCap {
|
|
|
213
228
|
resets_at: string // ISO 8601
|
|
214
229
|
spend_window_timezone: string // IANA zone, UTC by default
|
|
215
230
|
bulk_exempt: boolean
|
|
231
|
+
company_name: string | null // set for a Company member: this is their membership's cap
|
|
216
232
|
}
|
|
217
233
|
|
|
218
234
|
interface UserSpendCapUpdateRequest {
|
|
@@ -222,7 +238,9 @@ interface UserSpendCapUpdateRequest {
|
|
|
222
238
|
|
|
223
239
|
Exceeding the cap throws `SpendCapReachedError` (402) from
|
|
224
240
|
`lw.purchases.create()` — funding the wallet does NOT clear it. It clears at
|
|
225
|
-
`resetsAt`, or when the cap is raised/removed here.
|
|
241
|
+
`resetsAt`, or when the cap is raised/removed here. A Company member's cap is
|
|
242
|
+
set by a Company admin (`lw.company.members.update()`); `update()` here throws
|
|
243
|
+
`ForbiddenError` for a member.
|
|
226
244
|
|
|
227
245
|
#### lw.user.mcpKeys
|
|
228
246
|
|
|
@@ -246,6 +264,31 @@ interface McpApiKeyCreateRequest {
|
|
|
246
264
|
|
|
247
265
|
The `secret` in the create response is shown once — store it alongside `key`.
|
|
248
266
|
|
|
267
|
+
### lw.company
|
|
268
|
+
|
|
269
|
+
A Company is a shared wallet that pays for its members' purchases; each member
|
|
270
|
+
spends under their own daily Spend cap and never sees the Company balance.
|
|
271
|
+
`membership.*` and `invitations.accept()` are for any buyer; everything else is
|
|
272
|
+
Company-admin only (`ForbiddenError` for a plain member, `NotFoundError` when
|
|
273
|
+
not in a Company). List methods return `{ data }`.
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
lw.company.membership.get() / .leave()
|
|
277
|
+
lw.company.invitations.list() / .create({ email, role? }) / .revoke(id) / .accept({ token })
|
|
278
|
+
lw.company.members.list() / .update(membershipId, { role?, daily_spend_limit_cents? }) / .remove(membershipId)
|
|
279
|
+
lw.company.machineUsers.list() / .create({ name, description? }) / .update(id, { name?, description? }) / .deactivate(id) // deactivate is permanent
|
|
280
|
+
lw.company.machineUsers.buyerKeys.list(muId) / .create(muId, { name }) / .revoke(muId, keyId)
|
|
281
|
+
lw.company.machineUsers.mcpKeys.list(muId) / .create(muId, { label, scopes }) / .revoke(muId, keyId)
|
|
282
|
+
lw.company.wallet.get() / .createPaymentSession({ amount_cents, currency? }) / .listPendingTopUps() // get(): the Company balance, admin only
|
|
283
|
+
lw.company.purchases.list({ member?, from?, to?, kind?, page?, per_page? }) // paginated
|
|
284
|
+
lw.company.spend.list({ member?, from?, to? })
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
`members.*` take the membership id (`CompanyMember.id`), not `user_id`. Key
|
|
288
|
+
`secret`s from `machineUsers.*Keys.create()` are shown once. A Company top-up
|
|
289
|
+
is not found by `lw.wallet.getPaymentStatus()` — track it with
|
|
290
|
+
`listPendingTopUps()`, where it drops off once settled.
|
|
291
|
+
|
|
249
292
|
### lw.seller
|
|
250
293
|
|
|
251
294
|
Operations scoped to the authenticated seller's store.
|