ncc-06-js 0.3.0 → 0.3.1

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 (3) hide show
  1. package/DOCS.md +1 -1
  2. package/README.md +38 -0
  3. package/package.json +1 -1
package/DOCS.md CHANGED
@@ -79,7 +79,7 @@ Utilities for locator payload construction and evaluation.
79
79
  - Reads a config block (`k.mode`) and returns the expected `k` string for static/generate/tls modes; used by the sidecar.
80
80
 
81
81
  ### Key helpers
82
- - `generateKeypair()`, `toNpub()`, `fromNsec()` wrap `nostr-tools` key utilities for convenience.
82
+ - `generateKeypair()`, `toNpub()`, `fromNpub()`, `toNsec()`, `fromNsec()` wrap `nostr-tools` key utilities for convenience.
83
83
  - `ensureSelfSignedCert(options)` generates a self-signed cert for local `wss://` endpoints.
84
84
 
85
85
  ## Endpoint helpers
package/README.md CHANGED
@@ -39,6 +39,44 @@ const resolution = await resolveServiceEndpoint({
39
39
  console.log('Resolved API endpoint:', resolution.endpoint);
40
40
  ```
41
41
 
42
+ ### Resolving a Tor Service via Npub
43
+
44
+ ```js
45
+ import { resolveServiceEndpoint, fromNpub } from 'ncc-06-js';
46
+
47
+ const servicePubkey = fromNpub('npub1...');
48
+
49
+ const resolution = await resolveServiceEndpoint({
50
+ bootstrapRelays: ['wss://relay.damus.io'],
51
+ servicePubkey,
52
+ serviceId: 'relay',
53
+ locatorId: 'relay-locator',
54
+ torPreferred: true // Prefer .onion endpoints if available
55
+ });
56
+
57
+ console.log('Resolved Onion Endpoint:', resolution.endpoint);
58
+ ```
59
+
60
+ ### Configuring an Onion Service Sidecar
61
+
62
+ ```js
63
+ import { buildExternalEndpoints, buildSidecarConfig } from 'ncc-06-js';
64
+
65
+ // 1. Build endpoints (detects Onion, IPv6, IPv4)
66
+ const endpoints = await buildExternalEndpoints({
67
+ tor: { enabled: true },
68
+ ensureOnionService: async () => ({ address: 'abcdef...', servicePort: 80 })
69
+ });
70
+
71
+ // 2. Build config
72
+ const config = buildSidecarConfig({
73
+ secretKey: '...',
74
+ serviceUrl: 'ws://abcdef....onion', // Primary identity URL
75
+ externalEndpoints: endpoints,
76
+ serviceMode: 'public'
77
+ });
78
+ ```
79
+
42
80
  ### Building a Service Config
43
81
 
44
82
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ncc-06-js",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Reusable NCC-06 discovery helpers extracted from the example relay, sidecar, and client.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",