vesant-sdk 1.3.1 → 1.4.1

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.3.0";
227
+ var SDK_VERSION = "1.4.0";
228
228
 
229
229
  // src/shared/browser-utils.ts
230
230
  function generateUUID() {
@@ -318,6 +318,12 @@ var BaseClient = class {
318
318
  interceptors: this.interceptors,
319
319
  logger: this.logger
320
320
  };
321
+ if (this.config.environment === "sandbox" && this.config.apiKey?.startsWith("pk_live_")) {
322
+ this.logger.warn("Production API key used with sandbox environment. Use your sandbox API key (sk_sandbox_) instead.");
323
+ }
324
+ if (this.config.environment !== "sandbox" && this.config.apiKey?.startsWith("sk_sandbox_")) {
325
+ this.logger.warn("Sandbox API key used with production environment. Use your production API key (pk_live_) instead.");
326
+ }
321
327
  if (config.circuitBreaker) {
322
328
  this.circuitBreaker = new CircuitBreaker(config.circuitBreaker);
323
329
  }
@@ -341,8 +347,9 @@ var BaseClient = class {
341
347
  error.requestId = requestId;
342
348
  throw error;
343
349
  }
344
- const baseURL = this.config.environment === "sandbox" && this.config.sandboxBaseURL ? this.config.sandboxBaseURL : serviceURL || this.config.baseURL;
345
- const url = `${serviceURL || baseURL}${endpoint}`;
350
+ const DEFAULT_SANDBOX_URL = "https://sandbox-api.vesant.ai";
351
+ const resolvedBaseURL = this.config.environment === "sandbox" ? this.config.sandboxBaseURL || DEFAULT_SANDBOX_URL : serviceURL || this.config.baseURL;
352
+ const url = `${serviceURL || resolvedBaseURL}${endpoint}`;
346
353
  const headers = {
347
354
  "Content-Type": "application/json",
348
355
  "X-Tenant-ID": this.config.tenantId,
@@ -710,9 +717,13 @@ function encodePayload(payload) {
710
717
  async function generateCipherText(options, config) {
711
718
  const warnings = [];
712
719
  let requestLocation = options.requestLocation ?? false;
720
+ let gpsRequiredByConfig = false;
713
721
  if (config?.require_gps) {
714
722
  const reason = options.reason;
715
723
  if (reason === "login" && config.require_gps.login || reason === "registration" && config.require_gps.registration || reason === "transaction" && config.require_gps.transaction) {
724
+ if (!requestLocation) {
725
+ gpsRequiredByConfig = true;
726
+ }
716
727
  requestLocation = true;
717
728
  }
718
729
  }
@@ -725,6 +736,10 @@ async function generateCipherText(options, config) {
725
736
  );
726
737
  if (location) {
727
738
  locationData = location;
739
+ } else if (gpsRequiredByConfig) {
740
+ throw new Error(
741
+ `GPS location is required for ${options.reason} by tenant configuration, but GPS was not available or permission was denied`
742
+ );
728
743
  } else {
729
744
  warnings.push("GPS location not available or permission denied");
730
745
  }
@@ -1151,13 +1166,17 @@ var GeolocationClient = class extends BaseClient {
1151
1166
  */
1152
1167
  async generateCipherText(options, gpsConfig) {
1153
1168
  let signingKey = this.cachedSigningKey;
1169
+ let resolvedGpsConfig = gpsConfig;
1154
1170
  if (!signingKey) {
1155
1171
  const config = await this.getGPSConfig();
1156
1172
  signingKey = config.signing_key;
1173
+ if (!resolvedGpsConfig) {
1174
+ resolvedGpsConfig = config;
1175
+ }
1157
1176
  }
1158
1177
  return generateCipherText(
1159
1178
  { ...options, signingKey: signingKey || void 0 },
1160
- gpsConfig
1179
+ resolvedGpsConfig
1161
1180
  );
1162
1181
  }
1163
1182
  // ============================================================================