@softtynet/zca-js 2.2.6 โ†’ 2.2.8

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/CONTRIBUTING.md DELETED
@@ -1,470 +0,0 @@
1
- # Contributing to zca-js
2
-
3
- Thank you for your interest in contributing to zca-js! This project is maintained by the community and we welcome all contributions.
4
-
5
- ## Table of Contents
6
-
7
- - [Code of Conduct](#code-of-conduct)
8
- - [Getting Started](#getting-started)
9
- - [Development Setup](#development-setup)
10
- - [How to Contribute](#how-to-contribute)
11
- - [Pull Request Process](#pull-request-process)
12
- - [Code Style Guidelines](#code-style-guidelines)
13
- - [Testing Guidelines](#testing-guidelines)
14
- - [Documentation Guidelines](#documentation-guidelines)
15
- - [Security Guidelines](#security-guidelines)
16
- - [Release Process](#release-process)
17
- - [Getting Help](#getting-help)
18
-
19
- ## Code of Conduct
20
-
21
- This project adheres to our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you agree to abide by these rules.
22
-
23
- ## Getting Started
24
-
25
- ### Prerequisites
26
-
27
- - Node.js >= 18.0.0
28
- - Bun (recommended) or npm
29
- - Git
30
-
31
- ### Fork and Clone
32
-
33
- 1. Fork this repository
34
- 2. Clone your fork:
35
- ```bash
36
- git clone https://github.com/YOUR_USERNAME/zca-js.git
37
- cd zca-js
38
- ```
39
- 3. Add upstream remote:
40
- ```bash
41
- git remote add upstream https://github.com/RFS-ADRENO/zca-js.git
42
- ```
43
-
44
- ## Development Setup
45
-
46
- ### Install Dependencies
47
-
48
- ```bash
49
- # Using Bun (recommended)
50
- bun install
51
-
52
- # Or using npm
53
- npm install
54
- ```
55
-
56
- ### Build Project
57
-
58
- ```bash
59
- # Build both ESM and CJS
60
- bun run build
61
-
62
- # Build ESM only
63
- bun run build:esm
64
-
65
- # Build CJS only
66
- bun run build:cjs
67
- ```
68
-
69
- ### Run Tests
70
-
71
- ```bash
72
- # Run feature tests
73
- bun run test:feat
74
-
75
- # Run specific test file
76
- bun run test/test.ts
77
- ```
78
-
79
- ### Code Formatting
80
-
81
- ```bash
82
- # Format code with Prettier
83
- bun run prettier
84
- ```
85
-
86
- ## How to Contribute
87
-
88
- ### Types of Contributions
89
-
90
- We welcome the following types of contributions:
91
-
92
- - ๐Ÿ› **Bug Reports**: Report bugs and issues
93
- - โœจ **Feature Requests**: Suggest new features
94
- - ๐Ÿ”ง **Code Contributions**: Fix bugs and add features
95
- - ๐Ÿ“š **Documentation**: Improve docs and examples
96
- - ๐Ÿงช **Tests**: Add or improve tests
97
- - ๐Ÿ”’ **Security**: Report security vulnerabilities
98
- - ๐ŸŒ **Translations**: Translate docs to other languages
99
-
100
- ### Before You Start
101
-
102
- 1. **Check existing issues**: Search for existing issues before creating new ones
103
- 2. **Discuss major changes**: Create an issue to discuss major changes
104
- 3. **Follow the roadmap**: Check the current roadmap and priorities
105
-
106
- ## Pull Request Process
107
-
108
- ### Creating a Pull Request
109
-
110
- 1. **Create a feature branch**:
111
- ```bash
112
- git checkout -b feature/your-feature-name
113
- # or
114
- git checkout -b fix/your-bug-fix
115
- ```
116
-
117
- 2. **Make your changes**:
118
- - Follow code style guidelines
119
- - Add tests for new functionality
120
- - Update documentation if needed
121
-
122
- 3. **Test your changes**:
123
- ```bash
124
- bun run build
125
- bun run test:feat
126
- ```
127
-
128
- 4. **Commit your changes**:
129
- ```bash
130
- git add .
131
- git commit -m "feat: add new API method for group management"
132
- ```
133
-
134
- 5. **Push to your fork**:
135
- ```bash
136
- git push origin feature/your-feature-name
137
- ```
138
-
139
- 6. **Create a Pull Request**:
140
- - Use the provided PR template
141
- - Link related issues
142
- - Provide clear description of changes
143
-
144
- ### PR Review Process
145
-
146
- 1. **Automated checks** must pass
147
- 2. **Code review** by at least one maintainer
148
- 3. **Security review** for security-related changes
149
- 4. **Documentation review** for API changes
150
- 5. **Final approval** before merge
151
-
152
- ## Code Style Guidelines
153
-
154
- ### TypeScript Guidelines
155
-
156
- - Use TypeScript strict mode
157
- - Prefer interfaces over types for object shapes
158
- - Use meaningful variable and function names
159
- - Add JSDoc comments for public APIs
160
- - Use async/await over Promises when possible
161
-
162
- ### Code Organization
163
-
164
- The project follows a modular structure for better maintainability and organization:
165
-
166
- ```
167
- zca-js/
168
- โ”œโ”€โ”€ src/ # Source code directory
169
- โ”‚ โ”œโ”€โ”€ apis/ # API methods (100+ files)
170
- โ”‚ โ”‚ โ”œโ”€โ”€ sendMessage.ts # Core messaging functionality
171
- โ”‚ โ”‚ โ”œโ”€โ”€ login.ts # Authentication methods
172
- โ”‚ โ”‚ โ”œโ”€โ”€ loginQR.ts # QR code login
173
- โ”‚ โ”‚ โ”œโ”€โ”€ listen.ts # Event listening
174
- โ”‚ โ”‚ โ”œโ”€โ”€ sendVideo.ts # Video sending
175
- โ”‚ โ”‚ โ”œโ”€โ”€ sendVoice.ts # Voice sending
176
- โ”‚ โ”‚ โ”œโ”€โ”€ sendSticker.ts # Sticker sending
177
- โ”‚ โ”‚ โ”œโ”€โ”€ createGroup.ts # Group management
178
- โ”‚ โ”‚ โ”œโ”€โ”€ addReaction.ts # Message reactions
179
- โ”‚ โ”‚ โ”œโ”€โ”€ uploadAttachment.ts # File uploads
180
- โ”‚ โ”‚ โ””โ”€โ”€ ... # 90+ other API methods
181
- โ”‚ โ”œโ”€โ”€ models/ # TypeScript interfaces and types
182
- โ”‚ โ”‚ โ”œโ”€โ”€ Message.ts # Message interface
183
- โ”‚ โ”‚ โ”œโ”€โ”€ Attachment.ts # File attachment types
184
- โ”‚ โ”‚ โ”œโ”€โ”€ Reaction.ts # Reaction types
185
- โ”‚ โ”‚ โ”œโ”€โ”€ FriendEvent.ts # Friend event types
186
- โ”‚ โ”‚ โ”œโ”€โ”€ GroupEvent.ts # Group event types
187
- โ”‚ โ”‚ โ”œโ”€โ”€ Typing.ts # Typing indicators
188
- โ”‚ โ”‚ โ”œโ”€โ”€ SeenMessage.ts # Message seen events
189
- โ”‚ โ”‚ โ”œโ”€โ”€ DeliveredMessage.ts # Message delivery events
190
- โ”‚ โ”‚ โ”œโ”€โ”€ Undo.ts # Undo functionality
191
- โ”‚ โ”‚ โ”œโ”€โ”€ Enum.ts # Enumerations
192
- โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Model exports
193
- โ”‚ โ”œโ”€โ”€ Errors/ # Error handling
194
- โ”‚ โ”‚ โ”œโ”€โ”€ ZaloApiError.ts # Custom API error class
195
- โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Error exports
196
- โ”‚ โ”œโ”€โ”€ context.ts # Context management and state
197
- โ”‚ โ”œโ”€โ”€ utils.ts # Utility functions and helpers
198
- โ”‚ โ”œโ”€โ”€ zalo.ts # Main Zalo class implementation
199
- โ”‚ โ”œโ”€โ”€ update.ts # Update checking functionality
200
- โ”‚ โ””โ”€โ”€ index.ts # Public API exports
201
- โ”œโ”€โ”€ examples/ # Usage examples
202
- โ”‚ โ””โ”€โ”€ echobot.ts # Echo bot example
203
- โ”œโ”€โ”€ test/ # Test files
204
- โ”‚ โ”œโ”€โ”€ feat.ts # Feature tests
205
- โ”‚ โ”œโ”€โ”€ feat.test.ts # Feature test suite
206
- โ”‚ โ”œโ”€โ”€ test.ts # General tests
207
- โ”‚ โ””โ”€โ”€ a.png # Test assets
208
- โ”œโ”€โ”€ .github/ # GitHub configuration
209
- โ”‚ โ””โ”€โ”€ ISSUE_TEMPLATE/ # Issue templates
210
- โ”œโ”€โ”€ .dev/ # Development tools (developer generated)
211
- โ”œโ”€โ”€ dist/ # Build output (generated)
212
- โ”œโ”€โ”€ node_modules/ # Dependencies (generated)
213
- โ”œโ”€โ”€ package.json # Project configuration
214
- โ”œโ”€โ”€ tsconfig.json # TypeScript configuration
215
- โ”œโ”€โ”€ rollup.config.js # Build configuration
216
- โ”œโ”€โ”€ README.md # Project documentation
217
- โ”œโ”€โ”€ CONTRIBUTING.md # Contribution guidelines
218
- โ”œโ”€โ”€ SECURITY.md # Security policy
219
- โ”œโ”€โ”€ CODE_OF_CONDUCT.md # Community guidelines
220
- โ””โ”€โ”€ LICENSE # MIT License
221
- ```
222
-
223
- ### Key Directories Explained
224
-
225
- - **`src/apis/`**: Contains all API method implementations (~100 files)
226
-
227
- - **`src/models/`**: TypeScript interfaces and type definitions
228
- - Core data structures for messages, events, and API responses
229
- - Ensures type safety across the application
230
-
231
- - **`src/Errors/`**: Custom error handling
232
- - `ZaloApiError.ts`: Handles API-specific errors
233
- - Provides consistent error handling across the library
234
-
235
- - **`examples/`**: Usage examples and demonstrations
236
- - `echobot.ts`: Complete example of a Zalo bot implementation
237
-
238
- - **`test/`**: Test suites and test assets
239
- - Feature tests for core functionality
240
- - Integration tests for API methods
241
-
242
- ### Naming Conventions
243
-
244
- - **Files**: camelCase (e.g., `sendMessage.ts`)
245
- - **Classes**: PascalCase (e.g., `ZaloApiError`)
246
- - **Functions**: camelCase (e.g., `sendMessage`)
247
- - **Constants**: UPPER_SNAKE_CASE (e.g., `API_BASE_URL`)
248
- - **Interfaces**: PascalCase with `I` prefix (e.g., `IMessage`)
249
-
250
- ### Error Handling
251
-
252
- ```typescript
253
- // Good
254
- try {
255
- const result = await api.sendMessage(message);
256
- return result;
257
- } catch (error) {
258
- if (error instanceof ZaloApiError) {
259
- throw error;
260
- }
261
- throw new ZaloApiError(`Failed to send message: ${error.message}`);
262
- }
263
-
264
- // Bad
265
- try {
266
- const result = await api.sendMessage(message);
267
- return result;
268
- } catch (error) {
269
- console.error(error);
270
- return null;
271
- }
272
- ```
273
-
274
- ## Testing Guidelines
275
-
276
- ### Test Structure
277
-
278
- ```typescript
279
- describe('API Method', () => {
280
- beforeEach(() => {
281
- // Setup
282
- });
283
-
284
- afterEach(() => {
285
- // Cleanup
286
- });
287
-
288
- it('should handle success case', async () => {
289
- // Test implementation
290
- });
291
-
292
- it('should handle error case', async () => {
293
- // Test error handling
294
- });
295
- });
296
- ```
297
-
298
- ### Testing Best Practices
299
-
300
- - Test both success and failure scenarios
301
- - Mock external dependencies
302
- - Use descriptive test names
303
- - Keep tests independent
304
- - Test edge cases and error conditions
305
-
306
- ### Running Tests
307
-
308
- ```bash
309
- # Run all tests
310
- bun run test:feat
311
-
312
- # Run specific test
313
- bun run test/test.ts
314
-
315
- # Run with coverage (if available)
316
- bun run test:coverage
317
- ```
318
-
319
- ## Documentation Guidelines
320
-
321
- ### API Documentation
322
-
323
- - Document all public methods with JSDoc
324
- - Include parameter types and descriptions
325
- - Provide usage examples
326
- - Document error conditions
327
-
328
- ```typescript
329
- /**
330
- * Sends a message to a specific thread
331
- * @param message - The message object containing content and metadata
332
- * @param threadId - The ID of the thread to send the message to
333
- * @param threadType - The type of thread (User or Group)
334
- * @returns Promise<Message> - The sent message object
335
- * @throws {ZaloApiError} When the API request fails
336
- * @example
337
- * ```typescript
338
- * const message = await api.sendMessage(
339
- * { msg: "Hello, world!" },
340
- * "123456789",
341
- * ThreadType.User
342
- * );
343
- * ```
344
- */
345
- async sendMessage(message: IMessage, threadId: string, threadType: ThreadType): Promise<Message>
346
- ```
347
-
348
- ### README Updates
349
-
350
- - Update README.md for new features
351
- - Add examples for new APIs
352
- - Update installation instructions if needed
353
- - Keep the table of contents updated
354
-
355
- ## Security Guidelines
356
-
357
- ### Security Best Practices
358
-
359
- - Never commit sensitive data (tokens, passwords, etc.)
360
- - Use environment variables for configuration
361
- - Validate all user inputs
362
- - Follow the principle of least privilege
363
- - Report security issues privately
364
-
365
- ### Security Reporting
366
-
367
- If you discover a security vulnerability:
368
-
369
- 1. **DO NOT** create a public issue
370
- 2. Use the [SECURITY.md](SECURITY.md) reporting process
371
- 3. Create a private issue with `[SECURITY]` label
372
- 4. Contact team members directly for urgent issues
373
-
374
- ### Code Security
375
-
376
- ```typescript
377
- // Good - Validate inputs
378
- function sendMessage(content: string, threadId: string) {
379
- if (!content || typeof content !== 'string') {
380
- throw new ZaloApiError('Content must be a non-empty string');
381
- }
382
- if (!threadId || typeof threadId !== 'string') {
383
- throw new ZaloApiError('ThreadId must be a non-empty string');
384
- }
385
- // Implementation
386
- }
387
-
388
- // Bad - No validation
389
- function sendMessage(content: any, threadId: any) {
390
- // Implementation without validation
391
- }
392
- ```
393
-
394
- ## Release Process
395
-
396
- ### Versioning
397
-
398
- We follow [Semantic Versioning](https://semver.org/):
399
-
400
- - **MAJOR**: Breaking changes
401
- - **MINOR**: New features (backward compatible)
402
- - **PATCH**: Bug fixes (backward compatible)
403
-
404
- ### Release Checklist
405
-
406
- - [ ] All tests pass
407
- - [ ] Documentation is updated
408
- - [ ] Version is bumped in package.json
409
- - [ ] Build is successful
410
- - [ ] Release notes are prepared
411
-
412
- ### Publishing
413
-
414
- ```bash
415
- # Build the project
416
- bun run build
417
-
418
- # Run tests
419
- bun run test:feat
420
-
421
- # Publish to npm
422
- npm publish
423
- ```
424
-
425
- ## Getting Help
426
-
427
- ### Communication Channels
428
-
429
- - **GitHub Issues**: For bug reports and feature requests
430
- - **GitHub Discussions**: For questions and general discussion
431
- - **Pull Requests**: For code contributions
432
- - **Security Issues**: Use `[SECURITY]` label
433
-
434
- ### Team Members
435
-
436
- - [@RFS-ADRENO](https://github.com/RFS-ADRENO)
437
- - [@truong9c2208](https://github.com/truong9c2208)
438
- - [@JustKemForFun](https://github.com/JustKemForFun)
439
-
440
- ### Resources
441
-
442
- - [API Documentation](https://zca-js.tdung.com)
443
- - [Examples](examples/)
444
- - [Security Policy](SECURITY.md)
445
- - [Code of Conduct](CODE_OF_CONDUCT.md)
446
-
447
- ## Special Considerations for zca-js
448
-
449
- ### Unofficial API Library
450
-
451
- > [!IMPORTANT]
452
- > โš ๏ธ zca-js is an unofficial API library for Zalo. Please be aware of:
453
-
454
- - **Account Risk**: Using this API may result in account suspension
455
- - **Terms of Service**: Respect Zalo's ToS in your contributions
456
- - **Rate Limiting**: Be mindful of API usage limits
457
- - **Privacy**: Protect user privacy and data
458
-
459
- ### Responsible Development
460
-
461
- - Test changes thoroughly before submitting
462
- - Avoid introducing features that could harm users
463
- - Consider the impact on Zalo's infrastructure
464
- - Document any risks or limitations
465
-
466
- ---
467
-
468
- **Thank you for contributing to zca-js!** ๐Ÿš€
469
-
470
- Your contributions help make this library better for the entire community.
package/SECURITY.md DELETED
@@ -1,83 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- We actively maintain and provide security updates for the following versions:
6
-
7
- | Version | Supported |
8
- | ------- | ------------------ |
9
- | 2.0.x | :white_check_mark: |
10
- | 1.x.x | :x: |
11
- | < 1.0 | :x: |
12
-
13
- ## Reporting a Vulnerability
14
-
15
- We take security vulnerabilities seriously. If you discover a security vulnerability in zca-js, please follow these steps:
16
-
17
- ### 1. **DO NOT** create a public GitHub issue
18
- Security vulnerabilities should be reported privately to prevent potential exploitation.
19
-
20
- ### 2. Report the vulnerability
21
- Send an email to the maintainers with the following information:
22
- - **Subject**: `[SECURITY] zca-js vulnerability report`
23
- - **Description**: Detailed description of the vulnerability
24
- - **Steps to reproduce**: Clear steps to reproduce the issue
25
- - **Impact assessment**: Potential impact of the vulnerability
26
- - **Suggested fix** (if available): Any suggestions for fixing the issue
27
-
28
- ### 3. Response timeline
29
- - **Initial response**: Within 48 hours
30
- - **Status update**: Within 1 week
31
- - **Resolution**: As soon as possible, typically within 30 days
32
-
33
- ## Security Considerations
34
-
35
- ### Important Warnings
36
-
37
- โš ๏ธ **This is an unofficial API library** that simulates browser interactions with Zalo Web. Please be aware of the following security considerations:
38
-
39
- 1. **Account Risk**: Using this API may result in your Zalo account being locked or banned. Use at your own risk.
40
-
41
- 2. **Authentication**: The library handles sensitive authentication data. Ensure proper security measures when storing or transmitting this information.
42
-
43
- 3. **Rate Limiting**: Respect Zalo's rate limits to avoid triggering security measures.
44
-
45
- 4. **Data Privacy**: Be mindful of user privacy and comply with relevant data protection regulations.
46
-
47
- ### Best Practices
48
-
49
- 1. **Environment Variables**: Store sensitive configuration in environment variables, not in code
50
- 2. **HTTPS Only**: Always use HTTPS when transmitting data
51
- 3. **Input Validation**: Validate all inputs before processing
52
- 4. **Error Handling**: Implement proper error handling to avoid information disclosure
53
- 5. **Regular Updates**: Keep the library updated to the latest version
54
-
55
- ### Known Limitations
56
-
57
- - This library is not officially supported by Zalo
58
- - API endpoints and behavior may change without notice
59
- - No guarantee of service availability or stability
60
- - May break with Zalo Web updates
61
-
62
- ## Security Updates
63
-
64
- Security updates will be released as patch versions (e.g., 2.0.1, 2.0.2) and will be clearly marked in the changelog.
65
-
66
- ## Contact Information
67
-
68
- For security-related issues, please contact:
69
- - **GitHub Issues**: Create a private issue with the `[SECURITY]` label
70
- - **GitHub Discussions**: Use the "Security" category for general security questions
71
- - **Team Members**:
72
- - [@RFS-ADRENO](https://github.com/RFS-ADRENO)
73
- - [@truong9c2208](https://github.com/truong9c2208)
74
- - [@JustKemForFun](https://github.com/JustKemForFun)
75
- - **Alternative**: Contact any team member through GitHub for urgent security matters
76
-
77
- ## Acknowledgments
78
-
79
- We appreciate security researchers and community members who responsibly disclose vulnerabilities. Contributors will be acknowledged in our security advisories unless they prefer to remain anonymous.
80
-
81
- ---
82
-
83
- **Note**: This security policy is subject to change. Please check back regularly for updates.