@oxy.so/contracts 1.0.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.
Files changed (147) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +16 -0
  3. package/dist/cjs/.tsbuildinfo +1 -0
  4. package/dist/cjs/accountGraph.js +489 -0
  5. package/dist/cjs/agency.js +439 -0
  6. package/dist/cjs/browserHub.js +215 -0
  7. package/dist/cjs/civic.js +163 -0
  8. package/dist/cjs/commonsSignIn.js +59 -0
  9. package/dist/cjs/deviceBoot.js +50 -0
  10. package/dist/cjs/deviceDirectory.js +189 -0
  11. package/dist/cjs/devicePairing.js +138 -0
  12. package/dist/cjs/deviceSession.js +164 -0
  13. package/dist/cjs/emailAgentContext.js +32 -0
  14. package/dist/cjs/followGraph.js +28 -0
  15. package/dist/cjs/identity.js +258 -0
  16. package/dist/cjs/inboxPush.js +24 -0
  17. package/dist/cjs/index.js +618 -0
  18. package/dist/cjs/inference/accountBilling.js +334 -0
  19. package/dist/cjs/inference/aliaModelRelease.js +262 -0
  20. package/dist/cjs/inference/attribution.js +106 -0
  21. package/dist/cjs/inference/catalogue.js +487 -0
  22. package/dist/cjs/inference/entitlement.js +217 -0
  23. package/dist/cjs/inference/errors.js +309 -0
  24. package/dist/cjs/inference/identifiers.js +224 -0
  25. package/dist/cjs/inference/inbox.js +105 -0
  26. package/dist/cjs/inference/modelDocumentation.js +433 -0
  27. package/dist/cjs/inference/money.js +188 -0
  28. package/dist/cjs/inference/priceVersion.js +110 -0
  29. package/dist/cjs/inference/providerConnection.js +455 -0
  30. package/dist/cjs/inference/request.js +477 -0
  31. package/dist/cjs/inference/routingPolicy.js +318 -0
  32. package/dist/cjs/inference/streamEvents.js +258 -0
  33. package/dist/cjs/inference/usage.js +329 -0
  34. package/dist/cjs/inference/version.js +105 -0
  35. package/dist/cjs/keyRecovery.js +91 -0
  36. package/dist/cjs/keyRotation.js +75 -0
  37. package/dist/cjs/links.js +68 -0
  38. package/dist/cjs/moderationReputation.js +298 -0
  39. package/dist/cjs/oauth.js +66 -0
  40. package/dist/cjs/oxyRecordTypes.js +71 -0
  41. package/dist/cjs/protocol.js +53 -0
  42. package/dist/cjs/recommendations.js +168 -0
  43. package/dist/cjs/reputation.js +297 -0
  44. package/dist/cjs/sessionStatus.js +121 -0
  45. package/dist/cjs/transparency.js +89 -0
  46. package/dist/cjs/updates.js +252 -0
  47. package/dist/cjs/userInvalidation.js +89 -0
  48. package/dist/cjs/userResponse.js +245 -0
  49. package/dist/cjs/username.js +290 -0
  50. package/dist/cjs/webauthn.js +71 -0
  51. package/dist/esm/.tsbuildinfo +1 -0
  52. package/dist/esm/accountGraph.js +480 -0
  53. package/dist/esm/agency.js +436 -0
  54. package/dist/esm/browserHub.js +212 -0
  55. package/dist/esm/civic.js +160 -0
  56. package/dist/esm/commonsSignIn.js +56 -0
  57. package/dist/esm/deviceBoot.js +47 -0
  58. package/dist/esm/deviceDirectory.js +186 -0
  59. package/dist/esm/devicePairing.js +135 -0
  60. package/dist/esm/deviceSession.js +161 -0
  61. package/dist/esm/emailAgentContext.js +29 -0
  62. package/dist/esm/followGraph.js +27 -0
  63. package/dist/esm/identity.js +255 -0
  64. package/dist/esm/inboxPush.js +21 -0
  65. package/dist/esm/index.js +172 -0
  66. package/dist/esm/inference/accountBilling.js +331 -0
  67. package/dist/esm/inference/aliaModelRelease.js +259 -0
  68. package/dist/esm/inference/attribution.js +103 -0
  69. package/dist/esm/inference/catalogue.js +484 -0
  70. package/dist/esm/inference/entitlement.js +214 -0
  71. package/dist/esm/inference/errors.js +306 -0
  72. package/dist/esm/inference/identifiers.js +221 -0
  73. package/dist/esm/inference/inbox.js +102 -0
  74. package/dist/esm/inference/modelDocumentation.js +430 -0
  75. package/dist/esm/inference/money.js +185 -0
  76. package/dist/esm/inference/priceVersion.js +107 -0
  77. package/dist/esm/inference/providerConnection.js +452 -0
  78. package/dist/esm/inference/request.js +474 -0
  79. package/dist/esm/inference/routingPolicy.js +315 -0
  80. package/dist/esm/inference/streamEvents.js +255 -0
  81. package/dist/esm/inference/usage.js +326 -0
  82. package/dist/esm/inference/version.js +102 -0
  83. package/dist/esm/keyRecovery.js +88 -0
  84. package/dist/esm/keyRotation.js +72 -0
  85. package/dist/esm/links.js +65 -0
  86. package/dist/esm/moderationReputation.js +295 -0
  87. package/dist/esm/oauth.js +63 -0
  88. package/dist/esm/oxyRecordTypes.js +68 -0
  89. package/dist/esm/protocol.js +50 -0
  90. package/dist/esm/recommendations.js +165 -0
  91. package/dist/esm/reputation.js +293 -0
  92. package/dist/esm/sessionStatus.js +118 -0
  93. package/dist/esm/transparency.js +86 -0
  94. package/dist/esm/updates.js +249 -0
  95. package/dist/esm/userInvalidation.js +85 -0
  96. package/dist/esm/userResponse.js +240 -0
  97. package/dist/esm/username.js +283 -0
  98. package/dist/esm/webauthn.js +68 -0
  99. package/dist/types/.tsbuildinfo +1 -0
  100. package/dist/types/accountGraph.d.ts +378 -0
  101. package/dist/types/agency.d.ts +2162 -0
  102. package/dist/types/browserHub.d.ts +856 -0
  103. package/dist/types/civic.d.ts +338 -0
  104. package/dist/types/commonsSignIn.d.ts +58 -0
  105. package/dist/types/deviceBoot.d.ts +74 -0
  106. package/dist/types/deviceDirectory.d.ts +1317 -0
  107. package/dist/types/devicePairing.d.ts +130 -0
  108. package/dist/types/deviceSession.d.ts +411 -0
  109. package/dist/types/emailAgentContext.d.ts +248 -0
  110. package/dist/types/followGraph.d.ts +150 -0
  111. package/dist/types/identity.d.ts +402 -0
  112. package/dist/types/inboxPush.d.ts +30 -0
  113. package/dist/types/index.d.ts +100 -0
  114. package/dist/types/inference/accountBilling.d.ts +738 -0
  115. package/dist/types/inference/aliaModelRelease.d.ts +609 -0
  116. package/dist/types/inference/attribution.d.ts +176 -0
  117. package/dist/types/inference/catalogue.d.ts +1618 -0
  118. package/dist/types/inference/entitlement.d.ts +519 -0
  119. package/dist/types/inference/errors.d.ts +242 -0
  120. package/dist/types/inference/identifiers.d.ts +182 -0
  121. package/dist/types/inference/inbox.d.ts +374 -0
  122. package/dist/types/inference/modelDocumentation.d.ts +1603 -0
  123. package/dist/types/inference/money.d.ts +185 -0
  124. package/dist/types/inference/priceVersion.d.ts +182 -0
  125. package/dist/types/inference/providerConnection.d.ts +968 -0
  126. package/dist/types/inference/request.d.ts +2800 -0
  127. package/dist/types/inference/routingPolicy.d.ts +616 -0
  128. package/dist/types/inference/streamEvents.d.ts +950 -0
  129. package/dist/types/inference/usage.d.ts +1164 -0
  130. package/dist/types/inference/version.d.ts +102 -0
  131. package/dist/types/keyRecovery.d.ts +138 -0
  132. package/dist/types/keyRotation.d.ts +103 -0
  133. package/dist/types/links.d.ts +96 -0
  134. package/dist/types/moderationReputation.d.ts +487 -0
  135. package/dist/types/oauth.d.ts +86 -0
  136. package/dist/types/oxyRecordTypes.d.ts +62 -0
  137. package/dist/types/protocol.d.ts +86 -0
  138. package/dist/types/recommendations.d.ts +542 -0
  139. package/dist/types/reputation.d.ts +457 -0
  140. package/dist/types/sessionStatus.d.ts +231 -0
  141. package/dist/types/transparency.d.ts +392 -0
  142. package/dist/types/updates.d.ts +545 -0
  143. package/dist/types/userInvalidation.d.ts +94 -0
  144. package/dist/types/userResponse.d.ts +1706 -0
  145. package/dist/types/username.d.ts +265 -0
  146. package/dist/types/webauthn.d.ts +77 -0
  147. package/package.json +87 -0
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Device-to-device identity transfer contracts (b3 Feature 2 — "add a device").
3
+ *
4
+ * SINGLE SOURCE OF TRUTH for the wire shape of the short-lived, unauthenticated
5
+ * relay that carries E2E-encrypted key material from an existing (old) device to
6
+ * a fresh (new) device so both end up holding the SAME secp256k1 private key
7
+ * (key cloning). The relay is E2E-encrypted via an ephemeral secp256k1 ECDH
8
+ * handshake: the server stores only the two ephemeral public keys plus an opaque
9
+ * AEAD ciphertext + nonce and NEVER holds a decryption key.
10
+ *
11
+ * Flow:
12
+ * 1. New device (no identity) generates an ephemeral pair and calls
13
+ * `POST /identity/device-transfer/init { newEphPub, newDeviceLabel? }` →
14
+ * `{ pairingId, expiresAt }`. The QR carries ONLY `pairingId` (not
15
+ * self-contained — mirrors the QR sign-in `approve-info` resolution).
16
+ * 2. Old device (has identity) scans, resolves the request via
17
+ * `GET /identity/device-transfer/:pairingId` (returns `newEphPub` + label),
18
+ * derives `transferKey = HKDF(ECDH(oldEphPriv, newEphPub), pairingId,
19
+ * 'oxy-device-transfer-v1')`, AEAD-encrypts `{ privateKey, publicKey }`, and
20
+ * calls `POST /identity/device-transfer/:pairingId/approve` with the
21
+ * ciphertext PLUS a fresh signature over
22
+ * `{ action:'approve_device_transfer', pairingId, timestamp }` made with the
23
+ * CURRENT identity key (dual-proof: a bearer alone cannot exfiltrate the key).
24
+ * 3. New device (socket push or poll fallback) re-derives the same
25
+ * `transferKey` from `ECDH(newEphPriv, oldEphPub)`, decrypts, and imports the
26
+ * private key, then completes a NORMAL challenge/verify sign-in.
27
+ *
28
+ * The load-bearing response shapes are declared as explicit `interface`s (same
29
+ * `moduleResolution: node` rationale as `UserNameResponse` / the identity/civic
30
+ * contracts: a nested `z.infer<>` can degrade to `{}` under a consumer's
31
+ * `moduleResolution: "node"`), with the runtime schemas annotated
32
+ * `z.ZodType<Interface>`.
33
+ *
34
+ * Platform-agnostic — zod only, no react/react-native/expo, ESM-safe.
35
+ */
36
+ import { z } from 'zod';
37
+ /**
38
+ * Pairing lifecycle:
39
+ * - `pending` — created by the new device, awaiting the old device's approval.
40
+ * - `approved` — the old device sealed and posted the encrypted key material.
41
+ * - `denied` — the old device explicitly cancelled the transfer.
42
+ * - `expired` — the 3-minute TTL elapsed before approval.
43
+ */
44
+ export declare const devicePairingStatusSchema: z.ZodEnum<["pending", "approved", "denied", "expired"]>;
45
+ export type DevicePairingStatus = z.infer<typeof devicePairingStatusSchema>;
46
+ /** Request body for `POST /identity/device-transfer/init` (public). */
47
+ export declare const deviceTransferInitRequestSchema: z.ZodObject<{
48
+ /** The new device's ephemeral secp256k1 public key (single-use). */
49
+ newEphPub: z.ZodString;
50
+ /** Optional human-readable label for the new device (e.g. "iPhone 15"). */
51
+ newDeviceLabel: z.ZodOptional<z.ZodString>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ newEphPub: string;
54
+ newDeviceLabel?: string | undefined;
55
+ }, {
56
+ newEphPub: string;
57
+ newDeviceLabel?: string | undefined;
58
+ }>;
59
+ export type DeviceTransferInitRequest = z.infer<typeof deviceTransferInitRequestSchema>;
60
+ export interface DeviceTransferInitResponse {
61
+ /** 128-bit single-use handle carried in the QR. Also the HKDF salt. */
62
+ pairingId: string;
63
+ /** ISO-8601 expiry (3 minutes from creation). */
64
+ expiresAt: string;
65
+ }
66
+ export declare const deviceTransferInitResponseSchema: z.ZodType<DeviceTransferInitResponse>;
67
+ export interface DeviceTransferInfoResponse {
68
+ pairingId: string;
69
+ /** The new device's ephemeral public key (so the old device can ECDH). */
70
+ newDeviceEphemeralPublicKey: string;
71
+ /** Optional new-device label supplied at init. */
72
+ newDeviceLabel: string | null;
73
+ status: DevicePairingStatus;
74
+ /** ISO-8601 expiry. */
75
+ expiresAt: string;
76
+ /**
77
+ * The old device's ephemeral public key — present ONLY once `status` is
78
+ * `approved` (so the new device can re-derive the shared secret).
79
+ */
80
+ oldDeviceEphemeralPublicKey: string | null;
81
+ /** AEAD ciphertext (hex) — present ONLY once `status` is `approved`. */
82
+ ciphertext: string | null;
83
+ /** AEAD nonce (hex) — present ONLY once `status` is `approved`. */
84
+ nonce: string | null;
85
+ }
86
+ export declare const deviceTransferInfoResponseSchema: z.ZodType<DeviceTransferInfoResponse>;
87
+ /**
88
+ * Request body for `POST /identity/device-transfer/:pairingId/approve`
89
+ * (bearer-authenticated AND signature-proven). The `signature` covers
90
+ * `JSON.stringify({ action:'approve_device_transfer', pairingId, timestamp })`
91
+ * made with the caller's CURRENT identity key — dual-proof so a bearer token
92
+ * alone can never exfiltrate the private key.
93
+ */
94
+ export declare const deviceTransferApproveRequestSchema: z.ZodObject<{
95
+ /** The old device's ephemeral secp256k1 public key (single-use). */
96
+ oldEphPub: z.ZodString;
97
+ /** AEAD ciphertext of `{ privateKey, publicKey }`, hex. */
98
+ ciphertext: z.ZodString;
99
+ /** AEAD nonce, hex (24 bytes). */
100
+ nonce: z.ZodString;
101
+ /** ECDSA (DER, hex) signature proving control of the CURRENT identity key. */
102
+ signature: z.ZodString;
103
+ /** Signing timestamp (ms since epoch) — freshness-checked server-side. */
104
+ timestamp: z.ZodNumber;
105
+ }, "strip", z.ZodTypeAny, {
106
+ signature: string;
107
+ nonce: string;
108
+ ciphertext: string;
109
+ oldEphPub: string;
110
+ timestamp: number;
111
+ }, {
112
+ signature: string;
113
+ nonce: string;
114
+ ciphertext: string;
115
+ oldEphPub: string;
116
+ timestamp: number;
117
+ }>;
118
+ export type DeviceTransferApproveRequest = z.infer<typeof deviceTransferApproveRequestSchema>;
119
+ export interface DeviceTransferApproveResponse {
120
+ success: boolean;
121
+ pairingId: string;
122
+ status: DevicePairingStatus;
123
+ }
124
+ export declare const deviceTransferApproveResponseSchema: z.ZodType<DeviceTransferApproveResponse>;
125
+ export interface DeviceTransferDenyResponse {
126
+ success: boolean;
127
+ pairingId: string;
128
+ status: DevicePairingStatus;
129
+ }
130
+ export declare const deviceTransferDenyResponseSchema: z.ZodType<DeviceTransferDenyResponse>;
@@ -0,0 +1,411 @@
1
+ import { z } from 'zod';
2
+ export declare const sessionAccountSchema: z.ZodObject<{
3
+ accountId: z.ZodString;
4
+ sessionId: z.ZodString;
5
+ authuser: z.ZodNumber;
6
+ operatedByUserId: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ accountId: string;
9
+ sessionId: string;
10
+ authuser: number;
11
+ operatedByUserId?: string | undefined;
12
+ }, {
13
+ accountId: string;
14
+ sessionId: string;
15
+ authuser: number;
16
+ operatedByUserId?: string | undefined;
17
+ }>;
18
+ export declare const deviceSessionStateSchema: z.ZodObject<{
19
+ deviceId: z.ZodString;
20
+ accounts: z.ZodArray<z.ZodObject<{
21
+ accountId: z.ZodString;
22
+ sessionId: z.ZodString;
23
+ authuser: z.ZodNumber;
24
+ operatedByUserId: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ accountId: string;
27
+ sessionId: string;
28
+ authuser: number;
29
+ operatedByUserId?: string | undefined;
30
+ }, {
31
+ accountId: string;
32
+ sessionId: string;
33
+ authuser: number;
34
+ operatedByUserId?: string | undefined;
35
+ }>, "many">;
36
+ activeAccountId: z.ZodNullable<z.ZodString>;
37
+ revision: z.ZodNumber;
38
+ updatedAt: z.ZodNumber;
39
+ }, "strip", z.ZodTypeAny, {
40
+ updatedAt: number;
41
+ deviceId: string;
42
+ accounts: {
43
+ accountId: string;
44
+ sessionId: string;
45
+ authuser: number;
46
+ operatedByUserId?: string | undefined;
47
+ }[];
48
+ activeAccountId: string | null;
49
+ revision: number;
50
+ }, {
51
+ updatedAt: number;
52
+ deviceId: string;
53
+ accounts: {
54
+ accountId: string;
55
+ sessionId: string;
56
+ authuser: number;
57
+ operatedByUserId?: string | undefined;
58
+ }[];
59
+ activeAccountId: string | null;
60
+ revision: number;
61
+ }>;
62
+ export declare const activeTokenSchema: z.ZodObject<{
63
+ accessToken: z.ZodString;
64
+ expiresAt: z.ZodString;
65
+ }, "strip", z.ZodTypeAny, {
66
+ expiresAt: string;
67
+ accessToken: string;
68
+ }, {
69
+ expiresAt: string;
70
+ accessToken: string;
71
+ }>;
72
+ export declare const deviceSessionSyncSchema: z.ZodObject<{
73
+ state: z.ZodObject<{
74
+ deviceId: z.ZodString;
75
+ accounts: z.ZodArray<z.ZodObject<{
76
+ accountId: z.ZodString;
77
+ sessionId: z.ZodString;
78
+ authuser: z.ZodNumber;
79
+ operatedByUserId: z.ZodOptional<z.ZodString>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ accountId: string;
82
+ sessionId: string;
83
+ authuser: number;
84
+ operatedByUserId?: string | undefined;
85
+ }, {
86
+ accountId: string;
87
+ sessionId: string;
88
+ authuser: number;
89
+ operatedByUserId?: string | undefined;
90
+ }>, "many">;
91
+ activeAccountId: z.ZodNullable<z.ZodString>;
92
+ revision: z.ZodNumber;
93
+ updatedAt: z.ZodNumber;
94
+ }, "strip", z.ZodTypeAny, {
95
+ updatedAt: number;
96
+ deviceId: string;
97
+ accounts: {
98
+ accountId: string;
99
+ sessionId: string;
100
+ authuser: number;
101
+ operatedByUserId?: string | undefined;
102
+ }[];
103
+ activeAccountId: string | null;
104
+ revision: number;
105
+ }, {
106
+ updatedAt: number;
107
+ deviceId: string;
108
+ accounts: {
109
+ accountId: string;
110
+ sessionId: string;
111
+ authuser: number;
112
+ operatedByUserId?: string | undefined;
113
+ }[];
114
+ activeAccountId: string | null;
115
+ revision: number;
116
+ }>;
117
+ activeToken: z.ZodNullable<z.ZodObject<{
118
+ accessToken: z.ZodString;
119
+ expiresAt: z.ZodString;
120
+ }, "strip", z.ZodTypeAny, {
121
+ expiresAt: string;
122
+ accessToken: string;
123
+ }, {
124
+ expiresAt: string;
125
+ accessToken: string;
126
+ }>>;
127
+ }, "strip", z.ZodTypeAny, {
128
+ state: {
129
+ updatedAt: number;
130
+ deviceId: string;
131
+ accounts: {
132
+ accountId: string;
133
+ sessionId: string;
134
+ authuser: number;
135
+ operatedByUserId?: string | undefined;
136
+ }[];
137
+ activeAccountId: string | null;
138
+ revision: number;
139
+ };
140
+ activeToken: {
141
+ expiresAt: string;
142
+ accessToken: string;
143
+ } | null;
144
+ }, {
145
+ state: {
146
+ updatedAt: number;
147
+ deviceId: string;
148
+ accounts: {
149
+ accountId: string;
150
+ sessionId: string;
151
+ authuser: number;
152
+ operatedByUserId?: string | undefined;
153
+ }[];
154
+ activeAccountId: string | null;
155
+ revision: number;
156
+ };
157
+ activeToken: {
158
+ expiresAt: string;
159
+ accessToken: string;
160
+ } | null;
161
+ }>;
162
+ export type SessionAccount = z.infer<typeof sessionAccountSchema>;
163
+ export type DeviceSessionState = z.infer<typeof deviceSessionStateSchema>;
164
+ export type ActiveToken = z.infer<typeof activeTokenSchema>;
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
+ * `accountId` pins the mint to ONE account of that device instead of whichever
174
+ * account is currently active. It exists for identity-bound clients (Commons),
175
+ * whose authenticated user is determined by a local cryptographic key and must
176
+ * never follow an account switch made by another app on the same device. The
177
+ * account must already be a member of the device session; the mint NEVER
178
+ * mutates `activeAccountId`, so pinning is read-only with respect to the device
179
+ * state every other app observes.
180
+ */
181
+ export declare const deviceTokenMintRequestSchema: z.ZodObject<{
182
+ deviceId: z.ZodString;
183
+ deviceSecret: z.ZodString;
184
+ accountId: z.ZodOptional<z.ZodString>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ deviceId: string;
187
+ deviceSecret: string;
188
+ accountId?: string | undefined;
189
+ }, {
190
+ deviceId: string;
191
+ deviceSecret: string;
192
+ accountId?: string | undefined;
193
+ }>;
194
+ /**
195
+ * Wire shape of a successful `POST /session/device/token`: the freshly-minted
196
+ * short access token for the active account, its expiry, the device secret the
197
+ * client must persist (`nextDeviceSecret` — on mint this echoes the presented
198
+ * secret unchanged so concurrent refreshes from multiple origins do not race),
199
+ * and the projected device-session state. Sign-in rotates the secret via
200
+ * `issueDeviceSecret`; mint does not.
201
+ */
202
+ export declare const deviceTokenMintResponseSchema: z.ZodObject<{
203
+ accessToken: z.ZodString;
204
+ expiresAt: z.ZodString;
205
+ nextDeviceSecret: z.ZodString;
206
+ state: z.ZodObject<{
207
+ deviceId: z.ZodString;
208
+ accounts: z.ZodArray<z.ZodObject<{
209
+ accountId: z.ZodString;
210
+ sessionId: z.ZodString;
211
+ authuser: z.ZodNumber;
212
+ operatedByUserId: z.ZodOptional<z.ZodString>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ accountId: string;
215
+ sessionId: string;
216
+ authuser: number;
217
+ operatedByUserId?: string | undefined;
218
+ }, {
219
+ accountId: string;
220
+ sessionId: string;
221
+ authuser: number;
222
+ operatedByUserId?: string | undefined;
223
+ }>, "many">;
224
+ activeAccountId: z.ZodNullable<z.ZodString>;
225
+ revision: z.ZodNumber;
226
+ updatedAt: z.ZodNumber;
227
+ }, "strip", z.ZodTypeAny, {
228
+ updatedAt: number;
229
+ deviceId: string;
230
+ accounts: {
231
+ accountId: string;
232
+ sessionId: string;
233
+ authuser: number;
234
+ operatedByUserId?: string | undefined;
235
+ }[];
236
+ activeAccountId: string | null;
237
+ revision: number;
238
+ }, {
239
+ updatedAt: number;
240
+ deviceId: string;
241
+ accounts: {
242
+ accountId: string;
243
+ sessionId: string;
244
+ authuser: number;
245
+ operatedByUserId?: string | undefined;
246
+ }[];
247
+ activeAccountId: string | null;
248
+ revision: number;
249
+ }>;
250
+ }, "strip", z.ZodTypeAny, {
251
+ expiresAt: string;
252
+ accessToken: string;
253
+ state: {
254
+ updatedAt: number;
255
+ deviceId: string;
256
+ accounts: {
257
+ accountId: string;
258
+ sessionId: string;
259
+ authuser: number;
260
+ operatedByUserId?: string | undefined;
261
+ }[];
262
+ activeAccountId: string | null;
263
+ revision: number;
264
+ };
265
+ nextDeviceSecret: string;
266
+ }, {
267
+ expiresAt: string;
268
+ accessToken: string;
269
+ state: {
270
+ updatedAt: number;
271
+ deviceId: string;
272
+ accounts: {
273
+ accountId: string;
274
+ sessionId: string;
275
+ authuser: number;
276
+ operatedByUserId?: string | undefined;
277
+ }[];
278
+ activeAccountId: string | null;
279
+ revision: number;
280
+ };
281
+ nextDeviceSecret: string;
282
+ }>;
283
+ export type DeviceTokenMintRequest = z.infer<typeof deviceTokenMintRequestSchema>;
284
+ export type DeviceTokenMintResponse = z.infer<typeof deviceTokenMintResponseSchema>;
285
+ /**
286
+ * Name of the token-free Socket.IO event emitted to room `user:<userId>` on
287
+ * every DeviceSession mutation that changes what is signed in for that user.
288
+ *
289
+ * This is a pure SIGNAL — it carries NO access token, NO deviceSecret and NO
290
+ * account bodies. A client that receives it re-fetches its authenticated
291
+ * session/account state (`GET /session/device/state`, `GET /accounts`). Unlike
292
+ * `session_state` (scoped to `device:<deviceId>`, i.e. a single origin), this
293
+ * reaches ALL of a user's connected sockets across their devices/origins so
294
+ * every Oxy app reflects an add / switch / signout instantly.
295
+ */
296
+ export declare const SESSION_ACCOUNTS_CHANGED_EVENT = "session_accounts_changed";
297
+ /**
298
+ * Why the signed-in set changed:
299
+ * - `login` — a brand-new session was minted for the user (QR / cross-app authorize)
300
+ * - `add` — an account was registered onto a device set
301
+ * - `switch` — the active account on a device changed
302
+ * - `signout` — one or all accounts were signed out of a device
303
+ * - `revoke` — a dead/revoked account was healed out of a device set
304
+ */
305
+ export declare const sessionAccountsChangedReasonSchema: z.ZodEnum<["login", "add", "switch", "signout", "revoke"]>;
306
+ /**
307
+ * Payload of {@link SESSION_ACCOUNTS_CHANGED_EVENT}. `revision` is the mutated
308
+ * DeviceSession revision for device-scoped reasons (`add`/`switch`/`signout`/
309
+ * `revoke`); for `login` (no device mutation at emit time) it is `0`. The
310
+ * payload is deliberately minimal and secret-free — the client refetches.
311
+ */
312
+ export declare const sessionAccountsChangedEventSchema: z.ZodObject<{
313
+ userId: z.ZodString;
314
+ revision: z.ZodNumber;
315
+ reason: z.ZodEnum<["login", "add", "switch", "signout", "revoke"]>;
316
+ }, "strip", z.ZodTypeAny, {
317
+ reason: "login" | "add" | "switch" | "signout" | "revoke";
318
+ revision: number;
319
+ userId: string;
320
+ }, {
321
+ reason: "login" | "add" | "switch" | "signout" | "revoke";
322
+ revision: number;
323
+ userId: string;
324
+ }>;
325
+ export type SessionAccountsChangedReason = z.infer<typeof sessionAccountsChangedReasonSchema>;
326
+ export type SessionAccountsChangedEvent = z.infer<typeof sessionAccountsChangedEventSchema>;
327
+ /**
328
+ * Response from `POST /session/device/background-credential` — provisioned by
329
+ * the SDK WHILE THE APP IS RUNNING (bearer required, `deviceId` and account
330
+ * derived server-side from it) and consumed afterwards only by native
331
+ * background code, which has no JS runtime to mint a token for itself.
332
+ *
333
+ * Deliberately a SEPARATE credential from the rotating `deviceSecret`: that one
334
+ * rotates on every mint, so background code presenting it would become a second
335
+ * writer of a value the JS runtime depends on, and background code killed
336
+ * mid-rotation would silently sign the user out on the next cold start. Against
337
+ * this credential background code is the sole writer, and it can never rotate
338
+ * anything JS reads.
339
+ *
340
+ * The raw `secret` is returned exactly once, at provision time — never stored
341
+ * retrievably, never logged, never re-read. A caller that loses it provisions
342
+ * a new one.
343
+ *
344
+ * `expiresAt` is an unvalidated string, like every other expiry in this file:
345
+ * no consumer on the JS path interprets it (native background code parses it
346
+ * itself), and a `.datetime()` here alone would leave one strict field beside
347
+ * two lax ones. If expiry is ever validated it goes on all three at once, with
348
+ * the API's serializers checked against it — the producer is the same server.
349
+ */
350
+ export declare const deviceBackgroundCredentialResponseSchema: z.ZodObject<{
351
+ deviceId: z.ZodString;
352
+ secret: z.ZodString;
353
+ accountId: z.ZodString;
354
+ expiresAt: z.ZodString;
355
+ }, "strip", z.ZodTypeAny, {
356
+ accountId: string;
357
+ expiresAt: string;
358
+ deviceId: string;
359
+ secret: string;
360
+ }, {
361
+ accountId: string;
362
+ expiresAt: string;
363
+ deviceId: string;
364
+ secret: string;
365
+ }>;
366
+ /**
367
+ * Request body for `POST /session/device/background-token` — presented by
368
+ * native background code with NO bearer and NO cookies: possession of the
369
+ * background `secret` IS the proof, as it is for the device-secret mint.
370
+ *
371
+ * Unlike that mint this one NEVER rotates the presented secret (hence no
372
+ * `next…` field to persist in the response), so background code interrupted
373
+ * anywhere between request and response leaves the credential intact and
374
+ * usable on its next run.
375
+ */
376
+ export declare const deviceBackgroundTokenRequestSchema: z.ZodObject<{
377
+ deviceId: z.ZodString;
378
+ secret: z.ZodString;
379
+ }, "strip", z.ZodTypeAny, {
380
+ deviceId: string;
381
+ secret: string;
382
+ }, {
383
+ deviceId: string;
384
+ secret: string;
385
+ }>;
386
+ /**
387
+ * Wire shape of a successful `POST /session/device/background-token`: the short
388
+ * access token, its expiry, and the account the token belongs to — the last so
389
+ * a caller can key cached data per account and drop data belonging to a
390
+ * foreign one.
391
+ *
392
+ * Carries NO device state — no account list, no `activeAccountId`, no
393
+ * `revision`, unlike {@link deviceTokenMintResponseSchema} — deliberately, to
394
+ * cap what a compromised credential record yields.
395
+ */
396
+ export declare const deviceBackgroundTokenResponseSchema: z.ZodObject<{
397
+ accessToken: z.ZodString;
398
+ expiresAt: z.ZodString;
399
+ accountId: z.ZodString;
400
+ }, "strip", z.ZodTypeAny, {
401
+ accountId: string;
402
+ expiresAt: string;
403
+ accessToken: string;
404
+ }, {
405
+ accountId: string;
406
+ expiresAt: string;
407
+ accessToken: string;
408
+ }>;
409
+ export type DeviceBackgroundCredentialResponse = z.infer<typeof deviceBackgroundCredentialResponseSchema>;
410
+ export type DeviceBackgroundTokenRequest = z.infer<typeof deviceBackgroundTokenRequestSchema>;
411
+ export type DeviceBackgroundTokenResponse = z.infer<typeof deviceBackgroundTokenResponseSchema>;