@ermis-network/ermis-chat-sdk 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -0,0 +1,9 @@
1
+ # @ermis-network/ermis-chat-sdk
2
+
3
+ The official core SDK for Ermis Chat.
4
+
5
+ ## Documentation
6
+
7
+ For full documentation, API references, and integration guides, please visit our official documentation website:
8
+
9
+ 👉 **[Ermis Chat Documentation](https://ermisnetwork.github.io/ermis-chat-monorepo/)**
@@ -3606,17 +3606,24 @@ var ErmisChat = class _ErmisChat {
3606
3606
  async unpinChannel(channelType, channelId) {
3607
3607
  return await this.post(this.baseURL + `/channels/${channelType}/${channelId}/unpin`);
3608
3608
  }
3609
- channel(channelType, channelID, custom = {}) {
3609
+ channel(channelType, channelIDOrCustom, custom) {
3610
3610
  if (!this.userID) {
3611
3611
  throw Error("Call connectUser before creating a channel");
3612
3612
  }
3613
3613
  if (~channelType.indexOf(":")) {
3614
3614
  throw Error(`Invalid channel group ${channelType}, can't contain the : character`);
3615
3615
  }
3616
- return this.getChannelById(channelType, channelID, custom);
3616
+ let channelID = void 0;
3617
+ let customData = custom || {};
3618
+ if (typeof channelIDOrCustom === "string") {
3619
+ channelID = channelIDOrCustom;
3620
+ } else if (typeof channelIDOrCustom === "object" && channelIDOrCustom !== null) {
3621
+ customData = channelIDOrCustom;
3622
+ }
3623
+ return this.getChannelById(channelType, channelID, customData);
3617
3624
  }
3618
3625
  getChannelById = (channelType, channelID, custom) => {
3619
- const cid = `${channelType}:${channelID}`;
3626
+ const cid = `${channelType}:${channelID || ""}`;
3620
3627
  if (cid in this.activeChannels && !this.activeChannels[cid].disconnected) {
3621
3628
  const channel2 = this.activeChannels[cid];
3622
3629
  if (Object.keys(custom).length > 0) {
@@ -3659,7 +3666,7 @@ var ErmisChat = class _ErmisChat {
3659
3666
  return pinExpires;
3660
3667
  }
3661
3668
  getUserAgent() {
3662
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.0"}`;
3669
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.2"}`;
3663
3670
  }
3664
3671
  setUserAgent(userAgent) {
3665
3672
  this.userAgent = userAgent;
@@ -6993,7 +7000,7 @@ var ErmisAuthProvider = class {
6993
7000
  return data;
6994
7001
  }
6995
7002
  getUserAgent() {
6996
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.0"}`;
7003
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.2"}`;
6997
7004
  }
6998
7005
  setUserAgent(userAgent) {
6999
7006
  this.userAgent = userAgent;