@memberstack/dom 1.9.33 → 1.9.34

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/lib/auth/index.js CHANGED
@@ -65,11 +65,20 @@ function isLocalStorageAvailable() {
65
65
  }
66
66
  var localStorageAvailable = isLocalStorageAvailable();
67
67
  var setCookieOnRootDomain = false;
68
+ var extractDomainFromHostname = (hostname) => {
69
+ const hostnameParts = hostname.split(".");
70
+ const isCountryCodeTLD = hostnameParts.length >= 3 && hostnameParts[hostnameParts.length - 2].length <= 3;
71
+ if (isCountryCodeTLD) {
72
+ return hostnameParts.slice(-3).join(".");
73
+ } else {
74
+ return hostnameParts.slice(-2).join(".");
75
+ }
76
+ };
68
77
  var removeMemberToken = () => {
69
78
  if (localStorageAvailable) {
70
79
  localStorage.removeItem(memberAuthTokenName);
71
80
  }
72
- const domain = window.location.hostname.split(".").slice(-2).join(".");
81
+ const domain = extractDomainFromHostname(window.location.hostname);
73
82
  import_js_cookie.default.set(memberAuthTokenName, "", __spreadValues({
74
83
  expires: -1,
75
84
  sameSite: "strict"
@@ -29,11 +29,20 @@ function isLocalStorageAvailable() {
29
29
  }
30
30
  var localStorageAvailable = isLocalStorageAvailable();
31
31
  var setCookieOnRootDomain = false;
32
+ var extractDomainFromHostname = (hostname) => {
33
+ const hostnameParts = hostname.split(".");
34
+ const isCountryCodeTLD = hostnameParts.length >= 3 && hostnameParts[hostnameParts.length - 2].length <= 3;
35
+ if (isCountryCodeTLD) {
36
+ return hostnameParts.slice(-3).join(".");
37
+ } else {
38
+ return hostnameParts.slice(-2).join(".");
39
+ }
40
+ };
32
41
  var removeMemberToken = () => {
33
42
  if (localStorageAvailable) {
34
43
  localStorage.removeItem(memberAuthTokenName);
35
44
  }
36
- const domain = window.location.hostname.split(".").slice(-2).join(".");
45
+ const domain = extractDomainFromHostname(window.location.hostname);
37
46
  Cookie.set(memberAuthTokenName, "", __spreadValues({
38
47
  expires: -1,
39
48
  sameSite: "strict"
package/lib/index.d.mts CHANGED
@@ -12,7 +12,7 @@ declare const _default: {
12
12
  hideModal: () => void;
13
13
  _hideLoader: (element?: any) => void;
14
14
  _showLoader: (element?: any) => void;
15
- _showMessage: (msg: any, isError: any) => void;
15
+ _showMessage: (msg: any, isError: any) => Promise<void>;
16
16
  getMemberCookie: () => any;
17
17
  onAuthChange: (cb: any) => {
18
18
  unsubscribe: () => boolean;
@@ -25,6 +25,10 @@ declare const _default: {
25
25
  getChannelInfo(params?: {
26
26
  channelKey: string;
27
27
  }): Promise<any>;
28
+ subscribeToChannel(params?: {
29
+ channelKey: string;
30
+ action: "NONE" | "THREADS_ONLY";
31
+ }): Promise<void>;
28
32
  getPosts(params?: GetPostsParams): Promise<GetPostsPayload>;
29
33
  getThreads(params?: GetThreadsParams): Promise<GetThreadsPayload>;
30
34
  createPost(params?: CreatePostParams): Promise<CreatePostPayload>;
package/lib/index.d.ts CHANGED
@@ -12,7 +12,7 @@ declare const _default: {
12
12
  hideModal: () => void;
13
13
  _hideLoader: (element?: any) => void;
14
14
  _showLoader: (element?: any) => void;
15
- _showMessage: (msg: any, isError: any) => void;
15
+ _showMessage: (msg: any, isError: any) => Promise<void>;
16
16
  getMemberCookie: () => any;
17
17
  onAuthChange: (cb: any) => {
18
18
  unsubscribe: () => boolean;
@@ -25,6 +25,10 @@ declare const _default: {
25
25
  getChannelInfo(params?: {
26
26
  channelKey: string;
27
27
  }): Promise<any>;
28
+ subscribeToChannel(params?: {
29
+ channelKey: string;
30
+ action: "NONE" | "THREADS_ONLY";
31
+ }): Promise<void>;
28
32
  getPosts(params?: GetPostsParams): Promise<GetPostsPayload>;
29
33
  getThreads(params?: GetThreadsParams): Promise<GetThreadsPayload>;
30
34
  createPost(params?: CreatePostParams): Promise<CreatePostPayload>;