vesant-sdk 1.4.4 → 1.4.5

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.
@@ -224,7 +224,7 @@ function createConsoleLogger() {
224
224
  }
225
225
 
226
226
  // src/core/version.ts
227
- var SDK_VERSION = "1.4.4";
227
+ var SDK_VERSION = "1.4.5";
228
228
 
229
229
  // src/shared/browser-utils.ts
230
230
  function generateUUID() {
@@ -308,9 +308,20 @@ var BaseClient = class {
308
308
  }
309
309
  this.interceptors = config.interceptors || [];
310
310
  this.logger = config.logger || createConsoleLogger();
311
+ let environment = config.environment;
312
+ const apiKey = config.apiKey || "";
313
+ if (apiKey.startsWith("pk_test_")) {
314
+ if (environment === "production") {
315
+ this.logger.warn('Sandbox API key (pk_test_*) used with environment: "production" \u2014 overriding to "sandbox"');
316
+ }
317
+ environment = "sandbox";
318
+ } else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
319
+ this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 the X-Sandbox header will be sent for backward compatibility');
320
+ }
311
321
  this.config = {
312
322
  ...config,
313
- apiKey: config.apiKey || "",
323
+ apiKey,
324
+ environment,
314
325
  headers: config.headers || {},
315
326
  timeout: config.timeout || 1e4,
316
327
  retries: config.retries || 3,