@oxyhq/contracts 0.9.0 → 0.10.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.
@@ -44,31 +44,55 @@ import { type UserResponse } from './userResponse';
44
44
  */
45
45
  export declare const deviceBootReasonSchema: z.ZodEnum<["session", "no_session", "new_device"]>;
46
46
  export type DeviceBootReason = z.infer<typeof deviceBootReasonSchema>;
47
- /**
48
- * The `#oxy_boot=<json>` fragment `GET /auth/device/bootstrap` appends to the
49
- * `return_to` URL. Carries the CSRF `state` echo, the resolution `reason`, an
50
- * optional single-use exchange `code` (present iff `reason === 'session'`), and
51
- * the opaque `deviceToken`. NEVER carries tokens or a deviceId.
52
- */
53
- export declare const deviceBootFragmentSchema: z.ZodObject<{
47
+ export declare const deviceBootFragmentSchema: z.ZodDiscriminatedUnion<"reason", [z.ZodObject<{
48
+ reason: z.ZodLiteral<"session">;
49
+ code: z.ZodString;
54
50
  v: z.ZodLiteral<1>;
55
51
  state: z.ZodString;
56
- reason: z.ZodEnum<["session", "no_session", "new_device"]>;
57
- code: z.ZodOptional<z.ZodString>;
58
52
  deviceToken: z.ZodString;
59
53
  }, "strip", z.ZodTypeAny, {
60
- reason: "session" | "no_session" | "new_device";
54
+ code: string;
55
+ reason: "session";
61
56
  v: 1;
62
57
  state: string;
63
58
  deviceToken: string;
64
- code?: string | undefined;
65
59
  }, {
66
- reason: "session" | "no_session" | "new_device";
60
+ code: string;
61
+ reason: "session";
67
62
  v: 1;
68
63
  state: string;
69
64
  deviceToken: string;
70
- code?: string | undefined;
71
- }>;
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
+ }>]>;
72
96
  export type DeviceBootFragment = z.infer<typeof deviceBootFragmentSchema>;
73
97
  /** Request body for `POST /auth/device/exchange` — the single-use boot code. */
