pubky-homeserver 0.12.0

A Pubky homeserver implementation.
Documentation
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
---
openapi: 3.1.0
info:
  title: Pubky Homeserver Admin API
  description: |-
    The Admin Server exposes homeserver administration and WebDAV operations on a
    separate interface from the client API.

    Most operations require the `X-Admin-Password` header. The root identification
    endpoint is public, while `/dav/{path}` uses HTTP Basic authentication with
    username `admin` and the admin password.
  version: 0.9.0
  license:
    name: MIT
    identifier: MIT
servers:
- url: http://localhost:6288
  description: Admin server (default port)
security: []
tags:
- name: General
  description: Public admin server identification
- name: Events
  description: Administrative event streaming
- name: Admin
  description: Password-protected administration and WebDAV operations
paths:
  "/":
    get:
      tags:
      - General
      summary: Admin server info
      description: Public health check and admin server identification.
      operationId: getAdminRoot
      responses:
        '200':
          description: Server name
          content:
            text/plain:
              schema:
                type: string
                example: Homeserver - Admin Endpoint
  "/info":
    get:
      tags:
      - Admin
      summary: Server statistics
      operationId: getAdminInfo
      security:
      - adminPassword: []
      responses:
        '200':
          description: Server statistics
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/AdminInfoResponse"
        '401':
          description: Missing or invalid admin password
  "/generate_signup_token":
    get:
      tags:
      - Admin
      summary: Generate signup token (default limits)
      operationId: generateSignupToken
      security:
      - adminPassword: []
      responses:
        '200':
          description: Generated token
          content:
            text/plain:
              schema:
                type: string
        '401':
          description: Missing or invalid admin password
    post:
      tags:
      - Admin
      summary: Generate signup token (custom limits)
      operationId: generateSignupTokenWithLimits
      security:
      - adminPassword: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/UserQuota"
            examples:
              customLimits:
                value:
                  storage_quota_mb: 1024
                  rate_read: 200mb/m
              unlimited:
                value:
                  storage_quota_mb: unlimited
                  rate_read: unlimited
                  rate_write: unlimited
      responses:
        '200':
          description: Generated token
          content:
            text/plain:
              schema:
                type: string
        '401':
          description: Missing or invalid admin password
        '422':
          description: Invalid quota format
  "/signup_tokens":
    get:
      tags:
      - Admin
      summary: List signup tokens
      description: |
        Paginated list of signup tokens with usage information.
        Supports filtering by state (`all`, `used`, `unused`).
      operationId: listSignupTokens
      security:
      - adminPassword: []
      parameters:
      - name: limit
        in: query
        description: Maximum number of tokens to return per page.
        schema:
          type: integer
          minimum: 1
          maximum: 65535
      - name: cursor
        in: query
        description: Pagination cursor (token string from `next_cursor` of a previous
          response).
        schema:
          type: string
      - name: state
        in: query
        description: Filter by token state.
        schema:
          type: string
          enum:
          - all
          - used
          - unused
          default: all
      responses:
        '200':
          description: Paginated list of signup tokens
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/SignupTokensResponse"
        '400':
          description: Invalid query parameters (bad cursor format, unknown state,
            limit=0)
        '401':
          description: Missing or invalid admin password
  "/events-stream":
    get:
      tags:
      - Events
      summary: Real-time event stream (SSE)
      description: |-
        Admin-only Server-Sent Events feed over all public and private homeserver events.

        Two modes are supported:
        - **Batch mode** (`live=false` or omitted): fetches historical events then closes.
        - **Live mode** (`live=true`): fetches historical events, then streams new events in real-time.

        Omit `user` to stream every user, or repeat it to filter by z-base-32 public key.
        The standalone `cursor` parameter is a single global cursor over the combined feed.
        Slow clients that fall behind in live mode will have their connection closed.

        Each SSE message has an event type (`PUT` or `DEL`) and multiline data:
        ```
        event: PUT
        data: pubky://user_pubkey/pub/example.txt
        data: cursor: 42
        data: content_hash: r0NJufX5oaagQE3qNtzJSZvLJcmtwRK3zJqTyuQfMmI=
        ```
      operationId: getAdminEventStream
      security:
      - adminPassword: []
      parameters:
      - name: user
        in: query
        required: false
        description: |-
          Optional z-base-32 user public key filter. Repeat for multiple users.
          Omit the parameter to stream every user. Per-user cursor suffixes are not accepted.
          Duplicate values are ignored; more than 50 distinct users returns `400`.
        schema:
          type: array
          items:
            type: string
        style: form
        explode: true
        examples:
          single:
            value:
            - o1gg96ewuojmopcjbz8895478wdtxtzzuxnfjjz8o8e77csa1ngo
      - name: cursor
        in: query
        description: Resume the combined feed after this single global event cursor.
        schema:
          type: string
      - name: limit
        in: query
        description: Maximum total events to send.
        schema:
          type: integer
          minimum: 1
          maximum: 65535
      - name: reverse
        in: query
        description: Reverse chronological order. Cannot be combined with `live=true`.
        schema:
          type: boolean
          default: false
      - name: live
        in: query
        description: Enable live streaming mode. Cannot be combined with `reverse=true`.
        schema:
          type: boolean
          default: false
      - name: path
        in: query
        description: |-
          Path filter (repeatable; union semantics). A trailing slash matches a directory
          and its descendants; otherwise the exact file is matched. Both public and private
          paths may be requested.
        schema:
          type: array
          items:
            type: string
        style: form
        explode: true
        examples:
          publicDir:
            value:
            - "/pub/files/"
          mixed:
            value:
            - "/pub/"
            - "/priv/app/"
      responses:
        '200':
          description: SSE event stream
          headers:
            Cache-Control:
              schema:
                type: string
                example: no-store
          content:
            text/event-stream:
              schema:
                type: string
        '400':
          description: |-
            Invalid user public key or global cursor, excessive user parameters, zero/invalid
            limit, incompatible `live=true` and `reverse=true`, or invalid path.
        '401':
          description: Missing or invalid `X-Admin-Password`.
        '404':
          description: A requested user was not found.
  "/webdav/{entry_path}":
    delete:
      tags:
      - Admin
      summary: Delete entry via admin
      operationId: adminDeleteEntry
      security:
      - adminPassword: []
      parameters:
      - name: entry_path
        in: path
        required: true
        description: 'Full path: `{pubkey}/path` (e.g. `o1gg96ewuo.../pub/file.txt`)'
        schema:
          type: string
      responses:
        '204':
          description: Entry deleted
        '400':
          description: Invalid pubkey format
        '401':
          description: Missing or invalid admin password
        '404':
          description: Entry not found
  "/dav/{path}":
    description: |
      Full WebDAV endpoint. In addition to GET/PUT/DELETE shown here, this route
      accepts any HTTP method (via `any()` handler) including PROPFIND, MKCOL, etc.
    get:
      tags:
      - Admin
      summary: WebDAV GET
      operationId: adminDavGet
      security:
      - adminBasicAuth: []
      parameters:
      - name: path
        in: path
        required: true
        description: 'WebDAV path: `{pubkey}/{webdav_path}`'
        schema:
          type: string
      responses:
        '200':
          description: File content
        '404':
          description: Not found
    put:
      tags:
      - Admin
      summary: WebDAV PUT
      operationId: adminDavPut
      security:
      - adminBasicAuth: []
      parameters:
      - name: path
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '201':
          description: File created
    delete:
      tags:
      - Admin
      summary: WebDAV DELETE
      operationId: adminDavDelete
      security:
      - adminBasicAuth: []
      parameters:
      - name: path
        in: path
        required: true
        schema:
          type: string
      responses:
        '204':
          description: File deleted
  "/users/{pubkey}/disable":
    post:
      tags:
      - Admin
      summary: Disable user account
      operationId: disableUser
      security:
      - adminPassword: []
      parameters:
      - "$ref": "#/components/parameters/AdminPubkey"
      responses:
        '200':
          description: User disabled
          content:
            text/plain:
              schema:
                type: string
                example: Ok
        '400':
          description: Invalid pubkey format
        '401':
          description: Missing or invalid admin password
        '404':
          description: User not found
  "/users/{pubkey}/enable":
    post:
      tags:
      - Admin
      summary: Enable user account
      operationId: enableUser
      security:
      - adminPassword: []
      parameters:
      - "$ref": "#/components/parameters/AdminPubkey"
      responses:
        '200':
          description: User enabled
          content:
            text/plain:
              schema:
                type: string
                example: Ok
        '400':
          description: Invalid pubkey format
        '401':
          description: Missing or invalid admin password
        '404':
          description: User not found
  "/users/{pubkey}/quota":
    get:
      tags:
      - Admin
      summary: Get user quota
      description: |
        Returns both the effective quota (overrides merged with system defaults)
        and the raw per-user overrides.
      operationId: getUserQuota
      security:
      - adminPassword: []
      parameters:
      - "$ref": "#/components/parameters/AdminPubkey"
      responses:
        '200':
          description: User quota
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/UserQuotaResponse"
              examples:
                withDefaults:
                  value:
                    effective:
                      storage_quota_mb: 100
                      rate_read: 10mb/s
                      rate_write: 5mb/s
                    overrides: {}
                withOverrides:
                  value:
                    effective:
                      storage_quota_mb: 500
                      rate_read: 100mb/m
                      rate_write: unlimited
                    overrides:
                      storage_quota_mb: 500
                      rate_read: 100mb/m
        '400':
          description: Invalid pubkey format
        '401':
          description: Missing or invalid admin password
        '404':
          description: User not found
    patch:
      tags:
      - Admin
      summary: Update user quota
      description: |
        Partially update per-user quota overrides.
        - Absent fields: keep existing value
        - `null`: reset to system default
        - `"unlimited"`: no limit
        - Value: explicit custom limit
      operationId: patchUserQuota
      security:
      - adminPassword: []
      parameters:
      - "$ref": "#/components/parameters/AdminPubkey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/UserQuotaPatch"
            examples:
              setCustom:
                value:
                  storage_quota_mb: 500
                  rate_read: 100mb/m
              resetToDefault:
                value:
                  storage_quota_mb:
                  rate_read:
                  rate_write:
              setUnlimited:
                value:
                  rate_read: unlimited
      responses:
        '200':
          description: Quota updated
        '400':
          description: Invalid pubkey format
        '401':
          description: Missing or invalid admin password
        '404':
          description: User not found
        '422':
          description: Invalid quota format
