@oxyhq/contracts 0.18.0 → 0.20.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.
@@ -368,3 +323,88 @@ export declare const sessionAccountsChangedEventSchema: z.ZodObject<{
368
323
  }>;
369
324
  export type SessionAccountsChangedReason = z.infer<typeof sessionAccountsChangedReasonSchema>;
370
325
  export type SessionAccountsChangedEvent = z.infer<typeof sessionAccountsChangedEventSchema>;
326
+ /**
327
+ * Response from `POST /session/device/background-credential` — provisioned by
328
+ * the SDK WHILE THE APP IS RUNNING (bearer required, `deviceId` and account
329
+ * derived server-side from it) and consumed afterwards only by native
330
+ * background code, which has no JS runtime to mint a token for itself.
331
+ *
332
+ * Deliberately a SEPARATE credential from the rotating `deviceSecret`: that one
333
+ * rotates on every mint, so background code presenting it would become a second
334
+ * writer of a value the JS runtime depends on, and background code killed
335
+ * mid-rotation would silently sign the user out on the next cold start. Against
336
+ * this credential background code is the sole writer, and it can never rotate
337
+ * anything JS reads.
338
+ *
339
+ * The raw `secret` is returned exactly once, at provision time — never stored
340
+ * retrievably, never logged, never re-read. A caller that loses it provisions
341
+ * a new one.
342
+ *
343
+ * `expiresAt` is an unvalidated string, like every other expiry in this file:
344
+ * no consumer on the JS path interprets it (native background code parses it
345
+ * itself), and a `.datetime()` here alone would leave one strict field beside
346
+ * two lax ones. If expiry is ever validated it goes on all three at once, with
347
+ * the API's serializers checked against it — the producer is the same server.
348
+ */
349
+ export declare const deviceBackgroundCredentialResponseSchema: z.ZodObject<{
350
+ deviceId: z.ZodString;
351
+ secret: z.ZodString;
352
+ accountId: z.ZodString;
353
+ expiresAt: z.ZodString;
354
+ }, "strip", z.ZodTypeAny, {
355
+ expiresAt: string;
356
+ deviceId: string;
357
+ accountId: string;
358
+ secret: string;
359
+ }, {
360
+ expiresAt: string;
361
+ deviceId: string;
362
+ accountId: string;
363
+ secret: string;
364
+ }>;
365
+ /**
366
+ * Request body for `POST /session/device/background-token` — presented by
367
+ * native background code with NO bearer and NO cookies: possession of the
368
+ * background `secret` IS the proof, as it is for the device-secret mint.
369
+ *
370
+ * Unlike that mint this one NEVER rotates the presented secret (hence no
371
+ * `next…` field to persist in the response), so background code interrupted
372
+ * anywhere between request and response leaves the credential intact and
373
+ * usable on its next run.
374
+ */
375
+ export declare const deviceBackgroundTokenRequestSchema: z.ZodObject<{
376
+ deviceId: z.ZodString;
377
+ secret: z.ZodString;
378
+ }, "strip", z.ZodTypeAny, {
379
+ deviceId: string;
380
+ secret: string;
381
+ }, {
382
+ deviceId: string;
383
+ secret: string;
384
+ }>;
385
+ /**
386
+ * Wire shape of a successful `POST /session/device/background-token`: the short
387
+ * access token, its expiry, and the account the token belongs to — the last so
388
+ * a caller can key cached data per account and drop data belonging to a
389
+ * foreign one.
390
+ *
391
+ * Carries NO device state — no account list, no `activeAccountId`, no
392
+ * `revision`, unlike {@link deviceTokenMintResponseSchema} — deliberately, to
393
+ * cap what a compromised credential record yields.
394
+ */
395
+ export declare const deviceBackgroundTokenResponseSchema: z.ZodObject<{
396
+ accessToken: z.ZodString;
397
+ expiresAt: z.ZodString;
398
+ accountId: z.ZodString;
399
+ }, "strip", z.ZodTypeAny, {
400
+ expiresAt: string;
401
+ accessToken: string;
402
+ accountId: string;
403
+ }, {
404
+ expiresAt: string;
405
+ accessToken: string;
406
+ accountId: string;
407
+ }>;
408
+ export type DeviceBackgroundCredentialResponse = z.infer<typeof deviceBackgroundCredentialResponseSchema>;
409
+ export type DeviceBackgroundTokenRequest = z.infer<typeof deviceBackgroundTokenRequestSchema>;
410
+ export type DeviceBackgroundTokenResponse = z.infer<typeof deviceBackgroundTokenResponseSchema>;
@@ -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';
@@ -25,10 +29,12 @@ export { chainHeadResponseSchema, logPageResponseSchema, } from './protocol';
25
29
  export type { LexiconRecord, ChainHeadResponse, LogPageResponse, } from './protocol';
