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

Commit 95a0d51

Browse files
committed
reorder usings and imports
1 parent eeee8e8 commit 95a0d51

File tree

7 files changed

+236
-259
lines changed

7 files changed

+236
-259
lines changed

src/core/main.tsp

Lines changed: 2 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -2,212 +2,8 @@ import "@typespec/http";
22
import "@typespec/rest";
33
import "@typespec/openapi3";
44
import "./routes";
5+
import "./models";
56

6-
using TypeSpec.Http;
7-
using Routes;
8-
using FederatedIdentity;
9-
using Services;
10-
using Migration;
11-
using ResourceAddressingWithRelativeRoots;
7+
using Versioning;
128

139
namespace polyproto.core;
14-
15-
namespace models {
16-
model EncryptedPKM {
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-
model Service {
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-
model KeyTrial {
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-
model KeyTrialCompleted {
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-
model MessageBatch<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.")
101-
content: T;
102-
}[];
103-
}
104-
105-
model MessageBatchExample extends MessageBatch<string> {}
106-
107-
/** 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:
124-
*
125-
```json
126-
[
127-
{
128-
"2062a23e2a25b226ca4c546fec5ec06e0df9648281f45da8b5aaabebdf66cf4c.jxl": {
129-
"private": false,
130-
"public": false,
131-
"allowlist": ["user1@example.com", "instance.example.com"],
132-
"denylist": ["user2@example.com", "otherinstance@example.com"]
133-
}
134-
},
135-
{
136-
"a9144379a161e1fcf6b07801b70db6d6c481933bd634fe2409eb713723ab1a0a": {
137-
"private": true,
138-
"public": false,
139-
"allowlist": ["user1@example.com"],
140-
"denylist": []
141-
}
142-
}
143-
]
144-
```
145-
*
146-
* If the server where the data export was requested from is the actors' home server, the
147-
* archive will contain a folder `certs` and a file `crypt_certs.p2epk`. `certs` will contain all ID-Certs
148-
* the server has stored of the actor. The ID-Certs will be stored in
149-
* [ASCII PEM format](https://web.archive.org/web/20250107131731/https://learn.microsoft.com/en-us/azure/iot-hub/reference-x509-certificates#:~:text=ASN.1%20encoding.-,ascii%20pem%20format,-A%20PEM%20certificate).
150-
* 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-
model P2Export {}
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-
model ResourceAccessProperties {
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.")
168-
@example(#["[email protected]", "instance.example.com"])
169-
allowlist?: string[];
170-
171-
@doc("A list of actors and/or instances who cannot have access to this resource.")
172-
@example(#["[email protected]", "other_instance.example.com"])
173-
denylist?: string[];
174-
}
175-
176-
/**
177-
* 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-
enum ResourceListSorting {
181-
SizeAsc,
182-
SizeDesc,
183-
NewestFirst,
184-
OldestFirst,
185-
}
186-
187-
/**
188-
* A cacheable response to an ID-Cert request.
189-
*/
190-
model CacheableIDCert {
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.")
208-
@example("7ab2bbde7fe43c7481a3a61031546bab16bc1a8735b2f0cdd519958c7f2f99f8")
209-
@minLength(32)
210-
@maxLength(32)
211-
cacheSignature: string;
212-
}
213-
}

0 commit comments

Comments
 (0)