@oxy.so/contracts 1.4.0 → 1.5.0

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.
@@ -105,3 +105,5 @@ export type { EmailContextAddress, EmailContextMailbox, EmailContextMessage, Ema
105
105
  export { inboxComposeRequestSchema, inboxDailyBriefRequestSchema, inboxNaturalSearchRequestSchema, inboxMessageInferenceParamsSchema, inboxInferenceTextResponseSchema, inboxNaturalSearchResponseSchema, inboxSmartRepliesResponseSchema, inboxThreadSummaryResponseSchema, inboxInferenceStreamEventSchema, } from './inference/inbox';
106
106
  export type { InboxComposeRequest, InboxDailyBriefRequest, InboxInferenceTextResponse, InboxNaturalSearchResponse, InboxSmartRepliesResponse, InboxThreadSummaryResponse, InboxInferenceStreamEvent, } from './inference/inbox';
107
107
  export * from './externalIdentity';
108
+ export * from './linkedAccounts';
109
+ export * from './notifications';
@@ -0,0 +1,341 @@
1
+ /**
2
+ * Wire contract for Oxy linked accounts — external accounts (any Mastodon-API
3
+ * server, Bluesky) a LOCAL Oxy user has proven they own by completing an OAuth
4
+ * authorization there.
5
+ *
6
+ * Every response schema is `.strict()` and carries no field a third-party token
7
+ * could occupy: Oxy uses the OAuth flow only to learn which account authorized
8
+ * it, then discards the token. See `docs/identity/linked-accounts.md`.
9
+ *
10
+ * Platform-agnostic — zod only, no react/react-native/expo.
11
+ */
12
+ import { z } from 'zod';
13
+ export declare const LINKED_ACCOUNT_NETWORKS: readonly ["activitypub", "atproto"];
14
+ export type LinkedAccountNetwork = (typeof LINKED_ACCOUNT_NETWORKS)[number];
15
+ export declare const linkedAccountNetworkSchema: z.ZodEnum<["activitypub", "atproto"]>;
16
+ /**
17
+ * `POST /linked-accounts/:network/start`.
18
+ *
19
+ * - `instance` (activitypub): `mastodon.social`, `https://mastodon.social` or
20
+ * `@user@mastodon.social`.
21
+ * - `handle` (atproto): a handle (`alice.bsky.social`) or a DID.
22
+ * - `returnTo` + `clientId`: where the browser lands afterwards, with
23
+ * `?link_code=` or `?link_error=`. `returnTo` must exactly match a redirect
24
+ * URI registered on the TRUSTED (first-party) application `clientId` names.
25
+ */
26
+ export declare const startLinkedAccountRequestSchema: z.ZodObject<{
27
+ instance: z.ZodOptional<z.ZodString>;
28
+ handle: z.ZodOptional<z.ZodString>;
29
+ clientId: z.ZodString;
30
+ returnTo: z.ZodString;
31
+ }, "strict", z.ZodTypeAny, {
32
+ clientId: string;
33
+ returnTo: string;
34
+ handle?: string | undefined;
35
+ instance?: string | undefined;
36
+ }, {
37
+ clientId: string;
38
+ returnTo: string;
39
+ handle?: string | undefined;
40
+ instance?: string | undefined;
41
+ }>;
42
+ export type StartLinkedAccountRequest = z.infer<typeof startLinkedAccountRequestSchema>;
43
+ export declare const startLinkedAccountResponseSchema: z.ZodObject<{
44
+ authorizeUrl: z.ZodString;
45
+ expiresAt: z.ZodString;
46
+ }, "strict", z.ZodTypeAny, {
47
+ expiresAt: string;
48
+ authorizeUrl: string;
49
+ }, {
50
+ expiresAt: string;
51
+ authorizeUrl: string;
52
+ }>;
53
+ export type StartLinkedAccountResponse = z.infer<typeof startLinkedAccountResponseSchema>;
54
+ /**
55
+ * `POST /linked-accounts/complete`, with the session of the user who STARTED
56
+ * the flow: `code` is the one-time `link_code` the callback appended to
57
+ * `returnTo`. It expires five minutes after the callback. Presented by any
58
+ * other user it is refused (403) and burned.
59
+ */
60
+ export declare const completeLinkedAccountRequestSchema: z.ZodObject<{
61
+ code: z.ZodString;
62
+ }, "strict", z.ZodTypeAny, {
63
+ code: string;
64
+ }, {
65
+ code: string;
66
+ }>;
67
+ export type CompleteLinkedAccountRequest = z.infer<typeof completeLinkedAccountRequestSchema>;
68
+ /** One live linked account, as its owner sees it. */
69
+ export declare const linkedAccountSchema: z.ZodObject<{
70
+ id: z.ZodString;
71
+ network: z.ZodEnum<["activitypub", "atproto"]>;
72
+ /** `username@domain` for ActivityPub; the DID for atproto. */
73
+ accountKey: z.ZodString;
74
+ /** ActivityPub actor id, or the DID for atproto. */
75
+ actorUri: z.ZodString;
76
+ handle: z.ZodString;
77
+ host: z.ZodString;
78
+ proofMethod: z.ZodLiteral<"oauth">;
79
+ verifiedAt: z.ZodString;
80
+ createdAt: z.ZodString;
81
+ }, "strict", z.ZodTypeAny, {
82
+ id: string;
83
+ createdAt: string;
84
+ verifiedAt: string;
85
+ handle: string;
86
+ network: "activitypub" | "atproto";
87
+ actorUri: string;
88
+ accountKey: string;
89
+ host: string;
90
+ proofMethod: "oauth";
91
+ }, {
92
+ id: string;
93
+ createdAt: string;
94
+ verifiedAt: string;
95
+ handle: string;
96
+ network: "activitypub" | "atproto";
97
+ actorUri: string;
98
+ accountKey: string;
99
+ host: string;
100
+ proofMethod: "oauth";
101
+ }>;
102
+ export type LinkedAccount = z.infer<typeof linkedAccountSchema>;
103
+ export declare const completeLinkedAccountResponseSchema: z.ZodObject<{
104
+ linkedAccount: z.ZodObject<{
105
+ id: z.ZodString;
106
+ network: z.ZodEnum<["activitypub", "atproto"]>;
107
+ /** `username@domain` for ActivityPub; the DID for atproto. */
108
+ accountKey: z.ZodString;
109
+ /** ActivityPub actor id, or the DID for atproto. */
110
+ actorUri: z.ZodString;
111
+ handle: z.ZodString;
112
+ host: z.ZodString;
113
+ proofMethod: z.ZodLiteral<"oauth">;
114
+ verifiedAt: z.ZodString;
115
+ createdAt: z.ZodString;
116
+ }, "strict", z.ZodTypeAny, {
117
+ id: string;
118
+ createdAt: string;
119
+ verifiedAt: string;
120
+ handle: string;
121
+ network: "activitypub" | "atproto";
122
+ actorUri: string;
123
+ accountKey: string;
124
+ host: string;
125
+ proofMethod: "oauth";
126
+ }, {
127
+ id: string;
128
+ createdAt: string;
129
+ verifiedAt: string;
130
+ handle: string;
131
+ network: "activitypub" | "atproto";
132
+ actorUri: string;
133
+ accountKey: string;
134
+ host: string;
135
+ proofMethod: "oauth";
136
+ }>;
137
+ }, "strict", z.ZodTypeAny, {
138
+ linkedAccount: {
139
+ id: string;
140
+ createdAt: string;
141
+ verifiedAt: string;
142
+ handle: string;
143
+ network: "activitypub" | "atproto";
144
+ actorUri: string;
145
+ accountKey: string;
146
+ host: string;
147
+ proofMethod: "oauth";
148
+ };
149
+ }, {
150
+ linkedAccount: {
151
+ id: string;
152
+ createdAt: string;
153
+ verifiedAt: string;
154
+ handle: string;
155
+ network: "activitypub" | "atproto";
156
+ actorUri: string;
157
+ accountKey: string;
158
+ host: string;
159
+ proofMethod: "oauth";
160
+ };
161
+ }>;
162
+ export type CompleteLinkedAccountResponse = z.infer<typeof completeLinkedAccountResponseSchema>;
163
+ export declare const linkedAccountListResponseSchema: z.ZodObject<{
164
+ linkedAccounts: z.ZodArray<z.ZodObject<{
165
+ id: z.ZodString;
166
+ network: z.ZodEnum<["activitypub", "atproto"]>;
167
+ /** `username@domain` for ActivityPub; the DID for atproto. */
168
+ accountKey: z.ZodString;
169
+ /** ActivityPub actor id, or the DID for atproto. */
170
+ actorUri: z.ZodString;
171
+ handle: z.ZodString;
172
+ host: z.ZodString;
173
+ proofMethod: z.ZodLiteral<"oauth">;
174
+ verifiedAt: z.ZodString;
175
+ createdAt: z.ZodString;
176
+ }, "strict", z.ZodTypeAny, {
177
+ id: string;
178
+ createdAt: string;
179
+ verifiedAt: string;
180
+ handle: string;
181
+ network: "activitypub" | "atproto";
182
+ actorUri: string;
183
+ accountKey: string;
184
+ host: string;
185
+ proofMethod: "oauth";
186
+ }, {
187
+ id: string;
188
+ createdAt: string;
189
+ verifiedAt: string;
190
+ handle: string;
191
+ network: "activitypub" | "atproto";
192
+ actorUri: string;
193
+ accountKey: string;
194
+ host: string;
195
+ proofMethod: "oauth";
196
+ }>, "many">;
197
+ }, "strict", z.ZodTypeAny, {
198
+ linkedAccounts: {
199
+ id: string;
200
+ createdAt: string;
201
+ verifiedAt: string;
202
+ handle: string;
203
+ network: "activitypub" | "atproto";
204
+ actorUri: string;
205
+ accountKey: string;
206
+ host: string;
207
+ proofMethod: "oauth";
208
+ }[];
209
+ }, {
210
+ linkedAccounts: {
211
+ id: string;
212
+ createdAt: string;
213
+ verifiedAt: string;
214
+ handle: string;
215
+ network: "activitypub" | "atproto";
216
+ actorUri: string;
217
+ accountKey: string;
218
+ host: string;
219
+ proofMethod: "oauth";
220
+ }[];
221
+ }>;
222
+ export type LinkedAccountListResponse = z.infer<typeof linkedAccountListResponseSchema>;
223
+ /**
224
+ * `GET /linked-accounts/by-user/:userId` (service token with the privileged
225
+ * `linked-accounts:read`). Adds `federatedUserId`: the FEDERATED shadow user Oxy
226
+ * already holds for that external account, if any — the anchor for adopting
227
+ * content Oxy federated in before the account was linked.
228
+ */
229
+ export declare const serviceLinkedAccountSchema: z.ZodObject<{
230
+ id: z.ZodString;
231
+ network: z.ZodEnum<["activitypub", "atproto"]>;
232
+ /** `username@domain` for ActivityPub; the DID for atproto. */
233
+ accountKey: z.ZodString;
234
+ /** ActivityPub actor id, or the DID for atproto. */
235
+ actorUri: z.ZodString;
236
+ handle: z.ZodString;
237
+ host: z.ZodString;
238
+ proofMethod: z.ZodLiteral<"oauth">;
239
+ verifiedAt: z.ZodString;
240
+ createdAt: z.ZodString;
241
+ } & {
242
+ federatedUserId: z.ZodNullable<z.ZodString>;
243
+ }, "strict", z.ZodTypeAny, {
244
+ id: string;
245
+ createdAt: string;
246
+ verifiedAt: string;
247
+ handle: string;
248
+ network: "activitypub" | "atproto";
249
+ actorUri: string;
250
+ accountKey: string;
251
+ host: string;
252
+ proofMethod: "oauth";
253
+ federatedUserId: string | null;
254
+ }, {
255
+ id: string;
256
+ createdAt: string;
257
+ verifiedAt: string;
258
+ handle: string;
259
+ network: "activitypub" | "atproto";
260
+ actorUri: string;
261
+ accountKey: string;
262
+ host: string;
263
+ proofMethod: "oauth";
264
+ federatedUserId: string | null;
265
+ }>;
266
+ export type ServiceLinkedAccount = z.infer<typeof serviceLinkedAccountSchema>;
267
+ export declare const serviceLinkedAccountListResponseSchema: z.ZodObject<{
268
+ userId: z.ZodString;
269
+ linkedAccounts: z.ZodArray<z.ZodObject<{
270
+ id: z.ZodString;
271
+ network: z.ZodEnum<["activitypub", "atproto"]>;
272
+ /** `username@domain` for ActivityPub; the DID for atproto. */
273
+ accountKey: z.ZodString;
274
+ /** ActivityPub actor id, or the DID for atproto. */
275
+ actorUri: z.ZodString;
276
+ handle: z.ZodString;
277
+ host: z.ZodString;
278
+ proofMethod: z.ZodLiteral<"oauth">;
279
+ verifiedAt: z.ZodString;
280
+ createdAt: z.ZodString;
281
+ } & {
282
+ federatedUserId: z.ZodNullable<z.ZodString>;
283
+ }, "strict", z.ZodTypeAny, {
284
+ id: string;
285
+ createdAt: string;
286
+ verifiedAt: string;
287
+ handle: string;
288
+ network: "activitypub" | "atproto";
289
+ actorUri: string;
290
+ accountKey: string;
291
+ host: string;
292
+ proofMethod: "oauth";
293
+ federatedUserId: string | null;
294
+ }, {
295
+ id: string;
296
+ createdAt: string;
297
+ verifiedAt: string;
298
+ handle: string;
299
+ network: "activitypub" | "atproto";
300
+ actorUri: string;
301
+ accountKey: string;
302
+ host: string;
303
+ proofMethod: "oauth";
304
+ federatedUserId: string | null;
305
+ }>, "many">;
306
+ }, "strict", z.ZodTypeAny, {
307
+ userId: string;
308
+ linkedAccounts: {
309
+ id: string;
310
+ createdAt: string;
311
+ verifiedAt: string;
312
+ handle: string;
313
+ network: "activitypub" | "atproto";
314
+ actorUri: string;
315
+ accountKey: string;
316
+ host: string;
317
+ proofMethod: "oauth";
318
+ federatedUserId: string | null;
319
+ }[];
320
+ }, {
321
+ userId: string;
322
+ linkedAccounts: {
323
+ id: string;
324
+ createdAt: string;
325
+ verifiedAt: string;
326
+ handle: string;
327
+ network: "activitypub" | "atproto";
328
+ actorUri: string;
329
+ accountKey: string;
330
+ host: string;
331
+ proofMethod: "oauth";
332
+ federatedUserId: string | null;
333
+ }[];
334
+ }>;
335
+ export type ServiceLinkedAccountListResponse = z.infer<typeof serviceLinkedAccountListResponseSchema>;
336
+ /**
337
+ * Error codes the callback appends as `?link_error=<code>` to `returnTo`. An
338
+ * account already linked to someone else is reported by `/complete` (409).
339
+ */
340
+ export declare const LINKED_ACCOUNT_CALLBACK_ERRORS: readonly ["access_denied", "verification_failed", "provider_unavailable"];
341
+ export type LinkedAccountCallbackError = (typeof LINKED_ACCOUNT_CALLBACK_ERRORS)[number];
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The closed set of Oxy in-app notification types — owned here so the API's
3
+ * CHECK constraint (`notifications.type`), its request validation and the SDK
4
+ * all read one tuple.
5
+ *
6
+ * `system` is a message from an Oxy service about the recipient's OWN account
7
+ * (Oxy Move's "your migration finished"): the actor is the recipient, and the
8
+ * entity is their profile or an `app` id. It is the only type an actor does not
9
+ * cause.
10
+ *
11
+ * Platform-agnostic — zod only, no react/react-native/expo.
12
+ */
13
+ import { z } from 'zod';
14
+ export declare const OXY_NOTIFICATION_TYPES: readonly ["like", "reply", "mention", "follow", "repost", "quote", "welcome", "system"];
15
+ export type OxyNotificationType = (typeof OXY_NOTIFICATION_TYPES)[number];
16
+ /**
17
+ * What a notification's `entityId` names.
18
+ *
19
+ * `app` means `entityId` is an OPAQUE id in the notifying application's own
20
+ * namespace (Oxy Move's migration job id). Oxy never resolves it; it exists so
21
+ * a `system` notification about something that is not a post or a profile does
22
+ * not have to pretend to be one. Valid only with `type: 'system'`.
23
+ */
24
+ export declare const OXY_NOTIFICATION_ENTITY_TYPES: readonly ["post", "reply", "profile", "app"];
25
+ export type OxyNotificationEntityType = (typeof OXY_NOTIFICATION_ENTITY_TYPES)[number];
26
+ /** Length caps on the text a `system` notification carries (enforced by CHECKs too). */
27
+ export declare const OXY_SYSTEM_NOTIFICATION_TITLE_MAX = 120;
28
+ export declare const OXY_SYSTEM_NOTIFICATION_MESSAGE_MAX = 500;
29
+ export declare const OXY_NOTIFICATION_URL_MAX = 2048;
30
+ /**
31
+ * `POST /notifications` (service token with `notifications:write`).
32
+ *
33
+ * Only a `system` notification carries text: `title` and `message` are REQUIRED
34
+ * for it and stored, and `url` is an optional deep link (https, or a custom
35
+ * scheme registered as a redirect URI on the calling application). For every
36
+ * other type the client renders from `type` + entity, and `title` / `message` /
37
+ * `data` are accepted but discarded, as they always were.
38
+ *
39
+ * `system` notifications share the duplicate guard (recipient, actor, type,
40
+ * entityId): use a caller-unique `entityId` (a job id) for each distinct event.
41
+ */
42
+ export declare const createOxyNotificationRequestSchema: z.ZodEffects<z.ZodObject<{
43
+ recipientId: z.ZodString;
44
+ actorId: z.ZodString;
45
+ type: z.ZodEnum<["like", "reply", "mention", "follow", "repost", "quote", "welcome", "system"]>;
46
+ entityId: z.ZodString;
47
+ entityType: z.ZodEnum<["post", "reply", "profile", "app"]>;
48
+ title: z.ZodOptional<z.ZodString>;
49
+ message: z.ZodOptional<z.ZodString>;
50
+ url: z.ZodOptional<z.ZodString>;
51
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ type: "system" | "like" | "reply" | "follow" | "mention" | "quote" | "repost" | "welcome";
54
+ recipientId: string;
55
+ actorId: string;
56
+ entityId: string;
57
+ entityType: "profile" | "reply" | "post" | "app";
58
+ message?: string | undefined;
59
+ data?: Record<string, unknown> | undefined;
60
+ url?: string | undefined;
61
+ title?: string | undefined;
62
+ }, {
63
+ type: "system" | "like" | "reply" | "follow" | "mention" | "quote" | "repost" | "welcome";
64
+ recipientId: string;
65
+ actorId: string;
66
+ entityId: string;
67
+ entityType: "profile" | "reply" | "post" | "app";
68
+ message?: string | undefined;
69
+ data?: Record<string, unknown> | undefined;
70
+ url?: string | undefined;
71
+ title?: string | undefined;
72
+ }>, {
73
+ type: "system" | "like" | "reply" | "follow" | "mention" | "quote" | "repost" | "welcome";
74
+ recipientId: string;
75
+ actorId: string;
76
+ entityId: string;
77
+ entityType: "profile" | "reply" | "post" | "app";
78
+ message?: string | undefined;
79
+ data?: Record<string, unknown> | undefined;
80
+ url?: string | undefined;
81
+ title?: string | undefined;
82
+ }, {
83
+ type: "system" | "like" | "reply" | "follow" | "mention" | "quote" | "repost" | "welcome";
84
+ recipientId: string;
85
+ actorId: string;
86
+ entityId: string;
87
+ entityType: "profile" | "reply" | "post" | "app";
88
+ message?: string | undefined;
89
+ data?: Record<string, unknown> | undefined;
90
+ url?: string | undefined;
91
+ title?: string | undefined;
92
+ }>;
93
+ export type CreateOxyNotificationRequest = z.infer<typeof createOxyNotificationRequestSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/contracts",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "OxyHQ API contracts — single source of truth for request/response Zod schemas and inferred types, shared by the backend and the client SDKs",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",