@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/dist/index.js
CHANGED
|
@@ -113,7 +113,7 @@ function m(e) {
|
|
|
113
113
|
if (r.type !== "daily_spend_cap_reached") return null;
|
|
114
114
|
let i = t.cap_cents, a = t.spent_cents, o = t.remaining_cents, s = t.resets_at, c = t.bulk_exempt;
|
|
115
115
|
if (typeof i != "number" || typeof a != "number" || typeof o != "number" || typeof s != "string" || typeof c != "boolean") return null;
|
|
116
|
-
let l = typeof r.message == "string" ? r.message : "Daily spend cap reached.", u = typeof r.code == "number" ? r.code : void 0;
|
|
116
|
+
let l = typeof r.message == "string" ? r.message : typeof t.message == "string" ? t.message : "Daily spend cap reached.", u = typeof r.code == "number" ? r.code : void 0;
|
|
117
117
|
return new p(l, {
|
|
118
118
|
capCents: i,
|
|
119
119
|
spentCents: a,
|
|
@@ -385,6 +385,124 @@ var S = class {
|
|
|
385
385
|
return this.http.get(`/v1/checkout/state/${encodeURIComponent(e)}`);
|
|
386
386
|
}
|
|
387
387
|
}, A = class {
|
|
388
|
+
constructor(e) {
|
|
389
|
+
a(this, "http", void 0), this.http = e;
|
|
390
|
+
}
|
|
391
|
+
async list() {
|
|
392
|
+
return this.http.get("/v1/company/invitations");
|
|
393
|
+
}
|
|
394
|
+
async create(e) {
|
|
395
|
+
return this.http.post("/v1/company/invitations", e);
|
|
396
|
+
}
|
|
397
|
+
async revoke(e) {
|
|
398
|
+
return this.http.delete(`/v1/company/invitations/${encodeURIComponent(e)}`);
|
|
399
|
+
}
|
|
400
|
+
async accept(e) {
|
|
401
|
+
return this.http.post("/v1/company/invitations/accept", e);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/resources/company/machine-users.ts
|
|
406
|
+
function j(e) {
|
|
407
|
+
return `/v1/company/machine-users/${encodeURIComponent(e)}`;
|
|
408
|
+
}
|
|
409
|
+
var M = class {
|
|
410
|
+
constructor(e) {
|
|
411
|
+
a(this, "http", void 0), this.http = e;
|
|
412
|
+
}
|
|
413
|
+
async list(e) {
|
|
414
|
+
return this.http.get(`${j(e)}/buyer-keys`);
|
|
415
|
+
}
|
|
416
|
+
async create(e, t) {
|
|
417
|
+
return this.http.post(`${j(e)}/buyer-keys`, t);
|
|
418
|
+
}
|
|
419
|
+
async revoke(e, t) {
|
|
420
|
+
return this.http.delete(`${j(e)}/buyer-keys/${encodeURIComponent(t)}`);
|
|
421
|
+
}
|
|
422
|
+
}, N = class {
|
|
423
|
+
constructor(e) {
|
|
424
|
+
a(this, "http", void 0), this.http = e;
|
|
425
|
+
}
|
|
426
|
+
async list(e) {
|
|
427
|
+
return this.http.get(`${j(e)}/mcp-keys`);
|
|
428
|
+
}
|
|
429
|
+
async create(e, t) {
|
|
430
|
+
return this.http.post(`${j(e)}/mcp-keys`, t);
|
|
431
|
+
}
|
|
432
|
+
async revoke(e, t) {
|
|
433
|
+
return this.http.delete(`${j(e)}/mcp-keys/${encodeURIComponent(t)}`);
|
|
434
|
+
}
|
|
435
|
+
}, P = class {
|
|
436
|
+
constructor(e) {
|
|
437
|
+
a(this, "http", void 0), a(this, "buyerKeys", void 0), a(this, "mcpKeys", void 0), this.http = e, this.buyerKeys = new M(e), this.mcpKeys = new N(e);
|
|
438
|
+
}
|
|
439
|
+
async list() {
|
|
440
|
+
return this.http.get("/v1/company/machine-users");
|
|
441
|
+
}
|
|
442
|
+
async create(e) {
|
|
443
|
+
return this.http.post("/v1/company/machine-users", e);
|
|
444
|
+
}
|
|
445
|
+
async update(e, t) {
|
|
446
|
+
return this.http.patch(j(e), t);
|
|
447
|
+
}
|
|
448
|
+
async deactivate(e) {
|
|
449
|
+
return this.http.delete(j(e));
|
|
450
|
+
}
|
|
451
|
+
}, F = class {
|
|
452
|
+
constructor(e) {
|
|
453
|
+
a(this, "http", void 0), this.http = e;
|
|
454
|
+
}
|
|
455
|
+
async list() {
|
|
456
|
+
return this.http.get("/v1/company/members");
|
|
457
|
+
}
|
|
458
|
+
async update(e, t) {
|
|
459
|
+
return this.http.patch(`/v1/company/members/${encodeURIComponent(e)}`, t);
|
|
460
|
+
}
|
|
461
|
+
async remove(e) {
|
|
462
|
+
return this.http.delete(`/v1/company/members/${encodeURIComponent(e)}`);
|
|
463
|
+
}
|
|
464
|
+
}, I = class {
|
|
465
|
+
constructor(e) {
|
|
466
|
+
a(this, "http", void 0), this.http = e;
|
|
467
|
+
}
|
|
468
|
+
async get() {
|
|
469
|
+
return this.http.get("/v1/company/membership");
|
|
470
|
+
}
|
|
471
|
+
async leave() {
|
|
472
|
+
return this.http.delete("/v1/company/membership");
|
|
473
|
+
}
|
|
474
|
+
}, L = class {
|
|
475
|
+
constructor(e) {
|
|
476
|
+
a(this, "http", void 0), this.http = e;
|
|
477
|
+
}
|
|
478
|
+
async list(e) {
|
|
479
|
+
return this.http.get("/v1/company/purchases", e);
|
|
480
|
+
}
|
|
481
|
+
}, R = class {
|
|
482
|
+
constructor(e) {
|
|
483
|
+
a(this, "http", void 0), this.http = e;
|
|
484
|
+
}
|
|
485
|
+
async list(e) {
|
|
486
|
+
return this.http.get("/v1/company/spend", e);
|
|
487
|
+
}
|
|
488
|
+
}, z = class {
|
|
489
|
+
constructor(e) {
|
|
490
|
+
a(this, "http", void 0), this.http = e;
|
|
491
|
+
}
|
|
492
|
+
async get() {
|
|
493
|
+
return this.http.get("/v1/company/wallet");
|
|
494
|
+
}
|
|
495
|
+
async createPaymentSession(e) {
|
|
496
|
+
return this.http.post("/v1/company/wallet/payment-session", e);
|
|
497
|
+
}
|
|
498
|
+
async listPendingTopUps() {
|
|
499
|
+
return this.http.get("/v1/company/wallet/pending-top-ups");
|
|
500
|
+
}
|
|
501
|
+
}, B = class {
|
|
502
|
+
constructor(e) {
|
|
503
|
+
a(this, "membership", void 0), a(this, "invitations", void 0), a(this, "members", void 0), a(this, "machineUsers", void 0), a(this, "wallet", void 0), a(this, "purchases", void 0), a(this, "spend", void 0), this.membership = new I(e), this.invitations = new A(e), this.members = new F(e), this.machineUsers = new P(e), this.wallet = new z(e), this.purchases = new L(e), this.spend = new R(e);
|
|
504
|
+
}
|
|
505
|
+
}, V = class {
|
|
388
506
|
constructor(e) {
|
|
389
507
|
a(this, "http", void 0), this.http = e;
|
|
390
508
|
}
|
|
@@ -397,7 +515,7 @@ var S = class {
|
|
|
397
515
|
async revoke(e) {
|
|
398
516
|
return this.http.delete(`/v1/user/api-keys/${encodeURIComponent(e)}`);
|
|
399
517
|
}
|
|
400
|
-
},
|
|
518
|
+
}, H = class {
|
|
401
519
|
constructor(e) {
|
|
402
520
|
a(this, "http", void 0), this.http = e;
|
|
403
521
|
}
|
|
@@ -407,7 +525,7 @@ var S = class {
|
|
|
407
525
|
async update(e) {
|
|
408
526
|
return this.http.patch("/v1/user/spend-cap", e);
|
|
409
527
|
}
|
|
410
|
-
},
|
|
528
|
+
}, U = class {
|
|
411
529
|
constructor(e) {
|
|
412
530
|
a(this, "http", void 0), this.http = e;
|
|
413
531
|
}
|
|
@@ -420,31 +538,31 @@ var S = class {
|
|
|
420
538
|
async revoke(e) {
|
|
421
539
|
return this.http.delete(`/v1/mcp/keys/${encodeURIComponent(e)}`);
|
|
422
540
|
}
|
|
423
|
-
},
|
|
541
|
+
}, W = class {
|
|
424
542
|
constructor(e) {
|
|
425
|
-
a(this, "apiKeys", void 0), a(this, "spendCap", void 0), a(this, "mcpKeys", void 0), this.apiKeys = new
|
|
543
|
+
a(this, "apiKeys", void 0), a(this, "spendCap", void 0), a(this, "mcpKeys", void 0), this.apiKeys = new V(e), this.spendCap = new H(e), this.mcpKeys = new U(e);
|
|
426
544
|
}
|
|
427
545
|
};
|
|
428
546
|
//#endregion
|
|
429
547
|
//#region src/client.ts
|
|
430
|
-
function
|
|
548
|
+
function G(e) {
|
|
431
549
|
let t = e.baseUrl ?? "https://api.ledewire.com", n = new v({
|
|
432
550
|
storage: e.storage ?? new y(),
|
|
433
551
|
refreshFn: x(t),
|
|
434
552
|
...e.onAuthExpired !== void 0 && { onAuthExpired: e.onAuthExpired }
|
|
435
553
|
});
|
|
436
|
-
return new
|
|
554
|
+
return new K(new g({
|
|
437
555
|
baseUrl: t,
|
|
438
556
|
getAccessToken: () => n.getAccessToken(),
|
|
439
557
|
onUnauthorized: () => n.handleUnauthorized()
|
|
440
558
|
}), n, e);
|
|
441
559
|
}
|
|
442
|
-
var
|
|
560
|
+
var K = class {
|
|
443
561
|
constructor(e, t, n) {
|
|
444
|
-
a(this, "_http", void 0), a(this, "_tokenManager", void 0), a(this, "_config", void 0), a(this, "config", void 0), a(this, "auth", void 0), a(this, "checkout", void 0), a(this, "wallet", void 0), a(this, "purchases", void 0), a(this, "content", void 0), a(this, "seller", void 0), a(this, "user", void 0), this._http = e, this._tokenManager = t, this._config = n, this.config = new C(e), this.auth = new S(e, t), this.checkout = new k(e), this.wallet = new O(e), this.purchases = new T(e), this.content = new w(e), this.seller = new D(e, t), this.user = new
|
|
562
|
+
a(this, "_http", void 0), a(this, "_tokenManager", void 0), a(this, "_config", void 0), a(this, "config", void 0), a(this, "auth", void 0), a(this, "checkout", void 0), a(this, "wallet", void 0), a(this, "purchases", void 0), a(this, "content", void 0), a(this, "seller", void 0), a(this, "user", void 0), a(this, "company", void 0), this._http = e, this._tokenManager = t, this._config = n, this.config = new C(e), this.auth = new S(e, t), this.checkout = new k(e), this.wallet = new O(e), this.purchases = new T(e), this.content = new w(e), this.seller = new D(e, t), this.user = new W(e), this.company = new B(e);
|
|
445
563
|
}
|
|
446
|
-
},
|
|
447
|
-
function
|
|
564
|
+
}, q = "lw:tokens";
|
|
565
|
+
function J(e, t = q) {
|
|
448
566
|
return {
|
|
449
567
|
getTokens() {
|
|
450
568
|
let n = e.getItem(t);
|
|
@@ -465,15 +583,15 @@ function L(e, t = I) {
|
|
|
465
583
|
}
|
|
466
584
|
//#endregion
|
|
467
585
|
//#region src/local-storage-adapter.ts
|
|
468
|
-
function
|
|
469
|
-
return
|
|
586
|
+
function Y(e) {
|
|
587
|
+
return J(localStorage, e);
|
|
470
588
|
}
|
|
471
589
|
//#endregion
|
|
472
590
|
//#region src/session-storage-adapter.ts
|
|
473
|
-
function
|
|
474
|
-
return
|
|
591
|
+
function X(e) {
|
|
592
|
+
return J(sessionStorage, e);
|
|
475
593
|
}
|
|
476
594
|
//#endregion
|
|
477
|
-
export { l as AuthError, u as ForbiddenError, c as LedewireError, y as MemoryTokenStorage, d as NotFoundError, f as PurchaseError, p as SpendCapReachedError,
|
|
595
|
+
export { l as AuthError, u as ForbiddenError, c as LedewireError, y as MemoryTokenStorage, d as NotFoundError, f as PurchaseError, p as SpendCapReachedError, G as init, Y as localStorageAdapter, b as parseExpiresAt, X as sessionStorageAdapter };
|
|
478
596
|
|
|
479
597
|
//# sourceMappingURL=index.js.map
|