use crypto for JS
This commit is contained in:
@@ -587,7 +587,7 @@ class NATSClient {
|
|||||||
| Package | Purpose |
|
| Package | Purpose |
|
||||||
|---------|---------|
|
|---------|---------|
|
||||||
| `nats` | Core NATS functionality (nats.js) |
|
| `nats` | Core NATS functionality (nats.js) |
|
||||||
| `uuid` | UUID generation |
|
| `crypto` (built-in) | UUID generation (Node.js) |
|
||||||
| `node-fetch` or `axios` | HTTP client for file server |
|
| `node-fetch` or `axios` | HTTP client for file server |
|
||||||
| `apache-arrow` | Arrow IPC serialization |
|
| `apache-arrow` | Arrow IPC serialization |
|
||||||
|
|
||||||
@@ -596,7 +596,7 @@ class NATSClient {
|
|||||||
| Package | Purpose |
|
| Package | Purpose |
|
||||||
|---------|---------|
|
|---------|---------|
|
||||||
| `nats` | Browser-compatible NATS client |
|
| `nats` | Browser-compatible NATS client |
|
||||||
| `uuid` | UUID generation |
|
| `crypto` (built-in) | UUID generation (browser) |
|
||||||
| `fetch` (native) | HTTP client for file server |
|
| `fetch` (native) | HTTP client for file server |
|
||||||
| `apache-arrow` | Arrow IPC serialization |
|
| `apache-arrow` | Arrow IPC serialization |
|
||||||
|
|
||||||
|
|||||||
@@ -581,20 +581,24 @@ Pkg.add("Dates")
|
|||||||
### JavaScript Dependencies (Node.js)
|
### JavaScript Dependencies (Node.js)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install nats uuid apache-arrow node-fetch
|
npm install nats apache-arrow node-fetch
|
||||||
# or
|
# or
|
||||||
yarn add nats uuid apache-arrow node-fetch
|
yarn add nats apache-arrow node-fetch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note:** Node.js has a built-in `crypto` module for UUID generation, so no external `uuid` package is needed.
|
||||||
|
|
||||||
### JavaScript Dependencies (Browser)
|
### JavaScript Dependencies (Browser)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install nats uuid apache-arrow
|
npm install nats apache-arrow
|
||||||
# or use CDN:
|
# or use CDN:
|
||||||
# https://unpkg.com/nats-js/dist/bundle/nats.min.js
|
# https://unpkg.com/nats-js/dist/bundle/nats.min.js
|
||||||
# https://unpkg.com/apache-arrow/arrow.min.js
|
# https://unpkg.com/apache-arrow/arrow.min.js
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note:** For browser UUID generation, use the built-in `crypto.randomUUID()` API (available in modern browsers) or a lightweight alternative like `uuidv4` package.
|
||||||
|
|
||||||
### Python Dependencies (Desktop)
|
### Python Dependencies (Desktop)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -1099,9 +1103,12 @@ end
|
|||||||
```javascript
|
```javascript
|
||||||
// natsbridge.js
|
// natsbridge.js
|
||||||
const nats = require('nats');
|
const nats = require('nats');
|
||||||
const { v4: uuidv4 } = require('uuid');
|
const crypto = require('crypto');
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
// UUID generation using built-in crypto module
|
||||||
|
const uuidv4 = () => crypto.randomUUID();
|
||||||
|
|
||||||
const DEFAULT_SIZE_THRESHOLD = 1_000_000;
|
const DEFAULT_SIZE_THRESHOLD = 1_000_000;
|
||||||
const DEFAULT_BROKER_URL = 'nats://localhost:4222';
|
const DEFAULT_BROKER_URL = 'nats://localhost:4222';
|
||||||
const DEFAULT_FILESERVER_URL = 'http://localhost:8080';
|
const DEFAULT_FILESERVER_URL = 'http://localhost:8080';
|
||||||
@@ -1152,10 +1159,13 @@ module.exports = {
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const nats = require('nats');
|
const nats = require('nats');
|
||||||
const { v4: uuidv4 } = require('uuid');
|
const crypto = require('crypto');
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const arrow = require('apache-arrow');
|
const arrow = require('apache-arrow');
|
||||||
|
|
||||||
|
// UUID generation using built-in crypto module
|
||||||
|
const uuidv4 = () => crypto.randomUUID();
|
||||||
|
|
||||||
const DEFAULT_SIZE_THRESHOLD = 1_000_000;
|
const DEFAULT_SIZE_THRESHOLD = 1_000_000;
|
||||||
const DEFAULT_BROKER_URL = 'nats://localhost:4222';
|
const DEFAULT_BROKER_URL = 'nats://localhost:4222';
|
||||||
const DEFAULT_FILESERVER_URL = 'http://localhost:8080';
|
const DEFAULT_FILESERVER_URL = 'http://localhost:8080';
|
||||||
|
|||||||
Reference in New Issue
Block a user