@myronsi/messenger-api 2.1.0-alpha.43.next.151 → 2.1.0-alpha.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  Contract changes only. The backend changelog is `CHANGELOG.md` in the repository root. Rules: `docs/api-compatibility.md`.
4
4
 
5
+ ## 2.1.0-alpha.45
6
+
7
+ - `GET /search/messages` gains the query parameter `kind` (`MediaKind`: `image`, `visual`, `audio`, `voice`, `file`,
8
+ `link`) to find only messages with that kind of attachment or with a web link. `q` is now optional when `kind` is
9
+ given, which lists those messages newest first.
10
+
11
+ ## 2.1.0-alpha.44
12
+
13
+ - `GET /sync/changes` (`listSyncChanges`): edits, reaction changes, deletions, pin changes, cleared histories and
14
+ chats deleted for the caller since a cursor, for clients that keep messages offline. New schemas
15
+ `SyncChangesPage` and `SyncChange`.
16
+ - `POST /me/storage-key` (`getStorageKey`): the key of the current session for encrypting offline data, new schema
17
+ `StorageKey`.
18
+
5
19
  ## 2.1.0-alpha.43
6
20
 
7
21
  - Device-bound sessions: optional header parameter `DeviceProof` (`Device-Proof`, a DPoP-style ES256 proof) on
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.43. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.43";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.45. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.45";
3
3
  export type { paths, components, operations } from "./schema.js";
4
4
  export * from "./ws-events.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export const API_VERSION = "2.1.0-alpha.43";
1
+ export const API_VERSION = "2.1.0-alpha.45";
package/dist/openapi.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: Messenger API
4
- version: 2.1.0-alpha.43
4
+ version: 2.1.0-alpha.45
5
5
  summary: REST contract of the Messenger backend (v2).
6
6
  description: |
7
7
  Contract for the Go backend. The WebSocket protocol is described in `websocket/` and
@@ -570,6 +570,27 @@ paths:
570
570
  schema: { $ref: "#/components/schemas/SecuritySettings" }
571
571
  "401": { $ref: "#/components/responses/Unauthorized" }
572
572
  "422": { $ref: "#/components/responses/ValidationFailed" }
573
+ /me/storage-key:
574
+ parameters:
575
+ - $ref: "#/components/parameters/ClientVersion"
576
+ - $ref: "#/components/parameters/ClientApiVersion"
577
+ post:
578
+ tags: [me]
579
+ operationId: getStorageKey
580
+ summary: The key this device encrypts its offline data with
581
+ description: |
582
+ Returns the key of the current session, creating it on the first call; later calls return the same
583
+ key. It is deleted with the session, so data a device stored can no longer be read once it signs out
584
+ or is signed out from another device.
585
+ responses:
586
+ "426": { $ref: "#/components/responses/ClientOutdated" }
587
+ "400": { $ref: "#/components/responses/BadRequest" }
588
+ "200":
589
+ description: Key of this session
590
+ content:
591
+ application/json:
592
+ schema: { $ref: "#/components/schemas/StorageKey" }
593
+ "401": { $ref: "#/components/responses/Unauthorized" }
573
594
  /me/sessions:
574
595
  parameters:
575
596
  - $ref: "#/components/parameters/ClientVersion"
@@ -2414,11 +2435,18 @@ paths:
2414
2435
  hit is checked against the message store before it is returned (a deleted message never
2415
2436
  shows, even when the index lags behind). Edits and deletions reach the results within a
2416
2437
  few seconds.
2438
+
2439
+ With `kind`, only messages with that kind of attachment or with a web link are found, and `q` may be
2440
+ left out to list them newest first. Without `kind`, `q` is required (`422` otherwise).
2417
2441
  parameters:
2418
2442
  - name: q
2419
2443
  in: query
2420
- required: true
2444
+ description: Words to find; optional with `kind`
2421
2445
  schema: { type: string, minLength: 2, maxLength: 256 }
2446
+ - name: kind
2447
+ in: query
2448
+ description: Only messages with this kind of attachment, or with a web link (`link`)
2449
+ schema: { $ref: "#/components/schemas/MediaKind" }
2422
2450
  - name: chat_id
