You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: src/core/main.tsp
+2-206Lines changed: 2 additions & 206 deletions
Original file line number
Diff line number
Diff line change
@@ -2,212 +2,8 @@ import "@typespec/http";
2
2
import"@typespec/rest";
3
3
import"@typespec/openapi3";
4
4
import"./routes";
5
+
import"./models";
5
6
6
-
usingTypeSpec.Http;
7
-
usingRoutes;
8
-
usingFederatedIdentity;
9
-
usingServices;
10
-
usingMigration;
11
-
usingResourceAddressingWithRelativeRoots;
7
+
usingVersioning;
12
8
13
9
namespacepolyproto.core;
14
-
15
-
namespacemodels {
16
-
modelEncryptedPKM {
17
-
/**
18
-
* Custom variant of the X.509 `SubjectPublicKeyInfo`, where the `subject_public_key`
19
-
* field stores the encrypted private key, instead of a public key. Otherwise equal to
20
-
* `SubjectPublicKeyInfo`. Also referred to as `PrivateKeyInfo`.
21
-
*/
22
-
key_data:string;
23
-
24
-
@doc("The serial number of the ID-Cert this key material is associated with.")
25
-
serialNumber:uint64;
26
-
27
-
/**
28
-
* Information about the algorithms used to encrypt the data held by the `key_data` field.
29
-
* Order-sensitive; The encryption used for the first encryption operation must be the last
30
-
* item of this array and vice versa. Represents a list of OIDs.
31
-
*/
32
-
@minItems(1)
33
-
encryptionAlgorithms:Array<Array<uint16>>;
34
-
}
35
-
36
-
/**
37
-
* A resource representing information about a discoverable service for an actor. You can learn more about
38
-
* services and discoverability by reading [section #9](/Protocol Specifications/core#9-services) of
39
-
* the core protocol specification.
40
-
*
41
-
* This resource contains information about the name of the service that is being made discoverable,
42
-
* the URL of the service provider, and whether this service provider is the primary service provider
43
-
* for the actor.
44
-
*/
45
-
modelService {
46
-
@minLength(2)
47
-
@maxLength(64)
48
-
@doc("The name of the service that is being made discoverable. Must be formatted according to [section #8.2: Namespaces](/Protocol Specifications/core#82-namespaces) in the core protocol specification")
49
-
service:string;
50
-
51
-
@doc("The base URL of the service provider, not including `/.p2/<service_name>`. Trailing slashes are allowed. If `(/).p2/<service_name>` is added to the URL specified here, a polyproto client should be able to access the HTTP API routes provided by the service.")
52
-
url:url;
53
-
54
-
@doc("Whether the service provider specified in the url field is the primary service provider for this service and actor.")
55
-
primary:boolean;
56
-
}
57
-
58
-
/**
59
-
* A key trial as sent from the server to an actor.
60
-
*
61
-
* Used to verify an actor's private identity key possession,
62
-
* without revealing the private key itself
63
-
*/
64
-
modelKeyTrial {
65
-
@minLength(32)
66
-
@maxLength(256)
67
-
@doc("The key trial, which the client should sign with their private identity key.")
68
-
trial:string;
69
-
70
-
@doc("The UNIX timestamp after which the key trial expires.")
71
-
expires:uint64;
72
-
}
73
-
74
-
/**
75
-
* A completed key trial, as an actor would send to the server.
76
-
*/
77
-
modelKeyTrialCompleted {
78
-
@doc("The signature produced by signing the key trial string using a private identity key.")
79
-
signature:string;
80
-
81
-
@doc("The serial number of the ID-Cert corresponding to the private identity key used to sign the key trial string.")
82
-
serialNumber:uint64;
83
-
}
84
-
85
-
/**
86
-
* A message batch, as received from and sent to the server in the context of re-signing messages.
87
-
* This type is generic over `T`, where `T` represents the content of the actual message. This
88
-
* means, that the specific message content depends on the concrete implementation or extension
89
-
* of the polyproto protocol.
90
-
*/
91
-
modelMessageBatch<T> {
92
-
@doc("The ID-Cert that the following messages' signatures correspond to.")
93
-
idCert:string;
94
-
95
-
@doc("The actual message.")
96
-
messages: {
97
-
@doc("Signature of the whole message")
98
-
signature:string;
99
-
100
-
@doc("Arbitrary content `T`. This depends on the specific implementation or extension of the protocol.")
/** The data is a gzipped tarball (.tar.gz) named `export1234567890-user@subdomain.example.com`, where
108
-
* - `export[numbers]` is the word `export` with 20 random digits appended to it
109
-
* - `user` is the actors' name
110
-
* - `subdomain.example.com` is the FQDN of the server the actor is registered on.
111
-
* This file archive contains a file `messages.p2mb` which is a JSON file containing [message batches](https://docs.polyphony.chat/Protocol%20Specifications/core/#721-message-batches)
112
-
* of all messages sent by the user. If the server where the data export was requested from has
113
-
* [RawR](https://docs.polyphony.chat/Protocol%20Specifications/core/#731-resource-addressing-with-relative-roots) enabled, the file archive will contain a
114
-
* folder named `rawr`. This folder contains all RawR content uploaded by the actor to that server.
115
-
* The files in this folder are named after the resource ID given to the resource. File extensions are only
116
-
* added if they were known to the server. An example file name might be
117
-
* `2c851bfb6daffa944fa1723c7bd4d362ffbc9defe292f2daaf05e895989d179b.jxl`, referencing the file
118
-
* which was hosted at `<server_url>/.p2/core/resource/2c851bfb6daffa944fa1723c7bd4d362ffbc9defe292f2daaf05e895989d179b.jxl`.
119
-
* In addition, the folder `rawr` contains a file named `access_properties.p2al`. This JSON
120
-
* file contains a data structure mapping each resource ID to an access properties object.
121
-
* In particular, the file is structured as an array containing objects. Each object has a key which is equal
122
-
* to the resource ID of a resource in the `rawr` directory and a value which is an object
123
-
* representing the access properties. An example of the contents of this file is given below:
* The file `crypt_certs.p2epk` contains all [encrypted private key material](https://docs.polyphony.chat/Protocol%20Specifications/core/#63-private-key-loss-prevention-and-private-key-recovery)
151
-
* that the actor has uploaded to the server. Just like `messages.p2mb`, `crypt_certs.p2epk` is a standard
152
-
* JSON file.
153
-
*/
154
-
modelP2Export {}
155
-
156
-
/**
157
-
* `ResourceAccessProperties` define which actors may access an uploaded resource. Actors and
158
-
* entire instances can have access granted or revoked.
159
-
*/
160
-
modelResourceAccessProperties {
161
-
@doc("Whether the resource should be private by default. Private resources can only be accessed by the uploader and by instances and actors declared in the `allowlist`.")
162
-
private:boolean=false;
163
-
164
-
@doc("Whether the resource should be publicly retrievable, i.e. without requiring authentication. If this is `true`, the allow- and denylists are ignored.")
165
-
public:boolean=false;
166
-
167
-
@doc("A list of actors and/or instances allowed to access this resource.")
* When querying the server for a list of resources uploaded by you, you can optionally request
178
-
* the resulting list to be sorted in a specific way. These are the four options you have.
179
-
*/
180
-
enumResourceListSorting {
181
-
SizeAsc,
182
-
SizeDesc,
183
-
NewestFirst,
184
-
OldestFirst,
185
-
}
186
-
187
-
/**
188
-
* A cacheable response to an ID-Cert request.
189
-
*/
190
-
modelCacheableIDCert {
191
-
@doc("The requested ID-Cert in ASCII PEM format.")
192
-
@example("------BEGIN CERTIFICATE------...")
193
-
idCertPem:string;
194
-
195
-
@doc("UNIX timestamp that specifies when this specific id_cert has been marked as invalidated by the server. An ID-Cert is considered invalidated, if the server or actor choose to revoke the validity of the ID-Cert before the lifetime of the certificate was scheduled to end. If this property does not exist, the ID-Cert has not been invalidated.")
196
-
@example(1736610000)
197
-
invalidatedAt?:uint64;
198
-
199
-
@doc("UNIX timestamp that specifies the time from which this cache entry may be treated as valid.")
200
-
@example(1736606402)
201
-
cacheNotValidBefore:uint64;
202
-
203
-
@doc("UNIX timestamp that specifies a time until which this cache entry may be treated as valid.")
204
-
@example(1736613602)
205
-
cacheNotValidAfter:uint64;
206
-
207
-
@doc("Signature generated by the home server, encoded in [Hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) (base-16). This signature can be verified using the home servers' public identity key. A server generates the `cacheSignature` by concatenating the serial number of the ID-Cert in question with the `cacheValidNotBefore` timestamp, the `cacheValidNotAfter` timestamp, and the `invalidatedAt` timestamp, if present. Clients must reject certificates of which the `cacheSignature` can not be verified to be correct.")
0 commit comments