@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 +38 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8960,6 +8960,10 @@ var init_call = __esm({
|
|
|
8960
8960
|
});
|
|
8961
8961
|
var VolrContext = createContext(null);
|
|
8962
8962
|
var InternalAuthContext = createContext(null);
|
|
8963
|
+
var ERROR_CODES = {
|
|
8964
|
+
AUTH_PROJECT_NOT_FOUND: "AUTH_PROJECT_NOT_FOUND",
|
|
8965
|
+
AUTH_PROJECT_REQUIRED: "AUTH_PROJECT_REQUIRED",
|
|
8966
|
+
ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED"};
|
|
8963
8967
|
function mapBackendError(error) {
|
|
8964
8968
|
return new VolrError(error.code, error.message);
|
|
8965
8969
|
}
|
|
@@ -9036,6 +9040,32 @@ var STORAGE_CHANNELS = {
|
|
|
9036
9040
|
};
|
|
9037
9041
|
|
|
9038
9042
|
// src/headless/client.ts
|
|
9043
|
+
var CONFIG_ERROR_CODES = [
|
|
9044
|
+
ERROR_CODES.AUTH_PROJECT_NOT_FOUND,
|
|
9045
|
+
ERROR_CODES.AUTH_PROJECT_REQUIRED,
|
|
9046
|
+
ERROR_CODES.ORIGIN_NOT_ALLOWED
|
|
9047
|
+
];
|
|
9048
|
+
function logConfigurationError(errorCode, errorMessage) {
|
|
9049
|
+
const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
9050
|
+
const errorMessages = {
|
|
9051
|
+
[ERROR_CODES.AUTH_PROJECT_NOT_FOUND]: `[Volr SDK] \u274C Invalid projectApiKey: Project not found.
|
|
9052
|
+
Please verify your VolrProvider config.projectApiKey is correct.
|
|
9053
|
+
You can find your API key in the Volr Dashboard > Project Settings.`,
|
|
9054
|
+
[ERROR_CODES.AUTH_PROJECT_REQUIRED]: `[Volr SDK] \u274C Missing projectApiKey.
|
|
9055
|
+
Please provide projectApiKey in your VolrProvider config.
|
|
9056
|
+
Example: <VolrProvider config={{ projectApiKey: 'your-api-key', ... }}>`,
|
|
9057
|
+
[ERROR_CODES.ORIGIN_NOT_ALLOWED]: `[Volr SDK] \u274C Origin not allowed for this project.
|
|
9058
|
+
The current origin is not in your project's allowed origins list.
|
|
9059
|
+
Add this origin in Volr Dashboard > Project Settings > Security.`
|
|
9060
|
+
};
|
|
9061
|
+
const devMessage = errorMessages[errorCode] || `[Volr SDK] \u274C Configuration error: ${errorCode}
|
|
9062
|
+
${errorMessage}`;
|
|
9063
|
+
if (isDevelopment) {
|
|
9064
|
+
console.error(devMessage);
|
|
9065
|
+
} else {
|
|
9066
|
+
console.error(`[Volr SDK] Configuration error: ${errorCode}. Check console in development mode for details.`);
|
|
9067
|
+
}
|
|
9068
|
+
}
|
|
9039
9069
|
var APIClient = class {
|
|
9040
9070
|
constructor(config) {
|
|
9041
9071
|
this.refreshPromise = null;
|
|
@@ -9082,6 +9112,14 @@ var APIClient = class {
|
|
|
9082
9112
|
async (error) => {
|
|
9083
9113
|
const originalRequest = error.config;
|
|
9084
9114
|
const requestUrl = originalRequest?.url || "";
|
|
9115
|
+
const responseData = error.response?.data;
|
|
9116
|
+
if (responseData && !responseData.ok && responseData.error) {
|
|
9117
|
+
const errorCode = responseData.error.code;
|
|
9118
|
+
const errorMessage = responseData.error.message;
|
|
9119
|
+
if (CONFIG_ERROR_CODES.includes(errorCode)) {
|
|
9120
|
+
logConfigurationError(errorCode, errorMessage);
|
|
9121
|
+
}
|
|
9122
|
+
}
|
|
9085
9123
|
const publicAuthEndpoints = [
|
|
9086
9124
|
"/auth/refresh",
|
|
9087
9125
|
"/auth/siwe/nonce",
|