2423
2451
  in: query
2424
2452
  description: Only this chat
@@ -2455,6 +2483,44 @@ paths:
2455
2483
  "422": { $ref: "#/components/responses/ValidationFailed" }
2456
2484
  "429": { $ref: "#/components/responses/TooManyRequests" }
2457
2485
 
2486
+ /sync/changes:
2487
+ parameters:
2488
+ - $ref: "#/components/parameters/ClientVersion"
2489
+ - $ref: "#/components/parameters/ClientApiVersion"
2490
+ get:
2491
+ tags: [messages]
2492
+ operationId: listSyncChanges
2493
+ summary: What changed in my chats since a cursor
2494
+ description: |
2495
+ For clients that keep messages offline. Returns edits, reaction changes, deletions (for everyone or
2496
+ only for the caller), pin changes, cleared histories and chats the caller deleted for themselves,
2497
+ oldest first. New messages are not listed: load them with `after` from each chat's last stored message.
2498
+ Chats the caller left, was removed from or that were deleted are not listed either; they are missing
2499
+ from `GET /chats`.
2500
+
2501
+ Call without `cursor` once to get the current position, then keep `next_cursor`. Several changes of one
2502
+ message come as one entry with its current state. Entries are kept for 30 days; an older cursor answers
2503
+ `reset_required: true` with a fresh `next_cursor`, and the client drops what it stored and loads again.
2504
+ parameters:
2505
+ - name: cursor
2506
+ in: query
2507
+ description: "`next_cursor` of the previous answer"
2508
+ schema: { type: string, pattern: "^[0-9]{1,19}$" }
2509
+ - name: limit
2510
+ in: query
2511
+ description: Page size
2512
+ schema: { type: integer, minimum: 1, maximum: 500, default: 500 }
2513
+ responses:
2514
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2515
+ "400": { $ref: "#/components/responses/BadRequest" }
2516
+ "200":
2517
+ description: Changes after the cursor
2518
+ content:
2519
+ application/json:
2520
+ schema: { $ref: "#/components/schemas/SyncChangesPage" }
2521
+ "401": { $ref: "#/components/responses/Unauthorized" }
2522
+ "422": { $ref: "#/components/responses/ValidationFailed" }
2523
+
2458
2524
  # ------------------------------------------------------------ requests
2459
2525
  /requests:
2460
2526
  parameters:
@@ -7680,6 +7746,52 @@ components:
7680
7746
  removed_by_moderation:
7681
7747
  type: boolean
7682
7748
  description: "`true` when moderation removed the answered message. Absent otherwise."
7749
+ SyncChangesPage:
7750
+ type: object
7751
+ required: [changes, next_cursor, has_more, reset_required]
7752
+ properties:
7753
+ changes:
7754
+ type: array
7755
+ items: { $ref: "#/components/schemas/SyncChange" }
7756
+ next_cursor:
7757
+ type: string
7758
+ description: Send as `cursor` next time
7759
+ has_more:
7760
+ type: boolean
7761
+ description: More changes are waiting; ask again at once
7762
+ reset_required:
7763
+ type: boolean
7764
+ description: The cursor is too old; drop the stored messages and load them again
7765
+ SyncChange:
7766
+ type: object
7767
+ required: [type, chat_id]
7768
+ description: |
7769
+ `message_updated` carries the message as the caller sees it now (`message`). `message_deleted` names the
7770
+ message and its `scope`. `pins_changed`: load the pins of the chat again. `history_cleared`: drop the
7771
+ messages up to and including `before_message_id` (`scope` says for whom). `chat_hidden`: the caller
7772
+ deleted the chat for themselves up to `before_message_id`.
7773
+ properties:
7774
+ type:
7775
+ type: string
7776
+ enum: [message_updated, message_deleted, pins_changed, history_cleared, chat_hidden]
7777
+ chat_id: { $ref: "#/components/schemas/Id" }
7778
+ message_id: { $ref: "#/components/schemas/Id" }
7779
+ scope:
7780
+ type: string
7781
+ enum: [me, everyone]
7782
+ before_message_id: { $ref: "#/components/schemas/Id" }
7783
+ message: { $ref: "#/components/schemas/Message" }
7784
+ StorageKey:
7785
+ type: object
7786
+ required: [key, algorithm]
7787
+ properties:
7788
+ key:
7789
+ type: string
7790
+ description: 32 random bytes, base64url without padding
7791
+ pattern: "^[A-Za-z0-9_-]{43}$"
7792
+ algorithm:
7793
+ type: string
7794
+ enum: [A256GCM]
7683
7795
  Message:
