@cometchat/chat-sdk-javascript 4.0.0-beta1

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 (140) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/CometChat.js +1 -0
  3. package/dist/index.d.ts +5894 -0
  4. package/dist/javascript-chat-sdk/.git/COMMIT_EDITMSG +1 -0
  5. package/dist/javascript-chat-sdk/.git/FETCH_HEAD +4 -0
  6. package/dist/javascript-chat-sdk/.git/HEAD +1 -0
  7. package/dist/javascript-chat-sdk/.git/ORIG_HEAD +1 -0
  8. package/dist/javascript-chat-sdk/.git/config +19 -0
  9. package/dist/javascript-chat-sdk/.git/description +1 -0
  10. package/dist/javascript-chat-sdk/.git/hooks/applypatch-msg.sample +15 -0
  11. package/dist/javascript-chat-sdk/.git/hooks/commit-msg.sample +24 -0
  12. package/dist/javascript-chat-sdk/.git/hooks/fsmonitor-watchman.sample +174 -0
  13. package/dist/javascript-chat-sdk/.git/hooks/post-update.sample +8 -0
  14. package/dist/javascript-chat-sdk/.git/hooks/pre-applypatch.sample +14 -0
  15. package/dist/javascript-chat-sdk/.git/hooks/pre-commit.sample +49 -0
  16. package/dist/javascript-chat-sdk/.git/hooks/pre-merge-commit.sample +13 -0
  17. package/dist/javascript-chat-sdk/.git/hooks/pre-push.sample +53 -0
  18. package/dist/javascript-chat-sdk/.git/hooks/pre-rebase.sample +169 -0
  19. package/dist/javascript-chat-sdk/.git/hooks/pre-receive.sample +24 -0
  20. package/dist/javascript-chat-sdk/.git/hooks/prepare-commit-msg.sample +42 -0
  21. package/dist/javascript-chat-sdk/.git/hooks/push-to-checkout.sample +78 -0
  22. package/dist/javascript-chat-sdk/.git/hooks/update.sample +128 -0
  23. package/dist/javascript-chat-sdk/.git/index +0 -0
  24. package/dist/javascript-chat-sdk/.git/info/exclude +6 -0
  25. package/dist/javascript-chat-sdk/.git/logs/HEAD +13 -0
  26. package/dist/javascript-chat-sdk/.git/logs/refs/heads/master +1 -0
  27. package/dist/javascript-chat-sdk/.git/logs/refs/heads/master-v3 +3 -0
  28. package/dist/javascript-chat-sdk/.git/logs/refs/heads/master-v4 +4 -0
  29. package/dist/javascript-chat-sdk/.git/logs/refs/remotes/origin/HEAD +1 -0
  30. package/dist/javascript-chat-sdk/.git/logs/refs/remotes/origin/master-v3 +2 -0
  31. package/dist/javascript-chat-sdk/.git/logs/refs/remotes/origin/master-v4 +2 -0
  32. package/dist/javascript-chat-sdk/.git/logs/refs/stash +1 -0
  33. package/dist/javascript-chat-sdk/.git/objects/09/b9e17d9a0acd55c3644f4cfa19b1c40a139018 +0 -0
  34. package/dist/javascript-chat-sdk/.git/objects/0f/2d8999b370e8ddb236f767aa565b2aa72a6b21 +0 -0
  35. package/dist/javascript-chat-sdk/.git/objects/15/7f5161e31be14c74df7907c9c5046fbbea4461 +0 -0
  36. package/dist/javascript-chat-sdk/.git/objects/17/89200f3f5621f9df6d08d1071c59557ce5a29d +0 -0
  37. package/dist/javascript-chat-sdk/.git/objects/26/1de108a0253f54cf37e8a072f7f5f0098c7e89 +4 -0
  38. package/dist/javascript-chat-sdk/.git/objects/43/7ffc94a259dcd818cca308ab60a2780714092d +1 -0
  39. package/dist/javascript-chat-sdk/.git/objects/4e/6ab6a981ea6dccdb60b6438d7ca142aef269fc +0 -0
  40. package/dist/javascript-chat-sdk/.git/objects/5e/04a3d79cebcc2b02c14ea807f839ea73d44461 +0 -0
  41. package/dist/javascript-chat-sdk/.git/objects/65/bbff4d1cccc12285ea1c59a6f2082552f0d034 +0 -0
  42. package/dist/javascript-chat-sdk/.git/objects/6a/a6ef178cb2e3775bb149aba99ace8399525da6 +0 -0
  43. package/dist/javascript-chat-sdk/.git/objects/6b/e1ffe406de9ebb698ea891315b2b1459160029 +0 -0
  44. package/dist/javascript-chat-sdk/.git/objects/6b/efb8e9de892be7ecee5d39c30c0aa17d43d727 +2 -0
  45. package/dist/javascript-chat-sdk/.git/objects/6e/f136ca41bbb5684639947fa121b7eebb795592 +0 -0
  46. package/dist/javascript-chat-sdk/.git/objects/87/96f6311621c3ee4fc8d37eeec64a6c94e3e6ca +0 -0
  47. package/dist/javascript-chat-sdk/.git/objects/8b/2d226d44814b7265b68ab7953a87cd44d77965 +0 -0
  48. package/dist/javascript-chat-sdk/.git/objects/9c/bc4afb06153fd276e240e709984bf1099386ba +0 -0
  49. package/dist/javascript-chat-sdk/.git/objects/a9/6c6710dfb57871b6eccda3a94d83990ba94d9f +0 -0
  50. package/dist/javascript-chat-sdk/.git/objects/ad/1b70a4bb12b3fe2e6306d2b0922582036f4e42 +0 -0
  51. package/dist/javascript-chat-sdk/.git/objects/c1/655387f263ec50dbef8042099eead57dfe00c2 +0 -0
  52. package/dist/javascript-chat-sdk/.git/objects/e0/ad85d968302e5447402ed4d0bc8ace931b9167 +0 -0
  53. package/dist/javascript-chat-sdk/.git/objects/e8/0b03094191c92690d5bb92b4271058f188efd1 +1 -0
  54. package/dist/javascript-chat-sdk/.git/objects/f0/cc86624ec0504ed24dcd6a7b2cdee917b73395 +2 -0
  55. package/dist/javascript-chat-sdk/.git/objects/f9/95e0e3dc98868eb6404f8cdd84632ae140e1ff +2 -0
  56. package/dist/javascript-chat-sdk/.git/objects/fb/d9b82e03d33337a8d2606fc9e2f1652ffda3de +0 -0
  57. package/dist/javascript-chat-sdk/.git/objects/pack/pack-efd6261f29a0c404693064c4a255aada38ddab72.idx +0 -0
  58. package/dist/javascript-chat-sdk/.git/objects/pack/pack-efd6261f29a0c404693064c4a255aada38ddab72.pack +0 -0
  59. package/dist/javascript-chat-sdk/.git/packed-refs +107 -0
  60. package/dist/javascript-chat-sdk/.git/refs/heads/master +1 -0
  61. package/dist/javascript-chat-sdk/.git/refs/heads/master-v3 +1 -0
  62. package/dist/javascript-chat-sdk/.git/refs/heads/master-v4 +1 -0
  63. package/dist/javascript-chat-sdk/.git/refs/remotes/origin/HEAD +1 -0
  64. package/dist/javascript-chat-sdk/.git/refs/remotes/origin/master-v3 +1 -0
  65. package/dist/javascript-chat-sdk/.git/refs/remotes/origin/master-v4 +1 -0
  66. package/dist/javascript-chat-sdk/.git/refs/stash +1 -0
  67. package/dist/javascript-chat-sdk/.gitignore +2 -0
  68. package/dist/javascript-chat-sdk/CometChat.d.ts +4732 -0
  69. package/dist/javascript-chat-sdk/CometChat.js +1 -0
  70. package/dist/javascript-chat-sdk/LICENSE.md +3 -0
  71. package/dist/javascript-chat-sdk/README.md +189 -0
  72. package/dist/javascript-chat-sdk/package.json +36 -0
  73. package/dist/package.json +36 -0
  74. package/dist/type/index.d.ts +10 -0
  75. package/dist/type/lib/BannedMembersRequest.d.ts +60 -0
  76. package/dist/type/lib/BlockedUsersRequest.d.ts +67 -0
  77. package/dist/type/lib/CallSettings.d.ts +429 -0
  78. package/dist/type/lib/CometChat.d.ts +1954 -0
  79. package/dist/type/lib/CometChatErrorConstants.d.ts +124 -0
  80. package/dist/type/lib/CometChatHelper.d.ts +26 -0
  81. package/dist/type/lib/Constants.d.ts +953 -0
  82. package/dist/type/lib/ConversationRequest.d.ts +89 -0
  83. package/dist/type/lib/GroupMembersRequest.d.ts +61 -0
  84. package/dist/type/lib/GroupsRequest.d.ts +78 -0
  85. package/dist/type/lib/Helper.d.ts +46 -0
  86. package/dist/type/lib/ListenerHandlers.d.ts +101 -0
  87. package/dist/type/lib/MessagesRequest.d.ts +188 -0
  88. package/dist/type/lib/UsersRequest.d.ts +142 -0
  89. package/dist/type/lib/WebSockets/WSConnectionHelper.d.ts +41 -0
  90. package/dist/type/lib/WebSockets/WSConstants.d.ts +71 -0
  91. package/dist/type/lib/WebSockets/WSHelper.d.ts +3 -0
  92. package/dist/type/lib/controllers/CallController.d.ts +151 -0
  93. package/dist/type/lib/controllers/ConversationController.d.ts +14 -0
  94. package/dist/type/lib/controllers/GroupMemberController.d.ts +10 -0
  95. package/dist/type/lib/controllers/GroupsController.d.ts +9 -0
  96. package/dist/type/lib/controllers/MessageController.d.ts +18 -0
  97. package/dist/type/lib/controllers/PresenceController.d.ts +0 -0
  98. package/dist/type/lib/controllers/TypingNotificationController.d.ts +14 -0
  99. package/dist/type/lib/controllers/UserAuthController.d.ts +10 -0
  100. package/dist/type/lib/controllers/UsersController.d.ts +9 -0
  101. package/dist/type/lib/localStore/KeyStore.d.ts +45 -0
  102. package/dist/type/lib/localStore/MessageListenerEventMaping.d.ts +56 -0
  103. package/dist/type/lib/localStore/MessagesStore.d.ts +72 -0
  104. package/dist/type/lib/localStore/UserStore.d.ts +72 -0
  105. package/dist/type/lib/localStore/store.d.ts +61 -0
  106. package/dist/type/lib/models/Action.d.ts +159 -0
  107. package/dist/type/lib/models/AppSettings.d.ts +135 -0
  108. package/dist/type/lib/models/BaseMessage.d.ts +259 -0
  109. package/dist/type/lib/models/CCExtension.d.ts +15 -0
  110. package/dist/type/lib/models/Call.d.ts +159 -0
  111. package/dist/type/lib/models/CometChatAuthEvent.d.ts +25 -0
  112. package/dist/type/lib/models/CometChatEvent.d.ts +25 -0
  113. package/dist/type/lib/models/CometChatMessageEvent.d.ts +9 -0
  114. package/dist/type/lib/models/CometChatPingEvent.d.ts +6 -0
  115. package/dist/type/lib/models/CometChatPresenceEvent.d.ts +15 -0
  116. package/dist/type/lib/models/CometChatReceiptEvent.d.ts +14 -0
  117. package/dist/type/lib/models/CometChatTransientEvent.d.ts +11 -0
  118. package/dist/type/lib/models/CometChatTypingEvent.d.ts +14 -0
  119. package/dist/type/lib/models/ConversationModel.d.ts +73 -0
  120. package/dist/type/lib/models/CustomError.d.ts +13 -0
  121. package/dist/type/lib/models/CustomMessage.d.ts +71 -0
  122. package/dist/type/lib/models/ErrorModel.d.ts +12 -0
  123. package/dist/type/lib/models/Group.d.ts +190 -0
  124. package/dist/type/lib/models/GroupMember.d.ts +43 -0
  125. package/dist/type/lib/models/Listner.d.ts +258 -0
  126. package/dist/type/lib/models/MediaDevice.d.ts +36 -0
  127. package/dist/type/lib/models/MediaMessage.d.ts +115 -0
  128. package/dist/type/lib/models/MessageReceipt.d.ts +99 -0
  129. package/dist/type/lib/models/RTCUser.d.ts +18 -0
  130. package/dist/type/lib/models/TextMessage.d.ts +84 -0
  131. package/dist/type/lib/models/TransientMessage.d.ts +48 -0
  132. package/dist/type/lib/models/TypingNotification.d.ts +52 -0
  133. package/dist/type/lib/models/UserModel.d.ts +175 -0
  134. package/dist/type/lib/models/UserPresence.d.ts +0 -0
  135. package/dist/type/lib/models/attachment.d.ts +74 -0
  136. package/dist/type/lib/rest-api/EndPointUtils.d.ts +9 -0
  137. package/dist/type/lib/rest-api/EndpointFactory.d.ts +28 -0
  138. package/dist/type/lib/rest-api/HttpHelper.d.ts +10 -0
  139. package/package.json +48 -0
  140. package/readme.md +189 -0
