@stackframe/stack-shared 2.7.28 → 2.7.29

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.7.29
4
+
5
+ ### Patch Changes
6
+
7
+ - Various changes
8
+
3
9
  ## 2.7.28
4
10
 
5
11
  ### Patch Changes
@@ -116,7 +116,7 @@ export declare class StackClientInterface {
116
116
  signUpWithCredential(email: string, password: string, emailVerificationRedirectUrl: string, session: InternalSession): Promise<Result<{
117
117
  accessToken: string;
118
118
  refreshToken: string;
119
- }, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
119
+ }, KnownErrors["UserWithEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
120
120
  signInWithMagicLink(code: string): Promise<Result<{
121
121
  newUser: boolean;
122
122
  accessToken: string;
@@ -566,7 +566,7 @@ export class StackClientInterface {
566
566
  password,
567
567
  verification_callback_url: emailVerificationRedirectUrl,
568
568
  }),
569
- }, session, [KnownErrors.UserEmailAlreadyExists, KnownErrors.PasswordRequirementsNotMet]);
569
+ }, session, [KnownErrors.UserWithEmailAlreadyExists, KnownErrors.PasswordRequirementsNotMet]);
570
570
  if (res.status === "error") {
571
571
  return Result.error(res.error);
572
572
  }
@@ -204,7 +204,7 @@ export declare const KnownErrors: {
204
204
  };
205
205
  InvalidProjectForAccessToken: KnownErrorConstructor<KnownError & KnownErrorBrand<"SESSION_AUTHENTICATION_ERROR"> & {
206
206
  constructorArgs: [statusCode: number, humanReadableMessage: string, details?: Json | undefined];
207
- } & KnownErrorBrand<"INVALID_SESSION_AUTHENTICATION"> & KnownErrorBrand<"INVALID_ACCESS_TOKEN"> & KnownErrorBrand<"INVALID_PROJECT_FOR_ACCESS_TOKEN">, []> & {
207
+ } & KnownErrorBrand<"INVALID_SESSION_AUTHENTICATION"> & KnownErrorBrand<"INVALID_ACCESS_TOKEN"> & KnownErrorBrand<"INVALID_PROJECT_FOR_ACCESS_TOKEN">, [expectedProjectId: string, actualProjectId: string]> & {
208
208
  errorCode: "INVALID_PROJECT_FOR_ACCESS_TOKEN";
209
209
  };
210
210
  RefreshTokenError: KnownErrorConstructor<KnownError & KnownErrorBrand<"REFRESH_TOKEN_ERROR">, [statusCode: number, humanReadableMessage: string, details?: Json | undefined]> & {
@@ -220,7 +220,7 @@ export declare const KnownErrors: {
220
220
  } & KnownErrorBrand<"REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED">, []> & {
221
221
  errorCode: "REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED";
222
222
  };
223
- UserEmailAlreadyExists: KnownErrorConstructor<KnownError & KnownErrorBrand<"USER_EMAIL_ALREADY_EXISTS">, []> & {
223
+ UserWithEmailAlreadyExists: KnownErrorConstructor<KnownError & KnownErrorBrand<"USER_EMAIL_ALREADY_EXISTS">, [email: string]> & {
224
224
  errorCode: "USER_EMAIL_ALREADY_EXISTS";
225
225
  };
226
226
  EmailNotVerified: KnownErrorConstructor<KnownError & KnownErrorBrand<"EMAIL_NOT_VERIFIED">, []> & {
@@ -246,10 +246,14 @@ const AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCE
246
246
  `Access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
247
247
  { expired_at_millis: expiredAt?.getTime() ?? null },
248
248
  ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : undefined]);
249
- const InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", () => [
249
+ const InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
250
250
  401,
251
- "Access token not valid for this project.",
252
- ], () => []);
251
+ `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
252
+ {
253
+ expected_project_id: expectedProjectId,
254
+ actual_project_id: actualProjectId,
255
+ },
256
+ ], (json) => [json.expected_project_id, json.actual_project_id]);
253
257
  const RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
254
258
  const RefreshTokenNotFoundOrExpired = createKnownErrorConstructor(RefreshTokenError, "REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED", () => [
255
259
  401,
@@ -263,10 +267,13 @@ const ProviderRejected = createKnownErrorConstructor(RefreshTokenError, "PROVIDE
263
267
  401,
264
268
  "The provider refused to refresh their token. This usually means that the provider used to authenticate the user no longer regards this session as valid, and the user must re-authenticate.",
265
269
  ], () => []);
266
- const UserEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", () => [
270
+ const UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email) => [
267
271
  409,
268
- "User email already exists.",
269
- ], () => []);
272
+ `A user with email ${JSON.stringify(email)} already exists.`,
273
+ {
274
+ email,
275
+ },
276
+ ], (json) => [json.email]);
270
277
  const EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [
271
278
  400,
272
279
  "The email is not verified.",
@@ -590,7 +597,7 @@ export const KnownErrors = {
590
597
  RefreshTokenError,
591
598
  ProviderRejected,
592
599
  RefreshTokenNotFoundOrExpired,
593
- UserEmailAlreadyExists,
600
+ UserWithEmailAlreadyExists,
594
601
  EmailNotVerified,
595
602
  UserIdDoesNotExist,
596
603
  UserNotFound,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.7.28",
3
+ "version": "2.7.29",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",