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

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,14 @@
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.44
6
+
7
+ - `GET /sync/changes` (`listSyncChanges`): edits, reaction changes, deletions, pin changes, cleared histories and
8
+ chats deleted for the caller since a cursor, for clients that keep messages offline. New schemas
9
+ `SyncChangesPage` and `SyncChange`.
10
+ - `POST /me/storage-key` (`getStorageKey`): the key of the current session for encrypting offline data, new schema
11
+ `StorageKey`.
12
+
5
13
  ## 2.1.0-alpha.43
6
14
 
7
15
  - 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.44. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.44";
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.44";
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.44
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"
@@ -2455,6 +2476,44 @@ paths:
2455
2476
  "422": { $ref: "#/components/responses/ValidationFailed" }
2456
2477
  "429": { $ref: "#/components/responses/TooManyRequests" }
2457
2478
 
2479
+ /sync/changes:
2480
+ parameters:
2481
+ - $ref: "#/components/parameters/ClientVersion"
2482
+ - $ref: "#/components/parameters/ClientApiVersion"
2483
+ get:
2484
+ tags: [messages]
2485
+ operationId: listSyncChanges
2486
+ summary: What changed in my chats since a cursor
2487
+ description: |
2488
+ For clients that keep messages offline. Returns edits, reaction changes, deletions (for everyone or
2489
+ only for the caller), pin changes, cleared histories and chats the caller deleted for themselves,
2490
+ oldest first. New messages are not listed: load them with `after` from each chat's last stored message.
2491
+ Chats the caller left, was removed from or that were deleted are not listed either; they are missing
2492
+ from `GET /chats`.
2493
+
2494
+ Call without `cursor` once to get the current position, then keep `next_cursor`. Several changes of one
2495
+ message come as one entry with its current state. Entries are kept for 30 days; an older cursor answers
2496
+ `reset_required: true` with a fresh `next_cursor`, and the client drops what it stored and loads again.
2497
+ parameters:
2498
+ - name: cursor
2499
+ in: query
2500
+ description: "`next_cursor` of the previous answer"
2501
+ schema: { type: string, pattern: "^[0-9]{1,19}$" }
2502
+ - name: limit
2503
+ in: query
2504
+ description: Page size
2505
+ schema: { type: integer, minimum: 1, maximum: 500, default: 500 }
2506
+ responses:
2507
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2508
+ "400": { $ref: "#/components/responses/BadRequest" }
2509
+ "200":
2510
+ description: Changes after the cursor
2511
+ content:
2512
+ application/json:
2513
+ schema: { $ref: "#/components/schemas/SyncChangesPage" }
2514
+ "401": { $ref: "#/components/responses/Unauthorized" }
2515
+ "422": { $ref: "#/components/responses/ValidationFailed" }
2516
+
2458
2517
  # ------------------------------------------------------------ requests
2459
2518
  /requests:
2460
2519
  parameters:
@@ -7680,6 +7739,52 @@ components:
7680
7739
  removed_by_moderation:
7681
7740
  type: boolean
7682
7741
  description: "`true` when moderation removed the answered message. Absent otherwise."
7742
+ SyncChangesPage:
7743
+ type: object
7744
+ required: [changes, next_cursor, has_more, reset_required]
7745
+ properties:
7746
+ changes:
7747
+ type: array
7748
+ items: { $ref: "#/components/schemas/SyncChange" }
7749
+ next_cursor:
7750
+ type: string
7751
+ description: Send as `cursor` next time
7752
+ has_more:
7753
+ type: boolean
7754
+ description: More changes are waiting; ask again at once
7755
+ reset_required:
7756
+ type: boolean
7757
+ description: The cursor is too old; drop the stored messages and load them again
7758
+ SyncChange:
7759
+ type: object
7760
+ required: [type, chat_id]
7761
+ description: |
7762
+ `message_updated` carries the message as the caller sees it now (`message`). `message_deleted` names the
7763
+ message and its `scope`. `pins_changed`: load the pins of the chat again. `history_cleared`: drop the
7764
+ messages up to and including `before_message_id` (`scope` says for whom). `chat_hidden`: the caller
7765
+ deleted the chat for themselves up to `before_message_id`.
7766
+ properties:
7767
+ type:
7768
+ type: string
7769
+ enum: [message_updated, message_deleted, pins_changed, history_cleared, chat_hidden]
7770
+ chat_id: { $ref: "#/components/schemas/Id" }
7771
+ message_id: { $ref: "#/components/schemas/Id" }
7772
+ scope:
7773
+ type: string
7774
+ enum: [me, everyone]
7775
+ before_message_id: { $ref: "#/components/schemas/Id" }
7776
+ message: { $ref: "#/components/schemas/Message" }
7777
+ StorageKey:
7778
+ type: object
7779
+ required: [key, algorithm]
7780
+ properties:
7781
+ key:
7782
+ type: string
7783
+ description: 32 random bytes, base64url without padding
7784
+ pattern: "^[A-Za-z0-9_-]{43}$"
7785
+ algorithm:
7786
+ type: string
7787
+ enum: [A256GCM]
7683
7788
  Message:
7684
7789
  type: object
7685
7790
  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.44. 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;
@@ -2135,6 +2162,39 @@ export interface paths {
2135
2162
  patch?: never;
2136
2163
  trace?: never;
2137
2164
  };