@@ -0,0 +1,175 @@
1
+ /** @private */
2
+ export interface UserObj {
3
+ uid: string;
4
+ name: string;
5
+ authToken: string;
6
+ avatar: string;
7
+ lastActiveAt: number;
8
+ link: string;
9
+ metadata: string;
10
+ role: string;
11
+ status: string;
12
+ statusMessage: string;
13
+ tags: Array<string>;
14
+ deactivatedAt: number;
15
+ }
16
+ /**
17
+ * Implementation of UserObject
18
+ */
19
+ export declare class User {
20
+ private uid;
21
+ private name;
22
+ private authToken;
23
+ private avatar;
24
+ private lastActiveAt;
25
+ private link;
26
+ private metadata;
27
+ private role;
28
+ private status;
29
+ private statusMessage;
30
+ private hasBlockedMe;
31
+ private blockedByMe;
32
+ private tags;
33
+ private deactivatedAt;
34
+ /**
35
+ * Method to get UID of the user.
36
+ * @returns {string}
37
+ */
38
+ getUid(): string;
39
+ /**
40
+ * Method to set UID of the user.
41
+ * @param {string} uid
42
+ */
43
+ setUid(uid: string): void;
44
+ /**
45
+ * Method to get name of the user.
46
+ * @returns {string}
47
+ */
48
+ getName(): string;
49
+ /**
50
+ * Method to set name of the user.
51
+ * @param {string} name
52
+ */
53
+ setName(name: string): void;
54
+ /**
55
+ * Method to get authToken of the user.
56
+ * @returns {string}
57
+ */
58
+ getAuthToken(): string;
59
+ /**
60
+ * Method to set authToken of the user.
61
+ * @param {string} authToken
62
+ */
63
+ setAuthToken(authToken: string): void;
64
+ /**
65
+ * Method to get avatar of the user.
66
+ * @returns {string}
67
+ */
68
+ getAvatar(): string;
69
+ /**
70
+ * Method to set avatar of the user.
71
+ * @param {string} avatar
72
+ */
73
+ setAvatar(avatar: string): void;
74
+ /**
75
+ * Method to get last active at timestamp of the user.
76
+ * @returns {number}
77
+ */
78
+ getLastActiveAt(): number;
79
+ /**
80
+ * Method to set last active at timestamp of the user.
81
+ * @param {number} lastActiveAt
82
+ */
83
+ setLastActiveAt(lastActiveAt: number): void;
84
+ /**
85
+ * Method to get link of the user.
86
+ * @returns {string}
87
+ */
88
+ getLink(): string;
89
+ /**
90
+ * Method to set link of the user.
91
+ * @param {string} link
92
+ */
93
+ setLink(link: string): string;
94
+ /**
95
+ * Method to get metadata of the user.
96
+ * @returns {string}
97
+ */
98
+ getMetadata(): string;
99
+ /**
100
+ * Method to set metadata of the user.
101
+ * @param {string} metadata
102
+ */
103
+ setMetadata(metadata: string): void;
104
+ /**
105
+ * Method to get role of the user.
106
+ * @returns {string}
107
+ */
108
+ getRole(): string;
109
+ /**
110
+ * Method to set role of the user.
111
+ * @param {string} role
112
+ */
113
+ setRole(role: string): void;
114
+ /**
115
+ * Method to get status of the user.
116
+ * @returns {string}
117
+ */
118
+ getStatus(): string;
119
+ /**
120
+ * Method to set status of the user.
121
+ * @param {string} status
122
+ */
123
+ setStatus(status: string): void;
124
+ /**
125
+ * Method to get status message of the user.
126
+ * @returns {string}
127
+ */
128
+ getStatusMessage(): string;
129
+ /**
130
+ * Method to set status message of the user.
131
+ * @param {string} statusMessage
132
+ */
133
+ setStatusMessage(statusMessage: string): void;
134
+ setBlockedByMe(blockedByMe: boolean): void;
135
+ /**
136
+ * Method to know if the logged-in user has blocked the other user.
137
+ * @returns {boolean}
138
+ */
139
+ getBlockedByMe(): boolean;
140
+ setHasBlockedMe(hasBlockedMe: boolean): void;
141
+ /**
142
+ * Method to know if the logged-in user has been blocked by the other user.
143
+ * @returns {boolean}
144
+ */
145
+ getHasBlockedMe(): boolean;
146
+ /**
147
+ * Method to set tags of the user.
148
+ * @param {string[]} tags
149
+ */
150
+ setTags(tags: Array<string>): void;
151
+ /**
152
+ * Method to get tags of the user.
153
+ * @returns {string[]}
154
+ */
155
+ getTags(): Array<string>;
156
+ /**
157
+ * Method to set deactivatedAt timestamp of a user.
158
+ * @param {number} deactivatedAt
159
+ */
160
+ setDeactivatedAt(deactivatedAt: number): void;
161
+ /**
162
+ * Method to get deactivatedAt timestamp of a user.
163
+ * @returns {number}
164
+ */
165
+ getDeactivatedAt(): number;
166
+ constructor(...userObj: any[]);
167
+ }
168
+ /** @private */
169
+ export declare class Me extends User {
170
+ private wsChannel;
171
+ private jwt;
172
+ constructor(userObj: UserObj | any);
173
+ getWsChannel(): any;
174
+ getJWT(): string;
175
+ }
File without changes
@@ -0,0 +1,74 @@
1
+ export declare class Attachment {
2
+ private extension;
3
+ private mimeType;
4
+ private name;
5
+ private size;
6
+ private url;
7
+ constructor(file: Object);
8
+ /**
9
+ * Create the file object from the provided JSON Object.
10
+ * @private
11
+ * @param {Object} file
12
+ * @returns {FileObject}
13
+ * @memberof FileObject
14
+ */
15
+ createFileFromJSON(file: Object): Attachment;
16
+ /**
17
+ * Converts the FileObject to JSON Object.
18
+ * @private
19
+ * @param {FileObject} fileObject
20
+ * @returns {Object}
21
+ * @memberof FileObject
22
+ */
23
+ static toJSON(attachment: Attachment): Object;
24
+ /**
25
+ * Get extension of the file.
26
+ * @returns {string}
27
+ */
28
+ getExtension(): string;
29
+ /**
30
+ * Method to set extension of the file.
31
+ * @param {string} extension
32
+ */
33
+ setExtension(extension: string): void;
34
+ /**
35
+ * Get mime type of the file.
36
+ * @returns {string}
37
+ */
38
+ getMimeType(): string;
39
+ /**
40
+ * Method to set mimeType of the file.
41
+ * @param {string} mimeType
42
+ */
43
+ setMimeType(mimeType: string): void;
44
+ /**
45
+ * Get name of the file.
46
+ * @returns {string}
47
+ */
48
+ getName(): string;
49
+ /**
50
+ * Method to set name of the file.
51
+ * @param {string} name
52
+ */
53
+ setName(name: string): void;
54
+ /**
55
+ * Get size of the file.
56
+ * @returns {string}
57
+ */
58
+ getSize(): number;
59
+ /**
60
+ * Method to set size of the file.
61
+ * @param {string} name
62
+ */
63
+ setSize(size: number): void;
64
+ /**
65
+ * Get URL of the file.
66
+ * @returns {string}
67
+ */
68
+ getUrl(): string;
69
+ /**
70
+ * Method to set URL of the file.
71
+ * @param {string} name
72
+ */
73
+ setUrl(url: string): void;
74
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ *
4
+ * @export
5
+ * @param {string} [endPointName=""]
6
+ * @param {object} [params={}]
7
+ * @returns
8
+ */
9
+ export declare function getEndPoint(endPointName?: string, params?: object): Promise<Object>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ *Endpoint factory class which will give enpoint data to client.
3
+ *
4
+ * @export
5
+ * @class EndpointFactory
6
+ */
7
+ export declare class EndpointFactory {
8
+ baseUrl: string;
9
+ apiVersion: string;
10
+ adminApiUrl: string;
11
+ adminApiVersion: string;
12
+ extensionApi: string;
13
+ prosodyApi: string;
14
+ wsApi: string;
15
+ /**
16
+ * FIXME: Need to use string templating.
17
+ */
18
+ /**
19
+ * User AuthToken generation Endpoints:
20
+ */
21
+ private uriEndpoints;
22
+ /**
23
+ *
24
+ * @param endpointName accepts enpoint name
25
+ * @returns enpoint object with type, headers,and expected data
26
+ */
27
+ getEndpointData(endpointName: string): Promise<Object>;
28
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @export
3
+ * @param {string} [endPointName=""]
4
+ * @param {object} [params={}]
5
+ * @param {*} [data={}]
6
+ * @returns
7
+ */
8
+ export declare function makeApiCall(endPointName?: string, params?: object, data?: any, isFile?: boolean): any;
9
+ export declare function makeAdminApiCall(endPointName?: string, params?: object, data?: any, isFile?: boolean): any;
10
+ export declare function postData(url?: string, method?: string, data?: any, headers?: any, isFile?: boolean): any;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@cometchat/chat-sdk-javascript",
3
+ "version": "4.0.0-beta1",
4
+ "description": "",
5
+ "main": "dist/CometChat.js",
6
+ "module": "dist/CometChat.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist/"
10
+ ],
11
+ "dependencies": {
12
+ "localforage": "^1.7.3",
13
+ "uuid": "^3.3.3"
14
+ },
15
+ "devDependencies": {
16
+ "@babel/core": "^7.3.4",
17
+ "browser-env": "^3.3.0",
18
+ "chai": "^4.2.0",
19
+ "chai-as-promised": "^7.1.1",
20
+ "chai-http": "^4.3.0",
21
+ "dts-bundle-webpack": "^1.0.2",
22
+ "editable-sources-webpack-plugin": "^1.0.2",
23
+ "form-data": "^4.0.0",
24
+ "mocha": "^7.1.1",
25
+ "node-fetch": "^2.6.5",
26
+ "pre-commit": "^1.2.2",
27
+ "strip-comments": "^1.0.2",
28
+ "ts-loader": "4.5.0",
29
+ "typedoc": "^0.20.34",
30
+ "typedoc-plugin-merge-modules": "^2.0.0",
31
+ "typescript": "^3.9.6",
32
+ "uglifyjs-webpack-plugin": "^2.1.2",
33
+ "webpack": "^4.29.6",
34
+ "webpack-cli": "^3.2.3",
35
+ "webpack-dev-server": "^3.1.14"
36
+ },
37
+ "scripts": {
38
+ "start": "webpack-dev-server --mode development --port 3030 --https true --host localhost",
39
+ "build": "webpack --mode production",
40
+ "test": "mocha testcases/tests.js --bail --exit"
41
+ },
42
+ "pre-commit": [
43
+ "test"
44
+ ],
45
+ "keywords": [],
46
+ "author": "cometchat <engineering.pro@cometchat.com> ",
47
+ "license": "ISC"
48
+ }
package/readme.md ADDED
@@ -0,0 +1,189 @@
1
+ <div style="width:100%">
2
+ <div style="width:100%">
3
+ <div style="width:50%; display:inline-block">
4
+ <p align="center">
5
+ <img style="text-align:center" width="180" height="180" alt="" src="https://avatars2.githubusercontent.com/u/45484907?s=200&v=4">
6
+ </p>
7
+ </div>
8
+ </div>
9
+ </br>
10
+ </br>
11
+ </div>
12
+
13
+ # CometChat Javascript SDK
14
+
15
+ CometChat Pro enables you to add voice, video & text chat for your website & app.
16
+ This guide demonstrates how to add chat to a WebSite using CometChat Pro.
17
+
18
+ ## Features
19
+
20
+ <ul>
21
+ <li> 1-1 & Group Conversations </li>
22
+ <li> Voice & video calling & conferencing </li>
23
+ <li> Rich Media Attachments </li>
24
+ <li> Typing Indicators </li>
25
+ <li> Custom Messages </li>
26
+ <li> Read receipts </li>
27
+ <li> Online Presence Indicators </li>
28
+ <li> Message History </li>
29
+ <li> Single Sign-on </li>
30
+ <li> Webhooks </li>
31
+ <li> Bots </li>
32
+ <li> Users & Friends List </li>
33
+ <li> Groups List </li>
34
+ <li> Conversations List </li>
35
+ <li> Threaded Conversations </li>
36
+ </ul>
37
+
38
+ ## Extensions
39
+
40
+ [Push Notification](https://prodocs.cometchat.com/docs/extensions-enhanced-push-notification) | [Email Notification](https://prodocs.cometchat.com/docs/extensions-email-notification) | [SMS Notification](https://prodocs.cometchat.com/docs/extensions-sms-notification) | [Thumbnail Generation](https://prodocs.cometchat.com/docs/extensions-thumbnail-generation) | [Link Preview](https://prodocs.cometchat.com/docs/extensions-link-preview) | [Rich Media Preview](https://prodocs.cometchat.com/docs/extensions-rich-media-preview) | [Voice Transcription](https://prodocs.cometchat.com/docs/extensions-voice-transcription) | [Smart Reply](https://prodocs.cometchat.com/docs/extensions-smart-reply) | [Message Translation](https://prodocs.cometchat.com/docs/extensions-message-translation) | [Emojis](https://prodocs.cometchat.com/docs/extensions-emojis) | [Polls](https://prodocs.cometchat.com/docs/extensions-polls) | [Reactions](https://prodocs.cometchat.com/docs/extensions-reactions) | [Stickers](https://prodocs.cometchat.com/docs/extensions-stickers) | [Video Broadcasting](https://prodocs.cometchat.com/docs/extensions-broadcast) | [Collaborative Documents](https://prodocs.cometchat.com/docs/extensions-collaborative-document) | [Collaborative Whiteboards](https://prodocs.cometchat.com/docs/extensions-collaborative-whiteboard) | [Data Masking Filter](https://prodocs.cometchat.com/docs/extensions-data-masking-filter) | [Profanity Filter](https://prodocs.cometchat.com/docs/extensions-profanity-filter) | [Image Moderation](https://prodocs.cometchat.com/docs/extensions-image-moderation)| [Sentiment Analysis](https://prodocs.cometchat.com/docs/extensions-sentiment-analysis) | [In-flight Message Moderation](https://prodocs.cometchat.com/docs/extensions-in-flight-message-moderation) | [Virus & Malware Scanner](https://prodocs.cometchat.com/docs/extensions-virus-malware-scanner) | [XSS Filter](https://prodocs.cometchat.com/docs/extensions-xss-filter)
41
+
42
+ [![Platform](https://img.shields.io/badge/Platform-Javascript-brightgreen)](#)
43
+ <a href=" "> <img src="https://img.shields.io/badge/Version-3.0.0-beta1-important" /></a>
44
+ ![GitHub repo size](https://img.shields.io/github/repo-size/cometchat-pro/javascript-chat-sdk)
45
+ ![GitHub contributors](https://img.shields.io/github/contributors/cometchat-pro/javascript-chat-sdk)
46
+ ![GitHub stars](https://img.shields.io/github/stars/cometchat-pro/javascript-chat-sdk?style=social)
47
+ ![Twitter Follow](https://img.shields.io/twitter/follow/cometchat?style=social)
48
+ <hr/>
49
+
50
+
51
+ ## Prerequisites :star:
52
+ Before you begin, ensure you have met the following requirements:<br/>
53
+ ✅ &nbsp; You have [`Visual Studio Code`](https://code.visualstudio.com/) or any other code editor installed in your machine.<br/>
54
+ ✅ &nbsp; You have [`npm`](https://www.npmjs.com/get-npm) installed in your machine.<br/>
55
+ ✅ &nbsp; You have read [CometChat Key Concepts](https://prodocs.cometchat.com/docs/concepts).<br/>
56
+
57
+ <hr/>
58
+
59
+ ## Installing CometChat Javascript SDK
60
+ ## Setup :wrench:
61
+
62
+ To setup Javascript SDK, you need to first register on CometChat Dashboard. [Click here to sign up](https://app.cometchat.com/login).
63
+
64
+ ### i. Get your Application Keys :key:
65
+
66
+ <a href="https://app.cometchat.io" target="_blank">Signup for CometChat</a> and then:
67
+
68
+ 1. Create a new app: Click **Add App** option available → Enter App Name & other information → Create App
69
+ 2. At the Top in **QuickStart** section you will find **Auth Key** & **App ID** or else you can head over to the **API & Auth Keys** section and note the **Auth Key** and **App ID**
70
+ <img align="center" src="https://files.readme.io/4b771c5-qs_copy.jpg"/>
71
+
72
+ <hr/>
73
+
74
+ ### ii. Add the CometChat Dependency
75
+ <ul>
76
+ <li>
77
+ <b>Install via NPM</b><br/>
78
+ 1. Run the following command to install the CometChat Pro Javascript SDK<br/>
79
+
80
+ ```javascript
81
+ npm install @cometchat-pro/chat@3.0.0-beta1 --save
82
+ ```
83
+ </li>
84
+
85
+ <li>
86
+ <b>Import via CDN</b><br/>
87
+ 1. Include the CometChat Pro Javascript library in your HTML code.<br/>
88
+
89
+ ```html
90
+ <script type="text/javascript" src="https://unpkg.com/@cometchat-pro/chat@3.0.0-beta1/CometChat.js"></script>
91
+ ```
92
+
93
+ You can refer to the below link for instructions on how to do so:<br/>
94
+ [📝 Add CometChat Dependency](https://prodocs.cometchat.com/docs/js-quick-start#add-the-cometchat-dependency)
95
+ </li>
96
+ </ul>
97
+ <hr/>
98
+
99
+ ## Configure CometChat Javascript SDK
100
+
101
+ ### i. Initialize CometChat 🌟
102
+ We suggest you call the init() method on app startup, preferably in the index.js file.
103
+
104
+ ```javascript
105
+ var appID = "APP_ID";
106
+ var region = "REGION";
107
+ var appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build();
108
+ CometChat.init(appID, appSetting).then(
109
+ () => {
110
+ console.log("Initialization completed successfully");
111
+ },
112
+ error => {
113
+ console.log("Initialization failed with error:", error);
114
+ }
115
+ );
116
+ ```
117
+
118
+ | :information_source: &nbsp; <b> Note: Make sure to replace `region` and `appID` with your credentials.</b> |
119
+ |------------------------------------------------------------------------------------------------------------|
120
+
121
+ ### ii. Create User 👤
122
+ Once initialisation is successful, you will need to create a user. You need to use createUser() method to create user on the fly.
123
+ ```javascript
124
+ let authKey = "AUTH_KEY";
125
+ var uid = "user1";
126
+ var name = "Kevin";
127
+
128
+ var user = new CometChat.User(uid);
129
+
130
+ user.setName(name);
131
+
132
+ CometChat.createUser(user, authKey).then(
133
+ user => {
134
+ console.log("user created", user);
135
+ },error => {
136
+ console.log("error", error);
137
+ }
138
+ );
139
+ ```
140
+ >:information_source: <b>Note: Make sure that UID and name are specified as these are mandatory fields to create a user.</b>
141
+ <hr/>
142
+
143
+ ### iii. Login User 👤
144
+ Once you have created the user successfully, you will need to log the user into CometChat using the login() method.
145
+ ```javascript
146
+ var UID = "SUPERHERO1";
147
+ var authKey = "AUTH_KEY";
148
+
149
+ CometChat.getLoggedinUser().then(
150
+ user => {
151
+ if(!user){
152
+ CometChat.login(UID, authKey).then(
153
+ user => {
154
+ console.log("Login Successful:", { user });
155
+ },
156
+ error => {
157
+ console.log("Login failed with exception:", { error });
158
+ }
159
+ );
160
+ }else{
161
+ // User already logged in
162
+ }
163
+ }, error => {
164
+ console.log("getLoggedinUser failed with exception:", { error });
165
+ }
166
+ );
167
+ ```
168
+
169
+ | :information_source: &nbsp; <b>Note - The login() method needs to be called only once. Also replace AUTH_KEY with your App Auth Key.</b> |
170
+ |------------------------------------------------------------------------------------------------------------|
171
+
172
+ <hr/>
173
+
174
+ 📝 Please refer to our [Developer Documentation](https://prodocs.cometchat.com/docs/js-quick-start) for more information on how to configure the CometChat Pro SDK and implement various features using the same.
175
+
176
+ <hr/>
177
+
178
+ ## Learn more about UI-Kit
179
+ [Angular UI Kit](https://github.com/cometchat-pro/javascript-angular-chat-ui-kit) | [React UI Kit](https://github.com/cometchat-pro/javascript-react-chat-ui-kit) | [Vue UI Kit](https://github.com/cometchat-pro/javascript-vue-chat-ui-kit)
180
+
181
+ ## Contributors :clap:
182
+ Thanks to the following people who have contributed to this project:
183
+ [👨‍💻 @ajaygajra](https://github.com/ajaygajra)
184
+ [👨‍💻 @mayur-bhandari](https://github.com/mayur-bhandari)
185
+ <hr/>
186
+
187
+ ## Contact :mailbox:
188
+ Contact us via real time support present in [CometChat Dashboard.](https://app.cometchat.io/)
189
+ <hr/>