@oxyhq/contracts 0.8.0 → 0.9.1

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.
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Device-first bootstrap & token contracts (auth centralization, wave 1).
3
+ *
4
+ * SINGLE SOURCE OF TRUTH for the wire shape of the new device-first session
5
+ * bootstrap: the top-level `#oxy_boot=…` fragment the API hands back from
6
+ * `GET /auth/device/bootstrap`, the token bundle a boot code / web-session
7
+ * fast-path exchanges into, the persisted-refresh rotation, the native
8
+ * device-token issuance, the IdP chooser's device-resolve, and the first-party
9
+ * password login result (2FA arm vs. session arm). The API validates its OUTPUT
10
+ * against these schemas; every consumer (`@oxyhq/core`'s device-boot mixin, the
11
+ * SDK cold boot, the IdP chooser) validates its INPUT against the same
12
+ * definitions, so producer and consumers cannot drift.
13
+ *
14
+ * Design anchors (from the auth-centralization plan):
15
+ * - The bootstrap fragment carries NO tokens and NO deviceId — only a
16
+ * `state` echo (CSRF), a `reason`, a short-lived single-use `code`, and an
17
+ * opaque `deviceToken`. Tokens are obtained by exchanging the `code` at
18
+ * `POST /auth/device/exchange` (origin-bound GETDEL burn).
19
+ * - Refresh is ONE rotating, single-use family shared by web and native.
20
+ * - `loginResult` mirrors what `POST /auth/login` returns today
21
+ * (`buildSessionAuthResponse` in the API's `session.controller.ts`): either a
22
+ * 2FA challenge (`{ twoFactorRequired: true, loginToken }`) or a session
23
+ * payload. The session arm matches `SessionAuthResponse` EXACTLY, plus an
24
+ * optional `refreshToken` the new server adds for the persisted-refresh lane.
25
+ *
26
+ * Nested-object response shapes are declared as explicit `interface`s with the
27
+ * runtime schema annotated `z.ZodType<Interface>` — the same rationale as
28
+ * `identity.ts` / `userResponse.ts`: a `z.infer<>` of a nested object schema can
29
+ * degrade to `{}` under a consumer's `moduleResolution: "node"` (node10), so the
30
+ * load-bearing shapes are pinned by literal interfaces. Flat request/response
31
+ * shapes (no nested-object hazard) are inferred via `z.infer<>`.
32
+ *
33
+ * Platform-agnostic — zod only, no react/react-native/expo. ESM-safe (no
34
+ * `require()`).
35
+ */
36
+ import { z } from 'zod';
37
+ import { type UserResponse } from './userResponse';
38
+ /**
39
+ * Why the bootstrap hop resolved the way it did.
40
+ * - `session` — the device cookie resolved an active session; a `code` is
41
+ * present to exchange for tokens.
42
+ * - `no_session` — the device is known but has no active session; no `code`.
43
+ * - `new_device` — first contact; the cookie was just planted, no session yet.
44
+ */
45
+ export declare const deviceBootReasonSchema: z.ZodEnum<["session", "no_session", "new_device"]>;
46
+ export type DeviceBootReason = z.infer<typeof deviceBootReasonSchema>;
47
+ export declare const deviceBootFragmentSchema: z.ZodDiscriminatedUnion<"reason", [z.ZodObject<{
48
+ reason: z.ZodLiteral<"session">;
49
+ code: z.ZodString;
50
+ v: z.ZodLiteral<1>;
51
+ state: z.ZodString;
52
+ deviceToken: z.ZodString;
53
+ }, "strip", z.ZodTypeAny, {
54
+ code: string;
55
+ reason: "session";
56
+ v: 1;
57
+ state: string;
58
+ deviceToken: string;
59
+ }, {
60
+ code: string;
61
+ reason: "session";
62
+ v: 1;
63
+ state: string;
64
+ deviceToken: string;
65
+ }>, z.ZodObject<{
66
+ reason: z.ZodLiteral<"no_session">;
67
+ v: z.ZodLiteral<1>;
68
+ state: z.ZodString;
69
+ deviceToken: z.ZodString;
70
+ }, "strip", z.ZodTypeAny, {
71
+ reason: "no_session";
72
+ v: 1;
73
+ state: string;
74
+ deviceToken: string;
75
+ }, {
76
+ reason: "no_session";
77
+ v: 1;
78
+ state: string;
79
+ deviceToken: string;
80
+ }>, z.ZodObject<{
81
+ reason: z.ZodLiteral<"new_device">;
82
+ v: z.ZodLiteral<1>;
83
+ state: z.ZodString;
84
+ deviceToken: z.ZodString;
85
+ }, "strip", z.ZodTypeAny, {
86
+ reason: "new_device";
87
+ v: 1;
88
+ state: string;
89
+ deviceToken: string;
90
+ }, {
91
+ reason: "new_device";
92
+ v: 1;
93
+ state: string;
94
+ deviceToken: string;
95
+ }>]>;
96
+ export type DeviceBootFragment = z.infer<typeof deviceBootFragmentSchema>;
97
+ /** Request body for `POST /auth/device/exchange` — the single-use boot code. */
98
+ export declare const deviceExchangeRequestSchema: z.ZodObject<{
99
+ code: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ code: string;
102
+ }, {
103
+ code: string;
104
+ }>;
105
+ export type DeviceExchangeRequest = z.infer<typeof deviceExchangeRequestSchema>;
106
+ /**
107
+ * The token bundle returned by `POST /auth/device/exchange` and
108
+ * `POST /auth/device/web-session` — the freshly-minted access token, its
109
+ * rotating refresh-family head, the owning `sessionId`, and the full canonical
110
+ * user object. `expiresAt` is an ISO string.
111
+ */
112
+ export interface AuthTokenBundle {
113
+ sessionId: string;
114
+ accessToken: string;
115
+ refreshToken: string;
116
+ expiresAt: string;
117
+ user: UserResponse;
118
+ }
119
+ export declare const authTokenBundleSchema: z.ZodType<AuthTokenBundle>;
120
+ /**
121
+ * The `*.oxy.so` same-site fast path returns a `reason`-discriminated result:
122
+ * a full session (the device cookie resolved an active session) OR a
123
+ * signed-out arm (the device is known / was just planted). BOTH arms carry the
124
+ * rotated opaque `deviceToken` to persist — the deviceToken is device-level
125
+ * attribution, not session-level, so it is refreshed even when signed out.
126
+ *
127
+ * IMPORTANT: the success arm nests the token bundle under `session` — it is
128
+ * NOT a bare {@link AuthTokenBundle}. That distinction is load-bearing for the
129
+ * consumer (`@oxyhq/core`'s cold boot uses `result.session` and persists the
130
+ * `deviceToken` from the SAME envelope).
131
+ */
132
+ /**
133
+ * Success arm: an active session resolved from the same-site device cookie.
134
+ */
135
+ export interface WebSessionSession {
136
+ reason: 'session';
137
+ session: AuthTokenBundle;
138
+ deviceToken: string;
139
+ }
140
+ /**
141
+ * Signed-out arm: the device is known (or freshly planted) but has no active
142
+ * session. Carries only the rotated `deviceToken`.
143
+ */
144
+ export interface WebSessionNoSession {
145
+ reason: 'no_session' | 'new_device';
146
+ deviceToken: string;
147
+ }
148
+ /** The `reason`-discriminated outcome of `POST /auth/device/web-session`. */
149
+ export type WebSessionResult = WebSessionSession | WebSessionNoSession;
150
+ export declare const webSessionResultSchema: z.ZodType<WebSessionResult>;
151
+ /** Request body for `POST /auth/refresh-token` — the current refresh token. */
152
+ export declare const tokenRefreshRequestSchema: z.ZodObject<{
153
+ refreshToken: z.ZodString;
154
+ }, "strip", z.ZodTypeAny, {
155
+ refreshToken: string;
156
+ }, {
157
+ refreshToken: string;
158
+ }>;
159
+ export type TokenRefreshRequest = z.infer<typeof tokenRefreshRequestSchema>;
160
+ /**
161
+ * Wire shape of `POST /auth/refresh-token`: the rotated (single-use) family —
162
+ * a new access token, the next refresh token, the new access-token expiry, and
163
+ * the owning session id. `expiresAt` is an ISO string.
164
+ */
165
+ export declare const tokenRefreshResponseSchema: z.ZodObject<{
166
+ accessToken: z.ZodString;
167
+ refreshToken: z.ZodString;
168
+ expiresAt: z.ZodString;
169
+ sessionId: z.ZodString;
170
+ }, "strip", z.ZodTypeAny, {
171
+ expiresAt: string;
172
+ accessToken: string;
173
+ sessionId: string;
174
+ refreshToken: string;
175
+ }, {
176
+ expiresAt: string;
177
+ accessToken: string;
178
+ sessionId: string;
179
+ refreshToken: string;
180
+ }>;
181
+ export type TokenRefreshResponse = z.infer<typeof tokenRefreshResponseSchema>;
182
+ /**
183
+ * Wire shape of `POST /auth/device/token` — issues (or rotates) the opaque
184
+ * device token for the native channel. The deviceId is taken from the bearer
185
+ * JWT claims server-side; only the token comes back.
186
+ */
187
+ export declare const deviceTokenIssueResponseSchema: z.ZodObject<{
188
+ deviceToken: z.ZodString;
189
+ }, "strip", z.ZodTypeAny, {
190
+ deviceToken: string;
191
+ }, {
192
+ deviceToken: string;
193
+ }>;
194
+ export type DeviceTokenIssueResponse = z.infer<typeof deviceTokenIssueResponseSchema>;
195
+ /**
196
+ * `POST /auth/login` when the account has 2FA enabled: a short-lived login
197
+ * token to be presented at the 2FA challenge, and no session yet.
198
+ */
199
+ export interface LoginTwoFactorRequired {
200
+ twoFactorRequired: true;
201
+ loginToken: string;
202
+ }
203
+ /**
204
+ * `POST /auth/login` when authentication completed in one step. Matches the
205
+ * API's `SessionAuthResponse` EXACTLY (`buildSessionAuthResponse`), plus the
206
+ * optional `refreshToken` the persisted-refresh lane adds. `user` is the
207
+ * truncated session-user shape the login endpoint emits (NOT the full
208
+ * `userResponseSchema`).
209
+ */
210
+ export interface LoginSessionResult {
211
+ sessionId: string;
212
+ deviceId: string;
213
+ expiresAt: string;
214
+ accessToken?: string;
215
+ refreshToken?: string;
216
+ user: {
217
+ id: string;
218
+ username?: string;
219
+ avatar?: string;
220
+ };
221
+ }
222
+ /** The discriminated outcome of `POST /auth/login`. */
223
+ export type LoginResult = LoginTwoFactorRequired | LoginSessionResult;
224
+ export declare const loginResultSchema: z.ZodType<LoginResult>;
225
+ /**
226
+ * Request body for `POST /auth/device/resolve` (X-Oxy-Internal, called by the
227
+ * IdP chooser) — the device key the chooser read from the first-party
228
+ * `oxy_device` cookie.
229
+ */
230
+ export declare const deviceResolveRequestSchema: z.ZodObject<{
231
+ deviceKey: z.ZodString;
232
+ }, "strip", z.ZodTypeAny, {
233
+ deviceKey: string;
234
+ }, {
235
+ deviceKey: string;
236
+ }>;
237
+ export type DeviceResolveRequest = z.infer<typeof deviceResolveRequestSchema>;
238
+ /** One account resolved for the IdP chooser from a device's session set. */
239
+ export interface DeviceResolveAccount {
240
+ user: UserResponse;
241
+ sessionId: string;
242
+ accessToken: string;
243
+ expiresAt: string;
244
+ }
245
+ /**
246
+ * Wire shape of `POST /auth/device/resolve` — the device's active account id
247
+ * (or `null` when signed out of all) plus every account signed in on the
248
+ * device. Replaces the IdP's `/auth/refresh-all` chooser feed.
249
+ */
250
+ export interface DeviceResolveResponse {
251
+ activeAccountId: string | null;
252
+ accounts: DeviceResolveAccount[];
253
+ }
254
+ export declare const deviceResolveResponseSchema: z.ZodType<DeviceResolveResponse>;
@@ -5,14 +5,14 @@ export declare const sessionAccountSchema: z.ZodObject<{
5
5
  authuser: z.ZodNumber;
6
6
  operatedByUserId: z.ZodOptional<z.ZodString>;
7
7
  }, "strip", z.ZodTypeAny, {
8
- accountId: string;
9
- sessionId: string;
10
8
  authuser: number;
9
+ sessionId: string;
10
+ accountId: string;
11
11
  operatedByUserId?: string | undefined;
12
12
  }, {
13
- accountId: string;
14
- sessionId: string;
15
13
  authuser: number;
14
+ sessionId: string;
15
+ accountId: string;
16
16
  operatedByUserId?: string | undefined;
17
17
  }>;
18
18
  export declare const deviceSessionStateSchema: z.ZodObject<{
@@ -23,14 +23,14 @@ export declare const deviceSessionStateSchema: z.ZodObject<{
23
23
  authuser: z.ZodNumber;
24
24
  operatedByUserId: z.ZodOptional<z.ZodString>;
25
25
  }, "strip", z.ZodTypeAny, {
26
- accountId: string;
27
- sessionId: string;
28
26
  authuser: number;
27
+ sessionId: string;
28
+ accountId: string;
29
29
  operatedByUserId?: string | undefined;
30
30
  }, {
31
- accountId: string;
32
- sessionId: string;
33
31
  authuser: number;
32
+ sessionId: string;
33
+ accountId: string;
34
34
  operatedByUserId?: string | undefined;
35
35
  }>, "many">;
36
36
  activeAccountId: z.ZodNullable<z.ZodString>;
@@ -38,24 +38,24 @@ export declare const deviceSessionStateSchema: z.ZodObject<{
38
38
  updatedAt: z.ZodNumber;
39
39
  }, "strip", z.ZodTypeAny, {
40
40
  updatedAt: number;
41
- deviceId: string;
42
41
  accounts: {
43
- accountId: string;
44
- sessionId: string;
45
42
  authuser: number;
43
+ sessionId: string;
44
+ accountId: string;
46
45
  operatedByUserId?: string | undefined;
47
46
  }[];
47
+ deviceId: string;
48
48
  activeAccountId: string | null;
49
49
  revision: number;
50
50
  }, {
51
51
  updatedAt: number;
52
- deviceId: string;
53
52
  accounts: {
54
- accountId: string;
55
- sessionId: string;
56
53
  authuser: number;
54
+ sessionId: string;
55
+ accountId: string;
57
56
  operatedByUserId?: string | undefined;
58
57
  }[];
58
+ deviceId: string;
59
59
  activeAccountId: string | null;
60
60
  revision: number;
61
61
  }>;
@@ -78,14 +78,14 @@ export declare const deviceSessionSyncSchema: z.ZodObject<{
78
78
  authuser: z.ZodNumber;
79
79
  operatedByUserId: z.ZodOptional<z.ZodString>;
80
80
  }, "strip", z.ZodTypeAny, {
81
- accountId: string;
82
- sessionId: string;
83
81
  authuser: number;
82
+ sessionId: string;
83
+ accountId: string;
84
84
  operatedByUserId?: string | undefined;
85
85
  }, {
86
- accountId: string;
87
- sessionId: string;
88
86
  authuser: number;
87
+ sessionId: string;
88
+ accountId: string;
89
89
  operatedByUserId?: string | undefined;
90
90
  }>, "many">;
91
91
  activeAccountId: z.ZodNullable<z.ZodString>;
@@ -93,24 +93,24 @@ export declare const deviceSessionSyncSchema: z.ZodObject<{
93
93
  updatedAt: z.ZodNumber;
94
94
  }, "strip", z.ZodTypeAny, {
95
95
  updatedAt: number;
96
- deviceId: string;
97
96
  accounts: {
98
- accountId: string;
99
- sessionId: string;
100
97
  authuser: number;
98
+ sessionId: string;
99
+ accountId: string;
101
100
  operatedByUserId?: string | undefined;
102
101
  }[];
102
+ deviceId: string;
103
103
  activeAccountId: string | null;
104
104
  revision: number;
105
105
  }, {
106
106
  updatedAt: number;
107
- deviceId: string;
108
107
  accounts: {
109
- accountId: string;
110
- sessionId: string;
111
108
  authuser: number;
109
+ sessionId: string;
110
+ accountId: string;
112
111
  operatedByUserId?: string | undefined;
113
112
  }[];
113
+ deviceId: string;
114
114
  activeAccountId: string | null;
115
115
  revision: number;
116
116
  }>;
@@ -127,13 +127,13 @@ export declare const deviceSessionSyncSchema: z.ZodObject<{
127
127
  }, "strip", z.ZodTypeAny, {
128
128
  state: {
129
129
  updatedAt: number;
130
- deviceId: string;
131
130
  accounts: {
132
- accountId: string;
133
- sessionId: string;
134
131
  authuser: number;
132
+ sessionId: string;
133
+ accountId: string;
135
134
  operatedByUserId?: string | undefined;
136
135
  }[];
136
+ deviceId: string;
137
137
  activeAccountId: string | null;
138
138
  revision: number;
139
139
  };
@@ -144,13 +144,13 @@ export declare const deviceSessionSyncSchema: z.ZodObject<{
144
144
  }, {
145
145
  state: {
146
146
  updatedAt: number;
147
- deviceId: string;
148
147
  accounts: {
149
- accountId: string;
150
- sessionId: string;
151
148
  authuser: number;
149
+ sessionId: string;
150
+ accountId: string;
152
151
  operatedByUserId?: string | undefined;
153
152
  }[];
153
+ deviceId: string;
154
154
  activeAccountId: string | null;
155
155
  revision: number;
156
156
  };
@@ -15,8 +15,8 @@ export { applicationTypeSchema, publicApplicationSchema, sessionStatusSchema, }
15
15
  export type { ApplicationTypeContract, PublicApplicationResponse, SessionStatusResponse, } from './sessionStatus';
16
16
  export { fedcmTokenPayloadSchema, } from './fedcmToken';
17
17
  export type { FedcmTokenPayload, } from './fedcmToken';
18
- export { recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, } from './recommendations';
19
- export type { RecommendationExcludeType, RecommendationBoost, RecommendationSignalWeights, RecommendationRequest, RecommendationCount, RecommendationItem, RecommendationResponse, AppEndorsementInput, AppInterestInput, AppUserSignalIngest, } from './recommendations';
18
+ export { recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, appAffinityEventTypeSchema, appAffinityEventSchema, appAffinityEventsIngestSchema, } from './recommendations';
19
+ export type { RecommendationExcludeType, RecommendationBoost, RecommendationSignalWeights, RecommendationRequest, RecommendationCount, RecommendationItem, RecommendationResponse, AppEndorsementInput, AppInterestInput, AppUserSignalIngest, AppAffinityEventType, AppAffinityEvent, AppAffinityEventsIngest, } from './recommendations';
20
20
  export { verificationMethodSchema, didServiceSchema, didDocumentSchema, signedRecordEnvelopeSchema, verifiedDomainSchema, domainVerificationRequestSchema, domainVerificationInstructionsSchema, authMethodEntrySchema, authMethodsResponseSchema, exportAttestationSchema, exportBundleSchema, } from './identity';
21
21
  export type { VerificationMethod, Secp256k1VerificationMethod, MultikeyVerificationMethod, DidService, DidDocument, SignedRecordEnvelope, VerifiedDomain, DomainVerificationRequest, DomainVerificationInstructions, AuthMethodEntry, AuthMethodsResponse, ExportAttestation, ExportBundle, } from './identity';
22
22
  export { oxySignedRecordTypeSchema, } from './oxyRecordTypes';
@@ -29,3 +29,5 @@ export { linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchRespo
29
29
  export type { LinkPreviewStatus, LinkPreview, LinkPreviewBatchRequest, LinkPreviewBatchResponse, } from './links';
30
30
  export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, } from './deviceSession';
31
31
  export type { SessionAccount, DeviceSessionState, ActiveToken, DeviceSessionSync, } from './deviceSession';
32
+ export { deviceBootReasonSchema, deviceBootFragmentSchema, deviceExchangeRequestSchema, authTokenBundleSchema, webSessionResultSchema, tokenRefreshRequestSchema, tokenRefreshResponseSchema, deviceTokenIssueResponseSchema, loginResultSchema, deviceResolveRequestSchema, deviceResolveResponseSchema, } from './deviceBoot';
33
+ export type { DeviceBootReason, DeviceBootFragment, DeviceExchangeRequest, AuthTokenBundle, WebSessionResult, WebSessionSession, WebSessionNoSession, TokenRefreshRequest, TokenRefreshResponse, DeviceTokenIssueResponse, LoginTwoFactorRequired, LoginSessionResult, LoginResult, DeviceResolveRequest, DeviceResolveAccount, DeviceResolveResponse, } from './deviceBoot';
@@ -47,6 +47,7 @@ export declare const recommendationSignalWeightsSchema: z.ZodObject<{
47
47
  interest: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
48
48
  appBoost: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
49
49
  repCandidate: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
50
+ affinity: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
50
51
  }, "strip", z.ZodTypeAny, {
51
52
  verified?: number | undefined;
52
53
  graph?: number | undefined;
@@ -55,6 +56,7 @@ export declare const recommendationSignalWeightsSchema: z.ZodObject<{
55
56
  interest?: number | undefined;
56
57
  appBoost?: number | undefined;
57
58
  repCandidate?: number | undefined;
59
+ affinity?: number | undefined;
58
60
  }, {
59
61
  verified?: number | undefined;
60
62
  graph?: number | undefined;
@@ -63,6 +65,7 @@ export declare const recommendationSignalWeightsSchema: z.ZodObject<{
63
65
  interest?: number | undefined;
64
66
  appBoost?: number | undefined;
65
67
  repCandidate?: number | undefined;
68
+ affinity?: number | undefined;
66
69
  }>;
67
70
  export type RecommendationSignalWeights = z.infer<typeof recommendationSignalWeightsSchema>;
68
71
  /**
@@ -100,6 +103,7 @@ export declare const recommendationRequestSchema: z.ZodObject<{
100
103
  interest: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
101
104
  appBoost: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
102
105
  repCandidate: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
106
+ affinity: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
103
107
  }, "strip", z.ZodTypeAny, {
104
108
  verified?: number | undefined;
105
109
  graph?: number | undefined;
@@ -108,6 +112,7 @@ export declare const recommendationRequestSchema: z.ZodObject<{
108
112
  interest?: number | undefined;
109
113
  appBoost?: number | undefined;
110
114
  repCandidate?: number | undefined;
115
+ affinity?: number | undefined;
111
116
  }, {
112
117
  verified?: number | undefined;
113
118
  graph?: number | undefined;
@@ -116,6 +121,7 @@ export declare const recommendationRequestSchema: z.ZodObject<{
116
121
  interest?: number | undefined;
117
122
  appBoost?: number | undefined;
118
123
  repCandidate?: number | undefined;
124
+ affinity?: number | undefined;
119
125
  }>>;
120
126
  }, "strip", z.ZodTypeAny, {
121
127
  clientId?: string | undefined;
@@ -136,6 +142,7 @@ export declare const recommendationRequestSchema: z.ZodObject<{
136
142
  interest?: number | undefined;
137
143
  appBoost?: number | undefined;
138
144
  repCandidate?: number | undefined;
145
+ affinity?: number | undefined;
139
146
  } | undefined;
140
147
  }, {
141
148
  clientId?: string | undefined;
@@ -156,6 +163,7 @@ export declare const recommendationRequestSchema: z.ZodObject<{
156
163
  interest?: number | undefined;
157
164
  appBoost?: number | undefined;
158
165
  repCandidate?: number | undefined;
166
+ affinity?: number | undefined;
159
167
  } | undefined;
160
168
  }>;
161
169
  export type RecommendationRequest = z.infer<typeof recommendationRequestSchema>;
@@ -443,3 +451,92 @@ export declare const appUserSignalIngestSchema: z.ZodEffects<z.ZodObject<{
443
451
  }[] | undefined;
444
452
  }>;
445
453
  export type AppUserSignalIngest = z.infer<typeof appUserSignalIngestSchema>;
454
+ /**
455
+ * The directed interaction types a consuming app may report between two users.
456
+ * Each type carries a server-side default weight (see the API's
457
+ * `AFFINITY_EVENT_WEIGHTS`); a caller may override the applied weight per event.
458
+ */
459
+ export declare const appAffinityEventTypeSchema: z.ZodEnum<["like", "reply", "boost", "follow", "mention", "profile_view", "quote", "repost"]>;
460
+ export type AppAffinityEventType = z.infer<typeof appAffinityEventTypeSchema>;
461
+ /**
462
+ * One directed interaction event: `fromUserId` interacted with `toUserId`
463
+ * (`type`) at `occurredAt`. The Oxy affinity-graph folds these into a per-app,
464
+ * time-decayed directed affinity edge (`fromUserId → toUserId`).
465
+ *
466
+ * - `weight` (optional) overrides the per-type default weight for this event.
467
+ * - `occurredAt` (optional, ISO) is the event time; absent means "now" at ingest.
468
+ * - `eventId` (optional) makes an event idempotent — a repeated `eventId` for the
469
+ * same application is folded at most once (bounded dedup window).
470
+ */
471
+ export declare const appAffinityEventSchema: z.ZodObject<{
472
+ fromUserId: z.ZodString;
473
+ toUserId: z.ZodString;
474
+ type: z.ZodEnum<["like", "reply", "boost", "follow", "mention", "profile_view", "quote", "repost"]>;
475
+ weight: z.ZodOptional<z.ZodNumber>;
476
+ occurredAt: z.ZodOptional<z.ZodString>;
477
+ eventId: z.ZodOptional<z.ZodString>;
478
+ }, "strip", z.ZodTypeAny, {
479
+ type: "like" | "reply" | "boost" | "follow" | "mention" | "profile_view" | "quote" | "repost";
480
+ fromUserId: string;
481
+ toUserId: string;
482
+ weight?: number | undefined;
483
+ occurredAt?: string | undefined;
484
+ eventId?: string | undefined;
485
+ }, {
486
+ type: "like" | "reply" | "boost" | "follow" | "mention" | "profile_view" | "quote" | "repost";
487
+ fromUserId: string;
488
+ toUserId: string;
489
+ weight?: number | undefined;
490
+ occurredAt?: string | undefined;
491
+ eventId?: string | undefined;
492
+ }>;
493
+ export type AppAffinityEvent = z.infer<typeof appAffinityEventSchema>;
494
+ /**
495
+ * Request body for `POST /app-signals/events` (service token, `signals:write`).
496
+ *
497
+ * A non-empty batch (1..1000) of directed interaction events for the requesting
498
+ * application. Self-edges (`fromUserId === toUserId`) are dropped server-side.
499
+ */
500
+ export declare const appAffinityEventsIngestSchema: z.ZodObject<{
501
+ events: z.ZodArray<z.ZodObject<{
502
+ fromUserId: z.ZodString;
503
+ toUserId: z.ZodString;
504
+ type: z.ZodEnum<["like", "reply", "boost", "follow", "mention", "profile_view", "quote", "repost"]>;
505
+ weight: z.ZodOptional<z.ZodNumber>;
506
+ occurredAt: z.ZodOptional<z.ZodString>;
507
+ eventId: z.ZodOptional<z.ZodString>;
508
+ }, "strip", z.ZodTypeAny, {
509
+ type: "like" | "reply" | "boost" | "follow" | "mention" | "profile_view" | "quote" | "repost";
510
+ fromUserId: string;
511
+ toUserId: string;
512
+ weight?: number | undefined;
513
+ occurredAt?: string | undefined;
514
+ eventId?: string | undefined;
515
+ }, {
516
+ type: "like" | "reply" | "boost" | "follow" | "mention" | "profile_view" | "quote" | "repost";
517
+ fromUserId: string;
518
+ toUserId: string;
519
+ weight?: number | undefined;
520
+ occurredAt?: string | undefined;
521
+ eventId?: string | undefined;
522
+ }>, "many">;
523
+ }, "strip", z.ZodTypeAny, {
524
+ events: {
525
+ type: "like" | "reply" | "boost" | "follow" | "mention" | "profile_view" | "quote" | "repost";
526
+ fromUserId: string;
527
+ toUserId: string;
528
+ weight?: number | undefined;
529
+ occurredAt?: string | undefined;
530
+ eventId?: string | undefined;
531
+ }[];
532
+ }, {
533
+ events: {
534
+ type: "like" | "reply" | "boost" | "follow" | "mention" | "profile_view" | "quote" | "repost";
535
+ fromUserId: string;
536
+ toUserId: string;
537
+ weight?: number | undefined;
538
+ occurredAt?: string | undefined;
539
+ eventId?: string | undefined;
540
+ }[];
541
+ }>;
542
+ export type AppAffinityEventsIngest = z.infer<typeof appAffinityEventsIngestSchema>;
@@ -189,7 +189,6 @@ export declare const userProfileUpdateSchema: z.ZodObject<{
189
189
  phone: z.ZodOptional<z.ZodString>;
190
190
  address: z.ZodOptional<z.ZodString>;
191
191
  birthday: z.ZodOptional<z.ZodString>;
192
- location: z.ZodOptional<z.ZodString>;
193
192
  locations: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
194
193
  links: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
195
194
  linksMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -236,7 +235,6 @@ export declare const userProfileUpdateSchema: z.ZodObject<{
236
235
  phone: z.ZodOptional<z.ZodString>;
237
236
  address: z.ZodOptional<z.ZodString>;
238
237
  birthday: z.ZodOptional<z.ZodString>;
239
- location: z.ZodOptional<z.ZodString>;
240
238
  locations: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
241
239
  links: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
242
240
  linksMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -283,7 +281,6 @@ export declare const userProfileUpdateSchema: z.ZodObject<{
283
281
  phone: z.ZodOptional<z.ZodString>;
284
282
  address: z.ZodOptional<z.ZodString>;
285
283
  birthday: z.ZodOptional<z.ZodString>;
286
- location: z.ZodOptional<z.ZodString>;
287
284
  locations: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
288
285
  links: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
289
286
  linksMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -419,9 +416,9 @@ export declare const refreshAllAccountSchema: z.ZodObject<{
419
416
  }, z.ZodTypeAny, "passthrough">>;
420
417
  }, "strip", z.ZodTypeAny, {
421
418
  expiresAt: string;
422
- sessionId: string;
423
419
  authuser: number;
424
420
  accessToken: string;
421
+ sessionId: string;
425
422
  user: {
426
423
  name: UserNameResponse;
427
424
  id?: string | undefined;
@@ -443,9 +440,9 @@ export declare const refreshAllAccountSchema: z.ZodObject<{
443
440
  };
444
441
  }, {
445
442
  expiresAt: string;
446
- sessionId: string;
447
443
  authuser: number;
448
444
  accessToken: string;
445
+ sessionId: string;
449
446
  user: {
450
447
  name: UserNameResponse;
451
448
  id?: string | undefined;
@@ -568,9 +565,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
568
565
  }, z.ZodTypeAny, "passthrough">>;
569
566
  }, "strip", z.ZodTypeAny, {
570
567
  expiresAt: string;
571
- sessionId: string;
572
568
  authuser: number;
573
569
  accessToken: string;
570
+ sessionId: string;
574
571
  user: {
575
572
  name: UserNameResponse;
576
573
  id?: string | undefined;
@@ -592,9 +589,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
592
589
  };
593
590
  }, {
594
591
  expiresAt: string;
595
- sessionId: string;
596
592
  authuser: number;
597
593
  accessToken: string;
594
+ sessionId: string;
598
595
  user: {
599
596
  name: UserNameResponse;
600
597
  id?: string | undefined;
@@ -618,9 +615,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
618
615
  }, "strip", z.ZodTypeAny, {
619
616
  accounts: {
620
617
  expiresAt: string;
621
- sessionId: string;
622
618
  authuser: number;
623
619
  accessToken: string;
620
+ sessionId: string;
624
621
  user: {
625
622
  name: UserNameResponse;
626
623
  id?: string | undefined;
@@ -644,9 +641,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
644
641
  }, {
645
642
  accounts: {
646
643
  expiresAt: string;
647
- sessionId: string;
648
644
  authuser: number;
649
645
  accessToken: string;
646
+ sessionId: string;
650
647
  user: {
651
648
  name: UserNameResponse;
652
649
  id?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/contracts",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
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",