@meistrari/auth-core 1.28.0 → 1.28.1

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.d.mts CHANGED
@@ -712,7 +712,13 @@ type DeviceAuthorizationActionResponse = {
712
712
  * `ApplicationError` to handle any application-related failure.
713
713
  */
714
714
  declare class ApplicationError extends BaseError {
715
- constructor(message: string, options?: ErrorOptions);
715
+ /**
716
+ * HTTP status of the upstream failure, when one was received.
717
+ */
718
+ readonly status?: number;
719
+ constructor(message: string, options?: ErrorOptions & {
720
+ status?: number;
721
+ });
716
722
  }
717
723
  /**
718
724
  * Thrown when a refresh token has expired or been revoked.
@@ -721,7 +727,9 @@ declare class ApplicationError extends BaseError {
721
727
  * to re-authenticate.
722
728
  */
723
729
  declare class RefreshTokenExpiredError extends ApplicationError {
724
- constructor(options?: ErrorOptions);
730
+ constructor(options?: ErrorOptions & {
731
+ status?: number;
732
+ });
725
733
  }
726
734
  /**
727
735
  * Thrown when an authorization flow fails unexpectedly.
@@ -903,7 +911,7 @@ declare class ApplicationService {
903
911
  * @throws {RefreshTokenExpiredError} When the refresh token has expired or is invalid
904
912
  * @throws {ApplicationError} For other API errors
905
913
  */
906
- refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse | null>;
914
+ refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse>;
907
915
  /**
908
916
  * Gets the current user and organization for a specific application.
909
917
  *
package/dist/index.d.ts CHANGED
@@ -712,7 +712,13 @@ type DeviceAuthorizationActionResponse = {
712
712
  * `ApplicationError` to handle any application-related failure.
713
713
  */
714
714
  declare class ApplicationError extends BaseError {
715
- constructor(message: string, options?: ErrorOptions);
715
+ /**
716
+ * HTTP status of the upstream failure, when one was received.
717
+ */
718
+ readonly status?: number;
719
+ constructor(message: string, options?: ErrorOptions & {
720
+ status?: number;
721
+ });
716
722
  }
717
723
  /**
718
724
  * Thrown when a refresh token has expired or been revoked.
@@ -721,7 +727,9 @@ declare class ApplicationError extends BaseError {
721
727
  * to re-authenticate.
722
728
  */
723
729
  declare class RefreshTokenExpiredError extends ApplicationError {
724
- constructor(options?: ErrorOptions);
730
+ constructor(options?: ErrorOptions & {
731
+ status?: number;
732
+ });
725
733
  }
726
734
  /**
727
735
  * Thrown when an authorization flow fails unexpectedly.
@@ -903,7 +911,7 @@ declare class ApplicationService {
903
911
  * @throws {RefreshTokenExpiredError} When the refresh token has expired or is invalid
904
912
  * @throws {ApplicationError} For other API errors
905
913
  */
906
- refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse | null>;
914
+ refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse>;
907
915
  /**
908
916
  * Gets the current user and organization for a specific application.
909
917
  *
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { defaultStatements } from 'better-auth/plugins/organization/access';
8
8
  import z, { z as z$1 } from 'zod';
9
9
  export { APIError } from 'better-auth';
10
10
 
11
- const version = "1.28.0";
11
+ const version = "1.28.1";
12
12
 
13
13
  function parsedEnumValues(schema) {
14
14
  return Object.fromEntries(
@@ -579,8 +579,13 @@ class BaseError extends Error {
579
579
  }
580
580
 
581
581
  class ApplicationError extends BaseError {
582
+ /**
583
+ * HTTP status of the upstream failure, when one was received.
584
+ */
585
+ status;
582
586
  constructor(message, options) {
583
587
  super("APPLICATION_ERROR", message, options);
588
+ this.status = options?.status;
584
589
  }
585
590
  }
586
591
  class RefreshTokenExpiredError extends ApplicationError {
@@ -1030,11 +1035,11 @@ class ApplicationService {
1030
1035
  async refreshAccessToken(refreshToken) {
1031
1036
  const handleRefreshError = (error) => {
1032
1037
  const status = error?.status;
1033
- if (status === 404) {
1034
- throw new RefreshTokenExpiredError({ cause: error });
1038
+ if (status === 401 || status === 404) {
1039
+ throw new RefreshTokenExpiredError({ cause: error, status });
1035
1040
  }
1036
1041
  const message = error?.message;
1037
- throw new ApplicationError(message || "Failed to refresh access token", { cause: error });
1042
+ throw new ApplicationError(message || "Failed to refresh access token", { cause: error, status });
1038
1043
  };
1039
1044
  try {
1040
1045
  const response = await this.client.applications.refreshAccessToken(refreshToken);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-core",
3
- "version": "1.28.0",
3
+ "version": "1.28.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {