hypercrm 1.0.1 → 1.0.4

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