components:
  securitySchemes:
    adminPassword:
      type: apiKey
      in: header
      name: X-Admin-Password
      description: Admin server password.
    adminBasicAuth:
      type: http
      scheme: basic
      description: Basic auth for WebDAV endpoints. Username `admin`, password is
        the admin password.
  parameters:
    AdminPubkey:
      name: pubkey
      in: path
      required: true
      description: User's z-base-32 encoded public key.
      schema:
        type: string
  schemas:
    SignupTokensResponse:
      type: object
      required:
      - items
      - next_cursor
      properties:
        items:
          type: array
          items:
            "$ref": "#/components/schemas/SignupTokenItem"
        next_cursor:
          type:
          - string
          - 'null'
          description: Cursor for the next page, or `null` if this is the last page.
    SignupTokenItem:
      type: object
      required:
      - token
      - created_at
      - used_at
      - used_by
      properties:
        token:
          type: string
          description: The signup token string.
        created_at:
          type: string
          format: date-time
          description: When the token was created.
        used_at:
          type:
          - string
          - 'null'
          format: date-time
          description: When the token was used, or `null` if unused.
        used_by:
          type:
          - string
          - 'null'
          description: z-base-32 public key of the user who used the token, or `null`
            if unused.
    AdminInfoResponse:
      type: object
      required:
      - num_users
      - num_disabled_users
      - total_disk_used_mb
      - num_signup_codes
      - num_unused_signup_codes
      - public_key
      - pkarr_pubky_address
      - pkarr_icann_domain
      - version
      properties:
        num_users:
          type: integer
          format: int64
          minimum: 0
        num_disabled_users:
          type: integer
          format: int64
          minimum: 0
        total_disk_used_mb:
          type: integer
          format: int64
          minimum: 0
        num_signup_codes:
          type: integer
          format: int64
          minimum: 0
        num_unused_signup_codes:
          type: integer
          format: int64
          minimum: 0
        public_key:
          type: string
          description: z-base-32 encoded homeserver public key.
        pkarr_pubky_address:
          type:
          - string
          - 'null'
          description: Pubky address from pkarr config.
        pkarr_icann_domain:
          type:
          - string
          - 'null'
          description: ICANN domain from pkarr config.
        version:
          type: string
          description: Homeserver version.
    UserQuota:
      type: object
      description: |
        Quota configuration. All fields are optional.
        - Absent or `null`: use system default
        - `"unlimited"`: no limit
        - Value: explicit limit
      properties:
        storage_quota_mb:
          description: Storage quota in megabytes, `"unlimited"`, or `null` for default.
          oneOf:
          - type: integer
          - type: string
            enum:
            - unlimited
        rate_read:
          description: Read bandwidth limit (e.g. `"200mb/m"`, `"unlimited"`, or `null`).
          type: string
        rate_write:
          description: Write bandwidth limit (e.g. `"100mb/m"`, `"unlimited"`, or
            `null`).
          type: string
        rate_read_burst:
          description: |
            Burst override for read rate limit, in the rate's natural unit
            (MB for "…mb/s", KB for "…kb/s"). `null` or absent = burst equals rate (default).
          type: integer
          format: int32
          minimum: 1
        rate_write_burst:
          description: |
            Burst override for write rate limit, in the rate's natural unit
            (MB for "…mb/s", KB for "…kb/s"). `null` or absent = burst equals rate (default).
          type: integer
          format: int32
          minimum: 1
        allowed_write_paths:
          description: |
            Restrict which paths a user can write to.
            - `null` or absent: unrestricted (all paths allowed) — default
            - `[]`: read-only (no writes allowed)
            - `["/pub/tokens/", "/pub/paykit/"]`: only these prefix paths
          type: array
          items:
            type: string
    UserQuotaPatch:
      type: object
      description: |
        Partial quota update. Only fields present in the body are changed.
        - Absent: keep existing value (no change)
        - `null`: reset to system default
        - `"unlimited"`: no limit
        - Value: explicit custom limit
      properties:
        storage_quota_mb:
          description: Storage quota in MB, `"unlimited"`, or `null` to reset.
          oneOf:
          - type: integer
          - type: string
            enum:
            - unlimited
          - type: 'null'
        rate_read:
          description: Read bandwidth limit string, `"unlimited"`, or `null` to reset.
          type:
          - string
          - 'null'
        rate_write:
          description: Write bandwidth limit string, `"unlimited"`, or `null` to reset.
          type:
          - string
          - 'null'
        rate_read_burst:
          description: Burst for read rate limit (in rate's natural unit), or `null`
            to reset to default.
          type:
          - integer
          - 'null'
          format: int32
          minimum: 1
        rate_write_burst:
          description: Burst for write rate limit (in rate's natural unit), or `null`
            to reset to default.
          type:
          - integer
          - 'null'
          format: int32
          minimum: 1
        allowed_write_paths:
          description: |
            Allowed write paths. Absent = keep existing, `null` = reset to unrestricted,
            `[]` = read-only, `["/pub/tokens/"]` = only these prefix paths.
          type:
          - array
          - 'null'
          items:
            type: string
    UserQuotaResponse:
      type: object
      required:
      - effective
      - overrides
      properties:
        effective:
          description: Overrides merged with system defaults. All fields are always
            present.
          allOf:
          - "$ref": "#/components/schemas/UserQuota"
        overrides:
          description: Only per-user customizations. Fields using the system default
            are omitted.
          allOf:
          - "$ref": "#/components/schemas/UserQuota"