@ledewire/browser 0.8.0 → 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/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,115 @@ 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 accept(e) {
398
+ return this.http.post("/v1/company/invitations/accept", e);
399
+ }
400
+ };
401
+ //#endregion
402
+ //#region src/resources/company/machine-users.ts
403
+ function j(e) {
404
+ return `/v1/company/machine-users/${encodeURIComponent(e)}`;
405
+ }
406
+ var M = class {
407
+ constructor(e) {
408
+ a(this, "http", void 0), this.http = e;
409
+ }
410
+ async list(e) {
411
+ return this.http.get(`${j(e)}/buyer-keys`);
412
+ }
413
+ async create(e, t) {
414
+ return this.http.post(`${j(e)}/buyer-keys`, t);
415
+ }
416
+ async revoke(e, t) {
417
+ return this.http.delete(`${j(e)}/buyer-keys/${encodeURIComponent(t)}`);
418
+ }
419
+ }, N = class {
420
+ constructor(e) {
421
+ a(this, "http", void 0), this.http = e;
422
+ }
423
+ async list(e) {
424
+ return this.http.get(`${j(e)}/mcp-keys`);
425
+ }
426
+ async create(e, t) {
427
+ return this.http.post(`${j(e)}/mcp-keys`, t);
428
+ }
429
+ async revoke(e, t) {
430
+ return this.http.delete(`${j(e)}/mcp-keys/${encodeURIComponent(t)}`);
431
+ }
432
+ }, P = class {
433
+ constructor(e) {
434
+ 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);
435
+ }
436
+ async list() {
437
+ return this.http.get("/v1/company/machine-users");
438
+ }
439
+ async create(e) {
440
+ return this.http.post("/v1/company/machine-users", e);
441
+ }
442
+ async deactivate(e) {
443
+ return this.http.delete(j(e));
444
+ }
445
+ }, F = class {
446
+ constructor(e) {
447
+ a(this, "http", void 0), this.http = e;
448
+ }
449
+ async list() {
450
+ return this.http.get("/v1/company/members");
451
+ }
452
+ async update(e, t) {
453
+ return this.http.patch(`/v1/company/members/${encodeURIComponent(e)}`, t);
454
+ }
455
+ async remove(e) {
456
+ return this.http.delete(`/v1/company/members/${encodeURIComponent(e)}`);
457
+ }
458
+ }, I = class {
459
+ constructor(e) {
460
+ a(this, "http", void 0), this.http = e;
461
+ }
462
+ async get() {
463
+ return this.http.get("/v1/company/membership");
464
+ }
465
+ async leave() {
466
+ return this.http.delete("/v1/company/membership");
467
+ }
468
+ }, L = class {
469
+ constructor(e) {
470
+ a(this, "http", void 0), this.http = e;
471
+ }
472
+ async list(e) {
473
+ return this.http.get("/v1/company/purchases", e);
474
+ }
475
+ }, R = class {
476
+ constructor(e) {
477
+ a(this, "http", void 0), this.http = e;
478
+ }
479
+ async list(e) {
480
+ return this.http.get("/v1/company/spend", e);
481
+ }
482
+ }, z = class {
483
+ constructor(e) {
484
+ a(this, "http", void 0), this.http = e;
485
+ }
486
+ async createPaymentSession(e) {
487
+ return this.http.post("/v1/company/wallet/payment-session", e);
488
+ }
489
+ async listPendingTopUps() {
490
+ return this.http.get("/v1/company/wallet/pending-top-ups");
491
+ }
492
+ }, B = class {
493
+ constructor(e) {
494
+ 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);
495
+ }
496
+ }, V = class {
388
497
  constructor(e) {
389
498
  a(this, "http", void 0), this.http = e;
390
499
  }
@@ -397,7 +506,7 @@ var S = class {
397
506
  async revoke(e) {
398
507
  return this.http.delete(`/v1/user/api-keys/${encodeURIComponent(e)}`);
399
508
  }
400
- }, j = class {
509
+ }, H = class {
401
510
  constructor(e) {
402
511
  a(this, "http", void 0), this.http = e;
403
512
  }
@@ -407,7 +516,7 @@ var S = class {
407
516
  async update(e) {
408
517
  return this.http.patch("/v1/user/spend-cap", e);
409
518
  }
410
- }, M = class {
519
+ }, U = class {
411
520
  constructor(e) {
412
521
  a(this, "http", void 0), this.http = e;
413
522
  }
@@ -420,31 +529,31 @@ var S = class {
420
529
  async revoke(e) {
421
530
  return this.http.delete(`/v1/mcp/keys/${encodeURIComponent(e)}`);
422
531
  }
423
- }, N = class {
532
+ }, W = class {
424
533
  constructor(e) {
425
- a(this, "apiKeys", void 0), a(this, "spendCap", void 0), a(this, "mcpKeys", void 0), this.apiKeys = new A(e), this.spendCap = new j(e), this.mcpKeys = new M(e);
534
+ 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
535
  }
427
536
  };
428
537
  //#endregion
429
538
  //#region src/client.ts
430
- function P(e) {
539
+ function G(e) {
431
540
  let t = e.baseUrl ?? "https://api.ledewire.com", n = new v({
432
541
  storage: e.storage ?? new y(),
433
542
  refreshFn: x(t),
434
543
  ...e.onAuthExpired !== void 0 && { onAuthExpired: e.onAuthExpired }
435
544
  });
436
- return new F(new g({
545
+ return new K(new g({
437
546
  baseUrl: t,
438
547
  getAccessToken: () => n.getAccessToken(),
439
548
  onUnauthorized: () => n.handleUnauthorized()
440
549
  }), n, e);
441
550
  }
442
- var F = class {
551
+ var K = class {
443
552
  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 N(e);
553
+ 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
554
  }
446
- }, I = "lw:tokens";
447
- function L(e, t = I) {
555
+ }, q = "lw:tokens";
556
+ function J(e, t = q) {
448
557
  return {
449
558
  getTokens() {
450
559
  let n = e.getItem(t);
@@ -465,15 +574,15 @@ function L(e, t = I) {
465
574
  }
466
575
  //#endregion
467
576
  //#region src/local-storage-adapter.ts
468
- function R(e) {
469
- return L(localStorage, e);
577
+ function Y(e) {
578
+ return J(localStorage, e);
470
579
  }
471
580
  //#endregion
472
581
  //#region src/session-storage-adapter.ts
473
- function z(e) {
474
- return L(sessionStorage, e);
582
+ function X(e) {
583
+ return J(sessionStorage, e);
475
584
  }
476
585
  //#endregion
477
- export { l as AuthError, u as ForbiddenError, c as LedewireError, y as MemoryTokenStorage, d as NotFoundError, f as PurchaseError, p as SpendCapReachedError, P as init, R as localStorageAdapter, b as parseExpiresAt, z as sessionStorageAdapter };
586
+ 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
587
 
479
588
  //# sourceMappingURL=index.js.map