@asiyst/sdk 0.1.9 → 0.1.11

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.d.cts CHANGED
@@ -217,6 +217,7 @@ declare const Asiyst: {
217
217
  close(): void;
218
218
  getConfig(): ProjectConfig;
219
219
  getConnectionStatus(): "connected" | "disconnected" | "offline";
220
+ getVerificationStatus(): "connected" | "inactive" | "not_detected" | "error";
220
221
  avatar: {
221
222
  show(): void;
222
223
  hide(): void;
package/dist/index.d.ts CHANGED
@@ -217,6 +217,7 @@ declare const Asiyst: {
217
217
  close(): void;
218
218
  getConfig(): ProjectConfig;
219
219
  getConnectionStatus(): "connected" | "disconnected" | "offline";
220
+ getVerificationStatus(): "connected" | "inactive" | "not_detected" | "error";
220
221
  avatar: {
221
222
  show(): void;
222
223
  hide(): void;
package/dist/index.js CHANGED
@@ -458,9 +458,10 @@ var HttpTransport = class {
458
458
 
459
459
  // src/communication/CloudClient.ts
460
460
  var CloudClient = class {
461
- constructor(transport, projectId) {
461
+ constructor(transport, projectId, publicKey = "") {
462
462
  this.transport = transport;
463
463
  this.projectId = projectId;
464
+ this.publicKey = publicKey;
464
465
  }
465
466
  async fetchConfig() {
466
467
  const response = await this.transport.request({
@@ -480,14 +481,22 @@ var CloudClient = class {
480
481
  path: "/sdk/heartbeat",
481
482
  method: "POST",
482
483
  body: {
483
- projectId: this.projectId,
484
- sdkVersion: SDK_VERSION,
485
- websiteOrigin: metadata.origin,
484
+ project_id: this.projectId,
485
+ public_key: this.publicKey,
486
+ sdk_version: SDK_VERSION,
487
+ origin: metadata.origin,
486
488
  environment: metadata.environment,
487
489
  timestamp: metadata.timestamp
488
490
  }
489
491
  });
490
- return { ok: response.ok, status: response.status };
492
+ const body = response.data && typeof response.data === "object" && !Array.isArray(response.data) ? response.data : void 0;
493
+ const rawStatus = body?.status ?? body?.connectionStatus ?? body?.verificationStatus;
494
+ const verificationStatus = rawStatus === "connected" || rawStatus === "inactive" || rawStatus === "not_detected" || rawStatus === "error" ? rawStatus : void 0;
495
+ return {
496
+ ok: response.ok && (verificationStatus === void 0 || verificationStatus === "connected"),
497
+ status: response.status,
498
+ verificationStatus
499
+ };
491
500
  }
492
501
  async requestTask(userText, pageUrl) {
493
502
  const response = await this.transport.request({
@@ -2361,6 +2370,7 @@ var AsiystRuntime = class {
2361
2370
  this.observer = new DomObserver(() => this.rescan());
2362
2371
  this.destroyed = false;
2363
2372
  this.connectionStatus = "disconnected";
2373
+ this.verificationStatus = "not_detected";
2364
2374
  this.rescanDebounced = debounce(() => this.rescan(), DOM_SCAN_DEBOUNCE_MS);
2365
2375
  if (!doc.body) {
2366
2376
  throw new InitializationError("document.body is not available");
@@ -2372,7 +2382,7 @@ var AsiystRuntime = class {
2372
2382
  publicKey: options.publicKey,
2373
2383
  avatarId: options.avatarId
2374
2384
  });
2375
- this.cloud = new CloudClient(transport, options.projectId);
2385
+ this.cloud = new CloudClient(transport, options.projectId, options.publicKey);
2376
2386
  this.config = new ConfigManager(options, this.cloud, this.events);
2377
2387
  this.analytics = new Analytics(options.projectId, this.cloud);
2378
2388
  this.host = new HostRoot(doc);
@@ -2430,6 +2440,7 @@ var AsiystRuntime = class {
2430
2440
  const domainCheck = validateWebsiteDomain(cfg, window.location.href);
2431
2441
  if (!domainCheck.allowed) {
2432
2442
  this.connectionStatus = "disconnected";
2443
+ this.verificationStatus = "not_detected";
2433
2444
  this.events.emit("asiyst:error", {
2434
2445
  code: "domain_not_authorized",
2435
2446
  message: "This website is not authorized for the current Asiyst project."
@@ -2445,14 +2456,19 @@ var AsiystRuntime = class {
2445
2456
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2446
2457
  });
2447
2458
  this.connectionStatus = heartbeat.ok ? "connected" : "disconnected";
2459
+ this.verificationStatus = heartbeat.verificationStatus ?? (heartbeat.ok ? "connected" : "not_detected");
2448
2460
  } catch {
2449
2461
  this.connectionStatus = "offline";
2462
+ this.verificationStatus = "error";
2450
2463
  }
2451
2464
  this.events.emit("asiyst:ready", { projectId: this.options.projectId, configVersion: cfg.version });
2452
2465
  }
2453
2466
  getConnectionStatus() {
2454
2467
  return this.connectionStatus;
2455
2468
  }
2469
+ getVerificationStatus() {
2470
+ return this.verificationStatus;
2471
+ }
2456
2472
  getConfig() {
2457
2473
  return this.config.get();
2458
2474
  }
@@ -2575,6 +2591,9 @@ var Asiyst = {
2575
2591
  getConnectionStatus() {
2576
2592
  return requireRuntime().getConnectionStatus();
2577
2593
  },
2594
+ getVerificationStatus() {
2595
+ return requireRuntime().getVerificationStatus();
2596
+ },
2578
2597
  avatar: {
2579
2598
  show() {
2580
2599
  withIsolation(() => requireRuntime().avatarApi().show());