@oxyhq/contracts 0.18.0 → 0.19.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.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Canonical contract for the "Sign in with Oxy" approval handoff.
3
+ *
4
+ * SINGLE SOURCE OF TRUTH for the closed set of reasons an approver may attach
5
+ * when it DENIES a pending request via
6
+ * `POST /auth/session/deny/:authorizeCode`.
7
+ *
8
+ * That endpoint is UNAUTHENTICATED — the public `authorizeCode` is the only
9
+ * credential — so a free-form string from it is never stored: it would be an
10
+ * unauthenticated write of arbitrary text onto a record other surfaces read.
11
+ * The set is therefore deliberately tiny, and closed:
12
+ *
13
+ * - `'declined'` the approver rejected a request they recognised ("Not now").
14
+ * - `'not_me'` the approver did not start the request ("This wasn't me").
15
+ * The ONE value that records the denial as suspicious rather
16
+ * than an ordinary cancel, so a UI may only offer it where the
17
+ * user genuinely said so.
18
+ *
19
+ * Why this lives in `@oxyhq/contracts` rather than in either consumer: the same
20
+ * closed set is enforced in three places — the request schema of the API route,
21
+ * the `enum` of the persisted `AuthSession.deniedReason` field, and the client
22
+ * SDK's `denyCommonsSignIn` parameter. Two hand-maintained copies of a wire
23
+ * contract drift the moment a value is added on one side only, and the failure
24
+ * lands at runtime, in an auth path, as a generic validation error. One
25
+ * declaration makes that impossible.
26
+ *
27
+ * Platform-agnostic — zod only, no react/react-native/expo. ESM-safe (no
28
+ * `require()`).
29
+ */
30
+ import { z } from 'zod';
31
+ /**
32
+ * The closed set, as a value — consumed directly where a runtime list is
33
+ * required (e.g. the Mongoose `enum` of `AuthSession.deniedReason`, which is
34
+ * the storage-level guarantee that an unauthenticated caller can never write
35
+ * free-form text into the field).
36
+ */
37
+ export const COMMONS_DENY_REASONS = ['declined', 'not_me'];
38
+ /**
39
+ * The same set as a zod enum — the edge validator. Anything outside it
40
+ * (including free-form text) is rejected with 400 before any handler runs.
41
+ */
42
+ export const commonsDenyReasonSchema = z.enum(COMMONS_DENY_REASONS);
43
+ /**
44
+ * Android notification channel id the identity-approval push is sent on.
45
+ *
46
+ * A wire contract for the same reason the deny set is: Android 8+ DROPS a
47
+ * notification whose channel id the app has not created, silently and with no
48
+ * client-side error. The API attaches this id when it sends, and the vault
49
+ * creates the channel with it before registering a push token — two hand-typed
50
+ * copies of that string would fail as "the notification never arrived", which
51
+ * is the single hardest push symptom to diagnose.
52
+ *
53
+ * The channel's user-visible NAME and description are deliberately NOT here:
54
+ * those are localized app copy, and the vault owns them.
55
+ */
56
+ export const IDENTITY_APPROVAL_PUSH_CHANNEL = 'auth-approval';
@@ -57,28 +57,6 @@ export const deviceTokenMintResponseSchema = z.object({
57
57
  state: deviceSessionStateSchema,
58
58
  });
59
59
  /* -------------------------------------------------------------------------- */
60
- /* Hub ticket — server-side cross-origin device credential sync */
61
- /* -------------------------------------------------------------------------- */
62
- /** Request body for `POST /session/device/hub-ticket`. */
63
- export const deviceHubTicketIssueRequestSchema = z.object({
64
- returnOrigin: z.string().min(1),
65
- });
66
- /** Response from `POST /session/device/hub-ticket`. */
67
- export const deviceHubTicketIssueResponseSchema = z.object({
68
- ticket: z.string().min(1),
69
- expiresIn: z.number().int().positive(),
70
- });
71
- /** Request body for `POST /session/device/redeem-ticket`. */
72
- export const deviceHubTicketRedeemRequestSchema = z.object({
73
- ticket: z.string().min(1),
74
- returnOrigin: z.string().min(1),
75
- });
76
- /** Response from `POST /session/device/redeem-ticket`. */
77
- export const deviceHubTicketRedeemResponseSchema = z.object({
78
- deviceId: z.string().min(1),
79
- deviceSecret: z.string().min(1),
80
- });
81
- /* -------------------------------------------------------------------------- */
82
60
  /* Instant cross-app session sync (token-free socket signal) */
83
61
  /* -------------------------------------------------------------------------- */
84
62
  /**
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Canonical contract for Inbox new-mail push notifications.
3
+ *
4
+ * The Android channel id and payload `type` are wire contracts: Android 8+
5
+ * drops a notification whose channel the app has not created, and the client
6
+ * only routes taps it recognises. Two hand-typed copies of either string fail as
7
+ * "the notification never arrived" or "tapping does nothing" — the hardest push
8
+ * symptoms to diagnose.
9
+ *
10
+ * Platform-agnostic — zod only, no react/react-native/expo.
11
+ */
12
+ import { z } from 'zod';
13
+ /** Android notification channel id the new-mail push is sent on. */
14
+ export const INBOX_EMAIL_PUSH_CHANNEL = 'email';
15
+ /** Runtime type discriminator of the new-mail push payload. */
16
+ export const INBOX_EMAIL_PUSH_TYPE = 'oxy_inbox_new_message';
17
+ export const inboxEmailPushDataSchema = z.object({
18
+ type: z.literal(INBOX_EMAIL_PUSH_TYPE),
19
+ messageId: z.string().min(1),
20
+ mailboxId: z.string().min(1),
21
+ });
package/dist/esm/index.js CHANGED
@@ -19,6 +19,12 @@ export {
19
19
  // Schemas
20
20
  applicationTypeSchema, publicApplicationSchema, sessionStatusSchema, } from './sessionStatus.js';
21
21
  export {
22
+ // Closed set of denial reasons for POST /auth/session/deny/:authorizeCode —
23
+ // shared by the API request schema, the persisted `AuthSession.deniedReason`
24
+ // enum, and the SDK's `denyCommonsSignIn`.
25
+ COMMONS_DENY_REASONS, commonsDenyReasonSchema, IDENTITY_APPROVAL_PUSH_CHANNEL, } from './commonsSignIn.js';
26
+ export { INBOX_EMAIL_PUSH_CHANNEL, INBOX_EMAIL_PUSH_TYPE, inboxEmailPushDataSchema, } from './inboxPush.js';
27
+ export {
22
28
  // Schemas
23
29
  recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, appAffinityEventTypeSchema, appAffinityEventSchema, appAffinityEventsIngestSchema, } from './recommendations.js';
24
30
  export {
@@ -38,7 +44,7 @@ credentialRecordSchema, verifiableCredentialResponseSchema, credentialIssueResul
38
44
  export {
39
45
  // Schemas
40
46
  linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links.js';
41
- export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceHubTicketIssueRequestSchema, deviceHubTicketIssueResponseSchema, deviceHubTicketRedeemRequestSchema, deviceHubTicketRedeemResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession.js';
47
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession.js';
42
48
  export {
43
49
  // Schemas
44
50
  loginResultSchema, } from './deviceBoot.js';