@oxyhq/contracts 0.9.1 → 0.11.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.
@@ -1,6 +1,16 @@
1
1
  /**
2
2
  * Canonical contract for the FedCM ID-token JWT payload.
3
3
  *
4
+ * DEAD SINCE THE WAVE-2 FEDCM DELETION (found during the comment sweep, not
5
+ * fixed here — this is a published `@oxyhq/contracts` export, so removing it
6
+ * is a breaking change/major-version decision, out of scope for a comment
7
+ * fix): `POST /fedcm/exchange`, `fedcm.service.exchangeIdToken`, and
8
+ * `packages/auth/server/index.ts`'s `mintSessionForClient` — every consumer
9
+ * and producer this file describes — are all deleted. No current code
10
+ * imports `fedcmTokenPayloadSchema` / `FedcmTokenPayload` outside this
11
+ * package. Flag for a follow-up major-version cleanup.
12
+ *
13
+ * Original doc (historical, describes the now-deleted system):
4
14
  * SINGLE SOURCE OF TRUTH for the decoded claims of the HS256 ID token the auth
5
15
  * IdP (`auth.oxy.so`) signs and `POST /fedcm/exchange` consumes. The API decodes
6
16
  * the JWT, verifies its signature, then validates the resulting claim object
package/dist/esm/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
  export {
13
13
  // Schemas
14
- userNameSchema, userResponseSchema, userProfileUpdateSchema, refreshAllAccountSchema, refreshAllResponseSchema, currentUserResponseSchema, deviceSessionAccountSchema, deviceSessionsResponseSchema,
14
+ userNameSchema, userResponseSchema, userProfileUpdateSchema, currentUserResponseSchema, deviceLinkedSessionSchema, deviceLinkedSessionsResponseSchema,
15
15
  // Helpers
16
16
  resolveUserId, safeParseContract, } from './userResponse.js';
17
17
  export {
@@ -19,9 +19,10 @@
19
19
  * Faithful to the producers:
20
20
  * - `packages/api/src/utils/serializeApplication.ts` `serializePublicApplication`
21
21
  * — the ONLY shape returned to an unauthenticated consent UI. Optional fields
22
- * (`description`, `icon`, `websiteUrl`, `developerName`) are OMITTED when
23
- * absent (never serialized as `null`), so they are `.optional()` — NOT
24
- * `.nullable()`. `type` is the `Application.type` enum.
22
+ * (`description`, `icon`, `websiteUrl`, `privacyPolicyUrl`, `termsUrl`,
23
+ * `developerName`) are OMITTED when absent (never serialized as `null`), so
24
+ * they are `.optional()` — NOT `.nullable()`. `type` is the `Application.type`
25
+ * enum.
25
26
  * - `packages/api/src/routes/auth.ts` `GET /session/status/:sessionToken` — the
26
27
  * inner object of the API's `{ data: ... }` success envelope. The handler
27
28
  * ALWAYS emits `status`, `authorized` (`status === 'authorized'`),
@@ -52,9 +53,10 @@ export const applicationTypeSchema = z.enum([
52
53
  * `GET /auth/oauth/client/:clientId` (OAuth code flow).
53
54
  *
54
55
  * Optional fields are `.optional()` (NOT `.nullable()`): the serializer OMITS
55
- * `description` / `icon` / `websiteUrl` / `developerName` when the underlying
56
- * value is absent — it never writes `null` for them. `developerName` is only
57
- * attached for non-official apps when a name could be resolved.
56
+ * `description` / `icon` / `websiteUrl` / `privacyPolicyUrl` / `termsUrl` /
57
+ * `developerName` when the underlying value is absent — it never writes `null`
58
+ * for them. `developerName` is only attached for non-official apps when a name
59
+ * could be resolved.
58
60
  */
