@oxyhq/contracts 0.11.0 → 0.12.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.
@@ -115,6 +115,14 @@ export interface AuthTokenBundle {
115
115
  refreshToken: string;
116
116
  expiresAt: string;
117
117
  user: UserResponse;
118
+ /**
119
+ * The device secret (phase 2c — zero-cookie transport). Present ONLY when
120
+ * the bundle is minted for a device that carries a `DeviceSession` doc; the
121
+ * client persists it first-party and later mints access tokens via
122
+ * `POST /session/device/token`. Optional and additive: cookie-lane bundles
123
+ * for a device with no doc omit it, so existing consumers are unaffected.
124
+ */
125
+ deviceSecret?: string;
118
126
  }
119
127
  export declare const authTokenBundleSchema: z.ZodType<AuthTokenBundle>;
120
128
  /**
@@ -213,6 +221,13 @@ export interface LoginSessionResult {
213
221
  expiresAt: string;
214
222
  accessToken?: string;
215
223
  refreshToken?: string;
224
+ /**
225
+ * The device secret (phase 2c — zero-cookie transport). Present ONLY when
226
+ * the sign-in resolved a device binding; the client persists it first-party
227
+ * and later mints access tokens via `POST /session/device/token`. Optional
228
+ * and additive — wired identically to `refreshToken`.
229
+ */
230
+ deviceSecret?: string;
216
231
  user: {
217
232
  id: string;
218
233
  username?: string;
@@ -163,3 +163,110 @@ export type SessionAccount = z.infer<typeof sessionAccountSchema>;
163
163
  export type DeviceSessionState = z.infer<typeof deviceSessionStateSchema>;
164
164
  export type ActiveToken = z.infer<typeof activeTokenSchema>;
165
165
  export type DeviceSessionSync = z.infer<typeof deviceSessionSyncSchema>;
166
+ /**
167
+ * Request body for `POST /session/device/token` — the client presents the
168
+ * `deviceId` it stored first-party plus the opaque `deviceSecret`. NO bearer:
169
+ * possession of the secret IS the proof of device ownership. The server matches
170
+ * `sha256(deviceSecret)` against the device's stored `secretHash` (constant-time)
171
+ * and mints a short access token for the device's active account.
172
+ */
173
+ export declare const deviceTokenMintRequestSchema: z.ZodObject<{
174
+ deviceId: z.ZodString;
175
+ deviceSecret: z.ZodString;
176
+ }, "strip", z.ZodTypeAny, {
177
+ deviceSecret: string;
178
+ deviceId: string;
179
+ }, {
180
+ deviceSecret: string;
181
+ deviceId: string;
182
+ }>;
183
+ /**
184
+ * Wire shape of a successful `POST /session/device/token`: the freshly-minted
185
+ * short access token for the active account, its expiry, the NEXT rotating
186
+ * device secret the client must persist (rotation-in-use — the presented secret
187
+ * stays valid for a short grace so multi-tab races don't lock out), and the
188
+ * projected device-session state.
189
+ */
190
+ export declare const deviceTokenMintResponseSchema: z.ZodObject<{
191
+ accessToken: z.ZodString;
192
+ expiresAt: z.ZodString;
193
+ nextDeviceSecret: z.ZodString;
194
+ state: z.ZodObject<{
195
+ deviceId: z.ZodString;
196
+ accounts: z.ZodArray<z.ZodObject<{
197
+ accountId: z.ZodString;
198
+ sessionId: z.ZodString;
199
+ authuser: z.ZodNumber;
200
+ operatedByUserId: z.ZodOptional<z.ZodString>;
201
+ }, "strip", z.ZodTypeAny, {
202
+ sessionId: string;
203
+ accountId: string;
204
+ authuser: number;
205
+ operatedByUserId?: string | undefined;
206
+ }, {
207
+ sessionId: string;
208
+ accountId: string;
209
+ authuser: number;
210
+ operatedByUserId?: string | undefined;
211
+ }>, "many">;
212
+ activeAccountId: z.ZodNullable<z.ZodString>;
213
+ revision: z.ZodNumber;
214
+ updatedAt: z.ZodNumber;
215
+ }, "strip", z.ZodTypeAny, {
216
+ updatedAt: number;
217
+ deviceId: string;
218
+ activeAccountId: string | null;
219
+ accounts: {
220
+ sessionId: string;
221
+ accountId: string;
222
+ authuser: number;
223
+ operatedByUserId?: string | undefined;
224
+ }[];
225
+ revision: number;
226
+ }, {
227
+ updatedAt: number;
228
+ deviceId: string;
229
+ activeAccountId: string | null;
230
+ accounts: {
231
+ sessionId: string;
232
+ accountId: string;
233
+ authuser: number;
234
+ operatedByUserId?: string | undefined;
235
+ }[];
236
+ revision: number;
237
+ }>;
238
+ }, "strip", z.ZodTypeAny, {
239
+ expiresAt: string;
240
+ state: {
241
+ updatedAt: number;
242
+ deviceId: string;
243
+ activeAccountId: string | null;
244
+ accounts: {
245
+ sessionId: string;
246
+ accountId: string;
247
+ authuser: number;
248
+ operatedByUserId?: string | undefined;
249
+ }[];
250
+ revision: number;
251
+ };
252
+ accessToken: string;
253
+ nextDeviceSecret: string;
254
+ }, {
255
+ expiresAt: string;
256
+ state: {
257
+ updatedAt: number;
258
+ deviceId: string;
259
+ activeAccountId: string | null;
260
+ accounts: {
261
+ sessionId: string;
262
+ accountId: string;
263
+ authuser: number;
264
+ operatedByUserId?: string | undefined;
265
+ }[];
266
+ revision: number;
267
+ };
268
+ accessToken: string;
269
+ nextDeviceSecret: string;
270
+ }>;
271
+ export type DeviceTokenMintRequest = z.infer<typeof deviceTokenMintRequestSchema>;
272
+ export type DeviceTokenMintResponse = z.infer<typeof deviceTokenMintResponseSchema>;
@@ -27,7 +27,7 @@ export { publicCardSchema, signedPublicCardSchema, realLifeAttestationRecordSche
27
27
  export type { CardTrustTier, PersonhoodStatus, PublicCard, SignedPublicCard, RealLifeAttestationRecord, RealLifeAttestationResult, ValidationVerdict, ValidationRequestStatus, ValidationVerdictRecord, ValidationOpenRequest, ValidationOpenResult, ValidationRequestSummary, ValidationVoteResult, PersonhoodVouchRecord, PersonhoodBreakdown, PersonhoodStatusResult, VouchResult, CredentialStatus, CredentialRecord, VerifiableCredentialResponse, CredentialIssueResult, CredentialListResult, CredentialVerifyResult, } from './civic';
28
28
  export { linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links';
29
29
  export type { LinkPreviewStatus, LinkPreview, LinkPreviewBatchRequest, LinkPreviewBatchResponse, } from './links';
30
- export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, } from './deviceSession';
31
- export type { SessionAccount, DeviceSessionState, ActiveToken, DeviceSessionSync, } from './deviceSession';
30
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, } from './deviceSession';
31
+ export type { SessionAccount, DeviceSessionState, ActiveToken, DeviceSessionSync, DeviceTokenMintRequest, DeviceTokenMintResponse, } from './deviceSession';
32
32
  export { deviceBootReasonSchema, deviceBootFragmentSchema, deviceExchangeRequestSchema, authTokenBundleSchema, webSessionResultSchema, tokenRefreshRequestSchema, tokenRefreshResponseSchema, deviceTokenIssueResponseSchema, loginResultSchema, deviceResolveRequestSchema, deviceResolveResponseSchema, } from './deviceBoot';
33
33
  export type { DeviceBootReason, DeviceBootFragment, DeviceExchangeRequest, AuthTokenBundle, WebSessionResult, WebSessionSession, WebSessionNoSession, TokenRefreshRequest, TokenRefreshResponse, DeviceTokenIssueResponse, LoginTwoFactorRequired, LoginSessionResult, LoginResult, DeviceResolveRequest, DeviceResolveAccount, DeviceResolveResponse, } from './deviceBoot';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/contracts",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",