Skip to content

Commit 352df4a

Browse files
committed
add webhook auth example
1 parent e778db7 commit 352df4a

File tree

6 files changed

+1700
-2
lines changed

6 files changed

+1700
-2
lines changed

resize/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ The `resize` method allows you to resize and reposition the browser window dynam
99
## Usage
1010

1111
```ts
12-
1312
// Client
1413
const hb = await Hyperbeam(container, embedUrl);
1514
hb.resize(
1615
width, // width in pixels
1716
height // height in pixels
1817
);
19-
2018
```
2119

2220
## Steps

webhook-auth/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Hyperbeam Timeout example
2+
3+
Bring down costs and add quickly add paywalls using timeouts.
4+
5+
## What is this useful for?
6+
7+
The Hyperbeam API lets you specify absolute, inactive and offine timeouts for your browser sessions. This is useful to bring down costs, add paywalls, reduce the number of concurrent sessions and more.
8+
9+
## Usage
10+
11+
```ts
12+
// Server
13+
const response = await axios.post(
14+
"https://engine.hyperbeam.com/v0/vm",
15+
{
16+
timeout: {
17+
offline: 10, // when clients are offline
18+
inactive: 30, // when clients have the vm open but are inactive
19+
absolute: 60, // absolute time before the vm is terminated
20+
warning: 15, // time before the vm is terminated to show a warning
21+
webhook: {
22+
url: webhookUrl, // url to send the timeout webhook event to
23+
bearer, // bearer token to send with the webhook
24+
},
25+
},
26+
},
27+
{ headers }
28+
);
29+
```
30+
31+
## Steps
32+
33+
- Use `npm install` to install the dependencies altogether and navigate to the examples you want to run for more information.
34+
- Set your API key by running the following command in your terminal:
35+
36+
```bash
37+
38+
# Linux/macOS
39+
export HB_API_KEY=your_api_key
40+
41+
# Windows
42+
set HB_API_KEY=your_api_key
43+
```
44+
45+
Replace `your_api_key` with your API key from the [Hyperbeam dashboard](https://hyperbeam.com/dashboard).
46+
47+
- Run `npm run start`, a server should be listening on port 8080.
48+
49+
- Open <http://localhost:8080> on your browser. You should be able to see the browser session being terminated after 60 seconds.
50+
51+
## Need more help?
52+
53+
Send us an email at [founders@hyperbeam.com](mailto:founders@hyperbeam.com) or join our community [Discord server](https://discord.gg/D78RsGfQjq).

webhook-auth/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Hyperbeam Webhook Auth Example</title>
5+
</head>
6+
<body>
7+
<div id="hyperbeam-container" style="height: 720px; width: 1280px"></div>
8+
<div id="logs"></div>
9+
<script type="module">
10+
import Hyperbeam from "https://unpkg.com/@hyperbeam/web@latest/dist/index.js";
11+
const container = document.getElementById("hyperbeam-container");
12+
13+
const resp = await fetch("/computer");
14+
const data = await resp.json();
15+
const hb = await Hyperbeam(container, data.embed_url, {
16+
webhookUserdata: {
17+
token: data.webhook_token,
18+
},
19+
});
20+
</script>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)