@oxyhq/contracts 0.6.0 → 0.7.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.
@@ -65,16 +65,9 @@ exports.didDocumentSchema = zod_1.z.object({
65
65
  exports.signedRecordEnvelopeSchema = zod_1.z
66
66
  .object({
67
67
  version: zod_1.z.union([zod_1.z.literal(1), zod_1.z.literal(2)]),
68
- type: zod_1.z.enum([
69
- 'identity',
70
- 'profile',
71
- 'reputation_attestation',
72
- 'real_life_attestation',
73
- 'validation_verdict',
74
- 'personhood_vouch',
75
- 'credential',
76
- 'node',
77
- ]),
68
+ // Open, app-defined category (see the `type` doc above). The Oxy STORE
69
+ // re-narrows to `oxySignedRecordTypeSchema`; an app to its own constant.
70
+ type: zod_1.z.string().min(1),
78
71
  subject: zod_1.z.string(),
79
72
  issuer: zod_1.z.string(),
80
73
  record: zod_1.z.record(zod_1.z.unknown()),
package/dist/cjs/index.js CHANGED
@@ -11,8 +11,8 @@
11
11
  * expo, no `require()` in the ESM build.
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.verifiableCredentialResponseSchema = exports.credentialRecordSchema = exports.vouchResultSchema = exports.personhoodStatusResultSchema = exports.personhoodBreakdownSchema = exports.personhoodVouchRecordSchema = exports.validationVoteResultSchema = exports.validationRequestSummarySchema = exports.validationOpenResultSchema = exports.validationOpenRequestSchema = exports.validationVerdictRecordSchema = exports.realLifeAttestationResultSchema = exports.realLifeAttestationRecordSchema = exports.signedPublicCardSchema = exports.publicCardSchema = exports.exportBundleSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = exports.appUserSignalIngestSchema = exports.appInterestInputSchema = exports.appEndorsementInputSchema = exports.recommendationResponseSchema = exports.recommendationItemSchema = exports.recommendationCountSchema = exports.recommendationRequestSchema = exports.recommendationSignalWeightsSchema = exports.recommendationBoostSchema = exports.recommendationExcludeTypeSchema = exports.fedcmTokenPayloadSchema = exports.sessionStatusSchema = exports.publicApplicationSchema = exports.applicationTypeSchema = exports.safeParseContract = exports.resolveUserId = exports.deviceSessionsResponseSchema = exports.deviceSessionAccountSchema = exports.currentUserResponseSchema = exports.refreshAllResponseSchema = exports.refreshAllAccountSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.userNameSchema = void 0;
15
- exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = void 0;
14
+ exports.personhoodStatusResultSchema = exports.personhoodBreakdownSchema = exports.personhoodVouchRecordSchema = exports.validationVoteResultSchema = exports.validationRequestSummarySchema = exports.validationOpenResultSchema = exports.validationOpenRequestSchema = exports.validationVerdictRecordSchema = exports.realLifeAttestationResultSchema = exports.realLifeAttestationRecordSchema = exports.signedPublicCardSchema = exports.publicCardSchema = exports.logPageResponseSchema = exports.chainHeadResponseSchema = exports.oxySignedRecordTypeSchema = exports.exportBundleSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = exports.appUserSignalIngestSchema = exports.appInterestInputSchema = exports.appEndorsementInputSchema = exports.recommendationResponseSchema = exports.recommendationItemSchema = exports.recommendationCountSchema = exports.recommendationRequestSchema = exports.recommendationSignalWeightsSchema = exports.recommendationBoostSchema = exports.recommendationExcludeTypeSchema = exports.fedcmTokenPayloadSchema = exports.sessionStatusSchema = exports.publicApplicationSchema = exports.applicationTypeSchema = exports.safeParseContract = exports.resolveUserId = exports.deviceSessionsResponseSchema = exports.deviceSessionAccountSchema = exports.currentUserResponseSchema = exports.refreshAllResponseSchema = exports.refreshAllAccountSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.userNameSchema = void 0;
15
+ exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = exports.verifiableCredentialResponseSchema = exports.credentialRecordSchema = exports.vouchResultSchema = void 0;
16
16
  var userResponse_1 = require("./userResponse");
17
17
  // Schemas
18
18
  Object.defineProperty(exports, "userNameSchema", { enumerable: true, get: function () { return userResponse_1.userNameSchema; } });
@@ -59,6 +59,13 @@ Object.defineProperty(exports, "authMethodEntrySchema", { enumerable: true, get:
59
59
  Object.defineProperty(exports, "authMethodsResponseSchema", { enumerable: true, get: function () { return identity_1.authMethodsResponseSchema; } });
60
60
  Object.defineProperty(exports, "exportAttestationSchema", { enumerable: true, get: function () { return identity_1.exportAttestationSchema; } });
61
61
  Object.defineProperty(exports, "exportBundleSchema", { enumerable: true, get: function () { return identity_1.exportBundleSchema; } });
62
+ var oxyRecordTypes_1 = require("./oxyRecordTypes");
63
+ // Schemas
64
+ Object.defineProperty(exports, "oxySignedRecordTypeSchema", { enumerable: true, get: function () { return oxyRecordTypes_1.oxySignedRecordTypeSchema; } });
65
+ var protocol_1 = require("./protocol");
66
+ // Schemas
67
+ Object.defineProperty(exports, "chainHeadResponseSchema", { enumerable: true, get: function () { return protocol_1.chainHeadResponseSchema; } });
68
+ Object.defineProperty(exports, "logPageResponseSchema", { enumerable: true, get: function () { return protocol_1.logPageResponseSchema; } });
62
69
  var civic_1 = require("./civic");
63
70
  // Schemas
64
71
  Object.defineProperty(exports, "publicCardSchema", { enumerable: true, get: function () { return civic_1.publicCardSchema; } });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * Oxy-scoped signed-record types.
4
+ *
5
+ * The base `signedRecordEnvelopeSchema` (`./identity`) now treats `type` as an
6
+ * OPEN, non-empty string so ANY Oxy app may define its own record categories
7
+ * (e.g. `app.mention.*`'s `app_record`) on the shared envelope grammar. The Oxy
8
+ * identity/civic/node STORE, however, accepts ONLY the closed set of categories
9
+ * it knows how to verify and materialize — this module is that closed set.
10
+ *
11
+ * `oxySignedRecordTypeSchema` is the runtime gate the Oxy store re-narrows with
12
+ * (the API's `verifyEnvelope` rejects any `type` outside it; the Mongoose
13
+ * `SignedRecord.type` enum is derived from `.options`); `OxySignedRecordType` is
14
+ * the matching compile-time union the SDK identity/civic mixins type against.
15
+ *
16
+ * The signing input INCLUDES `type`, so this set is part of the signed bytes —
17
+ * a record cannot have its category swapped after signing.
18
+ *
19
+ * v1 only ever carried `identity` / `profile` (already in production); v2 added
20
+ * the civic record types (reputation attestations, real-life / peer validations,
21
+ * personhood vouches, verifiable credentials) and the user-node registration
22
+ * record. Every value here is an Oxy `app.oxy.*` (or legacy v1) category — an
23
+ * app's own `type` (e.g. `app_record`) is intentionally NOT in this set and is
24
+ * rejected by the Oxy store.
25
+ *
26
+ * Platform-agnostic — zod only, no react/react-native/expo, ESM-safe.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.oxySignedRecordTypeSchema = void 0;
30
+ const zod_1 = require("zod");
31
+ exports.oxySignedRecordTypeSchema = zod_1.z.enum([
32
+ 'identity',
33
+ 'profile',
34
+ 'reputation_attestation',
35
+ 'real_life_attestation',
36
+ 'validation_verdict',
37
+ 'personhood_vouch',
38
+ 'credential',
39
+ 'node',
40
+ ]);
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /**
3
+ * Generic "Oxy Protocol" record surface — the app-agnostic conventions every app
4
+ * follows to decentralize its own content on the shared signed-record substrate.
5
+ *
6
+ * The base `signedRecordEnvelopeSchema` (`./identity`) is the WIRE grammar: a
7
+ * signed envelope whose `type` is an open string and whose `record` is an opaque
8
+ * `Record<string, unknown>`. An app layers its own LEXICON on top of that
9
+ * grammar — a typed projection of the `record` payload, addressed by an
10
+ * AtProto-style `(collection, rkey)` key — WITHOUT forking the envelope schema.
11
+ *
12
+ * ## Recipe — defining an app lexicon record
13
+ *
14
+ * For each record kind an app wants to publish:
15
+ *
16
+ * 1. Define the `record` PAYLOAD schema as a `z.ZodType<XPayload>` (e.g.
17
+ * `app.mention.feed.post` → `mentionPostRecordSchema: z.ZodType<MentionPost>`).
18
+ * This validates ONLY the inner `record`, not the envelope.
19
+ * 2. Declare the `collection` NSID as a constant (e.g.
20
+ * `export const MENTION_POST_COLLECTION = 'app.mention.feed.post'`).
21
+ * 3. Reuse the UNCHANGED {@link signedRecordEnvelopeSchema} for the envelope. The
22
+ * base treats `record` as `z.record(z.unknown())`, so the app validates the
23
+ * envelope with the base schema first, then parses `envelope.record` with its
24
+ * own payload schema. {@link LexiconRecord} is the typed projection that pairs
25
+ * the `(collection, rkey)` key with the parsed payload.
26
+ *
27
+ * The Oxy civic contracts (`./civic`) already follow this convention implicitly:
28
+ * each civic record (`real_life_attestation`, `personhood_vouch`, `credential`,
29
+ * …) ships a `record`-payload schema and is carried by the base envelope.
30
+ *
31
+ * ## Chain-wire shapes
32
+ *
33
+ * {@link ChainHeadResponse} and {@link LogPageResponse} are the shared response
34
+ * shapes every chain store exposes (Oxy's `GET /identity/records/:userId/chain/head`,
35
+ * `GET /identity/head/:userId`, `GET /identity/log/:userId`, and any app node's
36
+ * equivalents). They are defined ONCE here so producers and consumers (the API
37
+ * handlers, the SDK identity/nodes mixins, app nodes) cannot drift.
38
+ *
39
+ * Platform-agnostic — zod only, no react/react-native/expo, ESM-safe.
40
+ */
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.logPageResponseSchema = exports.chainHeadResponseSchema = void 0;
43
+ const zod_1 = require("zod");
44
+ const identity_1 = require("./identity");
45
+ exports.chainHeadResponseSchema = zod_1.z.object({
46
+ headRecordId: zod_1.z.string().nullable(),
47
+ seq: zod_1.z.number().int(),
48
+ recordCount: zod_1.z.number().int().nonnegative(),
49
+ });
50
+ exports.logPageResponseSchema = zod_1.z.object({
51
+ records: zod_1.z.array(identity_1.signedRecordEnvelopeSchema),
52
+ count: zod_1.z.number().int().nonnegative(),
53
+ });