59
61
  export const publicApplicationSchema = z.object({
60
62
  id: z.string(),
@@ -62,6 +64,8 @@ export const publicApplicationSchema = z.object({
62
64
  description: z.string().optional(),
63
65
  icon: z.string().optional(),
64
66
  websiteUrl: z.string().optional(),
67
+ privacyPolicyUrl: z.string().optional(),
68
+ termsUrl: z.string().optional(),
65
69
  type: applicationTypeSchema,
66
70
  isOfficial: z.boolean(),
67
71
  isInternal: z.boolean(),
@@ -16,7 +16,8 @@
16
16
  *
17
17
  * Faithful to the producers:
18
18
  * - `packages/api/src/utils/userTransform.ts` `formatUserResponse` — the
19
- * canonical serialization used by `/auth/refresh-all`, device sessions, etc.
19
+ * canonical serialization used by the device-first bootstrap/exchange
20
+ * endpoints (`deviceAuth.ts`), login/signup, device sessions, etc.
20
21
  * Emits `id` (NOT `_id`), forwards `username` verbatim (may be absent), and
21
22
  * emits `name` as the structured `{ first, last, full, displayName }`
22
23
  * subdocument.
@@ -24,8 +25,6 @@
24
25
  * `''`; `full` and `displayName` are Mongoose VIRTUALS. Formatted API
25
26
  * responses compose both fields, while raw-document responses may omit the
26
27
  * virtuals if the query did not materialise them.
27
- * - The `/auth/refresh-all` handler in `packages/api/src/routes/auth.ts`, whose
28
- * per-slot `authuser` is the numeric `oxy_rt_${authuser}` cookie slot.
29
28
  *
30
29
  * Platform-agnostic — zod only, no react/react-native/expo. ESM-safe (no
31
30
  * `require()`).
@@ -131,28 +130,6 @@ export const userProfileUpdateSchema = z
131
130
  export function resolveUserId(user) {
132
131
  return user.id ?? user._id;
133
132
  }
134
- /**
135
- * One rotated account entry from `POST /auth/refresh-all`.
136
- *
137
- * `authuser` is the device-local slot index (`0..N-1`). `user` is the canonical
138
- * {@link userResponseSchema} shape (the handler projects a whitelist and runs it
139
- * through `formatUserResponse`).
140
- */
141
- export const refreshAllAccountSchema = z.object({
142
- authuser: z.number().int().nonnegative(),
143
- accessToken: z.string(),
144
- expiresAt: z.string(),
145
- sessionId: z.string(),
146
- user: userResponseSchema,
147
- });
148
- /**
149
- * Wire shape of `POST /auth/refresh-all`: every valid device-local account,
150
- * sorted by `authuser` ascending. An empty `accounts` array means "no signed-in
151
- * accounts on this device" — the IdP must show the sign-in form.
152
- */
153
- export const refreshAllResponseSchema = z.object({
154
- accounts: z.array(refreshAllAccountSchema),
155
- });
156
133
  /**
157
134
  * Wire shape of `GET /users/me` — the API success envelope (`{ data: <user> }`)
158
135
  * wrapping the current-user DTO. Some older producers use `_id` instead of
@@ -168,13 +145,13 @@ export const currentUserResponseSchema = z.object({
168
145
  * session). Backs the multi-account chooser. The embedded user mirrors
169
146
  * `formatUserResponse`; it is nullable on slots that lost their user document.
170
147
  */
171
- export const deviceSessionAccountSchema = z.object({
148
+ export const deviceLinkedSessionSchema = z.object({
172
149
  sessionId: z.string(),
173
150
  isCurrent: z.boolean().optional(),
174
151
  user: userResponseSchema.nullable().optional(),
175
152
  });
176
153
  /** Wire shape of `GET /session/device/sessions/:sessionId` (an array). */
177
- export const deviceSessionsResponseSchema = z.array(deviceSessionAccountSchema);
154
+ export const deviceLinkedSessionsResponseSchema = z.array(deviceLinkedSessionSchema);
178
155
  /**
179
156
  * Safely parse a value against a contract schema. Returns the parsed (typed)
180
157
  * value, or `null` when validation fails — the same ergonomics the auth app's