-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
175 lines (167 loc) · 5.59 KB
/
openapi.yaml
File metadata and controls
175 lines (167 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
openapi: 3.0.3
info:
title: epochapi
version: 1.0.0
description: >-
Stateless high-performance Rust REST API for current timestamps, signed timestamps,
and signature validation.
servers:
- url: http://localhost:8080
description: Local development server
tags:
- name: time
description: Timestamp endpoints
- name: security
description: Signed timestamp and validation endpoints
paths:
/now:
get:
operationId: getNow
tags: [time]
summary: Get the current UTC timestamp
description: >-
Returns the current timestamp in one of the supported formats.
By default this endpoint returns plain text; add the `json` query key
(for example `?format=iso&json`) to receive a JSON response.
parameters:
- $ref: '#/components/parameters/FormatQuery'
- name: json
in: query
required: false
description: Presence-only key; if present, wraps response in JSON.
schema:
type: string
nullable: true
responses:
'200':
description: Current timestamp
content:
text/plain:
schema:
type: string
example: "1735689600"
application/json:
schema:
$ref: '#/components/schemas/TimestampResponse'
examples:
iso:
value:
format: iso
timestamp: "2026-01-01T00:00:00+00:00"
'400':
$ref: '#/components/responses/BadRequestText'
/secnow:
get:
operationId: getSecNow
tags: [security]
summary: Get the current UTC timestamp with signature
description: >-
Returns JSON containing the timestamp, detached signature, and token.
Token format is `<format>:<timestamp>.<base64url_signature>`.
parameters:
- $ref: '#/components/parameters/FormatQuery'
responses:
'200':
description: Signed timestamp payload
content:
application/json:
schema:
$ref: '#/components/schemas/SignedTimestampResponse'
examples:
iso:
value:
format: iso
timestamp: "2026-02-18T16:13:16.185877387+00:00"
signature: "0JSbPI7xNMJZcfDtSJJyEunLAsyO3n-YpcxjNSwYKpVrHNf987k-GWYbhhDPhBF2pbAssGD5MfMOnneHI82ACQ"
token: "iso:2026-02-18T16:13:16.185877387+00:00.0JSbPI7xNMJZcfDtSJJyEunLAsyO3n-YpcxjNSwYKpVrHNf987k-GWYbhhDPhBF2pbAssGD5MfMOnneHI82ACQ"
'400':
$ref: '#/components/responses/BadRequestText'
/validate:
post:
operationId: postValidate
tags: [security]
summary: Validate a signed timestamp payload
description: >-
Accepts the exact JSON payload returned by `/secnow`.
Returns 200 only if all checks pass:
- signature in `token` matches `signature` field,
- `format` and `timestamp` match the token payload,
- Ed25519 signature verifies.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SignedTimestampResponse'
responses:
'200':
description: Signature and payload are valid
content:
text/plain:
schema:
type: string
example: valid
'400':
description: Signature invalid or payload tampered
content:
text/plain:
schema:
type: string
example: invalid
'422':
description: Request body is not a valid SignedTimestampResponse shape
content:
text/plain:
schema:
type: string
example: "Failed to deserialize the JSON body into the target type"
components:
parameters:
FormatQuery:
name: format
in: query
required: false
description: Timestamp output format. Defaults to `seconds`.
schema:
type: string
enum: [seconds, ms, ns, iso, sec, s, millis, milliseconds, nanos, nanoseconds]
default: seconds
responses:
BadRequestText:
description: Bad request (invalid format or invalid payload)
content:
text/plain:
schema:
type: string
example: "invalid format: use seconds|ms|ns|iso"
schemas:
TimestampResponse:
type: object
required: [format, timestamp]
properties:
format:
type: string
example: iso
timestamp:
type: string
example: "2026-01-01T00:00:00+00:00"
SignedTimestampResponse:
type: object
required: [format, timestamp, signature, token]
properties:
format:
type: string
description: Echoed format identifier used to generate the timestamp.
example: iso
timestamp:
type: string
description: Current timestamp encoded in the selected format.
example: "2026-02-18T16:13:16.185877387+00:00"
signature:
type: string
description: Base64url (no padding) Ed25519 signature over `<format>:<timestamp>`.
example: 0JSbPI7xNMJZcfDtSJJyEunLAsyO3n-YpcxjNSwYKpVrHNf987k-GWYbhhDPhBF2pbAssGD5MfMOnneHI82ACQ
token:
type: string
description: Combined payload and signature.
example: "iso:2026-02-18T16:13:16.185877387+00:00.0JSbPI7xNMJZcfDtSJJyEunLAsyO3n-YpcxjNSwYKpVrHNf987k-GWYbhhDPhBF2pbAssGD5MfMOnneHI82ACQ"