astrogators-shared-ui 0.7.0-rc.1 → 0.7.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
@@ -211,14 +211,14 @@ var x = "astrogators_access_token", S = "astrogators_refresh_token", C = () => l
211
211
  async refreshAccessToken() {
212
212
  let e = E();
213
213
  if (!e) throw Error("No refresh token available");
214
- let t = await fetch(`${this.baseURL}/api/v1/auth/refresh-token`, {
214
+ let t = await fetch(`${this.baseURL}/api/v1/auth/refresh`, {
215
215
  method: "POST",
216
216
  headers: { "Content-Type": "application/json" },
217
217
  body: JSON.stringify({ refresh_token: e })
218
218
  });
219
219
  if (!t.ok) throw A(), this.onUnauthorized?.(), Error("Token refresh failed");
220
220
  let n = await t.json();
221
- return k(n.access_token, e), n.access_token;
221
+ return k(n.access_token, n.refresh_token), n.access_token;
222
222
  }
223
223
  async request(e, t = {}) {
224
224
  let n = C(), r = {
@@ -417,29 +417,41 @@ var x = "astrogators_access_token", S = "astrogators_refresh_token", C = () => l
417
417
  y(!1);
418
418
  }
419
419
  }, [r]), I = n(async (e) => {
420
+ r && typeof e == "number" ? (await N.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await F()) : !r && typeof e == "string" && (B(e), h(L()));
421
+ }, [r, F]), G = n((e) => {
422
+ if (_(e), H(e), e && r) {
423
+ let t = m.find((t) => "ally_code" in t && t.ally_code === e);
424
+ t && "id" in t && I(t.id);
425
+ } else e && !r && B(e);
426
+ }, [
427
+ r,
428
+ m,
429
+ I
430
+ ]), K = n(async (e) => {
420
431
  if (!/^\d{9}$/.test(e)) throw Error("Ally code must be exactly 9 digits");
421
432
  if (r) {
422
433
  let t = await N.post("/api/v1/users/me/ally-codes", { ally_code: e });
423
- h((e) => [t, ...e]), m.length === 0 && K(e);
434
+ h((e) => [t, ...e]), m.length === 0 && G(e);
424
435
  } else {
425
436
  let t = await N.get(`/api/v1/player-data/player/${e}`);
426
437
  if (!t) throw Error("Invalid ally code - player not found");
427
438
  R({
428
439
  ally_code: e,
429
- player_name: t?.data?.name || null,
440
+ player_name: t.data?.name ?? null,
430
441
  last_used_at: (/* @__PURE__ */ new Date()).toISOString()
431
- }), h(L()), m.length === 0 && K(e);
442
+ }), h(L()), m.length === 0 && G(e);
432
443
  }
433
- }, [r, m.length]), G = n(async (e) => {
434
- r && typeof e == "number" ? (await N.delete(`/api/v1/users/me/ally-codes/${e}`), h((t) => t.filter((t) => "id" in t && t.id !== e))) : !r && typeof e == "string" && (z(e), h(L()), g === e && K(null));
435
- }, [r, g]), K = n((e) => {
436
- if (_(e), H(e), e && r) {
437
- let t = m.find((t) => "ally_code" in t && t.ally_code === e);
438
- t && "id" in t && q(t.id);
439
- } else e && !r && B(e);
440
- }, [r, m]), q = n(async (e) => {
441
- r && typeof e == "number" ? (await N.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await F()) : !r && typeof e == "string" && (B(e), h(L()));
442
- }, [r, F]), J = n(() => {
444
+ }, [
445
+ r,
446
+ m.length,
447
+ G
448
+ ]), q = n(async (e) => {
449
+ r && typeof e == "number" ? (await N.delete(`/api/v1/users/me/ally-codes/${e}`), h((t) => t.filter((t) => "id" in t && t.id !== e))) : !r && typeof e == "string" && (z(e), h(L()), g === e && G(null));
450
+ }, [
451
+ r,
452
+ g,
453
+ G
454
+ ]), J = n(() => {
443
455
  x({
444
456
  show: !1,
445
457
  localStorageCodes: []
@@ -448,14 +460,14 @@ var x = "astrogators_access_token", S = "astrogators_refresh_token", C = () => l
448
460
  if (!r) return;
449
461
  let e = L();
450
462
  for (let t of e) try {
451
- await I(t.ally_code);
463
+ await K(t.ally_code);
452
464
  } catch (e) {
453
465
  console.error(`Failed to migrate ally code ${t.ally_code}:`, e);
454
466
  }
455
467
  U(), J();
456
468
  }, [
457
469
  r,
458
- I,
470
+ K,
459
471
  J
460
472
  ]);
461
473
  i(() => {
@@ -478,10 +490,10 @@ var x = "astrogators_access_token", S = "astrogators_refresh_token", C = () => l
478
490
  selectedAllyCode: g,
479
491
  isLoadingAllyCodes: v,
480
492
  fetchAllyCodes: F,
481
- addAllyCode: I,
482
- removeAllyCode: G,
483
- selectAllyCode: K,
484
- updateAllyCodeLastUsed: q,
493
+ addAllyCode: K,
494
+ removeAllyCode: q,
495
+ selectAllyCode: G,
496
+ updateAllyCodeLastUsed: I,
485
497
  migrationPrompt: b,
486
498
  dismissMigrationPrompt: J,
487
499
  migrateLocalStorageCodes: Y
@@ -638,7 +650,7 @@ var x = "astrogators_access_token", S = "astrogators_refresh_token", C = () => l
638
650
  style: h
639
651
  }),
640
652
  /* @__PURE__ */ s("div", {
641
- className: `chamfered-diagonal-border ${r === "asymmetric" ? "chamfered-diagonal-br-large" : "chamfered-diagonal-br"}`,
653
+ className: "chamfered-diagonal-border chamfered-diagonal-br",
642
654
  style: h
643
655
  })
644
656
  ] }), e]
@@ -37,7 +37,9 @@ export interface RefreshTokenRequest {
37
37
  }
38
38
  export interface RefreshTokenResponse {
39
39
  access_token: string;
40
+ refresh_token: string;
40
41
  token_type: string;
42
+ expires_in: number;
41
43
  }
42
44
  export interface ForgotPasswordRequest {
43
45
  email: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astrogators-shared-ui",
3
- "version": "0.7.0-rc.1",
3
+ "version": "0.7.0",
4
4
  "description": "Shared UI components and utilities for Astrogator's Table applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -51,8 +51,5 @@
51
51
  "vite": "^8.0.9",
52
52
  "vite-plugin-dts": "^4.5.4"
53
53
  },
54
- "dependencies": {
55
- "@fontsource-variable/inter-tight": "^5.2.7",
56
- "@fontsource/michroma": "^5.2.8"
57
- }
54
+ "dependencies": {}
58
55
  }