@oxyhq/contracts 0.14.0 → 0.14.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.
@@ -69,3 +69,44 @@ export const deviceHubTicketRedeemResponseSchema = z.object({
69
69
  deviceId: z.string().min(1),
70
70
  deviceSecret: z.string().min(1),
71
71
  });
72
+ /* -------------------------------------------------------------------------- */
73
+ /* Instant cross-app session sync (token-free socket signal) */
74
+ /* -------------------------------------------------------------------------- */
75
+ /**
76
+ * Name of the token-free Socket.IO event emitted to room `user:<userId>` on
77
+ * every DeviceSession mutation that changes what is signed in for that user.
78
+ *
79
+ * This is a pure SIGNAL — it carries NO access token, NO deviceSecret and NO
80
+ * account bodies. A client that receives it re-fetches its authenticated
81
+ * session/account state (`GET /session/device/state`, `GET /accounts`). Unlike
82
+ * `session_state` (scoped to `device:<deviceId>`, i.e. a single origin), this
83
+ * reaches ALL of a user's connected sockets across their devices/origins so
84
+ * every Oxy app reflects an add / switch / signout instantly.
85
+ */
86
+ export const SESSION_ACCOUNTS_CHANGED_EVENT = 'session_accounts_changed';
87
+ /**
88
+ * Why the signed-in set changed:
89
+ * - `login` — a brand-new session was minted for the user (QR / cross-app authorize)
90
+ * - `add` — an account was registered onto a device set
91
+ * - `switch` — the active account on a device changed
92
+ * - `signout` — one or all accounts were signed out of a device
93
+ * - `revoke` — a dead/revoked account was healed out of a device set
94
+ */
95
+ export const sessionAccountsChangedReasonSchema = z.enum([
96
+ 'login',
97
+ 'add',
98
+ 'switch',
99
+ 'signout',
100
+ 'revoke',
101
+ ]);
102
+ /**
103
+ * Payload of {@link SESSION_ACCOUNTS_CHANGED_EVENT}. `revision` is the mutated
104
+ * DeviceSession revision for device-scoped reasons (`add`/`switch`/`signout`/
105
+ * `revoke`); for `login` (no device mutation at emit time) it is `0`. The
106
+ * payload is deliberately minimal and secret-free — the client refetches.
107
+ */
108
+ export const sessionAccountsChangedEventSchema = z.object({
109
+ userId: z.string(),
110
+ revision: z.number().int().nonnegative(),
111
+ reason: sessionAccountsChangedReasonSchema,
112
+ });
package/dist/esm/index.js CHANGED
@@ -38,7 +38,7 @@ credentialRecordSchema, verifiableCredentialResponseSchema, credentialIssueResul
38
38
  export {
39
39
  // Schemas
40
40
  linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links.js';
41
- export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceHubTicketIssueRequestSchema, deviceHubTicketIssueResponseSchema, deviceHubTicketRedeemRequestSchema, deviceHubTicketRedeemResponseSchema, } from './deviceSession.js';
41
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceHubTicketIssueRequestSchema, deviceHubTicketIssueResponseSchema, deviceHubTicketRedeemRequestSchema, deviceHubTicketRedeemResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession.js';
42
42
  export {
43
43
  // Schemas
44
44
  loginResultSchema, } from './deviceBoot.js';