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.
package/dist/index.mjs CHANGED
@@ -239,7 +239,7 @@ var noopLogger = {
239
239
  };
240
240
 
241
241
  // src/core/version.ts
242
- var SDK_VERSION = "1.4.4";
242
+ var SDK_VERSION = "1.4.5";
243
243
 
244
244
  // src/shared/browser-utils.ts
245
245
  function generateUUID() {
@@ -323,9 +323,20 @@ var BaseClient = class {
323
323
  }
324
324
  this.interceptors = config.interceptors || [];
325
325
  this.logger = config.logger || createConsoleLogger();
326
+ let environment = config.environment;
327
+ const apiKey = config.apiKey || "";
328
+ if (apiKey.startsWith("pk_test_")) {
329
+ if (environment === "production") {
330
+ this.logger.warn('Sandbox API key (pk_test_*) used with environment: "production" \u2014 overriding to "sandbox"');
331
+ }
332
+ environment = "sandbox";
333
+ } else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
334
+ this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 the X-Sandbox header will be sent for backward compatibility');
335
+ }
326
336
  this.config = {
327
337
  ...config,
328
- apiKey: config.apiKey || "",
338
+ apiKey,
339
+ environment,
329
340
  headers: config.headers || {},
330
341
  timeout: config.timeout || 1e4,
331
342
  retries: config.retries || 3,