@volr/react 0.1.84 → 0.1.85

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.cjs CHANGED
@@ -8984,6 +8984,10 @@ var init_call = __esm({
8984
8984
  });
8985
8985
  var VolrContext = react.createContext(null);
8986
8986
  var InternalAuthContext = react.createContext(null);
8987
+ var ERROR_CODES = {
8988
+ AUTH_PROJECT_NOT_FOUND: "AUTH_PROJECT_NOT_FOUND",
8989
+ AUTH_PROJECT_REQUIRED: "AUTH_PROJECT_REQUIRED",
8990
+ ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED"};
8987
8991
  function mapBackendError(error) {
8988
8992
  return new sdkCore.VolrError(error.code, error.message);
8989
8993
  }
@@ -9060,6 +9064,32 @@ var STORAGE_CHANNELS = {
9060
9064
  };
9061
9065
 
9062
9066
  // src/headless/client.ts
9067
+ var CONFIG_ERROR_CODES = [
9068
+ ERROR_CODES.AUTH_PROJECT_NOT_FOUND,
9069
+ ERROR_CODES.AUTH_PROJECT_REQUIRED,
9070
+ ERROR_CODES.ORIGIN_NOT_ALLOWED
9071
+ ];
9072
+ function logConfigurationError(errorCode, errorMessage) {
9073
+ const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
9074
+ const errorMessages = {
9075
+ [ERROR_CODES.AUTH_PROJECT_NOT_FOUND]: `[Volr SDK] \u274C Invalid projectApiKey: Project not found.
9076
+ Please verify your VolrProvider config.projectApiKey is correct.
9077
+ You can find your API key in the Volr Dashboard > Project Settings.`,
9078
+ [ERROR_CODES.AUTH_PROJECT_REQUIRED]: `[Volr SDK] \u274C Missing projectApiKey.
9079
+ Please provide projectApiKey in your VolrProvider config.
9080
+ Example: <VolrProvider config={{ projectApiKey: 'your-api-key', ... }}>`,
9081
+ [ERROR_CODES.ORIGIN_NOT_ALLOWED]: `[Volr SDK] \u274C Origin not allowed for this project.
9082
+ The current origin is not in your project's allowed origins list.
9083
+ Add this origin in Volr Dashboard > Project Settings > Security.`
9084
+ };
9085
+ const devMessage = errorMessages[errorCode] || `[Volr SDK] \u274C Configuration error: ${errorCode}
9086
+ ${errorMessage}`;
9087
+ if (isDevelopment) {
9088
+ console.error(devMessage);
9089
+ } else {
9090
+ console.error(`[Volr SDK] Configuration error: ${errorCode}. Check console in development mode for details.`);
9091
+ }
9092
+ }
9063
9093
  var APIClient = class {
9064
9094
  constructor(config) {
9065
9095
  this.refreshPromise = null;
@@ -9106,6 +9136,14 @@ var APIClient = class {
9106
9136
  async (error) => {
9107
9137
  const originalRequest = error.config;
9108
9138
  const requestUrl = originalRequest?.url || "";
9139
+ const responseData = error.response?.data;
9140
+ if (responseData && !responseData.ok && responseData.error) {
9141
+ const errorCode = responseData.error.code;
9142
+ const errorMessage = responseData.error.message;
9143
+ if (CONFIG_ERROR_CODES.includes(errorCode)) {
9144
+ logConfigurationError(errorCode, errorMessage);
9145
+ }
9146
+ }
9109
9147
  const publicAuthEndpoints = [
9110
9148
  "/auth/refresh",
9111
9149
  "/auth/siwe/nonce",