26
30
  export { publicCardSchema, signedPublicCardSchema, realLifeAttestationRecordSchema, realLifeAttestationResultSchema, validationVerdictRecordSchema, validationOpenRequestSchema, validationOpenResultSchema, validationRequestSummarySchema, validationVoteResultSchema, personhoodVouchRecordSchema, personhoodBreakdownSchema, personhoodStatusResultSchema, vouchResultSchema, credentialRecordSchema, verifiableCredentialResponseSchema, credentialIssueResultSchema, credentialListResultSchema, credentialVerifyResultSchema, } from './civic';
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';
32
+ export { REPUTATION_CATEGORIES, REPUTATION_TRANSACTION_STATUSES, TRUST_TIERS, REPUTATION_TARGET_ENTITY_TYPES, REPUTATION_DISPUTE_STATUSES, REPUTATION_INFLUENCE_CONTEXTS, reputationCategorySchema, reputationTransactionStatusSchema, trustTierSchema, reputationTargetEntityTypeSchema, reputationDisputeStatusSchema, reputationInfluenceContextSchema, reputationTransactionSchema, reputationBalanceBreakdownSchema, reputationInfluenceSchema, reputationReliabilitySchema, reputationBalanceSummarySchema, reputationBalanceSchema, reputationDisputeSchema, reputationRuleSchema, reputationLeaderboardUserSchema, reputationLeaderboardEntrySchema, reputationInfluenceResultSchema, reverseReputationTransactionResultSchema, awardReputationSchema, createReputationDisputeSchema, resolveReputationDisputeSchema, upsertReputationRuleSchema, reverseReputationTransactionSchema, isFullReputationBalance, } from './reputation';
33
+ export type { ReputationCategory, ReputationTransactionStatus, TrustTier, ReputationTargetEntityType, ReputationDisputeStatus, ReputationInfluenceContext, ReputationTransaction, ReputationBalanceBreakdown, ReputationInfluence, ReputationReliability, ReputationBalanceSummary, ReputationBalance, ReputationBalanceView, ReputationDispute, ReputationRule, ReputationLeaderboardUser, ReputationLeaderboardEntry, ReputationInfluenceResult, ReverseReputationTransactionResult, AwardReputationInput, CreateReputationDisputeInput, ResolveReputationDisputeInput, UpsertReputationRuleInput, UpsertReputationRuleRequest, ReverseReputationTransactionInput, } from './reputation';
28
34
  export { linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links';
29
35
  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';
36
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceBackgroundCredentialResponseSchema, deviceBackgroundTokenRequestSchema, deviceBackgroundTokenResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession';
37
+ export type { SessionAccount, DeviceSessionState, ActiveToken, DeviceSessionSync, DeviceTokenMintRequest, DeviceTokenMintResponse, DeviceBackgroundCredentialResponse, DeviceBackgroundTokenRequest, DeviceBackgroundTokenResponse, SessionAccountsChangedReason, SessionAccountsChangedEvent, } from './deviceSession';
32
38
  export { loginResultSchema, } from './deviceBoot';
33
39
  export type { LoginSessionResult, LoginResult, SecurityAlert, SecurityAlertAnomaly, } from './deviceBoot';
34
40
  export { rotateKeyChallengeResponseSchema, rotateKeyCompleteRequestSchema, rotateKeyCompleteResponseSchema, } from './keyRotation';
@@ -62,18 +62,18 @@ export declare const encryptedBackupEnvelopeSchema: z.ZodObject<{
62
62
  version: number;
63
63
  nonce: string;
64
64
  ciphertext: string;
65
+ createdAt: string;
65
66
  algorithm: "xchacha20poly1305";
66
67
  kdfInfo: string;
67
68
  publicKeyHint: string;
68
- createdAt: string;
69
69
  }, {
70
70
  version: number;
71
71
  nonce: string;
72
72
  ciphertext: string;
73
+ createdAt: string;
73
74
  algorithm: "xchacha20poly1305";
74
75
  kdfInfo: string;
75
76
  publicKeyHint: string;
76
- createdAt: string;
77
77
  }>;
78
78
  export type EncryptedBackupEnvelope = z.infer<typeof encryptedBackupEnvelopeSchema>;
79
79
  /**
@@ -101,19 +101,19 @@ export declare const backupUploadRequestSchema: z.ZodObject<{
101
101
  version: number;
102
102
  nonce: string;
103
103
  ciphertext: string;
104
+ createdAt: string;
104
105
  algorithm: "xchacha20poly1305";
105
106
  kdfInfo: string;
106
107
  publicKeyHint: string;
107
- createdAt: string;
108
108
  lookupId: string;
109
109
  }, {
110
110
  version: number;
111
111
  nonce: string;
112
112
  ciphertext: string;
113
+ createdAt: string;
113
114
  algorithm: "xchacha20poly1305";
114
115
  kdfInfo: string;
115
116
  publicKeyHint: string;
116
- createdAt: string;
117
117
  lookupId: string;
118
118
  }>;
119
119
  export type BackupUploadRequest = z.infer<typeof backupUploadRequestSchema>;
@@ -128,11 +128,11 @@ export declare const backupStatusResponseSchema: z.ZodObject<{
128
128
  createdAt: z.ZodOptional<z.ZodString>;
129
129
  }, "strip", z.ZodTypeAny, {
130
130
  exists: boolean;
131
- publicKeyHint?: string | undefined;
132
131
  createdAt?: string | undefined;
132
+ publicKeyHint?: string | undefined;
133
133
  }, {
134
134
  exists: boolean;
135
- publicKeyHint?: string | undefined;
136
135
  createdAt?: string | undefined;
136
+ publicKeyHint?: string | undefined;
137
137
  }>;
138
138
  export type BackupStatusResponse = z.infer<typeof backupStatusResponseSchema>;