From 0ef8dd61a802f9812f46f9c41b00e590896d7926 Mon Sep 17 00:00:00 2001 From: narawat Date: Sun, 8 Mar 2026 11:34:10 +0700 Subject: [PATCH] use crypto for JS --- docs/updated_architecture.md | 4 ++-- docs/updated_implementation.md | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/updated_architecture.md b/docs/updated_architecture.md index 6b0763e..8b57af8 100644 --- a/docs/updated_architecture.md +++ b/docs/updated_architecture.md @@ -587,7 +587,7 @@ class NATSClient { | Package | Purpose | |---------|---------| | `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 | | `apache-arrow` | Arrow IPC serialization | @@ -596,7 +596,7 @@ class NATSClient { | Package | Purpose | |---------|---------| | `nats` | Browser-compatible NATS client | -| `uuid` | UUID generation | +| `crypto` (built-in) | UUID generation (browser) | | `fetch` (native) | HTTP client for file server | | `apache-arrow` | Arrow IPC serialization | diff --git a/docs/updated_implementation.md b/docs/updated_implementation.md index 82b703d..ed21567 100644 --- a/docs/updated_implementation.md +++ b/docs/updated_implementation.md @@ -581,20 +581,24 @@ Pkg.add("Dates") ### JavaScript Dependencies (Node.js) ```bash -npm install nats uuid apache-arrow node-fetch +npm install nats apache-arrow node-fetch # 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) ```bash -npm install nats uuid apache-arrow +npm install nats apache-arrow # or use CDN: # https://unpkg.com/nats-js/dist/bundle/nats.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) ```bash @@ -1099,9 +1103,12 @@ end ```javascript // natsbridge.js const nats = require('nats'); -const { v4: uuidv4 } = require('uuid'); +const crypto = require('crypto'); 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_BROKER_URL = 'nats://localhost:4222'; const DEFAULT_FILESERVER_URL = 'http://localhost:8080'; @@ -1152,10 +1159,13 @@ module.exports = { ```javascript const nats = require('nats'); -const { v4: uuidv4 } = require('uuid'); +const crypto = require('crypto'); const fetch = require('node-fetch'); 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_BROKER_URL = 'nats://localhost:4222'; const DEFAULT_FILESERVER_URL = 'http://localhost:8080';