74
98
  export declare const deviceExchangeRequestSchema: z.ZodObject<{
@@ -93,6 +117,37 @@ export interface AuthTokenBundle {
93
117
  user: UserResponse;
94
118
  }
95
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>;
96
151
  /** Request body for `POST /auth/refresh-token` — the current refresh token. */
97
152
  export declare const tokenRefreshRequestSchema: z.ZodObject<{
98
153
  refreshToken: z.ZodString;
@@ -114,13 +169,13 @@ export declare const tokenRefreshResponseSchema: z.ZodObject<{
114
169
  sessionId: z.ZodString;
115
170
  }, "strip", z.ZodTypeAny, {
116
171
  expiresAt: string;
117
- accessToken: string;
118
172
  sessionId: string;
173
+ accessToken: string;
119
174
  refreshToken: string;
120
175
  }, {
121
176
  expiresAt: string;
122
- accessToken: string;
123
177
  sessionId: string;
178
+ accessToken: string;
124
179
  refreshToken: string;
125
180
  }>;
126
181
  export type TokenRefreshResponse = z.infer<typeof tokenRefreshResponseSchema>;
@@ -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
- authuser: number;
9
8
  sessionId: string;
10
9
  accountId: string;
10
+ authuser: number;
11
11
  operatedByUserId?: string | undefined;
12
12
  }, {
13
- authuser: number;
14
13
  sessionId: string;
15
14
  accountId: string;
15
+ authuser: number;
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
- authuser: number;
27
26
  sessionId: string;
28
27
  accountId: string;
28
+ authuser: number;
29
29
  operatedByUserId?: string | undefined;
30
30
  }, {
31
- authuser: number;
32
31
  sessionId: string;
33
32
  accountId: string;
33
+ authuser: number;
34
34
  operatedByUserId?: string | undefined;
35
35
  }>, "many">;
36
36
  activeAccountId: z.ZodNullable<z.ZodString>;
@@ -38,25 +38,25 @@ export declare const deviceSessionStateSchema: z.ZodObject<{
38
38
  updatedAt: z.ZodNumber;
39
39
  }, "strip", z.ZodTypeAny, {
40
40
  updatedAt: number;
41
+ deviceId: string;
42
+ activeAccountId: string | null;
41
43
  accounts: {
42
- authuser: number;
43
44
  sessionId: string;
44
45
  accountId: string;
46
+ authuser: number;
45
47
  operatedByUserId?: string | undefined;
46
48
  }[];
47
- deviceId: string;
48
- activeAccountId: string | null;
49
49
  revision: number;
50
50
  }, {
51
51
  updatedAt: number;
52
+ deviceId: string;
53
+ activeAccountId: string | null;
52
54
  accounts: {
53
- authuser: number;
54
55
  sessionId: string;
55
56
  accountId: string;
57
+ authuser: number;
56
58
  operatedByUserId?: string | undefined;
57
59
  }[];
58
- deviceId: string;
59
- activeAccountId: string | null;
60
60
  revision: number;
61
61
  }>;
62
62
  export declare const activeTokenSchema: z.ZodObject<{
@@ -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
- authuser: number;
82
81
  sessionId: string;
83
82
  accountId: string;
83
+ authuser: number;
84
84
  operatedByUserId?: string | undefined;
85
85
  }, {
86
- authuser: number;
87
86
  sessionId: string;
88
87
  accountId: string;
88
+ authuser: number;
89
89
  operatedByUserId?: string | undefined;
90
90
  }>, "many">;
91
91
  activeAccountId: z.ZodNullable<z.ZodString>;
@@ -93,25 +93,25 @@ export declare const deviceSessionSyncSchema: z.ZodObject<{
93
93
  updatedAt: z.ZodNumber;
94
94
  }, "strip", z.ZodTypeAny, {
95
95
  updatedAt: number;
96
+ deviceId: string;
97
+ activeAccountId: string | null;
96
98
  accounts: {
97
- authuser: number;
98
99
  sessionId: string;
99
100
  accountId: string;
101
+ authuser: number;
100
102
  operatedByUserId?: string | undefined;
101
103
  }[];
102
- deviceId: string;
103
- activeAccountId: string | null;
104
104
  revision: number;
105
105
  }, {
106
106
  updatedAt: number;
107
+ deviceId: string;
108
+ activeAccountId: string | null;
107
109
  accounts: {
108
- authuser: number;
109
110
  sessionId: string;
110
111
  accountId: string;
112
+ authuser: number;
111
113
  operatedByUserId?: string | undefined;
112
114
  }[];
113
- deviceId: string;
114
- activeAccountId: string | null;
115
115
  revision: number;
116
116
  }>;
117
117
  activeToken: z.ZodNullable<z.ZodObject<{
@@ -127,14 +127,14 @@ export declare const deviceSessionSyncSchema: z.ZodObject<{
127
127
  }, "strip", z.ZodTypeAny, {
128
128
  state: {
129
129
  updatedAt: number;
130
+ deviceId: string;
131
+ activeAccountId: string | null;
130
132
  accounts: {
131
- authuser: number;
132
133
  sessionId: string;
133
134
  accountId: string;
135
+ authuser: number;
134
136
  operatedByUserId?: string | undefined;
135
137
  }[];
136
- deviceId: string;
137
- activeAccountId: string | null;
138
138
  revision: number;
139
139
  };
140
140
  activeToken: {
@@ -144,14 +144,14 @@ export declare const deviceSessionSyncSchema: z.ZodObject<{
144
144
  }, {
145
145
  state: {
146
146
  updatedAt: number;
147
+ deviceId: string;
148
+ activeAccountId: string | null;
147
149
  accounts: {
148
- authuser: number;
149
150
  sessionId: string;
150
151
  accountId: string;
152
+ authuser: number;
151
153
  operatedByUserId?: string | undefined;
152
154
  }[];
153
- deviceId: string;
154
- activeAccountId: string | null;
155
155
  revision: number;
156
156
  };
157
157
  activeToken: {
@@ -9,8 +9,8 @@
9
9
  * Platform-agnostic — zod is the only runtime dependency. No react/react-native/
10
10
  * expo, no `require()` in the ESM build.
11
11
  */
12
- export { userNameSchema, userResponseSchema, userProfileUpdateSchema, refreshAllAccountSchema, refreshAllResponseSchema, currentUserResponseSchema, deviceSessionAccountSchema, deviceSessionsResponseSchema, resolveUserId, safeParseContract, } from './userResponse';
13
- export type { UserNameResponse, UserResponse, UserProfileUpdate, RefreshAllAccountResponse, RefreshAllResponseContract, CurrentUserResponseContract, DeviceSessionAccountResponse, DeviceSessionsResponseContract, } from './userResponse';
12
+ export { userNameSchema, userResponseSchema, userProfileUpdateSchema, currentUserResponseSchema, deviceSessionAccountSchema, deviceSessionsResponseSchema, resolveUserId, safeParseContract, } from './userResponse';
13
+ export type { UserNameResponse, UserResponse, UserProfileUpdate, CurrentUserResponseContract, DeviceSessionAccountResponse, DeviceSessionsResponseContract, } from './userResponse';
14
14
  export { applicationTypeSchema, publicApplicationSchema, sessionStatusSchema, } from './sessionStatus';
15
15
  export type { ApplicationTypeContract, PublicApplicationResponse, SessionStatusResponse, } from './sessionStatus';
16
16
  export { fedcmTokenPayloadSchema, } from './fedcmToken';
@@ -29,5 +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, tokenRefreshRequestSchema, tokenRefreshResponseSchema, deviceTokenIssueResponseSchema, loginResultSchema, deviceResolveRequestSchema, deviceResolveResponseSchema, } from './deviceBoot';
33
- export type { DeviceBootReason, DeviceBootFragment, DeviceExchangeRequest, AuthTokenBundle, TokenRefreshRequest, TokenRefreshResponse, DeviceTokenIssueResponse, LoginTwoFactorRequired, LoginSessionResult, LoginResult, DeviceResolveRequest, DeviceResolveAccount, DeviceResolveResponse, } from './deviceBoot';
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';