|
| 1 | +# PulseBeam CLI |
| 2 | + |
| 3 | +Generates secure tokens for client-side applications. For example, clients using the `@pulsebeam/peer` WebRTC Peer-to-Peer Communication SDK. |
| 4 | + |
| 5 | +These tokens enable secure interaction with PulseBeam signaling servers for peer-to-peer connections. |
| 6 | + |
| 7 | +For a server-side token-generation alternative and more documentation, see [`@pulsebeam/server`](https://jsr.io/@pulsebeam/server). |
| 8 | + |
| 9 | +## Quick Start |
| 10 | + |
| 11 | +```bash |
| 12 | +cargo build |
| 13 | +./target/debug/pulsebeam-cli create-token \ |
| 14 | + --peer-id "peer-1" \ |
| 15 | + --group-id "test" \ |
| 16 | + --allow-policy "test:peer-*" \ |
| 17 | + --api-key "your_api_key" \ |
| 18 | + --api-secret "your_api_secret" |
| 19 | + |
| 20 | +./target/debug/pulsebeam-cli create-token \ |
| 21 | + --peer-id "peer-2" \ |
| 22 | + --group-id "test" \ |
| 23 | + --allow-policy "test:peer-*" \ |
| 24 | + --api-key "your_api_key" \ |
| 25 | + --api-secret "your_api_secret" |
| 26 | +``` |
| 27 | + |
| 28 | +Now you should have two tokens. You can use the tokens to connect the two peers together using PulseBeam. They are valid for the next hour. |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +1. Make sure you have Rust and Cargo installed: https://rustup.rs/ |
| 33 | +2. Clone this repository. |
| 34 | +3. Navigate to the project directory in your terminal. |
| 35 | +4. Build the project: `cargo build` |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```bash |
| 40 | +./target/debug/pulsebeam-cli create-token --help |
| 41 | +``` |
| 42 | +| Parameter | Description | |
| 43 | +|---------------|-------------------------------------------------------------------------------------------------------| |
| 44 | +| `peer-id` | ID for the peer this token is intended to be used by. [More info](https://jsr.io/@pulsebeam/server/doc/~/PeerClaims#constructor_0) | |
| 45 | +| `group-id` | ID for the group the peer is in, scoped to your application. [More info](https://jsr.io/@pulsebeam/server/doc/~/PeerClaims#constructor_0) | |
| 46 | +| `duration` | Duration in seconds TTL before token expiration. | |
| 47 | +| `allow-policy`| Defines which peer(s) this peer is allowed to connect to. Default: `\"*:*\"` (connect to any other peer)[^1]. [More info](https://jsr.io/@pulsebeam/server/doc/~/PeerPolicy) | |
| 48 | +| `create-token`| Generates a token[^2][^3] based on the provided inputs/defaults. | |
| 49 | + |
| 50 | +[^1]: Even with the `\"*:*\"` allow-policy, peers can only connect to other peers within the scope of your `<API_KEY>`. |
| 51 | + |
| 52 | +[^2]: Provide the CLI-generated token to your client's to allow them to talk to PulseBeam signaling servers and make connections with each other. |
| 53 | + |
| 54 | +[^3]: See billing section below. |
| 55 | + |
| 56 | +```bash |
| 57 | +./target/debug/pulsebeam-cli --help |
| 58 | +``` |
| 59 | + |
| 60 | +* Set `api-key` and `api-secret` with your credentials obtained from PulseBeam (https://pulsebeam.dev). |
| 61 | +* Warning: be sure to protect your <API_KEY> and <API_SECRET>. See information below |
| 62 | + |
| 63 | +## ⚠️ Security Warning |
| 64 | + |
| 65 | +**Keep your API credentials secure!** |
| 66 | + |
| 67 | +- The `<API_KEY>` and `<API_SECRET>` are sensitive credentials that grant access to your application’s PulseBeam resources. **Do not expose these credentials** in: |
| 68 | + - Public repositories. |
| 69 | + - Client-side code. |
| 70 | + - Shared or unencrypted environments. |
| 71 | + |
| 72 | +- Treat tokens generated by this CLI as sensitive data. Tokens should only be shared with trusted clients. |
| 73 | + |
| 74 | +### Recommended Practices: |
| 75 | +1. **Environment Variables:** Store your API credentials securely in environment variables instead of hardcoding them in your codebase. |
| 76 | + ```bash |
| 77 | + export PULSEBEAM_API_KEY="your_api_key" |
| 78 | + export PULSEBEAM_API_SECRET="your_api_secret" |
| 79 | + ``` |
| 80 | + |
| 81 | +2. **Access Controls:** Regularly rotate API credentials and limit their scope to only necessary permissions. |
| 82 | + |
| 83 | +3. **Auditing:** Monitor usage of your credentials and investigate any unauthorized activity. |
| 84 | + |
| 85 | +## 💳 Billing and Token Usage |
| 86 | + |
| 87 | +**Be aware:** Generating and using tokens can incur billing charges. Each token enables interactions with PulseBeam's infrastructure, which may contribute to your account’s usage costs. |
| 88 | +
|
| 89 | +### Billing Best Practices: |
| 90 | +1. **Understand Your Plan:** Familiarize yourself with the details of your billing plan. For more information, visit our [Billing Page](https://pulsebeam.dev/billing). |
| 91 | +2. **Monitor Usage:** Keep track of token usage to avoid unexpected charges. Utilize PulseBeam’s dashboards and APIs for real-time monitoring. |
| 92 | +3. **Token Expiration:** Set appropriate `duration` values for tokens to limit unnecessary usage. Tokens with a longer duration may result in increased billing if misused. |
| 93 | +4. **Audit Token Distribution:** Ensure tokens are only distributed to trusted clients to avoid misuse that could drive up costs. |
| 94 | +
|
| 95 | +### ⚠️ Important Billing Warning |
| 96 | +
|
| 97 | +- Tokens allow access to PulseBeam's infrastructure and **may result in charges depending on your usage**. |
| 98 | +- Misuse or unauthorized distribution of tokens can lead to **unexpected billing costs**. |
| 99 | +- **Ensure you monitor your account's activity regularly** and revoke tokens that are no longer needed. |
| 100 | +
|
| 101 | +For detailed information on billing and usage policies, visit our [Billing Page](https://pulsebeam.dev/billing). |
0 commit comments