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

Commit dce3182

Browse files
committed
feat: new namespaces, keypackages routes
1 parent 7141823 commit dce3182

File tree

1 file changed

+107
-64
lines changed

1 file changed

+107
-64
lines changed

polyproto/mls/operations.tsp

Lines changed: 107 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,77 +7,82 @@ import "../main.tsp";
77
using TypeSpec.Http;
88
using polyproto.models.errors;
99

10+
@useAuth(BearerAuth)
1011
namespace polyproto.mls.routes {
11-
/**
12-
* Create a new MLS group
13-
*/
14-
@post
15-
@route("/groups")
16-
op createGroup(@body keyPackage: KeyPackage): {
17-
@statusCode _s: 200;
18-
@body _b: Group;
19-
};
12+
namespace groups {
13+
/**
14+
* Create a new MLS group
15+
*/
16+
@post
17+
@route("/groups")
18+
op createGroup(@body keyPackage: KeyPackage): {
19+
@statusCode _s: 200;
20+
@body _b: Group;
21+
};
2022

21-
/**
22-
* Get information about an MLS group
23-
*/
24-
@get
25-
@route("/groups/{groupId}")
26-
op getGroup(@path groupId: string): {
27-
@statusCode _s: 200;
28-
@body _b: Group;
29-
} | NotFoundOrForbidden;
23+
/**
24+
* Get information about an MLS group
25+
*/
26+
@get
27+
@route("/groups/{groupId}")
28+
op getGroup(@path groupId: string): {
29+
@statusCode _s: 200;
30+
@body _b: Group;
31+
} | NotFoundOrForbidden;
3032

31-
/**
32-
* Submit a proposal to modify the group
33-
*/
34-
@post
35-
@route("/groups/{groupId}/proposals")
36-
op submitProposal(
37-
@path groupId: string,
38-
@body proposal: Proposal,
39-
): void | NotFoundOrForbidden;
33+
/**
34+
* Submit a proposal to modify the group
35+
*/
36+
@post
37+
@route("/groups/{groupId}/proposals")
38+
op submitProposal(
39+
@path groupId: string,
40+
@body proposal: Proposal,
41+
): void | NotFoundOrForbidden;
4042

41-
/**
42-
* Submit a commit to apply pending proposals
43-
*/
44-
@post
45-
@route("/groups/{groupId}/commits")
46-
op submitCommit(
47-
@path groupId: string,
48-
@body commit: Commit,
49-
): Welcome | NotFoundOrForbidden;
43+
/**
44+
* Submit a commit to apply pending proposals
45+
*/
46+
@post
47+
@route("/groups/{groupId}/commits")
48+
op submitCommit(
49+
@path groupId: string,
50+
@body commit: Commit,
51+
): Welcome | NotFoundOrForbidden;
52+
}
5053

51-
/**
52-
* Get the current state of a group member
53-
*/
54-
@get
55-
@route("/groups/{groupId}/members/{memberId}")
56-
op getMember(
57-
@path groupId: string,
58-
@path memberId: string,
59-
): GroupMember | NotFoundOrForbidden;
54+
namespace members {
55+
/**
56+
* Get the current state of a group member
57+
*/
58+
@get
59+
@route("/groups/{groupId}/members/{memberId}")
60+
op getMember(
61+
@path groupId: string,
62+
@path memberId: string,
63+
): GroupMember | NotFoundOrForbidden;
6064

61-
/**
62-
* Update a member's key package
63-
*/
64-
@put
65-
@route("/groups/{groupId}/members/{memberId}")
66-
op updateMember(
67-
@path groupId: string,
68-
@path memberId: string,
69-
@body keyPackage: KeyPackage,
70-
): void | NotFoundOrForbidden;
65+
/**
66+
* Update a member's key package
67+
*/
68+
@put
69+
@route("/groups/{groupId}/members/{memberId}")
70+
op updateMember(
71+
@path groupId: string,
72+
@path memberId: string,
73+
@body keyPackage: KeyPackage,
74+
): void | NotFoundOrForbidden;
7175

72-
/**
73-
* Remove a member from the group
74-
*/
75-
@delete
76-
@route("/groups/{groupId}/members/{memberId}")
77-
op removeMember(
78-
@path groupId: string,
79-
@path memberId: string,
80-
): void | NotFoundOrForbidden;
76+
/**
77+
* Remove a member from the group
78+
*/
79+
@delete
80+
@route("/groups/{groupId}/members/{memberId}")
81+
op removeMember(
82+
@path groupId: string,
83+
@path memberId: string,
84+
): void | NotFoundOrForbidden;
85+
}
8186

8287
/**
8388
* Get all pending proposals for a group
@@ -92,4 +97,42 @@ namespace polyproto.mls.routes {
9297
@get
9398
@route("/groups/{groupId}/commits/latest")
9499
op getLatestCommit(@path groupId: string): Commit | NotFoundOrForbidden;
100+
101+
namespace keypackages {
102+
/**
103+
* Upload KeyPackages to the server, enabling other actors to encrypt messages for you and form
104+
* groups with you.
105+
*/
106+
@post
107+
@route("/keypackages")
108+
@summary("Upload new KeyPackages")
109+
op addKeyPackages(@body keyPackages: KeyPackage[]): 200 | {
110+
@statusCode _s: 400;
111+
@body _b: {
112+
@doc("The identifier of a faulty keypackage")
113+
id: string;
114+
115+
@doc("A string describing what was wrong with this keypackage")
116+
reason: string;
117+
}[];
118+
} | 413;
119+
120+
/**
121+
* Discover KeyPackages for a certain user.
122+
* Filter (allowelist) by MLS protocol versions, ciphersuites and extensions.
123+
* */
124+
@get
125+
@route("/keypackages/{fid}")
126+
@summary("Retrieve one or more KeyPackages for a user")
127+
op discoverKeyPackages(
128+
@path fid: string,
129+
@query versions?: string[] = #["1.0"],
130+
131+
@minItems(1)
132+
@query
133+
ciphersuites: string[],
134+
135+
@query extensions?: string[] = #[],
136+
): KeyPackage[] | 404 | 204;
137+
}
95138
}

0 commit comments

Comments
 (0)