@@ -30,17 +30,16 @@ Run this code in your bash terminal (requires cURL):
31curl -i localhost:8080/~/login -X POST -d "password=lidlut-tabwed-pillex-ridrup"
31curl -i localhost:8080/~/login -X POST -d "password=lidlut-tabwed-pillex-ridrup"
34Let's explain what this does:
33Let's explain what this does:
36−- `-i` displays the headers, so that you can see the cookie that gets sent
35+ - `-i` displays the headers, so that you can see the cookie that gets sent
37−- `localhost:8080/~/login` is the URL to which you are POSTing. You will note this is also the URL you visit when you log into Landscape.
36+ - `localhost:8080/~/login` is the URL to which you are POSTing. You will note this is also the URL you visit when you log into Landscape.
38−- `-X POST` specifies that you are POSTing data, not GETting.
37+ - `-X POST` specifies that you are POSTing data, not GETting.
39−- `-d "password=lidlut-tabwed-pillex-ridrup"` specifies the code for your Urbit that we retrieved above. It is sent as form data, as if it were sent from an HTML form input field (which it is in Landscape)
38+ - `-d "password=lidlut-tabwed-pillex-ridrup"` specifies the code for your Urbit that we retrieved above. It is sent as form data, as if it were sent from an HTML form input field (which it is in Landscape)
41You should see the following:
40You should see the following:
44HTTP/1.1 200 ok
43HTTP/1.1 200 ok
45Date: Sun, 01 Jan 2020 00:00:00 GMT
44Date: Sun, 01 Jan 2020 00:00:00 GMT
46Connection: keep-alive
45Connection: keep-alive
@@ -53,11 +52,11 @@ The `Date` and `set-cookie` will be slightly different of course.
54Take a look at the `set-cookie` line. This is now your session authentication, and will need to be sent with any future requests. It consists of three parts:
53Take a look at the `set-cookie` line. This is now your session authentication, and will need to be sent with any future requests. It consists of three parts:
56−- `urbauth` is a prefix that Eyre uses to check for presence of authentication
55+ - `urbauth` is a prefix that Eyre uses to check for presence of authentication
57−- `~zod` is the name of the ship you are logging in as
56+ - `~zod` is the name of the ship you are logging in as
58−- `0v3.fvaqc.nnjda.vude1.vb5l6.kmjmg` is the actual authentication token.
57+ - `0v3.fvaqc.nnjda.vude1.vb5l6.kmjmg` is the actual authentication token.
60−At present there is no way to separate these parts — you must pass a cookie _as_ a cookie. This string must be in the `Cookie` header. The `set-cookie` header is only used for this request upon response. It is what browsers expect when receiving a cookie.
59+At present there is no way to separate these parts — you must pass a cookie *as* a cookie. This string must be in the `Cookie` header. The `set-cookie` header is only used for this request upon response. It is what browsers expect when receiving a cookie.
62## Interacting with Eyre
61## Interacting with Eyre
@@ -74,7 +73,7 @@ These can be used independently, i.e. you may choose to only send information or
75For this example, we will use the following channel:
74For this example, we will use the following channel:
78http://localhost:8080/~/channel/1601844290-ae45b
77http://localhost:8080/~/channel/1601844290-ae45b
@@ -136,23 +135,21 @@ This is all we need to send Urbit to say "On this URL through which I am sending
136You should be able to send this information if you were able to send the above cURL example. However, we now need to be able to listen to the SSEs. The `EventSource` object is available for JavaScript in the browser context, as this is why SSEs were invented, but there should be a library for it in your chosen language. Take a look at a Browser JavaScript example:
135You should be able to send this information if you were able to send the above cURL example. However, we now need to be able to listen to the SSEs. The `EventSource` object is available for JavaScript in the browser context, as this is why SSEs were invented, but there should be a library for it in your chosen language. Take a look at a Browser JavaScript example:
139−const eventSource = new EventSource(
140− "http://localhost:8080/~/channel/1601844290-ae45b",
138+const eventSource = new EventSource('http://localhost:8080/~/channel/1601844290-ae45b', {
142− withCredentials: true, // Required, sends your cookie
139+ withCredentials: true // Required, sends your cookie
146−eventSource.addEventListener("message", function (event) {
142+eventSource.addEventListener('message', function (event) {
147 ack(Number(event.lastEventId)); // See section below
143 ack(Number(event.lastEventId)); // See section below
148 const payload = JSON.parse(event.data); // Data is sent in JSON format
144 const payload = JSON.parse(event.data); // Data is sent in JSON format
149 payload.id === event.lastEventId; // The SSE spec includes event IDs. This information is duplicated in the payload.
145 payload.id === event.lastEventId; // The SSE spec includes event IDs. This information is duplicated in the payload.
150 const data = payload.json; // Beyond this, the actual data will vary between apps
146 const data = payload.json; // Beyond this, the actual data will vary between apps
153−eventSource.addEventListener("error", function (event) {
149+eventSource.addEventListener('error', function (event) {
154 handleError(event);
150 handleError(event);
158### Handling Received Events
155### Handling Received Events
@@ -169,7 +166,7 @@ Once you have received an event, it is expected that you will "ack" or "acknowle
170### Unsubscribing from Events
167### Unsubscribing from Events
172−You may want to stop receiving events from a particular app path, but you don't want to close the channel altogether yet. Let's look at how to do that. Take a look at the example for subscribing. We sent that message with `id: 2`. We will use that ID to cancel the relevant subscription:
169+You may want to stop receiving events from a particular app path, but you don't want to close the channel altogether yet. Let's look at how to do that. Take a look at the example for subscribing. We sent that message with `id: 2`. We will use that ID to cancel the relevant subscription:
174```javascript
171```javascript
@@ -200,7 +197,7 @@ Scrying lets you see what an app has exposed at a particular path. It does not m
201It takes the form `{url}/~/scry/{app}{path}.{mark}`
198It takes the form `{url}/~/scry/{app}{path}.{mark}`
203−Let's get the base hash of our fakezod in the same way that Landscape does it.
200+ Let's get the base hash of our fakezod in the same way that Landscape does it.
206curl --header "Content-Type: application/json" \
203curl --header "Content-Type: application/json" \