@andrey4emk/npm-app-back-b24 0.5.10 → 0.5.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrey4emk/npm-app-back-b24",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "description": "Bitrix24 OAuth helpers for Node.js projects",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2,29 +2,28 @@ import dotEnv from "dotenv";
2
2
  dotEnv.config();
3
3
 
4
4
  export class ChatApp {
5
+ /**
6
+ * @param {Object} makeParam - объект с параметрами для создания токена
7
+ * @param {string} makeParam.email - email для создания токена
8
+ * @param {string} makeParam.pass - пароль для создания токена
9
+ * @param {string} makeParam.appId - appId для создания токена
10
+ *
11
+ * @param {Object} authParam - объект с параметрами авторизации
12
+ * @param {string} authParam.accessToken - accessToken для авторизации
13
+ * @param {string} authParam.accessTokenEndTime - время окончания действия accessToken
14
+ * @param {string} authParam.refreshToken - refreshToken для обновления accessToken
15
+ * @param {string} authParam.refreshTokenEndTime - время окончания действия refreshToken
16
+ *
17
+ * @param {Object} typeParam - объект с типами мессенджеров и их параметрами
18
+ * @param {Object} typeParam.whatsApp - параметры для WhatsApp
19
+ * @param {string} typeParam.whatsApp.licenseId - ID лицензии для WhatsApp
20
+ * @param {Array} typeParam.whatsApp.messenger - массив с типами мессенджеров для WhatsApp
21
+ *
22
+ * @param {Object} typeParam.telegram - параметры для Telegram
23
+ * @param {string} typeParam.telegram.licenseId - ID лицензии для Telegram
24
+ * @param {Array} typeParam.telegram.messenger - массив с типами мессенджеров для Telegram
25
+ */
5
26
  constructor(makeParam, authParam, typeParam) {
6
- /**
7
- * @param {Object} makeParam - объект с параметрами для создания токена
8
- * @param {string} makeParam.email - email для создания токена
9
- * @param {string} makeParam.pass - пароль для создания токена
10
- * @param {string} makeParam.appId - appId для создания токена
11
- *
12
- * @param {Object} authParam - объект с параметрами авторизации
13
- * @param {string} authParam.accessToken - accessToken для авторизации
14
- * @param {string} authParam.accessTokenEndTime - время окончания действия accessToken
15
- * @param {string} authParam.refreshToken - refreshToken для обновления accessToken
16
- * @param {string} authParam.refreshTokenEndTime - время окончания действия refreshToken
17
- *
18
- * @param {Object} typeParam - объект с типами мессенджеров и их параметрами
19
- * @param {Object} typeParam.whatsApp - параметры для WhatsApp
20
- * @param {string} typeParam.whatsApp.licenseId - ID лицензии для WhatsApp
21
- * @param {Array} typeParam.whatsApp.messenger - массив с типами мессенджеров для WhatsApp
22
- *
23
- * @param {Object} typeParam.telegram - параметры для Telegram
24
- * @param {string} typeParam.telegram.licenseId - ID лицензии для Telegram
25
- * @param {Array} typeParam.telegram.messenger - массив с типами мессенджеров для Telegram
26
- */
27
-
28
27
  this.make = makeParam;
29
28
  this.auth = authParam;
30
29
  this.type = typeParam;
@@ -32,7 +31,6 @@ export class ChatApp {
32
31
  }
33
32
 
34
33
  async sendMessageChatApp(messangerType, messageData) {
35
- console.log("sendMessageChatApp called with:", messangerType, messageData);
36
34
  // Проверяем что верно указан messangerType и в messageData есть phone и message
37
35
  if (!["whatsApp"].includes(messangerType) && !["telegram"].includes(messangerType)) {
38
36
  return { error: true, message: "Неверный тип мессенджера", data: null };
@@ -120,8 +118,6 @@ export class ChatApp {
120
118
  }
121
119
 
122
120
  async checkTokenChatApp() {
123
- console.log("checkTokenChatApp called");
124
- console.log("Current accessToken:", this.auth.accessToken);
125
121
  try {
126
122
  const response = await fetch("https://api.chatapp.online/v1/tokens/check", {
127
123
  method: "GET",
@@ -133,7 +129,6 @@ export class ChatApp {
133
129
  });
134
130
 
135
131
  const data = await response.json();
136
- console.log("Token check response data:", data);
137
132
  if (!data.success) {
138
133
  await this.refreshTokenChatApp();
139
134
  return { error: false, message: "Токен обновлен" };
@@ -146,7 +141,7 @@ export class ChatApp {
146
141
  }
147
142
 
148
143
  async makeTokenChatApp() {
149
- console.log("makeTokenChatApp called");
144
+ console.warn("makeTokenChatApp called");
150
145
  try {
151
146
  const response = await fetch("https://api.chatapp.online/v1/tokens", {
152
147
  method: "POST",
@@ -163,7 +158,6 @@ export class ChatApp {
163
158
  });
164
159
 
165
160
  const data = await response.json();
166
- console.log("Token make response data:", data);
167
161
  if (!data.success) {
168
162
  return { error: true, message: "Не удалось получить токен ChatApp", data: data };
169
163
  } else {
@@ -180,7 +174,6 @@ export class ChatApp {
180
174
  }
181
175
 
182
176
  async refreshTokenChatApp() {
183
- console.log("refreshTokenChatApp called");
184
177
  try {
185
178
  const response = await fetch("https://api.chatapp.online/v1/tokens/refresh", {
186
179
  method: "POST",
@@ -194,7 +187,6 @@ export class ChatApp {
194
187
  }),
195
188
  });
196
189
  const data = await response.json();
197
- console.log("Token refresh response data:", data);
198
190
  if (!data.success) {
199
191
  let resMakeToken = await this.makeTokenChatApp();
200
192
 
@@ -2,10 +2,10 @@ import dotEnv from "dotenv";
2
2
 
3
3
  dotEnv.config();
4
4
 
5
- class Smsgold {
6
- constructor() {
7
- this.user = process.env.SMSGOLD_USER;
8
- this.pass = process.env.SMSGOLD_PASS;
5
+ export class Smsgold {
6
+ constructor(authParam) {
7
+ this.user = authParam.user;
8
+ this.pass = authParam.pass;
9
9
  }
10
10
 
11
11
  async sendSms(messageData) {
@@ -60,5 +60,3 @@ class Smsgold {
60
60
  }
61
61
  }
62
62
  }
63
-
64
- export const smsgold = new Smsgold();