@@ -1346,7 +1346,7 @@ paths:
1346
1346
200 :
1347
1347
$ref : " #/paths/~1batch/post/responses/200"
1348
1348
1349
- /oxen/v3 /lsrpc :
1349
+ /oxen/v4 /lsrpc :
1350
1350
post :
1351
1351
tags : [Onion]
1352
1352
summary : " Endpoint for submitting an encrypted onion request"
@@ -1359,66 +1359,54 @@ paths:
1359
1359
the onion encryption layer; the onion encryption payload itself is documented elsewhere.
1360
1360
required : true
1361
1361
content :
1362
- application/json :
1362
+ application/octet-stream :
1363
1363
schema :
1364
- type : object
1365
- required : [endpoint, method, headers]
1366
- properties :
1367
- method :
1368
- type : string
1369
- description : " The request method type as a string, i.e. `GET`, `POST`, `PUT`, `DELETE`."
1370
- endpoint :
1371
- type : string
1372
- description : >
1373
- The request path, e.g. `/room/123/messages/since/45678`. This name should be
1374
- the full path beginning with a `/`; methods without a leading / are
1375
- interpreted as legacy endpoints for older versions of Session and should not
1376
- be used.
1377
- headers :
1378
- type : object
1379
- description : >
1380
- HTTP headers for the request; should usually include the pubkey, nonce,
1381
- timestamp, and signature headers (`X-SOGS-Pubkey`, etc.), and sometimes a
1382
- `Content-Type` header (the latter, if omitted, defaults to `application/json`
1383
- if using `body`, and `application/octet-stream` if using `body_binary`).
1384
- body :
1385
- description : >
1386
- Request body of the onion request. This is typically used for text-based
1387
- values (such as JSON requests). Exclusive of `body_binary`. Not accepted for
1388
- `GET` requests.
1389
- type : string
1390
- body_binary :
1391
- description : >
1392
- Request body for a onion request to a binary endpoint, with the body encoded
1393
- in base64. Exclusive of `body`. Not accepted for `GET` requests.
1394
-
1395
-
1396
- The endpoint will be called with the *decoded* byte value as its body, thus
1397
- allowing you to POST to endpoints that require binary data (such as file
1398
- uploads). Note that when using the Content-Type header defaults to
1399
- `application/octet-stream`.
1400
-
1401
-
1402
- Note that when including a signature in the `X-SOGS-Signature` header, the
1403
- signature must use the decoded byte value of the body, *not* the encoded
1404
- base64 value.
1405
-
1406
-
1407
- This is somewhat wasteful because of the overhead of base64-encoding, but is a
1408
- limitation of onion requests.
1409
- type : string
1410
- format : byte
1364
+ type : string
1365
+ format : binary
1366
+ description : >
1367
+ The onion request data. This is encoded/encrypted in multiple layers, as follows.
1368
+
1369
+
1370
+ The data is first constructed as one or two parts: the first part is json contains
1371
+ request metadata with fields:
1372
+ - method -- "GET", "POST", etc. of the subrequest
1373
+ - endpoint -- the subrequest endpoint, e.g. `/room/some-room/messages/since/123`
1374
+ - headers -- request headers, typically containing X-SOGS-* auth info and, for
1375
+ POST/PUT requests, a Content-Type.
1376
+
1377
+
1378
+ The second part is the request body, in bytes (only for POST/PUT requests).
1379
+
1380
+
1381
+ These two pieces are encoded as a one- or two-string bencoded list, which has format:
1382
+
1383
+
1384
+ `l123:jsone` or `l123:json456:bodye` where 123 is the length of the json and 456 is
1385
+ the length of the body, if the request has a body. (Both strings are byte strings).
1386
+
1387
+
1388
+ This data is then encrypted using onion-request style encryption; see the
1389
+ oxen-storage-server for details on how this is done.
1411
1390
responses :
1412
1391
200 :
1413
1392
description : >
1414
- Request completed. The actual response will be base64-encoded and encrypted. For
1415
- requests that fail with an HTTP response (i.e. other than 200) the response will
1416
- base64+decrypt to the json value `{"status_code": N}` where `N` is the integer error
1417
- code that occurred (e.g. 404).
1393
+ Onion request completed. The subrequest response will be encoded in a two-string
1394
+ bencoded list (see the request details for the encoding specifics) where the first
1395
+ string contains the response metadata as json with keys:
1418
1396
1419
- For successful (i.e. 200) responses the returned value is whatever the body of the
1420
- request returned. (Returning headers via onion requests is not supported.)
1421
-
1397
+
1398
+ - code -- the HTTP response code of the subrequest, e.g. 200, 404
1399
+ - headers -- a dict of HTTP response headers; the header name keys are always
1400
+ lower-cased.
1401
+
1402
+
1403
+ The second part is the response body bytes; as in HTTP, interpreting this depends on the
1404
+ `content-type` header in the `headers` metadata, and the details of the invoked
1405
+ endpoint.
1406
+
1407
+
1408
+ These two byte strings are bencoded, and then the bencoded data is encrypted using the
1409
+ same ephemeral key and encryption type as was used in the request.
1422
1410
1423
1411
components :
1424
1412
schemas :
0 commit comments