2165
+ "/sync/changes": {
2166
+ parameters: {
2167
+ query?: never;
2168
+ header?: {
2169
+ /** @description Version of the client app, for logs and the per-client metric. */
2170
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
2171
+ /** @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`). */
2172
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
2173
+ };
2174
+ path?: never;
2175
+ cookie?: never;
2176
+ };
2177
+ /**
2178
+ * What changed in my chats since a cursor
2179
+ * @description For clients that keep messages offline. Returns edits, reaction changes, deletions (for everyone or
2180
+ * only for the caller), pin changes, cleared histories and chats the caller deleted for themselves,
2181
+ * oldest first. New messages are not listed: load them with `after` from each chat's last stored message.
2182
+ * Chats the caller left, was removed from or that were deleted are not listed either; they are missing
2183
+ * from `GET /chats`.
2184
+ *
2185
+ * Call without `cursor` once to get the current position, then keep `next_cursor`. Several changes of one
2186
+ * message come as one entry with its current state. Entries are kept for 30 days; an older cursor answers
2187
+ * `reset_required: true` with a fresh `next_cursor`, and the client drops what it stored and loads again.
2188
+ */
2189
+ get: operations["listSyncChanges"];
2190
+ put?: never;
2191
+ post?: never;
2192
+ delete?: never;
2193
+ options?: never;
2194
+ head?: never;
2195
+ patch?: never;
2196
+ trace?: never;
2197
+ };
2138
2198
  "/requests": {
2139
2199
  parameters: {
2140
2200
  query?: never;
@@ -5633,6 +5693,37 @@ export interface components {
5633
5693
  /** @description `true` when moderation removed the answered message. Absent otherwise. */
5634
5694
  removed_by_moderation?: boolean;
5635
5695
  };
5696
+ SyncChangesPage: {
5697
+ changes: components["schemas"]["SyncChange"][];
5698
+ /** @description Send as `cursor` next time */
5699
+ next_cursor: string;
5700
+ /** @description More changes are waiting; ask again at once */
5701
+ has_more: boolean;
5702
+ /** @description The cursor is too old; drop the stored messages and load them again */
5703
+ reset_required: boolean;
5704
+ };
5705
+ /**
5706
+ * @description `message_updated` carries the message as the caller sees it now (`message`). `message_deleted` names the
5707
+ * message and its `scope`. `pins_changed`: load the pins of the chat again. `history_cleared`: drop the
5708
+ * messages up to and including `before_message_id` (`scope` says for whom). `chat_hidden`: the caller
5709
+ * deleted the chat for themselves up to `before_message_id`.
5710
+ */
5711
+ SyncChange: {
5712
+ /** @enum {string} */
5713
+ type: "message_updated" | "message_deleted" | "pins_changed" | "history_cleared" | "chat_hidden";
5714
+ chat_id: components["schemas"]["Id"];
5715
+ message_id?: components["schemas"]["Id"];
5716
+ /** @enum {string} */
5717
+ scope?: "me" | "everyone";
5718
+ before_message_id?: components["schemas"]["Id"];
5719
+ message?: components["schemas"]["Message"];
5720
+ };
5721
+ StorageKey: {
5722
+ /** @description 32 random bytes, base64url without padding */
5723
+ key: string;
5724
+ /** @enum {string} */
5725
+ algorithm: "A256GCM";
5726
+ };
5636
5727
  Message: {
5637
5728
  id: components["schemas"]["Id"];
5638
5729
  chat_id: components["schemas"]["Id"];
@@ -7312,6 +7403,34 @@ export interface operations {
7312
7403
  426: components["responses"]["ClientOutdated"];
7313
7404
  };
7314
7405
  };
7406
+ getStorageKey: {
7407
+ parameters: {
7408
+ query?: never;
7409
+ header?: {
7410
+ /** @description Version of the client app, for logs and the per-client metric. */
7411
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
7412
+ /** @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`). */
7413
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
7414
+ };
7415
+ path?: never;
7416
+ cookie?: never;
7417
+ };
7418
+ requestBody?: never;
7419
+ responses: {
7420
+ /** @description Key of this session */
7421
+ 200: {
7422
+ headers: {
7423
+ [name: string]: unknown;
7424
+ };
7425
+ content: {
7426
+ "application/json": components["schemas"]["StorageKey"];
7427
+ };
7428
+ };
7429
+ 400: components["responses"]["BadRequest"];
7430
+ 401: components["responses"]["Unauthorized"];
7431
+ 426: components["responses"]["ClientOutdated"];
7432
+ };
7433
+ };
7315
7434
  listSessions: {
7316
7435
  parameters: {
7317
7436
  query?: never;
@@ -9855,6 +9974,40 @@ export interface operations {
9855
9974
  429: components["responses"]["TooManyRequests"];
9856
9975
  };
9857
9976
  };
9977
+ listSyncChanges: {
9978
+ parameters: {
9979
+ query?: {
9980
+ /** @description `next_cursor` of the previous answer */
9981
+ cursor?: string;
9982
+ /** @description Page size */
9983
+ limit?: number;
9984
+ };
9985
+ header?: {
9986
+ /** @description Version of the client app, for logs and the per-client metric. */
9987
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
9988
+ /** @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`). */
9989
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
9990
+ };
9991
+ path?: never;
9992
+ cookie?: never;
9993
+ };
9994
+ requestBody?: never;
9995
+ responses: {
9996
+ /** @description Changes after the cursor */
9997
+ 200: {
9998
+ headers: {
9999
+ [name: string]: unknown;
10000
+ };
10001
+ content: {
10002
+ "application/json": components["schemas"]["SyncChangesPage"];
10003
+ };
10004
+ };
10005
+ 400: components["responses"]["BadRequest"];
10006
+ 401: components["responses"]["Unauthorized"];
10007
+ 422: components["responses"]["ValidationFailed"];
10008
+ 426: components["responses"]["ClientOutdated"];
10009
+ };
10010
+ };
9858
10011
  listApprovalRequests: {
9859
10012
  parameters: {
9860
10013
  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.44. 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.44.next.153",
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": {