@oxyhq/contracts 0.6.0 → 0.8.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,165 @@
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>;
@@ -41,6 +41,13 @@ export declare const fedcmTokenPayloadSchema: z.ZodObject<{
41
41
  exp: z.ZodOptional<z.ZodNumber>;
42
42
  iat: z.ZodOptional<z.ZodNumber>;
43
43
  nonce: z.ZodOptional<z.ZodString>;
44
+ /**
45
+ * An explicit central deviceId minted by the IdP, threaded through so the
46
+ * RP session can inherit a unified device id instead of deriving one from
47
+ * the (userId, RP origin) stableDeviceKey. Optional and additive — omitted
48
+ * tokens fall back to the existing stableDeviceKey/UA-IP derivation.
49
+ */
50
+ deviceId: z.ZodOptional<z.ZodString>;
44
51
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
45
52
  iss: z.ZodOptional<z.ZodString>;
46
53
  sub: z.ZodOptional<z.ZodString>;
@@ -48,6 +55,13 @@ export declare const fedcmTokenPayloadSchema: z.ZodObject<{
48
55
  exp: z.ZodOptional<z.ZodNumber>;
49
56
  iat: z.ZodOptional<z.ZodNumber>;
50
57
  nonce: z.ZodOptional<z.ZodString>;
58
+ /**
59
+ * An explicit central deviceId minted by the IdP, threaded through so the
60
+ * RP session can inherit a unified device id instead of deriving one from
61
+ * the (userId, RP origin) stableDeviceKey. Optional and additive — omitted
62
+ * tokens fall back to the existing stableDeviceKey/UA-IP derivation.
63
+ */
64
+ deviceId: z.ZodOptional<z.ZodString>;
51
65
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
52
66
  iss: z.ZodOptional<z.ZodString>;
53
67
  sub: z.ZodOptional<z.ZodString>;
@@ -55,5 +69,12 @@ export declare const fedcmTokenPayloadSchema: z.ZodObject<{
55
69
  exp: z.ZodOptional<z.ZodNumber>;
56
70
  iat: z.ZodOptional<z.ZodNumber>;
57
71
  nonce: z.ZodOptional<z.ZodString>;
72
+ /**
73
+ * An explicit central deviceId minted by the IdP, threaded through so the
74
+ * RP session can inherit a unified device id instead of deriving one from
75
+ * the (userId, RP origin) stableDeviceKey. Optional and additive — omitted
76
+ * tokens fall back to the existing stableDeviceKey/UA-IP derivation.
77
+ */
78
+ deviceId: z.ZodOptional<z.ZodString>;
58
79
  }, z.ZodTypeAny, "passthrough">>;
59
80
  export type FedcmTokenPayload = z.infer<typeof fedcmTokenPayloadSchema>;
@@ -39,19 +39,74 @@
39
39
  */
40
40
  import { z } from 'zod';
41
41
  /**
42
- * A single DID verification method. Mirrors the secp256k1 key entries the API
43
- * derives from `User.publicKey` + each `authMethods[]` of type `identity`.
44
- * `id` is a fragment reference within the DID document (e.g.
45
- * `did:web:oxy.so:u:<id>#key-1`); `controller` is the controlling DID;
46
- * `publicKeyHex` is the uncompressed/compressed secp256k1 public key in hex.
42
+ * A `EcdsaSecp256k1VerificationKey2019` verification method the canonical Oxy
43
+ * key form. Mirrors the secp256k1 key entries the API derives from
44
+ * `User.publicKey` + each `authMethods[]` of type `identity`. `id` is a fragment
45
+ * reference within the DID document (e.g. `did:web:oxy.so:u:<id>#key-1`);
46
+ * `controller` is the controlling DID; `publicKeyHex` is the (uncompressed)
47
+ * secp256k1 public key in hex.
47
48
  */
48
- export interface VerificationMethod {
49
+ export interface Secp256k1VerificationMethod {
49
50
  id: string;
50
51
  type: 'EcdsaSecp256k1VerificationKey2019';
51
52
  controller: string;
52
53
  publicKeyHex: string;
53
54
  }
54
- export declare const verificationMethodSchema: z.ZodType<VerificationMethod>;
55
+ /**
56
+ * A `Multikey` verification method — the AtProto/Bluesky key form. The SAME
57
+ * secp256k1 key as an account's {@link Secp256k1VerificationMethod}, re-encoded
58
+ * the way atproto expects: `publicKeyMultibase` is the `did:key`-style multibase
59
+ * (`base58btc`, leading `z`) of the multicodec-prefixed (`0xe7 0x01`, secp256k1)
60
+ * COMPRESSED public key. This is the verification method a foreign Bluesky
61
+ * AppView reads when it routes to the user's bridge PDS; it is additive and only
62
+ * present for atproto-bridged self-sovereign accounts.
63
+ */
64
+ export interface MultikeyVerificationMethod {
65
+ id: string;
66
+ type: 'Multikey';
67
+ controller: string;
68
+ publicKeyMultibase: string;
69
+ }
70
+ /**
71
+ * A single DID verification method — either the canonical Oxy secp256k1 form
72
+ * ({@link Secp256k1VerificationMethod}) or the atproto `Multikey` form
73
+ * ({@link MultikeyVerificationMethod}). Discriminated on `type`, so an
74
+ * `EcdsaSecp256k1VerificationKey2019` entry keeps its exact `publicKeyHex` shape
75
+ * (every document already served verifies byte-identically) and the `Multikey`
76
+ * entry carries `publicKeyMultibase`.
77
+ */
78
+ export type VerificationMethod = Secp256k1VerificationMethod | MultikeyVerificationMethod;
79
+ export declare const verificationMethodSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
80
+ id: z.ZodString;
81
+ type: z.ZodLiteral<"EcdsaSecp256k1VerificationKey2019">;
82
+ controller: z.ZodString;
83
+ publicKeyHex: z.ZodString;
84
+ }, "strip", z.ZodTypeAny, {
85
+ id: string;
86
+ type: "EcdsaSecp256k1VerificationKey2019";
87
+ controller: string;
88
+ publicKeyHex: string;
89
+ }, {
90
+ id: string;
91
+ type: "EcdsaSecp256k1VerificationKey2019";
92
+ controller: string;
93
+ publicKeyHex: string;
94
+ }>, z.ZodObject<{
95
+ id: z.ZodString;
96
+ type: z.ZodLiteral<"Multikey">;
97
+ controller: z.ZodString;
98
+ publicKeyMultibase: z.ZodString;
99
+ }, "strip", z.ZodTypeAny, {
100
+ id: string;
101
+ type: "Multikey";
102
+ controller: string;
103
+ publicKeyMultibase: string;
104
+ }, {
105
+ id: string;
106
+ type: "Multikey";
107
+ controller: string;
108
+ publicKeyMultibase: string;
109
+ }>]>;
55
110
  /**
56
111
  * A DID service entry (the `service[]` array). Oxy publishes its API root and
57
112
  * profile endpoints here so a resolver can discover where to fetch the user's
@@ -85,14 +140,6 @@ export interface DidDocument {
85
140
  service: DidService[];
86
141
  }
87
142
  export declare const didDocumentSchema: z.ZodType<DidDocument>;
88
- /**
89
- * The category of a signed record. v1 only ever carried `identity` / `profile`
90
- * (already in production); v2 widens the union with the civic record types
91
- * (reputation attestations, real-life / peer validations, personhood vouches,
92
- * verifiable credentials) and the user-node registration record. The signing
93
- * input includes `type`, so this union is part of the signed bytes.
94
- */
95
- export type SignedRecordType = 'identity' | 'profile' | 'reputation_attestation' | 'real_life_attestation' | 'validation_verdict' | 'personhood_vouch' | 'credential' | 'node';
96
143
  /**
97
144
  * A signed record envelope. `record` is the arbitrary payload; the signing
98
145
  * input is the canonical-JSON of every envelope field EXCEPT `publicKey` and
@@ -100,6 +147,18 @@ export type SignedRecordType = 'identity' | 'profile' | 'reputation_attestation'
100
147
  * and the signer's DID — equal for self-issued records, `OXY_DID` for a
101
148
  * custodial provenance attestation). `issuedAt` is epoch milliseconds.
102
149
  *
150
+ * ## `type` — open by design
151
+ *
152
+ * `type` is an OPEN, non-empty string: it is the application-defined category of
153
+ * the record (e.g. Oxy's `identity`/`profile`/civic types, or `app.mention.*`'s
154
+ * `app_record`). The base envelope is app-agnostic, so it cannot enumerate every
155
+ * app's record categories — each app re-narrows `type` to its own closed set on
156
+ * the way INTO its own store (Oxy via {@link OxySignedRecordType}; an app via
157
+ * its own constant). Widening `type` from a closed enum to a string is
158
+ * canonical-bytes-safe: {@link signedRecordSigningInput} serializes `type` as the
159
+ * same JSON string either way, so every record already signed in production
160
+ * verifies byte-for-byte.
161
+ *
103
162
  * ## Versioning
104
163
  *
105
164
  * - **v1** is the original shape (`{version, type, subject, issuer, record,
@@ -121,7 +180,8 @@ export type SignedRecordType = 'identity' | 'profile' | 'reputation_attestation'
121
180
  */
122
181
  export interface SignedRecordEnvelope {
123
182
  version: 1 | 2;
124
- type: SignedRecordType;
183
+ /** App-defined record category (open string); each store re-narrows it. */
184
+ type: string;
125
185
  subject: string;
126
186
  issuer: string;
127
187
  record: Record<string, unknown>;
@@ -18,8 +18,14 @@ export type { FedcmTokenPayload, } from './fedcmToken';
18
18
  export { recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, } from './recommendations';
19
19
  export type { RecommendationExcludeType, RecommendationBoost, RecommendationSignalWeights, RecommendationRequest, RecommendationCount, RecommendationItem, RecommendationResponse, AppEndorsementInput, AppInterestInput, AppUserSignalIngest, } from './recommendations';
20
20
  export { verificationMethodSchema, didServiceSchema, didDocumentSchema, signedRecordEnvelopeSchema, verifiedDomainSchema, domainVerificationRequestSchema, domainVerificationInstructionsSchema, authMethodEntrySchema, authMethodsResponseSchema, exportAttestationSchema, exportBundleSchema, } from './identity';
21
- export type { VerificationMethod, DidService, DidDocument, SignedRecordEnvelope, SignedRecordType, VerifiedDomain, DomainVerificationRequest, DomainVerificationInstructions, AuthMethodEntry, AuthMethodsResponse, ExportAttestation, ExportBundle, } from './identity';
21
+ export type { VerificationMethod, Secp256k1VerificationMethod, MultikeyVerificationMethod, DidService, DidDocument, SignedRecordEnvelope, VerifiedDomain, DomainVerificationRequest, DomainVerificationInstructions, AuthMethodEntry, AuthMethodsResponse, ExportAttestation, ExportBundle, } from './identity';
22
+ export { oxySignedRecordTypeSchema, } from './oxyRecordTypes';
23
+ export type { OxySignedRecordType, } from './oxyRecordTypes';
24
+ export { chainHeadResponseSchema, logPageResponseSchema, } from './protocol';
25
+ export type { LexiconRecord, ChainHeadResponse, LogPageResponse, } from './protocol';
22
26
  export { publicCardSchema, signedPublicCardSchema, realLifeAttestationRecordSchema, realLifeAttestationResultSchema, validationVerdictRecordSchema, validationOpenRequestSchema, validationOpenResultSchema, validationRequestSummarySchema, validationVoteResultSchema, personhoodVouchRecordSchema, personhoodBreakdownSchema, personhoodStatusResultSchema, vouchResultSchema, credentialRecordSchema, verifiableCredentialResponseSchema, credentialIssueResultSchema, credentialListResultSchema, credentialVerifyResultSchema, } from './civic';
23
27
  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';
24
28
  export { linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links';
25
29
  export type { LinkPreviewStatus, LinkPreview, LinkPreviewBatchRequest, LinkPreviewBatchResponse, } from './links';
30
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, } from './deviceSession';
31
+ export type { SessionAccount, DeviceSessionState, ActiveToken, DeviceSessionSync, } from './deviceSession';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Oxy-scoped signed-record types.
3
+ *
4
+ * The base `signedRecordEnvelopeSchema` (`./identity`) now treats `type` as an
5
+ * OPEN, non-empty string so ANY Oxy app may define its own record categories
6
+ * (e.g. `app.mention.*`'s `app_record`) on the shared envelope grammar. The Oxy
7
+ * identity/civic/node STORE, however, accepts ONLY the closed set of categories
8
+ * it knows how to verify and materialize — this module is that closed set.
9
+ *
10
+ * `oxySignedRecordTypeSchema` is the runtime gate the Oxy store re-narrows with
11
+ * (the API's `verifyEnvelope` rejects any `type` outside it; the Mongoose
12
+ * `SignedRecord.type` enum is derived from `.options`); `OxySignedRecordType` is
13
+ * the matching compile-time union the SDK identity/civic mixins type against.
14
+ *
15
+ * The signing input INCLUDES `type`, so this set is part of the signed bytes —
16
+ * a record cannot have its category swapped after signing.
17
+ *
18
+ * v1 only ever carried `identity` / `profile` (already in production); v2 added
19
+ * the civic record types (reputation attestations, real-life / peer validations,
20
+ * personhood vouches, verifiable credentials) and the user-node registration
21
+ * record. Every value here is an Oxy `app.oxy.*` (or legacy v1) category — an
22
+ * app's own `type` (e.g. `app_record`) is intentionally NOT in this set and is
23
+ * rejected by the Oxy store.
24
+ *
25
+ * Platform-agnostic — zod only, no react/react-native/expo, ESM-safe.
26
+ */
27
+ import { z } from 'zod';
28
+ export declare const oxySignedRecordTypeSchema: z.ZodEnum<["identity", "profile", "reputation_attestation", "real_life_attestation", "validation_verdict", "personhood_vouch", "credential", "node"]>;
29
+ /**
30
+ * The closed set of record categories the Oxy identity/civic/node store accepts.
31
+ * The base envelope `type` is an open string; this is what the Oxy store
32
+ * re-narrows it to.
33
+ */
34
+ export type OxySignedRecordType = z.infer<typeof oxySignedRecordTypeSchema>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Generic "Oxy Protocol" record surface — the app-agnostic conventions every app
3
+ * follows to decentralize its own content on the shared signed-record substrate.
4
+ *
5
+ * The base `signedRecordEnvelopeSchema` (`./identity`) is the WIRE grammar: a
6
+ * signed envelope whose `type` is an open string and whose `record` is an opaque
7
+ * `Record<string, unknown>`. An app layers its own LEXICON on top of that
8
+ * grammar — a typed projection of the `record` payload, addressed by an
9
+ * AtProto-style `(collection, rkey)` key — WITHOUT forking the envelope schema.
10
+ *
11
+ * ## Recipe — defining an app lexicon record
12
+ *
13
+ * For each record kind an app wants to publish:
14
+ *
15
+ * 1. Define the `record` PAYLOAD schema as a `z.ZodType<XPayload>` (e.g.
16
+ * `app.mention.feed.post` → `mentionPostRecordSchema: z.ZodType<MentionPost>`).
17
+ * This validates ONLY the inner `record`, not the envelope.
18
+ * 2. Declare the `collection` NSID as a constant (e.g.
19
+ * `export const MENTION_POST_COLLECTION = 'app.mention.feed.post'`).
20
+ * 3. Reuse the UNCHANGED {@link signedRecordEnvelopeSchema} for the envelope. The
21
+ * base treats `record` as `z.record(z.unknown())`, so the app validates the
22
+ * envelope with the base schema first, then parses `envelope.record` with its
23
+ * own payload schema. {@link LexiconRecord} is the typed projection that pairs
24
+ * the `(collection, rkey)` key with the parsed payload.
25
+ *
26
+ * The Oxy civic contracts (`./civic`) already follow this convention implicitly:
27
+ * each civic record (`real_life_attestation`, `personhood_vouch`, `credential`,
28
+ * …) ships a `record`-payload schema and is carried by the base envelope.
29
+ *
30
+ * ## Chain-wire shapes
31
+ *
32
+ * {@link ChainHeadResponse} and {@link LogPageResponse} are the shared response
33
+ * shapes every chain store exposes (Oxy's `GET /identity/records/:userId/chain/head`,
34
+ * `GET /identity/head/:userId`, `GET /identity/log/:userId`, and any app node's
35
+ * equivalents). They are defined ONCE here so producers and consumers (the API
36
+ * handlers, the SDK identity/nodes mixins, app nodes) cannot drift.
37
+ *
38
+ * Platform-agnostic — zod only, no react/react-native/expo, ESM-safe.
39
+ */
40
+ import { z } from 'zod';
41
+ import { type SignedRecordEnvelope } from './identity';
42
+ /**
43
+ * The typed projection of a signed envelope's `record` payload, addressed by an
44
+ * AtProto-style `(collection, rkey)` key.
45
+ *
46
+ * - `collection` is the lexicon NSID (e.g. `app.mention.feed.post`) — the
47
+ * envelope's `collection` field.
48
+ * - `rkey` is the record key within the collection (e.g. a post id) — the
49
+ * envelope's `rkey` field.
50
+ * - `record` is the app-typed payload (`TPayload`) the app validated out of the
51
+ * envelope's opaque `record`.
52
+ *
53
+ * This is a COMPILE-TIME convenience only: the wire shape is the base envelope.
54
+ * An app builds a `LexiconRecord<TPayload>` from a verified envelope by parsing
55
+ * `envelope.record` with its own `z.ZodType<TPayload>` payload schema.
56
+ */
57
+ export interface LexiconRecord<TPayload> {
58
+ collection: string;
59
+ rkey: string;
60
+ record: TPayload;
61
+ }
62
+ /**
63
+ * The current head of a subject's per-subject hash chain.
64
+ *
65
+ * `headRecordId` is the content address of the latest record (or `null` when the
66
+ * subject has no chain yet); `seq` is its sequence number (`-1` when there is no
67
+ * chain — so the next record's coordinates are always `seq: head.seq + 1`,
68
+ * genesis `0`, and `prev: head.headRecordId`, genesis `null`); `recordCount` is
69
+ * the total number of records on the chain.
70
+ */
71
+ export interface ChainHeadResponse {
72
+ headRecordId: string | null;
73
+ seq: number;
74
+ recordCount: number;
75
+ }
76
+ export declare const chainHeadResponseSchema: z.ZodType<ChainHeadResponse>;
77
+ /**
78
+ * An ordered page of a subject's verified signed-record chain — the FULL
79
+ * envelopes (so a node or any verifier re-checks them independently). `count` is
80
+ * `records.length`, echoed for convenience.
81
+ */
82
+ export interface LogPageResponse {
83
+ records: SignedRecordEnvelope[];
84
+ count: number;
85
+ }
86
+ export declare const logPageResponseSchema: z.ZodType<LogPageResponse>;
@@ -64,8 +64,8 @@ export declare const publicApplicationSchema: z.ZodObject<{
64
64
  scopes: z.ZodArray<z.ZodString, "many">;
65
65
  developerName: z.ZodOptional<z.ZodString>;
66
66
  }, "strip", z.ZodTypeAny, {
67
- type: "first_party" | "third_party" | "internal" | "system";
68
67
  id: string;
68
+ type: "first_party" | "third_party" | "internal" | "system";
69
69
  name: string;
70
70
  isOfficial: boolean;
71
71
  isInternal: boolean;
@@ -75,8 +75,8 @@ export declare const publicApplicationSchema: z.ZodObject<{
75
75
  websiteUrl?: string | undefined;
76
76
  developerName?: string | undefined;
77
77
  }, {
78
- type: "first_party" | "third_party" | "internal" | "system";
79
78
  id: string;
79
+ type: "first_party" | "third_party" | "internal" | "system";
80
80
  name: string;
81
81
  isOfficial: boolean;
82
82
  isInternal: boolean;
@@ -122,8 +122,8 @@ export declare const sessionStatusSchema: z.ZodObject<{
122
122
  scopes: z.ZodArray<z.ZodString, "many">;
123
123
  developerName: z.ZodOptional<z.ZodString>;
124
124
  }, "strip", z.ZodTypeAny, {
125
- type: "first_party" | "third_party" | "internal" | "system";
126
125
  id: string;
126
+ type: "first_party" | "third_party" | "internal" | "system";
127
127
  name: string;
128
128
  isOfficial: boolean;
129
129
  isInternal: boolean;
@@ -133,8 +133,8 @@ export declare const sessionStatusSchema: z.ZodObject<{
133
133
  websiteUrl?: string | undefined;
134
134
  developerName?: string | undefined;
135
135
  }, {
136
- type: "first_party" | "third_party" | "internal" | "system";
137
136
  id: string;
137
+ type: "first_party" | "third_party" | "internal" | "system";
138
138
  name: string;
139
139
  isOfficial: boolean;
140
140
  isInternal: boolean;
@@ -157,8 +157,8 @@ export declare const sessionStatusSchema: z.ZodObject<{
157
157
  authorized?: boolean | undefined;
158
158
  sessionToken?: string | undefined;
159
159
  application?: {
160
- type: "first_party" | "third_party" | "internal" | "system";
161
160
  id: string;
161
+ type: "first_party" | "third_party" | "internal" | "system";
162
162
  name: string;
163
163
  isOfficial: boolean;
164
164
  isInternal: boolean;
@@ -177,8 +177,8 @@ export declare const sessionStatusSchema: z.ZodObject<{
177
177
  authorized?: boolean | undefined;
178
178
  sessionToken?: string | undefined;
179
179
  application?: {
180
- type: "first_party" | "third_party" | "internal" | "system";
181
180
  id: string;
181
+ type: "first_party" | "third_party" | "internal" | "system";
182
182
  name: string;
183
183
  isOfficial: boolean;
184
184
  isInternal: boolean;
@@ -419,9 +419,9 @@ export declare const refreshAllAccountSchema: z.ZodObject<{
419
419
  }, z.ZodTypeAny, "passthrough">>;
420
420
  }, "strip", z.ZodTypeAny, {
421
421
  expiresAt: string;
422
+ sessionId: string;
422
423
  authuser: number;
423
424
  accessToken: string;
424
- sessionId: string;
425
425
  user: {
426
426
  name: UserNameResponse;
427
427
  id?: string | undefined;
@@ -443,9 +443,9 @@ export declare const refreshAllAccountSchema: z.ZodObject<{
443
443
  };
444
444
  }, {
445
445
  expiresAt: string;
446
+ sessionId: string;
446
447
  authuser: number;
447
448
  accessToken: string;
448
- sessionId: string;
449
449
  user: {
450
450
  name: UserNameResponse;
451
451
  id?: string | undefined;
@@ -568,9 +568,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
568
568
  }, z.ZodTypeAny, "passthrough">>;
569
569
  }, "strip", z.ZodTypeAny, {
570
570
  expiresAt: string;
571
+ sessionId: string;
571
572
  authuser: number;
572
573
  accessToken: string;
573
- sessionId: string;
574
574
  user: {
575
575
  name: UserNameResponse;
576
576
  id?: string | undefined;
@@ -592,9 +592,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
592
592
  };
593
593
  }, {
594
594
  expiresAt: string;
595
+ sessionId: string;
595
596
  authuser: number;
596
597
  accessToken: string;
597
- sessionId: string;
598
598
  user: {
599
599
  name: UserNameResponse;
600
600
  id?: string | undefined;
@@ -618,9 +618,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
618
618
  }, "strip", z.ZodTypeAny, {
619
619
  accounts: {
620
620
  expiresAt: string;
621
+ sessionId: string;
621
622
  authuser: number;
622
623
  accessToken: string;
623
- sessionId: string;
624
624
  user: {
625
625
  name: UserNameResponse;
626
626
  id?: string | undefined;
@@ -644,9 +644,9 @@ export declare const refreshAllResponseSchema: z.ZodObject<{
644
644
  }, {
645
645
  accounts: {
646
646
  expiresAt: string;
647
+ sessionId: string;
647
648
  authuser: number;
648
649
  accessToken: string;
649
- sessionId: string;
650
650
  user: {
651
651
  name: UserNameResponse;
652
652
  id?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/contracts",
3
- "version": "0.6.0",
3
+ "version": "0.8.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",