7684
7796
  type: object
7685
7797
  required:
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.43. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.45. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -463,6 +463,33 @@ export interface paths {
463
463
  patch: operations["updateSecuritySettings"];
464
464
  trace?: never;
465
465
  };
466
+ "/me/storage-key": {
467
+ parameters: {
468
+ query?: never;
469
+ header?: {
470
+ /** @description Version of the client app, for logs and the per-client metric. */
471
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
472
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
473
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
474
+ };
475
+ path?: never;
476
+ cookie?: never;
477
+ };
478
+ get?: never;
479
+ put?: never;
480
+ /**
481
+ * The key this device encrypts its offline data with
482
+ * @description Returns the key of the current session, creating it on the first call; later calls return the same
483
+ * key. It is deleted with the session, so data a device stored can no longer be read once it signs out
484
+ * or is signed out from another device.
485
+ */
486
+ post: operations["getStorageKey"];
487
+ delete?: never;
488
+ options?: never;
489
+ head?: never;
490
+ patch?: never;
491
+ trace?: never;
492
+ };
466
493
  "/me/sessions": {
467
494
  parameters: {
468
495
  query?: never;
@@ -2125,6 +2152,9 @@ export interface paths {
2125
2152
  * hit is checked against the message store before it is returned (a deleted message never
2126
2153
  * shows, even when the index lags behind). Edits and deletions reach the results within a
2127
2154
  * few seconds.
2155
+ *
2156
+ * With `kind`, only messages with that kind of attachment or with a web link are found, and `q` may be
2157
+ * left out to list them newest first. Without `kind`, `q` is required (`422` otherwise).
2128
2158
  */
2129
2159
  get: operations["searchAllMessages"];
2130
2160
  put?: never;
@@ -2135,6 +2165,39 @@ export interface paths {
2135
2165
  patch?: never;
2136
2166
  trace?: never;
2137
2167
  };
2168
+ "/sync/changes": {
2169
+ parameters: {
2170
+ query?: never;
2171
+ header?: {
2172
+ /** @description Version of the client app, for logs and the per-client metric. */
2173
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
2174
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
2175
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
2176
+ };
2177
+ path?: never;
2178
+ cookie?: never;
2179
+ };
2180
+ /**
2181
+ * What changed in my chats since a cursor
2182
+ * @description For clients that keep messages offline. Returns edits, reaction changes, deletions (for everyone or
2183
+ * only for the caller), pin changes, cleared histories and chats the caller deleted for themselves,
2184
+ * oldest first. New messages are not listed: load them with `after` from each chat's last stored message.
2185
+ * Chats the caller left, was removed from or that were deleted are not listed either; they are missing
2186
+ * from `GET /chats`.
2187
+ *
2188
+ * Call without `cursor` once to get the current position, then keep `next_cursor`. Several changes of one
2189
+ * message come as one entry with its current state. Entries are kept for 30 days; an older cursor answers
2190
+ * `reset_required: true` with a fresh `next_cursor`, and the client drops what it stored and loads again.
2191
+ */
2192
+ get: operations["listSyncChanges"];
2193
+ put?: never;
2194
+ post?: never;
2195
+ delete?: never;
2196
+ options?: never;
2197
+ head?: never;
2198
+ patch?: never;
2199
+ trace?: never;
2200
+ };
2138
2201
  "/requests": {
2139
2202
  parameters: {
2140
2203
  query?: never;
@@ -5633,6 +5696,37 @@ export interface components {
5633
5696
  /** @description `true` when moderation removed the answered message. Absent otherwise. */
5634
5697
  removed_by_moderation?: boolean;
5635
5698
  };
5699
+ SyncChangesPage: {
5700
+ changes: components["schemas"]["SyncChange"][];
5701
+ /** @description Send as `cursor` next time */
5702
+ next_cursor: string;
5703
+ /** @description More changes are waiting; ask again at once */
5704
+ has_more: boolean;
5705
+ /** @description The cursor is too old; drop the stored messages and load them again */
5706
+ reset_required: boolean;
5707
+ };
5708
+ /**
5709
+ * @description `message_updated` carries the message as the caller sees it now (`message`). `message_deleted` names the
5710
+ * message and its `scope`. `pins_changed`: load the pins of the chat again. `history_cleared`: drop the
5711
+ * messages up to and including `before_message_id` (`scope` says for whom). `chat_hidden`: the caller
5712
+ * deleted the chat for themselves up to `before_message_id`.
5713
+ */
5714
+ SyncChange: {
5715
+ /** @enum {string} */
5716
+ type: "message_updated" | "message_deleted" | "pins_changed" | "history_cleared" | "chat_hidden";
5717
+ chat_id: components["schemas"]["Id"];
5718
+ message_id?: components["schemas"]["Id"];
5719
+ /** @enum {string} */
5720
+ scope?: "me" | "everyone";
5721
+ before_message_id?: components["schemas"]["Id"];
5722
+ message?: components["schemas"]["Message"];
5723
+ };
5724
+ StorageKey: {
5725
+ /** @description 32 random bytes, base64url without padding */
5726
+ key: string;
5727
+ /** @enum {string} */
5728
+ algorithm: "A256GCM";
5729
+ };
5636
5730
  Message: {
5637
5731
  id: components["schemas"]["Id"];
5638
5732
  chat_id: components["schemas"]["Id"];
@@ -7312,6 +7406,34 @@ export interface operations {
7312
7406
  426: components["responses"]["ClientOutdated"];
7313
7407
  };
7314
7408
  };
7409
+ getStorageKey: {
7410
+ parameters: {
7411
+ query?: never;
7412
+ header?: {
7413
+ /** @description Version of the client app, for logs and the per-client metric. */
7414
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
7415
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
7416
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
7417
+ };
7418
+ path?: never;
7419
+ cookie?: never;
7420
+ };
7421
+ requestBody?: never;
7422
+ responses: {
7423
+ /** @description Key of this session */
7424
+ 200: {
7425
+ headers: {
7426
+ [name: string]: unknown;
7427
+ };
7428
+ content: {
7429
+ "application/json": components["schemas"]["StorageKey"];
7430
+ };
7431
+ };
7432
+ 400: components["responses"]["BadRequest"];
7433
+ 401: components["responses"]["Unauthorized"];
7434
+ 426: components["responses"]["ClientOutdated"];
7435
+ };
7436
+ };
7315
7437
  listSessions: {
7316
7438
  parameters: {
7317
7439
  query?: never;
@@ -9811,8 +9933,11 @@ export interface operations {
9811
9933
  };
9812
9934
  searchAllMessages: {
9813
9935
  parameters: {
9814
- query: {
9815
- q: string;
9936
+ query?: {
9937
+ /** @description Words to find; optional with `kind` */
9938
+ q?: string;
9939
+ /** @description Only messages with this kind of attachment, or with a web link (`link`) */
9940
+ kind?: components["schemas"]["MediaKind"];
9816
9941
  /** @description Only this chat */
9817
9942
  chat_id?: components["schemas"]["Id"];
9818
9943
  /** @description Only messages of this user */
@@ -9855,6 +9980,40 @@ export interface operations {
9855
9980
  429: components["responses"]["TooManyRequests"];
9856
9981
  };
9857
9982
  };
9983
+ listSyncChanges: {
9984
+ parameters: {
9985
+ query?: {
9986
+ /** @description `next_cursor` of the previous answer */
9987
+ cursor?: string;
9988
+ /** @description Page size */
9989
+ limit?: number;
9990
+ };
9991
+ header?: {
9992
+ /** @description Version of the client app, for logs and the per-client metric. */
9993
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
9994
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
9995
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
9996
+ };
9997
+ path?: never;
9998
+ cookie?: never;
9999
+ };
10000
+ requestBody?: never;
10001
+ responses: {
10002
+ /** @description Changes after the cursor */
10003
+ 200: {
10004
+ headers: {
10005
+ [name: string]: unknown;
10006
+ };
10007
+ content: {
10008
+ "application/json": components["schemas"]["SyncChangesPage"];
10009
+ };
10010
+ };
10011
+ 400: components["responses"]["BadRequest"];
10012
+ 401: components["responses"]["Unauthorized"];
10013
+ 422: components["responses"]["ValidationFailed"];
10014
+ 426: components["responses"]["ClientOutdated"];
10015
+ };
10016
+ };
9858
10017
  listApprovalRequests: {
9859
10018
  parameters: {
9860
10019
  query?: {
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.43. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.45. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -3028,6 +3028,94 @@
3028
3028
  }
3029
3029
  }
3030
3030
  },
3031
+ "SyncChangesPage": {
3032
+ "type": "object",
3033
+ "required": [
3034
+ "changes",
3035
+ "next_cursor",
3036
+ "has_more",
3037
+ "reset_required"
3038
+ ],
3039
+ "properties": {
3040
+ "changes": {
3041
+ "type": "array",
3042
+ "items": {
3043
+ "$ref": "#/$defs/SyncChange"
3044
+ }
3045
+ },
3046
+ "next_cursor": {
3047
+ "type": "string",
3048
+ "description": "Send as `cursor` next time"
3049
+ },
3050
+ "has_more": {
3051
+ "type": "boolean",
3052
+ "description": "More changes are waiting; ask again at once"
3053
+ },
3054
+ "reset_required": {
3055
+ "type": "boolean",
3056
+ "description": "The cursor is too old; drop the stored messages and load them again"
3057
+ }
3058
+ }
3059
+ },
3060
+ "SyncChange": {
3061
+ "type": "object",
3062
+ "required": [
3063
+ "type",
3064
+ "chat_id"
3065
+ ],
3066
+ "description": "`message_updated` carries the message as the caller sees it now (`message`). `message_deleted` names the\nmessage and its `scope`. `pins_changed`: load the pins of the chat again. `history_cleared`: drop the\nmessages up to and including `before_message_id` (`scope` says for whom). `chat_hidden`: the caller\ndeleted the chat for themselves up to `before_message_id`.\n",
3067
+ "properties": {
3068
+ "type": {
3069
+ "type": "string",
3070
+ "enum": [
3071
+ "message_updated",
3072
+ "message_deleted",
3073
+ "pins_changed",
3074
+ "history_cleared",
3075
+ "chat_hidden"
3076
+ ]
3077
+ },
3078
+ "chat_id": {
3079
+ "$ref": "#/$defs/Id"
3080
+ },
3081
+ "message_id": {
3082
+ "$ref": "#/$defs/Id"
3083
+ },
3084
+ "scope": {
3085
+ "type": "string",
3086
+ "enum": [
3087
+ "me",
3088
+ "everyone"
3089
+ ]
3090
+ },
3091
+ "before_message_id": {
3092
+ "$ref": "#/$defs/Id"
3093
+ },
3094
+ "message": {
3095
+ "$ref": "#/$defs/Message"
3096
+ }
3097
+ }
3098
+ },
3099
+ "StorageKey": {
3100
+ "type": "object",
3101
+ "required": [
3102
+ "key",
3103
+ "algorithm"
3104
+ ],
3105
+ "properties": {
3106
+ "key": {
3107
+ "type": "string",
3108
+ "description": "32 random bytes, base64url without padding",
3109
+ "pattern": "^[A-Za-z0-9_-]{43}$"
3110
+ },
3111
+ "algorithm": {
3112
+ "type": "string",
3113
+ "enum": [
3114
+ "A256GCM"
3115
+ ]
3116
+ }
3117
+ }
3118
+ },
3031
3119
  "Message": {
3032
3120
  "type": "object",
3033
3121
  "required": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.43.next.151",
3
+ "version": "2.1.0-alpha.45",
4
4
  "description": "API contract of the Messenger backend: OpenAPI document, WebSocket event schemas and generated TypeScript types",
5
5
  "license": "MIT",
6
6
  "repository": {