Add custom peer ID support to register method

- Update register() to accept optional customPeerId parameter
- Add TypeScript documentation with JSDoc comments
- Update README with usage examples and documentation
- Maintain backward compatibility with auto-generated IDs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-22 16:10:24 +01:00
parent f5aa6e2189
commit aa53d5bc3d
3 changed files with 26 additions and 6 deletions

View File

@@ -436,14 +436,26 @@ const newPeers = await client.offers.findByTopic('movie-xyz', {
### Authentication
#### `client.register()`
#### `client.register(customPeerId?)`
Register a new peer and receive credentials.
```typescript
// Auto-generate peer ID
const creds = await client.register();
// { peerId: '...', secret: '...' }
// { peerId: 'f17c195f067255e357232e34cf0735d9', secret: '...' }
// Or use a custom peer ID (1-128 characters)
const customCreds = await client.register('my-custom-peer-id');
// { peerId: 'my-custom-peer-id', secret: '...' }
```
**Parameters:**
- `customPeerId` (optional): Custom peer ID (1-128 characters). If not provided, a random ID will be generated.
**Notes:**
- Returns 409 Conflict if the custom peer ID is already in use
- Custom peer IDs must be non-empty and between 1-128 characters
### Topics
#### `client.offers.getTopics(options?)`