@insight-health/aura 0.0.4 → 0.0.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.
@@ -14,7 +14,7 @@ declare class AuraWidgetService {
14
14
  private postMessage;
15
15
  init: (params: AuraWidgetInitParams) => Promise<void>;
16
16
  registerTemplates: (payload: AuraRegisterTemplatePayload) => void;
17
- setUser: (params: Pick<AuraWidgetInitParams, "user" | "subTenantId" | "language">) => void;
17
+ setUser: (params: Pick<AuraWidgetInitParams, "tenantId" | "tenantName" | "user" | "language">) => void;
18
18
  show: () => void;
19
19
  hide: () => void;
20
20
  reset: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EAEpB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AA0BjB;;;GAGG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,cAAc,CAAsB;IAC5C,YAAY,EAAE,OAAO,CAAS;IAC9B,oBAAoB,EAAE,OAAO,CAAS;;IAatC,OAAO,CAAC,WAAW,CASjB;IAEF,IAAI,GAAI,QAAQ,oBAAoB,mBAgElC;IAEF,iBAAiB,GAAI,SAAS,2BAA2B,UAKvD;IAEF,OAAO,GACL,QAAQ,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,CAAC,UAiBvE;IAEF,IAAI,aAeF;IAEF,IAAI,aAIF;IAEF,KAAK,aASH;IAEF,IAAI,GAAI,OAAO,mBAAmB,UAGhC;IAEF,EAAE,GAAI,OAAO,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,gBAEhD;IAEF;;OAEG;IACH,SAAS,oCAEP;IACF,UAAU,eAER;CACH;AAgBD,eAAO,MAAM,UAAU,mBAAgB,CAAC"}
1
+ {"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EAEpB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AA0BjB;;;GAGG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,cAAc,CAAsB;IAC5C,YAAY,EAAE,OAAO,CAAS;IAC9B,oBAAoB,EAAE,OAAO,CAAS;;IAatC,OAAO,CAAC,WAAW,CASjB;IAEF,IAAI,GAAI,QAAQ,oBAAoB,mBAiElC;IAEF,iBAAiB,GAAI,SAAS,2BAA2B,UAKvD;IAEF,OAAO,GACL,QAAQ,IAAI,CACV,oBAAoB,EACpB,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAChD,UAmBD;IAEF,IAAI,aAeF;IAEF,IAAI,aAIF;IAEF,KAAK,aASH;IAEF,IAAI,GAAI,OAAO,mBAAmB,UAGhC;IAEF,EAAE,GAAI,OAAO,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,gBAEhD;IAEF;;OAEG;IACH,SAAS,oCAEP;IACF,UAAU,eAER;CACH;AAgBD,eAAO,MAAM,UAAU,mBAAgB,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W={insightBaseUrl:"https://anywhere.insighthealth.ai"};let f=null;function C(){return f}function v(s){f={...W,...s}}function B(s){v(s)}function g(){const s=C();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function m(){return"0.0.4"}class I{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(i=>i!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(i=>i(e))}}}const a=new I,c={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},l={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},U={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class H{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){c.warn("No widget iframe to communicate with");return}const e=g();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){this.reset();const i=g(),{subTenantId:r,user:o,language:w,container:d,widgetId:p,widgetStyles:n}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const b=(n==null?void 0:n.width)||"350px",F=(n==null?void 0:n.height)||"600px",y={...U,...n,...l};Object.assign(this.widgetFrame.style,y),this.widgetFrame.id=p||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=b,this.widgetFrame.__desiredHeight=F,this.widgetFrame.onerror=()=>{c.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C={insightBaseUrl:"https://anywhere.insighthealth.ai"};let m=null;function v(){return m}function B(s){m={...C,...s}}function I(s){B(s)}function d(){const s=v();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function w(){return"0.0.5"}class U{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(i=>i!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(i=>i(e))}}}const h=new U,l={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},f={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},H={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class S{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){l.warn("No widget iframe to communicate with");return}const e=d();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){this.reset();const i=d(),{tenantId:r,tenantName:o,user:a,language:p,container:c,widgetId:F,widgetStyles:n}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const b=(n==null?void 0:n.width)||"350px",y=(n==null?void 0:n.height)||"600px",A={...H,...n,...f};Object.assign(this.widgetFrame.style,A),this.widgetFrame.id=F||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=b,this.widgetFrame.__desiredHeight=y,this.widgetFrame.onerror=()=>{l.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
2
  frame-src ${i.insightBaseUrl}
3
- `)},(d&&document.querySelector(d)||document.body).appendChild(this.widgetFrame);const A=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:r,user:o,language:w})}),x=a.subscribe("Auth.Complete",()=>{var u;this.isFrameAuthenticated=!0,e(),(u=t.onAuthenticated)==null||u.call(t)});this.unsubsciptions.push(A,x)}}),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},this.setUser=t=>{const e=this.config.partnerKey,{subTenantId:i,user:r,language:o}=t;this.config.subTenantId=i,this.config.user=r,this.config.language=o,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,subTenantId:i,user:r,language:o}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...l})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>a.subscribe(t,e),this.getConfig=()=>this.config,this.getVersion=()=>m(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||a.emit(t.data.type,t.data.payload)})}}let h=null;function S(){return h||(h=new H),h}const $=S();exports.AuraWidget=$;exports.configure=B;exports.getConfig=g;exports.getVersion=m;
3
+ `)},(c&&document.querySelector(c)||document.body).appendChild(this.widgetFrame);const x=h.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:r,tenantName:o,user:a,language:p})}),W=h.subscribe("Auth.Complete",()=>{var u;this.isFrameAuthenticated=!0,e(),(u=t.onAuthenticated)==null||u.call(t)});this.unsubsciptions.push(x,W)}}),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},this.setUser=t=>{const e=this.config.partnerKey,{tenantId:i,tenantName:r,user:o,language:a}=t;this.config.tenantId=i,this.config.tenantName=r,this.config.user=o,this.config.language=a,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,tenantId:i,tenantName:r,user:o,language:a}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...f})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>h.subscribe(t,e),this.getConfig=()=>this.config,this.getVersion=()=>w(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||h.emit(t.data.type,t.data.payload)})}}let g=null;function $(){return g||(g=new S),g}const E=$();exports.AuraWidget=E;exports.configure=I;exports.getConfig=d;exports.getVersion=w;
package/dist/index.js CHANGED
@@ -1,28 +1,28 @@
1
- const A = {
1
+ const W = {
2
2
  insightBaseUrl: "https://anywhere.insighthealth.ai"
3
3
  };
4
- let f = null;
5
- function W() {
6
- return f;
4
+ let m = null;
5
+ function C() {
6
+ return m;
7
7
  }
8
- function C(s) {
9
- f = { ...A, ...s };
8
+ function B(s) {
9
+ m = { ...W, ...s };
10
10
  }
11
- function $(s) {
12
- C(s);
11
+ function E(s) {
12
+ B(s);
13
13
  }
14
14
  function u() {
15
- const s = W();
15
+ const s = C();
16
16
  if (!s)
17
17
  throw new Error(
18
18
  "Aura SDK not configured. Call configure() first to set global configuration."
19
19
  );
20
20
  return s;
21
21
  }
22
- function B() {
23
- return "0.0.4";
22
+ function I() {
23
+ return "0.0.5";
24
24
  }
25
- class I {
25
+ class U {
26
26
  constructor() {
27
27
  this.events = {}, this.subscribe = (t, e) => (this.events[t] || (this.events[t] = []), this.events[t].push(e), () => {
28
28
  this.events[t] = this.events[t].filter((i) => i !== e);
@@ -31,7 +31,7 @@ class I {
31
31
  };
32
32
  }
33
33
  }
34
- const a = new I(), c = {
34
+ const h = new U(), l = {
35
35
  log: (s) => {
36
36
  console.log(`[Insight Health Aura Widget]: ${s}`);
37
37
  },
@@ -41,14 +41,14 @@ const a = new I(), c = {
41
41
  error: (s) => {
42
42
  console.error(`[Insight Health Aura Widget]: ${s}`);
43
43
  }
44
- }, l = {
44
+ }, f = {
45
45
  opacity: "0",
46
46
  pointerEvents: "none",
47
47
  width: "0",
48
48
  height: "0",
49
49
  maxWidth: "0",
50
50
  maxHeight: "0"
51
- }, U = {
51
+ }, v = {
52
52
  border: "none",
53
53
  borderRadius: "10px",
54
54
  boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
@@ -60,12 +60,12 @@ const a = new I(), c = {
60
60
  transition: "opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",
61
61
  zIndex: "9999"
62
62
  };
63
- class v {
63
+ class H {
64
64
  constructor() {
65
65
  this.config = null, this.widgetFrame = null, this.unsubsciptions = [], this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.postMessage = (t) => {
66
66
  var i;
67
67
  if (!((i = this.widgetFrame) != null && i.contentWindow)) {
68
- c.warn("No widget iframe to communicate with");
68
+ l.warn("No widget iframe to communicate with");
69
69
  return;
70
70
  }
71
71
  const e = u();
@@ -76,39 +76,40 @@ class v {
76
76
  if (!this.widgetFrame) {
77
77
  this.reset();
78
78
  const i = u(), {
79
- subTenantId: r,
79
+ tenantId: r,
80
+ tenantName: a,
80
81
  user: o,
81
- language: m,
82
+ language: w,
82
83
  container: d,
83
- widgetId: w,
84
+ widgetId: p,
84
85
  widgetStyles: n
85
86
  } = t;
86
87
  this.config = t, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
87
- const p = (n == null ? void 0 : n.width) || "350px", F = (n == null ? void 0 : n.height) || "600px", b = {
88
- ...U,
88
+ const F = (n == null ? void 0 : n.width) || "350px", b = (n == null ? void 0 : n.height) || "600px", y = {
89
+ ...v,
89
90
  ...n,
90
- ...l
91
+ ...f
91
92
  };
92
- Object.assign(this.widgetFrame.style, b), this.widgetFrame.id = w || "aura-widget", this.widgetFrame.setAttribute(
93
+ Object.assign(this.widgetFrame.style, y), this.widgetFrame.id = p || "aura-widget", this.widgetFrame.setAttribute(
93
94
  "allow",
94
95
  `microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`
95
- ), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = p, this.widgetFrame.__desiredHeight = F, this.widgetFrame.onerror = () => {
96
- c.error(
96
+ ), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = F, this.widgetFrame.__desiredHeight = b, this.widgetFrame.onerror = () => {
97
+ l.error(
97
98
  `Failed to load iframe. Please ensure your Content Security Policy includes:
98
99
  frame-src ${i.insightBaseUrl}
99
100
  `
100
101
  );
101
102
  }, (d && document.querySelector(d) || document.body).appendChild(this.widgetFrame);
102
- const y = a.subscribe("Auth.Ready", () => {
103
- this.isFrameReady = !0, this.setUser({ subTenantId: r, user: o, language: m });
104
- }), x = a.subscribe(
103
+ const x = h.subscribe("Auth.Ready", () => {
104
+ this.isFrameReady = !0, this.setUser({ tenantId: r, tenantName: a, user: o, language: w });
105
+ }), A = h.subscribe(
105
106
  "Auth.Complete",
106
107
  () => {
107
- var g;
108
- this.isFrameAuthenticated = !0, e(), (g = t.onAuthenticated) == null || g.call(t);
108
+ var c;
109
+ this.isFrameAuthenticated = !0, e(), (c = t.onAuthenticated) == null || c.call(t);
109
110
  }
110
111
  );
111
- this.unsubsciptions.push(y, x);
112
+ this.unsubsciptions.push(x, A);
112
113
  }
113
114
  }), this.registerTemplates = (t) => {
114
115
  this.postMessage({
@@ -116,13 +117,14 @@ class v {
116
117
  payload: t
117
118
  });
118
119
  }, this.setUser = (t) => {
119
- const e = this.config.partnerKey, { subTenantId: i, user: r, language: o } = t;
120
- this.config.subTenantId = i, this.config.user = r, this.config.language = o, this.isFrameAuthenticated = !1, this.postMessage({
120
+ const e = this.config.partnerKey, { tenantId: i, tenantName: r, user: a, language: o } = t;
121
+ this.config.tenantId = i, this.config.tenantName = r, this.config.user = a, this.config.language = o, this.isFrameAuthenticated = !1, this.postMessage({
121
122
  type: "Auth.Login",
122
123
  payload: {
123
124
  partnerKey: e,
124
- subTenantId: i,
125
- user: r,
125
+ tenantId: i,
126
+ tenantName: r,
127
+ user: a,
126
128
  language: o
127
129
  }
128
130
  });
@@ -139,28 +141,28 @@ class v {
139
141
  Object.assign(this.widgetFrame.style, { ...i });
140
142
  }
141
143
  }, this.hide = () => {
142
- this.widgetFrame && Object.assign(this.widgetFrame.style, { ...l });
144
+ this.widgetFrame && Object.assign(this.widgetFrame.style, { ...f });
143
145
  }, this.reset = () => {
144
146
  this.widgetFrame && this.widgetFrame.remove(), this.widgetFrame = null, this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.unsubsciptions.forEach((t) => t == null ? void 0 : t()), this.unsubsciptions = [];
145
147
  }, this.emit = (t) => {
146
148
  this.postMessage(t), this.show();
147
- }, this.on = (t, e) => a.subscribe(t, e), this.getConfig = () => this.config, this.getVersion = () => B(), window.addEventListener(
149
+ }, this.on = (t, e) => h.subscribe(t, e), this.getConfig = () => this.config, this.getVersion = () => I(), window.addEventListener(
148
150
  "message",
149
151
  (t) => {
150
152
  var e;
151
- t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || a.emit(t.data.type, t.data.payload);
153
+ t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || h.emit(t.data.type, t.data.payload);
152
154
  }
153
155
  );
154
156
  }
155
157
  }
156
- let h = null;
157
- function H() {
158
- return h || (h = new v()), h;
158
+ let g = null;
159
+ function $() {
160
+ return g || (g = new H()), g;
159
161
  }
160
- const E = H();
162
+ const R = $();
161
163
  export {
162
- E as AuraWidget,
163
- $ as configure,
164
+ R as AuraWidget,
165
+ E as configure,
164
166
  u as getConfig,
165
- B as getVersion
167
+ I as getVersion
166
168
  };
package/dist/index.umd.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.InsightAura={}))})(this,function(n){"use strict";const o={insightBaseUrl:"https://anywhere.insighthealth.ai"};let c=null;function b(){return c}function F(s){c={...o,...s}}function y(s){F(s)}function g(){const s=b();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function l(){return"0.0.4"}class A{constructor(){this.events={},this.subscribe=(e,t)=>(this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(i=>i!==t)}),this.emit=(e,t)=>{this.events[e]&&this.events[e].forEach(i=>i(t))}}}const a=new A,f={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},m={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},x={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class W{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=e=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){f.warn("No widget iframe to communicate with");return}const t=g();this.widgetFrame.contentWindow.postMessage(e,{targetOrigin:t.insightBaseUrl})},this.init=e=>new Promise(t=>{if(!this.widgetFrame){this.reset();const i=g(),{subTenantId:h,user:d,language:v,container:w,widgetId:B,widgetStyles:r}=e;this.config=e,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const U=(r==null?void 0:r.width)||"350px",H=(r==null?void 0:r.height)||"600px",S={...x,...r,...m};Object.assign(this.widgetFrame.style,S),this.widgetFrame.id=B||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=U,this.widgetFrame.__desiredHeight=H,this.widgetFrame.onerror=()=>{f.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
1
+ (function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.InsightAura={}))})(this,function(n){"use strict";const o={insightBaseUrl:"https://anywhere.insighthealth.ai"};let l=null;function b(){return l}function y(s){l={...o,...s}}function A(s){y(s)}function u(){const s=b();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function f(){return"0.0.5"}class x{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(i=>i!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(i=>i(e))}}}const a=new x,m={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},w={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},W={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class C{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){m.warn("No widget iframe to communicate with");return}const e=u();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){this.reset();const i=u(),{tenantId:h,tenantName:d,user:g,language:B,container:p,widgetId:U,widgetStyles:r}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const H=(r==null?void 0:r.width)||"350px",S=(r==null?void 0:r.height)||"600px",$={...W,...r,...w};Object.assign(this.widgetFrame.style,$),this.widgetFrame.id=U||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=H,this.widgetFrame.__desiredHeight=S,this.widgetFrame.onerror=()=>{m.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
2
  frame-src ${i.insightBaseUrl}
3
- `)},(w&&document.querySelector(w)||document.body).appendChild(this.widgetFrame);const $=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:h,user:d,language:v})}),E=a.subscribe("Auth.Complete",()=>{var p;this.isFrameAuthenticated=!0,t(),(p=e.onAuthenticated)==null||p.call(e)});this.unsubsciptions.push($,E)}}),this.registerTemplates=e=>{this.postMessage({type:"Template.Register",payload:e})},this.setUser=e=>{const t=this.config.partnerKey,{subTenantId:i,user:h,language:d}=e;this.config.subTenantId=i,this.config.user=h,this.config.language=d,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:t,subTenantId:i,user:h,language:d}})},this.show=()=>{if(this.widgetFrame){const e=this.widgetFrame.__desiredWidth||"350px",t=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:e,height:t,maxWidth:e,maxHeight:t};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...m})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(e=>e==null?void 0:e()),this.unsubsciptions=[]},this.emit=e=>{this.postMessage(e),this.show()},this.on=(e,t)=>a.subscribe(e,t),this.getConfig=()=>this.config,this.getVersion=()=>l(),window.addEventListener("message",e=>{var t;e.source!==((t=this.widgetFrame)==null?void 0:t.contentWindow)||!e.data||a.emit(e.data.type,e.data.payload)})}}let u=null;function C(){return u||(u=new W),u}const I=C();n.AuraWidget=I,n.configure=y,n.getConfig=g,n.getVersion=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
3
+ `)},(p&&document.querySelector(p)||document.body).appendChild(this.widgetFrame);const E=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:h,tenantName:d,user:g,language:B})}),R=a.subscribe("Auth.Complete",()=>{var F;this.isFrameAuthenticated=!0,e(),(F=t.onAuthenticated)==null||F.call(t)});this.unsubsciptions.push(E,R)}}),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},this.setUser=t=>{const e=this.config.partnerKey,{tenantId:i,tenantName:h,user:d,language:g}=t;this.config.tenantId=i,this.config.tenantName=h,this.config.user=d,this.config.language=g,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,tenantId:i,tenantName:h,user:d,language:g}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...w})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>a.subscribe(t,e),this.getConfig=()=>this.config,this.getVersion=()=>f(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||a.emit(t.data.type,t.data.payload)})}}let c=null;function I(){return c||(c=new C),c}const v=I();n.AuraWidget=v,n.configure=A,n.getConfig=u,n.getVersion=f,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/dist/types.d.ts CHANGED
@@ -4,7 +4,8 @@ export type AuraWidgetEmitEvent<T = any> = {
4
4
  };
5
5
  export type AuraWidgetInitParams = {
6
6
  partnerKey: string;
7
- subTenantId: string;
7
+ tenantId: string | number;
8
+ tenantName: string;
8
9
  user: {
9
10
  email: string;
10
11
  firstName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,GAAG,IAAI;IACzC,IAAI,EAAE,MAAM,C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package for Insight Health AI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",