Socket
Book a DemoInstallSign in
Socket

green-chat

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

green-chat

``` npm install green-chat --save ```

1.0.97
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm install green-chat --save

Imports

Import the components and constants from the package into the file:

import { Chat, ChatList, CHAT_TOKEN } from "green-chat";

Important

After logging the user into your application, you should set the access token in the local storage of the browser for the chat components:

localStorage.setItem(CHAT_TOKEN, access_token);

After calling the function to refresh a token from your app, the new received token must be installed in local storage of the browser under the key CHAT_TOKEN and returned from the function.

Chat Component

import { Chat } from "green-chat";

  <Chat
    userId="userId"
    userLocale="locale"
    chatId="chatId"
    isOnlyChat={true}
    cbHandleCloseChat={cbCloseChat}
    handleRefreshToken={cbRefreshToken}
    classHeader="customCSSClass"
    classMessages="customCSSClass"
    classFieldBox="customCSSClass"
    cbHandleHideChat={cbHideChat}
    isDisplayGroupInfo={isDisplayGroupInfo}
    cbHandleHideChat={cbHandleHideChat}
  />
Chat props
propdefaulttypedescription
chatIdnonestringId of the chat or group
userIdnonestringUser id got from the access token by decoding
userLocaleru/enstringChat interface language. The browser language is set by default
isOnlyChatnonebooleantrue value is set when only the chat close functionality is used. false allows more chat functionality
cbHandleCloseChatnonefunctionA callback function that is called when the user clicks the close chat button
handleRefreshTokennonefunctionAn asynchronous callback function that is called if the chat API call returns an error. Takes an axios error as an argument. Should return the new user token
classHeader" "stringAdds a custom style class for the Chat header
classMessages" "stringAdds a custom style class for the box with messages
classFieldBox" "stringAdds a custom style class for the box with input field
cbHandleHideChatnonefunctionA callback function that is called when the user clicks on the close chat button to hide the chat, while the chat will work in the background
isDisplayGroupInfononebooleanIf you pass false, the "Chat" text will be displayed; if you pass true, information about the opponent or group will be displayed in the header

ChatList Component

import { ChatList } from "green-chat";

  <ChatList
    userId="userId"
    userLocale="locale"
    isOnlyChatList={true}
    cbHandleCloseChatList={handleCloseList}
    handleRefreshToken={handleRefreshToken}
    classList="customCSSClass"
    cbHandleOpenChat={handleOpenChat}
    isOpenChatList={boolean}
  />
ChatList props
propdefaulttypedescription
userIdnonestringUser id got from the access token by decoding
userLocaleru/enstringChatList interface language. The browser language is set by default.
isOnlyChatListnonebooleantrue value is set when only the chat list close functionality is used. false allows more chat list functionality.
cbHandleCloseChatListnonefunctionA callback function that is called when the user clicks the close chat button.
cbHandleOpenChatnonefunctionA callback function that is called when the user clicks on a specific chat in the list. Takes an string as a function argument: chat_id:string
handleRefreshTokennonefunctionAn asynchronous callback function that is called if the chat API call returns an error. Takes an axios error as an argument. Should return the new user token.
classList" "stringAdds a custom style class for the ChatList wrapper
isOpenChatListnonebooleanVariable for displaying the list. If false is passed, the list will be hidden from the page, but the socket connection will be open.

FAQs

Package last updated on 15 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.