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