@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,58 @@
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 declare const COMMONS_DENY_REASONS: readonly ["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 declare const commonsDenyReasonSchema: z.ZodEnum<["declined", "not_me"]>;
43
+ /** Why the approver denied a "Sign in with Oxy" request. */
44
+ export type CommonsDenyReason = z.infer<typeof commonsDenyReasonSchema>;
45
+ /**
46
+ * Android notification channel id the identity-approval push is sent on.
47
+ *
48
+ * A wire contract for the same reason the deny set is: Android 8+ DROPS a
49
+ * notification whose channel id the app has not created, silently and with no
50
+ * client-side error. The API attaches this id when it sends, and the vault
51
+ * creates the channel with it before registering a push token — two hand-typed
52
+ * copies of that string would fail as "the notification never arrived", which
53
+ * is the single hardest push symptom to diagnose.
54
+ *
55
+ * The channel's user-visible NAME and description are deliberately NOT here:
56
+ * those are localized app copy, and the vault owns them.
57
+ */
58
+ export declare const IDENTITY_APPROVAL_PUSH_CHANNEL = "auth-approval";
@@ -281,51 +281,6 @@ export declare const deviceTokenMintResponseSchema: z.ZodObject<{
281
281
  }>;
282
282
  export type DeviceTokenMintRequest = z.infer<typeof deviceTokenMintRequestSchema>;
283
283
  export type DeviceTokenMintResponse = z.infer<typeof deviceTokenMintResponseSchema>;
284
- /** Request body for `POST /session/device/hub-ticket`. */
285
- export declare const deviceHubTicketIssueRequestSchema: z.ZodObject<{
286
- returnOrigin: z.ZodString;
287
- }, "strip", z.ZodTypeAny, {
288
- returnOrigin: string;
289
- }, {
290
- returnOrigin: string;
291
- }>;
292
- /** Response from `POST /session/device/hub-ticket`. */
293
- export declare const deviceHubTicketIssueResponseSchema: z.ZodObject<{
294
- ticket: z.ZodString;
295
- expiresIn: z.ZodNumber;
296
- }, "strip", z.ZodTypeAny, {
297
- ticket: string;
298
- expiresIn: number;
299
- }, {
300
- ticket: string;
301
- expiresIn: number;
302
- }>;
303
- /** Request body for `POST /session/device/redeem-ticket`. */
304
- export declare const deviceHubTicketRedeemRequestSchema: z.ZodObject<{
305
- ticket: z.ZodString;
306
- returnOrigin: z.ZodString;
307
- }, "strip", z.ZodTypeAny, {
308
- returnOrigin: string;
309
- ticket: string;
310
- }, {
311
- returnOrigin: string;
312
- ticket: string;
313
- }>;
314
- /** Response from `POST /session/device/redeem-ticket`. */
315
- export declare const deviceHubTicketRedeemResponseSchema: z.ZodObject<{
316
- deviceId: z.ZodString;
317
- deviceSecret: z.ZodString;
318
- }, "strip", z.ZodTypeAny, {
319
- deviceId: string;
320
- deviceSecret: string;
321
- }, {
322
- deviceId: string;
323
- deviceSecret: string;
324
- }>;
325
- export type DeviceHubTicketIssueRequest = z.infer<typeof deviceHubTicketIssueRequestSchema>;
326
- export type DeviceHubTicketIssueResponse = z.infer<typeof deviceHubTicketIssueResponseSchema>;
327
- export type DeviceHubTicketRedeemRequest = z.infer<typeof deviceHubTicketRedeemRequestSchema>;
328
- export type DeviceHubTicketRedeemResponse = z.infer<typeof deviceHubTicketRedeemResponseSchema>;
329
284
  /**
330
285
  * Name of the token-free Socket.IO event emitted to room `user:<userId>` on
331
286
  * every DeviceSession mutation that changes what is signed in for that user.
@@ -0,0 +1,30 @@
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 declare const INBOX_EMAIL_PUSH_CHANNEL = "email";
15
+ /** Runtime type discriminator of the new-mail push payload. */
16
+ export declare const INBOX_EMAIL_PUSH_TYPE = "oxy_inbox_new_message";
17
+ export declare const inboxEmailPushDataSchema: z.ZodObject<{
18
+ type: z.ZodLiteral<"oxy_inbox_new_message">;
19
+ messageId: z.ZodString;
20
+ mailboxId: z.ZodString;
21
+ }, "strip", z.ZodTypeAny, {
22
+ type: "oxy_inbox_new_message";
23
+ messageId: string;
24
+ mailboxId: string;
25
+ }, {
26
+ type: "oxy_inbox_new_message";
27
+ messageId: string;
28
+ mailboxId: string;
29
+ }>;
30
+ export type InboxEmailPushData = z.infer<typeof inboxEmailPushDataSchema>;
@@ -15,6 +15,10 @@ export { userNameSchema, userRelationshipSchema, themePreferenceSchema, userResp
15
15
  export type { UserNameResponse, UserRelationship, ThemePreference, UserResponse, UserProfileUpdate, CurrentUserResponseContract, DeviceLinkedSessionResponse, DeviceLinkedSessionsResponseContract, } from './userResponse';
16
16
  export { applicationTypeSchema, publicApplicationSchema, sessionStatusSchema, } from './sessionStatus';
17
17
  export type { ApplicationTypeContract, PublicApplicationResponse, SessionStatusResponse, } from './sessionStatus';
18
+ export { COMMONS_DENY_REASONS, commonsDenyReasonSchema, IDENTITY_APPROVAL_PUSH_CHANNEL, } from './commonsSignIn';
19
+ export type { CommonsDenyReason } from './commonsSignIn';
20
+ export { INBOX_EMAIL_PUSH_CHANNEL, INBOX_EMAIL_PUSH_TYPE, inboxEmailPushDataSchema, } from './inboxPush';
21
+ export type { InboxEmailPushData } from './inboxPush';
18
22
  export { recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, appAffinityEventTypeSchema, appAffinityEventSchema, appAffinityEventsIngestSchema, } from './recommendations';
19
23
  export type { RecommendationExcludeType, RecommendationBoost, RecommendationSignalWeights, RecommendationRequest, RecommendationCount, RecommendationItem, RecommendationResponse, AppEndorsementInput, AppInterestInput, AppUserSignalIngest, AppAffinityEventType, AppAffinityEvent, AppAffinityEventsIngest, } from './recommendations';
20
24
  export { verificationMethodSchema, didServiceSchema, didDocumentSchema, signedRecordEnvelopeSchema, verifiedDomainSchema, domainVerificationRequestSchema, domainVerificationInstructionsSchema, authMethodEntrySchema, authMethodsResponseSchema, exportAttestationSchema, exportBundleSchema, } from './identity';
@@ -27,8 +31,8 @@ export { publicCardSchema, signedPublicCardSchema, realLifeAttestationRecordSche
27
31
  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
32
  export { linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links';
29
33
  export type { LinkPreviewStatus, LinkPreview, LinkPreviewBatchRequest, LinkPreviewBatchResponse, } from './links';
30
- export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceHubTicketIssueRequestSchema, deviceHubTicketIssueResponseSchema, deviceHubTicketRedeemRequestSchema, deviceHubTicketRedeemResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession';
31
- export type { SessionAccount, DeviceSessionState, ActiveToken, DeviceSessionSync, DeviceTokenMintRequest, DeviceTokenMintResponse, DeviceHubTicketIssueRequest, DeviceHubTicketIssueResponse, DeviceHubTicketRedeemRequest, DeviceHubTicketRedeemResponse, SessionAccountsChangedReason, SessionAccountsChangedEvent, } from './deviceSession';
34
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession';
35
+ export type { SessionAccount, DeviceSessionState, ActiveToken, DeviceSessionSync, DeviceTokenMintRequest, DeviceTokenMintResponse, SessionAccountsChangedReason, SessionAccountsChangedEvent, } from './deviceSession';
32
36
  export { loginResultSchema, } from './deviceBoot';
33
37
  export type { LoginSessionResult, LoginResult, SecurityAlert, SecurityAlertAnomaly, } from './deviceBoot';
34
38
  export { rotateKeyChallengeResponseSchema, rotateKeyCompleteRequestSchema, rotateKeyCompleteResponseSchema, } from './keyRotation';
@@ -621,8 +621,8 @@ export declare const currentUserResponseSchema: z.ZodObject<{
621
621
  did?: string | undefined;
622
622
  verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
623
623
  verified?: boolean | undefined;
624
- _id?: string | undefined;
625
624
  email?: string | undefined;
625
+ _id?: string | undefined;
626
626
  phone?: string | undefined;
627
627
  address?: string | undefined;
628
628
  birthday?: string | undefined;
@@ -644,8 +644,8 @@ export declare const currentUserResponseSchema: z.ZodObject<{
644
644
  did?: string | undefined;
645
645
  verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
646
646
  verified?: boolean | undefined;
647
- _id?: string | undefined;
648
647
  email?: string | undefined;
648
+ _id?: string | undefined;
649
649
  phone?: string | undefined;
650
650
  address?: string | undefined;
651
651
  birthday?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/contracts",
3
- "version": "0.18.0",
3
+ "version": "0.19.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",