Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 5c3b47e

Browse files
committed
feat: improvements, model outsourcing, new version
1 parent dd32d17 commit 5c3b47e

File tree

6 files changed

+69
-96
lines changed

6 files changed

+69
-96
lines changed

polyproto/core/models/main.tsp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ namespace polyproto.core.Models {
159159
denylist?: string[];
160160
}
161161

162+
/**
163+
* Information about a RawR resource.
164+
*/
165+
model ResourceInformation {
166+
@doc("A unique ID of a resource")
167+
resourceId: string;
168+
169+
@doc("Size of the resource, in bytes")
170+
size: uint64;
171+
172+
@doc("Access information for this resource")
173+
access: ResourceAccessProperties;
174+
}
175+
162176
/**
163177
* When querying the server for a list of resources uploaded by you, you can optionally request
164178
* the resulting list to be sorted in a specific way. These are the four options you have.

polyproto/core/routes/federated_identity.tsp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
1818
*/
1919
@route("/idcert")
2020
@summary("Get a new ID-Cert")
21-
@added(Version.`v1.0-beta.1`)
21+
@added(Version.`v1.0-beta.2`)
2222
@post
2323
@tag("Sensitive Actions")
2424
op newIdCert(
@@ -51,7 +51,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
5151
*/
5252
@route("/session/keymaterial")
5353
@summary("Upload encrypted private key material")
54-
@added(Version.`v1.0-beta.1`)
54+
@added(Version.`v1.0-beta.2`)
5555
@post
5656
op uploadEncryptedPKM(
5757
@body @minItems(1) pkm: polyproto.core.Models.EncryptedPKM[],
@@ -83,7 +83,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
8383
*/
8484
@route("/session/keymaterial")
8585
@summary("Get encrypted private key material")
86-
@added(Version.`v1.0-beta.1`)
86+
@added(Version.`v1.0-beta.2`)
8787
@get
8888
op getEncryptedPKM(@query serials?: uint64[]): {
8989
@statusCode statusCode: 200;
@@ -108,7 +108,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
108108
@route("/session/keymaterial")
109109
@tag("Sensitive Actions")
110110
@summary("Delete encrypted private key material")
111-
@added(Version.`v1.0-beta.1`)
111+
@added(Version.`v1.0-beta.2`)
112112
@delete
113113
op deleteEncryptedPKM(
114114
@doc("Sensitive actions require a second factor of authentication to be executed. Read [section 4.1.2 of the protocol definition](https://docs.polyphony.chat/Protocol%20Specifications/core/#412-sensitive-actions) for more information.")
@@ -134,7 +134,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
134134
*/
135135
@route("/session/keymaterial/size")
136136
@summary("Get encrypted private key material upload size limit")
137-
@added(Version.`v1.0-beta.1`)
137+
@added(Version.`v1.0-beta.2`)
138138
@get
139139
@useAuth(NoAuth)
140140
op encryptedPKMsizeLimit(): {
@@ -150,7 +150,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
150150
*/
151151
@route("/session")
152152
@delete
153-
@added(Version.`v1.0-beta.1`)
153+
@added(Version.`v1.0-beta.2`)
154154
@summary("Delete/Revoke Session")
155155
@useAuth(BearerAuth)
156156
op deleteSession(
@@ -174,7 +174,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
174174
*/
175175
@route("/key/server")
176176
@summary("Rotate Server Identity Key")
177-
@added(Version.`v1.0-beta.1`)
177+
@added(Version.`v1.0-beta.2`)
178178
@post
179179
@useAuth(BearerAuth)
180180
@tag("Sensitive Actions")
@@ -196,7 +196,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
196196
*/
197197
@route("/idcert/server")
198198
@get
199-
@added(Version.`v1.0-beta.1`)
199+
@added(Version.`v1.0-beta.2`)
200200
@summary("Get Server ID-Cert")
201201
op serverIdCert(
202202
@query timestamp?: uint64,
@@ -212,7 +212,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
212212
*/
213213
@route("/idcert/actor")
214214
@get
215-
@added(Version.`v1.0-beta.1`)
215+
@added(Version.`v1.0-beta.2`)
216216
@summary("Get Actor ID-Cert(s)")
217217
op actorCerts(
218218
@path fid: string,
@@ -232,7 +232,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
232232
*/
233233
@route("/session/idcert/extern")
234234
@put
235-
@added(Version.`v1.0-beta.1`)
235+
@added(Version.`v1.0-beta.2`)
236236
@useAuth(BearerAuth)
237237
@summary("Update session ID-Cert")
238238
op updateSessionCert(@body id_cert: string): {
@@ -247,7 +247,7 @@ namespace polyproto.core.Routes.FederatedIdentity {
247247
*/
248248
@route("/session/auth")
249249
@post
250-
@added(Version.`v1.0-beta.1`)
250+
@added(Version.`v1.0-beta.2`)
251251
@summary("Authenticate on a foreign server")
252252
op requestToken(
253253
@body

polyproto/core/routes/main.tsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ using TypeSpec.OpenAPI;
2525
namespace polyproto.core;
2626

2727
enum Version {
28-
`v1.0-beta.1`,
28+
`v1.0-beta.2`,
2929
}

polyproto/core/routes/migration.tsp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace polyproto.core.Routes.Migration {
3030
*/
3131
@route("/redirect")
3232
@post
33-
@added(Version.`v1.0-beta.1`)
33+
@added(Version.`v1.0-beta.2`)
3434
@summary("Set up a redirect for migrating identities")
3535
op setupRedirect(
3636
@body newActorFid: string,
@@ -50,7 +50,7 @@ namespace polyproto.core.Routes.Migration {
5050
@route("/redirect")
5151
@delete
5252
@useAuth(BearerAuth)
53-
@added(Version.`v1.0-beta.1`)
53+
@added(Version.`v1.0-beta.2`)
5454
@summary("Remove a redirect for migrating identities")
5555
op removeRedirect(@query removeActorFid: string): {
5656
@statusCode statusCode: 204;
@@ -71,7 +71,7 @@ namespace polyproto.core.Routes.Migration {
7171
*/
7272
@route("/data")
7373
@post
74-
@added(Version.`v1.0-beta.1`)
74+
@added(Version.`v1.0-beta.2`)
7575
@summary("Import data to server")
7676
@tag("Sensitive Actions")
7777
op importData(
@@ -101,7 +101,7 @@ namespace polyproto.core.Routes.Migration {
101101
*/
102102
@route("/redirect/extern")
103103
@post
104-
@added(Version.`v1.0-beta.1`)
104+
@added(Version.`v1.0-beta.2`)
105105
@summary("Set up a redirect for migrating identities")
106106
op setupRedirectExtern(@query redirectSourceFid: string): {
107107
@statusCode statusCode: 202 | 200;
@@ -117,7 +117,7 @@ namespace polyproto.core.Routes.Migration {
117117
*/
118118
@route("/redirect/extern")
119119
@delete
120-
@added(Version.`v1.0-beta.1`)
120+
@added(Version.`v1.0-beta.2`)
121121
@summary("Remove a redirect for migrating identities")
122122
op removeRedirectExtern(@query redirectSourceFid: string): {
123123
@statusCode statusCode: 200;
@@ -132,7 +132,7 @@ namespace polyproto.core.Routes.Migration {
132132
*/
133133
@route("/messages")
134134
@delete
135-
@added(Version.`v1.0-beta.1`)
135+
@added(Version.`v1.0-beta.2`)
136136
@summary("Abort message re-signing")
137137
op removeResigningExtern(@query removeActorFid: string): {
138138
@statusCode statusCode: 404;
@@ -150,7 +150,7 @@ namespace polyproto.core.Routes.Migration {
150150
*/
151151
@route("/messages")
152152
@post
153-
@added(Version.`v1.0-beta.1`)
153+
@added(Version.`v1.0-beta.2`)
154154
@summary("Request message re-signing")
155155
op requestAllowResigning(
156156
@body body: {
@@ -180,7 +180,7 @@ namespace polyproto.core.Routes.Migration {
180180
*/
181181
@route("/messages/commit")
182182
@post
183-
@added(Version.`v1.0-beta.1`)
183+
@added(Version.`v1.0-beta.2`)
184184
@summary("Commit re-signed messages")
185185
op commitMessages(
186186
@body messages: polyproto.core.Models.MessageBatch<string>[],
@@ -213,7 +213,7 @@ namespace polyproto.core.Routes.Migration {
213213
*/
214214
@route("/messages")
215215
@get
216-
@added(Version.`v1.0-beta.1`)
216+
@added(Version.`v1.0-beta.2`)
217217
@summary("Fetch messages to-be-resigned")
218218
op getMessages(
219219
@query limit?: uint32 = 300,
@@ -250,7 +250,7 @@ namespace polyproto.core.Routes.Migration {
250250
*/
251251
@route("/keytrial/{fid}")
252252
@get
253-
@added(Version.`v1.0-beta.1`)
253+
@added(Version.`v1.0-beta.2`)
254254
@summary("Fetch key trials and key trial responses from actor")
255255
op getKeyTrials(
256256
@path fid: string,
@@ -286,7 +286,7 @@ namespace polyproto.core.Routes.Migration {
286286
*/
287287
@route("/data")
288288
@delete
289-
@added(Version.`v1.0-beta.1`)
289+
@added(Version.`v1.0-beta.2`)
290290
@summary("Delete own actor data from the server")
291291
op deleteData(
292292
@query breakRedirect?: boolean = false,
@@ -317,7 +317,7 @@ namespace polyproto.core.Routes.Migration {
317317
*/
318318
@route("/data")
319319
@get
320-
@added(Version.`v1.0-beta.1`)
320+
@added(Version.`v1.0-beta.2`)
321321
@summary("Export all data")
322322
op exportData(
323323
@doc("A list of completed `KeyTrial`s")

polyproto/core/routes/rawr.tsp

Lines changed: 26 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,22 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
2020
* - `200`: File found and retrieved.
2121
* - `308`: URI root has changed.
2222
* - `401`: Server or resource requires authentication to access this endpoint.
23-
* - `403`: Server or resource not accessible for the actor making this request.
24-
* - `404`: Resource not found.
23+
* - `404`: Separately documented.
2524
*/
2625
@route("/{rid}")
2726
@get
2827
@useAuth(BearerAuth | NoAuth)
29-
@added(Version.`v1.0-beta.1`)
28+
@added(Version.`v1.0-beta.2`)
3029
@summary("Get resource by resource ID")
31-
op getResource(@path rid: string):
32-
| {
33-
@statusCode _: 200;
34-
@body body: File;
35-
}
36-
| {
37-
@statusCode _: 308;
30+
op getResource(@path rid: string): {
31+
@statusCode _: 200;
32+
@body body: File;
33+
} | {
34+
@statusCode _: 308;
3835

39-
@header(#{ name: "Location" })
40-
location: url;
41-
42-
@body reason: "ROOT_CHANGED";
43-
}
44-
| {
45-
@statusCode _: 403;
46-
@body reason: "ACCESS_FORBIDDEN";
47-
}
48-
| {
49-
@statusCode _: 401;
50-
@body reason: "NEEDS_AUTHENTICATION";
51-
}
52-
| {
53-
@statusCode _: 404;
54-
@body reason: "NOT_FOUND";
55-
};
36+
@header(#{ name: "Location" })
37+
location: url;
38+
} | polyproto.models.errors.NotFoundOrForbidden;
5639

5740
/**
5841
* Query the server for information about a RawR resource.
@@ -63,44 +46,22 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
6346
* @returns
6447
* - `200`: Found, contains resource information
6548
* - `308`: URI root has changed.
66-
* - `401`: Server or resource requires authentication to access this endpoint.
67-
* - `403`: Server or resource not accessible for the actor making this request.
68-
* - `404`: Resource not found.
49+
* - `404`: Separately documented.
6950
*/
7051
@route("/{rid}/info/")
7152
@get
7253
@useAuth(BearerAuth | NoAuth)
73-
@added(Version.`v1.0-beta.1`)
54+
@added(Version.`v1.0-beta.2`)
7455
@summary("Retrieve information about a RawR resource")
75-
op getResourceInfos(@path rid: string):
76-
| {
77-
@statusCode statusCode: 200;
78-
@body body: {
79-
resourceId: string;
80-
size: uint64;
81-
access: polyproto.core.Models.ResourceAccessProperties;
82-
}[];
83-
}
84-
| {
85-
@statusCode _: 308;
86-
87-
@header(#{ name: "Location" })
88-
location: url;
56+
op getResourceInfos(@path rid: string): {
57+
@statusCode statusCode: 200;
58+
@body body: polyproto.core.Models.ResourceInformation[];
59+
} | {
60+
@statusCode _: 308;
8961

90-
@body reason: "ROOT_CHANGED";
91-
}
92-
| {
93-
@statusCode _: 403;
94-
@body reason: "ACCESS_FORBIDDEN";
95-
}
96-
| {
97-
@statusCode _: 401;
98-
@body reason: "NEEDS_AUTHENTICATION";
99-
}
100-
| {
101-
@statusCode _: 404;
102-
@body reason: "NOT_FOUND";
103-
};
62+
@header(#{ name: "Location" })
63+
location: url;
64+
} | polyproto.models.errors.NotFoundOrForbidden;
10465
}
10566

10667
@tag("Resource addressing with relative roots - Registration required")
@@ -123,7 +84,7 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
12384
*/
12485
@route("/{rid}")
12586
@post
126-
@added(Version.`v1.0-beta.1`)
87+
@added(Version.`v1.0-beta.2`)
12788
@summary("Upload RawR resource")
12889
op postResource(
12990
@path rid: string,
@@ -171,7 +132,7 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
171132

172133
@route("/{rid}")
173134
@delete
174-
@added(Version.`v1.0-beta.1`)
135+
@added(Version.`v1.0-beta.2`)
175136
@summary("Delete RawR resource")
176137
op deleteResource(@path rid: string): {
177138
@statusCode _: 204;
@@ -185,7 +146,7 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
185146
*/
186147
@route("/{rid}")
187148
@put
188-
@added(Version.`v1.0-beta.1`)
149+
@added(Version.`v1.0-beta.2`)
189150
@summary("Update RawR resource access properties")
190151
op modifyResource(
191152
@path rid: string,
@@ -206,7 +167,7 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
206167
*/
207168
@route("/resources")
208169
@get
209-
@added(Version.`v1.0-beta.1`)
170+
@added(Version.`v1.0-beta.2`)
210171
@summary("List your uploaded resources")
211172
op getResourceList(
212173
@query limit?: uint32 = 50,
@@ -218,9 +179,7 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
218179
): {
219180
@statusCode statusCode: 200;
220181
@body body: {
221-
resourceId: string;
222-
size: uint64;
223-
access: polyproto.core.Models.ResourceAccessProperties;
182+
resourceInformation: polyproto.core.Models.ResourceInformation;
224183

225184
@doc("Only present, if `previews` was set to `true` in the request, and if the response contains preview-supported file types.")
226185
preview?: File;
@@ -239,7 +198,7 @@ namespace polyproto.core.Routes.ResourceAddressingWithRelativeRoots {
239198
*/
240199
@route("/usage")
241200
@get
242-
@added(Version.`v1.0-beta.1`)
201+
@added(Version.`v1.0-beta.2`)
243202
@summary("Retrieve information about your storage usage")
244203
op getStorageLimitInfo(): {
245204
@statusCode _s: 200;

0 commit comments

Comments
 (0)