@hexdspace/react 0.0.25 → 0.0.27

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.
@@ -72,7 +72,7 @@
72
72
  @layer components {
73
73
  .card {
74
74
  background: var(--surface-2);
75
- border: 1px solid color-mix(in oklab, var(--border), transparent 45%);
75
+ border: 1px solid color-mix(in oklab, var(--border), transparent 80%);
76
76
  border-radius: var(--radius-card);
77
77
  box-shadow: var(--shadow-elevated);
78
78
  }
package/dist/index.d.ts CHANGED
@@ -177,7 +177,9 @@ interface GenericResponse {
177
177
  }
178
178
 
179
179
  interface ErrorResponse {
180
- error: string;
180
+ message: string;
181
+ status: number;
182
+ name: string;
181
183
  details?: unknown;
182
184
  }
183
185
 
@@ -253,7 +255,7 @@ interface LogoutUser {
253
255
  }
254
256
 
255
257
  interface RegisterUser {
256
- execute(email: string, password: string): AsyncResult<Error, GenericResponse>;
258
+ execute(email: string, password: string, attributes?: Record<string, string>): AsyncResult<Error, GenericResponse>;
257
259
  }
258
260
 
259
261
  interface GetAuthenticatedUser {
@@ -263,7 +265,7 @@ interface GetAuthenticatedUser {
263
265
  interface AuthProvider$1 {
264
266
  getAuthenticatedUser(): AsyncResult<Error, User | null>;
265
267
  login(email: string, password: string): AsyncResult<Error, User>;
266
- register(email: string, password: string): AsyncResult<Error, GenericResponse>;
268
+ register(email: string, password: string, attributes?: Record<string, string>): AsyncResult<Error, GenericResponse>;
267
269
  logout(): AsyncResult<Error, null>;
268
270
  }
269
271
 
@@ -275,7 +277,7 @@ declare class AuthController {
275
277
  constructor(loginUser: LoginUser, logoutUser: LogoutUser, registerUser: RegisterUser, getAuthenticatedUser: GetAuthenticatedUser);
276
278
  login(email: string, password: string): AsyncResult<Error, User>;
277
279
  logout(): AsyncResult<Error, null>;
278
- register(email: string, password: string): AsyncResult<Error, {
280
+ register(email: string, password: string, attributes?: Record<string, string>): AsyncResult<Error, {
279
281
  message: string;
280
282
  }>;
281
283
  getCurrentUser(): AsyncResult<Error, User | null>;
@@ -309,7 +311,7 @@ declare function useAuth(): AuthState;
309
311
  declare function useAuthActions(): {
310
312
  login: (email: string, password: string) => Promise<Result<Error, User>>;
311
313
  logout: () => void;
312
- register: (email: string, password: string) => Promise<Result<Error, {
314
+ register: (email: string, password: string, attributes?: Record<string, string>) => Promise<Result<Error, {
313
315
  message: string;
314
316
  }>>;
315
317
  };
package/dist/index.js CHANGED
@@ -524,7 +524,7 @@ var FetchHttpClient = class {
524
524
  const data = await (res.headers.get("content-type")?.includes("application/json") ? res.json() : res.text());
525
525
  if (!res.ok) {
526
526
  const errorResponse = data;
527
- const message = errorResponse?.error ?? res.statusText;
527
+ const message = errorResponse?.message ?? res.statusText;
528
528
  throw new HttpError(message, res.status, errorResponse);
529
529
  }
530
530
  return {
@@ -535,7 +535,11 @@ var FetchHttpClient = class {
535
535
  } catch (err) {
536
536
  if (err instanceof HttpError) throw err;
537
537
  const message = err instanceof Error ? err.message : "HTTP request failed";
538
- throw new HttpError(message, 0, { error: JSON.stringify(err) });
538
+ throw new HttpError(message, 0, {
539
+ name: "Error",
540
+ message: JSON.stringify(err),
541
+ status: 500
542
+ });
539
543
  }
540
544
  }
541
545
  resolve(url) {
@@ -550,7 +554,11 @@ async function refresh(httpClient2) {
550
554
  if (err instanceof HttpError) {
551
555
  return nok(err);
552
556
  } else {
553
- return nok(new HttpError("Unknown error during refresh", 0, { error: JSON.stringify(err) }));
557
+ return nok(new HttpError("Unknown error during refresh", 0, {
558
+ name: "Error",
559
+ message: JSON.stringify(err),
560
+ status: 500
561
+ }));
554
562
  }
555
563
  }
556
564
  }
@@ -630,9 +638,12 @@ var HttpCookieAuthProvider = class {
630
638
  }
631
639
  }
632
640
  }
633
- async register(email, password) {
641
+ async register(email, password, attributes) {
634
642
  try {
635
- const res = await this.httpClient.post("/auth/register", { email, password });
643
+ const res = await this.httpClient.post(
644
+ "/auth/register",
645
+ { email, password, ...attributes ?? {} }
646
+ );
636
647
  return ok2(res.data);
637
648
  } catch (err) {
638
649
  if (err instanceof Error) {
@@ -684,8 +695,8 @@ var RegisterUserUseCase = class {
684
695
  constructor(authProvider) {
685
696
  this.authProvider = authProvider;
686
697
  }
687
- execute(email, password) {
688
- return this.authProvider.register(email, password);
698
+ execute(email, password, attributes) {
699
+ return this.authProvider.register(email, password, attributes);
689
700
  }
690
701
  };
691
702
 
@@ -713,8 +724,8 @@ var AuthController = class {
713
724
  async logout() {
714
725
  return this.logoutUser.execute();
715
726
  }
716
- async register(email, password) {
717
- return this.registerUser.execute(email, password);
727
+ async register(email, password, attributes) {
728
+ return this.registerUser.execute(email, password, attributes);
718
729
  }
719
730
  async getCurrentUser() {
720
731
  return this.getAuthenticatedUser.execute();
@@ -848,9 +859,9 @@ function useAuthActions() {
848
859
  const logout = useCallback2(() => {
849
860
  authController2.logout().then(() => dispatch({ type: "LOGOUT" }));
850
861
  }, [dispatch, authController2]);
851
- const register = useCallback2(async (email, password) => {
862
+ const register = useCallback2(async (email, password, attributes) => {
852
863
  dispatch({ type: "REQUEST" });
853
- const res = await authController2.register(email, password);
864
+ const res = await authController2.register(email, password, attributes);
854
865
  dispatchRegisterResult(res, dispatch);
855
866
  return res;
856
867
  }, [dispatch, authController2]);
@@ -872,7 +883,7 @@ function dispatchRegisterResult(res, dispatch) {
872
883
  }
873
884
  function getErrorMessage(error) {
874
885
  if (error instanceof HttpError) {
875
- return error.response.error ?? error.message;
886
+ return error.response.message;
876
887
  }
877
888
  return error.message;
878
889
  }
@@ -973,7 +984,7 @@ function httpResponse(data, status = 200) {
973
984
  return { data, status, headers: {} };
974
985
  }
975
986
  function unauthorized() {
976
- return new HttpError("Unauthorized", 401, { error: "Unauthorized" });
987
+ return new HttpError("Unauthorized", 401, { message: "Unauthorized", status: 401, name: "Unauthorized" });
977
988
  }
978
989
  var MockAuthHttpClient = class extends MockHttpClient {
979
990
  fixtures;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdspace/react",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",