hypercrm 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/assets/widget.js +28 -3
  2. package/package.json +1 -1
package/assets/widget.js CHANGED
@@ -1157,6 +1157,15 @@
1157
1157
  letter-spacing: 0;
1158
1158
  }
1159
1159
 
1160
+ .hypercrm-powered a {
1161
+ color: inherit;
1162
+ text-decoration: none;
1163
+ }
1164
+
1165
+ .hypercrm-powered a:hover {
1166
+ text-decoration: underline;
1167
+ }
1168
+
1160
1169
  .hypercrm-events-grid {
1161
1170
  display: flex;
1162
1171
  flex-direction: column;
@@ -1599,7 +1608,7 @@
1599
1608
  </div>
1600
1609
  <div id="hypercrm-attachment-chips" class="hypercrm-attachment-chips"></div>
1601
1610
  <div id="hypercrm-composer-note" class="hypercrm-composer-note"></div>
1602
- <div class="hypercrm-powered">Powered by HyperCRM</div>
1611
+ <div class="hypercrm-powered">Powered by <a href="https://hypercrm.dev" target="_blank" rel="noopener noreferrer">HyperCRM</a></div>
1603
1612
  </div>
1604
1613
  </div>
1605
1614
  </div>
@@ -2716,13 +2725,28 @@
2716
2725
  try {
2717
2726
  if (!this.orgInfo) await this.loadOrgInfo();
2718
2727
  if (!this.orgInfo?.id) return;
2728
+ let socketToken = null;
2729
+ try {
2730
+ const tokenResp = await fetch(`${this.apiUrl}/organizations/public/socket-token`, {
2731
+ headers: { 'X-API-Key': this.apiKey },
2732
+ });
2733
+ if (tokenResp.ok) {
2734
+ const tokenJson = await tokenResp.json();
2735
+ socketToken = tokenJson?.token || null;
2736
+ }
2737
+ } catch (_) {}
2738
+ if (!socketToken) return;
2719
2739
  await this.loadSocketIoScript();
2720
2740
  if (this.socket) {
2721
2741
  try { this.socket.disconnect(); } catch (_) {}
2722
2742
  this.socket = null;
2723
2743
  }
2724
2744
  if (!global.io) return;
2725
- this.socket = global.io(this.apiOrigin, { transports: ['websocket'], forceNew: true });
2745
+ this.socket = global.io(this.apiOrigin, {
2746
+ transports: ['websocket'],
2747
+ forceNew: true,
2748
+ auth: { token: socketToken },
2749
+ });
2726
2750
  this.socket.on('connect', () => {
2727
2751
  this.socketConnected = true;
2728
2752
  try { this.socket.emit('join-organization', this.orgInfo.id); } catch (_) {}
@@ -2903,7 +2927,8 @@
2903
2927
 
2904
2928
  let activeWidget = null;
2905
2929
  const defaultOptions = global.HyperCRM_WIDGET_OPTIONS || {};
2906
- const shouldAutoInit = defaultOptions.autoInit !== false;
2930
+ const hasAutoConfig = !!(defaultOptions.apiUrl || defaultOptions.apiKey || defaultOptions.orgId || defaultOptions.scriptUrl);
2931
+ const shouldAutoInit = defaultOptions.autoInit !== false && hasAutoConfig;
2907
2932
 
2908
2933
  const api = {
2909
2934
  init(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercrm",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "HyperCRM widget loader with optional React component.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",