@oxyhq/contracts 0.20.0 → 0.22.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.
@@ -1,14 +1,76 @@
1
1
  "use strict";
2
2
  /**
3
- * Account graph wire contracts — organization taxonomy and create-account input.
3
+ * Account graph wire contracts — the account-kind vocabulary, organization
4
+ * taxonomy, and create-account input.
4
5
  *
5
6
  * `organizationCategory` classifies `kind: 'organization'` accounts (agency,
6
7
  * cooperative, landlord, …) without polluting `User.kind`. Meaningful only when
7
8
  * `kind === 'organization'`.
8
9
  */
9
10
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createAccountRequestSchema = exports.organizationCategorySchema = exports.ORGANIZATION_CATEGORIES = void 0;
11
+ exports.createAccountRequestSchema = exports.organizationCategorySchema = exports.ORGANIZATION_CATEGORIES = exports.childAccountKindSchema = exports.CHILD_ACCOUNT_KINDS = exports.accountKindSchema = exports.ACCOUNT_KINDS = void 0;
12
+ exports.isActAsEligibleKind = isActAsEligibleKind;
13
+ exports.isAccountKind = isAccountKind;
11
14
  const zod_1 = require("zod");
15
+ /**
16
+ * The union is spelled out above and the array proves coverage BOTH ways
17
+ * (`satisfies` here, the `Gap` alias below) — the same shape this package's
18
+ * `ORGANIZATION_CATEGORIES` / `TRUST_TIERS` pairs use, and the one
19
+ * `db/schema/users.ts` mirrors to keep the `users_kind_check` CHECK honest.
20
+ *
21
+ * Deriving the union from the array instead would cost nothing here and be paid
22
+ * by consumers: `kind` travels into `@oxyhq/services` through
23
+ * `SwitchableAccount`, where an indexed-access type is materially more
24
+ * expensive to check than a literal union.
25
+ */
26
+ exports.ACCOUNT_KINDS = [
27
+ 'personal',
28
+ 'organization',
29
+ 'project',
30
+ 'bot',
31
+ 'channel',
32
+ ];
33
+ exports.accountKindSchema = zod_1.z.enum(exports.ACCOUNT_KINDS);
34
+ exports.CHILD_ACCOUNT_KINDS = [
35
+ 'organization',
36
+ 'project',
37
+ 'bot',
38
+ 'channel',
39
+ ];
40
+ exports.childAccountKindSchema = zod_1.z.enum(exports.CHILD_ACCOUNT_KINDS);
41
+ /**
42
+ * Whether an operator may ACT AS an account of this kind — switch the whole app
43
+ * into it (`POST /accounts/:id/switch`) or authorise an app to act as it
44
+ * (an OAuth delegated subject).
45
+ *
46
+ * Two kinds are refused, for opposite reasons:
47
+ *
48
+ * - `personal` is a human login, so assuming it would be impersonation.
49
+ * - `channel` is a CONTENT identity, not an operating one. A channel exists so
50
+ * that posts can be authored BY it; it is never a seat anybody occupies. Its
51
+ * operators act on it through their own membership, and an application
52
+ * publishes to it with its own credential. Refusing act-as is what makes
53
+ * "no login, ever" structural rather than incidental: no session can be
54
+ * minted whose subject is a channel, so no bearer exists that could add an
55
+ * auth method to one (every auth-method write resolves its target from the
56
+ * authenticated subject, never from a parameter).
57
+ *
58
+ * Consumers must gate on this predicate rather than testing `kind === 'personal'`,
59
+ * which silently admits every kind added after it was written.
60
+ */
61
+ function isActAsEligibleKind(kind) {
62
+ return kind === 'organization' || kind === 'project' || kind === 'bot';
63
+ }
64
+ /**
65
+ * Narrow an unknown value to an {@link AccountKind}.
66
+ *
67
+ * The user-DTO serializers read from structurally-permissive `unknown` sources
68
+ * (a Drizzle row, a Mongo document, an already-formatted object), so each one
69
+ * would otherwise hand-roll this check and they would drift on what counts.
70
+ */
71
+ function isAccountKind(value) {
72
+ return typeof value === 'string' && exports.ACCOUNT_KINDS.includes(value);
73
+ }
12
74
  exports.ORGANIZATION_CATEGORIES = [
13
75
  'agency',
14
76
  'cooperative',
@@ -16,10 +78,25 @@ exports.ORGANIZATION_CATEGORIES = [
16
78
  'other',
17
79
  ];
18
80
  exports.organizationCategorySchema = zod_1.z.enum(exports.ORGANIZATION_CATEGORIES);
81
+ /**
82
+ * An account's name on the create/update wire.
83
+ *
84
+ * `displayName` is EXPLICIT and stored, not derived. `first`/`last` model a
85
+ * human name, and composing a display string from them is right for a person —
86
+ * but a non-personal account has a TITLE, not a given and family name. Without
87
+ * this field the only way to name a channel "Notas de Nate" was to put the whole
88
+ * title in `first`, which renders correctly by accident while recording it as
89
+ * somebody's given name.
90
+ *
91
+ * When present it wins over the composed `first`/`last` (see the API's
92
+ * `composeDisplayName`, which already preferred an explicit value — only the
93
+ * storage for one was missing).
94
+ */
19
95
  const accountNameSchema = zod_1.z
20
96
  .object({
21
97
  first: zod_1.z.string().trim().max(100).optional(),
22
98
  last: zod_1.z.string().trim().max(100).optional(),
99
+ displayName: zod_1.z.string().trim().max(100).optional(),
23
100
  })
24
101
  .optional();
25
102
  /**
@@ -29,7 +106,7 @@ const accountNameSchema = zod_1.z
29
106
  exports.createAccountRequestSchema = zod_1.z
30
107
  .object({
31
108
  parentAccountId: zod_1.z.string().trim().min(1).optional(),
32
- kind: zod_1.z.enum(['organization', 'project', 'bot']),
109
+ kind: exports.childAccountKindSchema,
33
110
  username: zod_1.z.string().trim().min(1).max(100),
34
111
  name: accountNameSchema,
35
112
  bio: zod_1.z.string().trim().max(500).optional(),
package/dist/cjs/index.js CHANGED
@@ -11,11 +11,18 @@
11
11
  * expo, no `require()` in the ESM build.
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- 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.appAffinityEventsIngestSchema = exports.appAffinityEventSchema = exports.appAffinityEventTypeSchema = exports.appUserSignalIngestSchema = exports.appInterestInputSchema = exports.appEndorsementInputSchema = exports.recommendationResponseSchema = exports.recommendationItemSchema = exports.recommendationCountSchema = exports.recommendationRequestSchema = exports.recommendationSignalWeightsSchema = exports.recommendationBoostSchema = exports.recommendationExcludeTypeSchema = exports.inboxEmailPushDataSchema = exports.INBOX_EMAIL_PUSH_TYPE = exports.INBOX_EMAIL_PUSH_CHANNEL = exports.IDENTITY_APPROVAL_PUSH_CHANNEL = exports.commonsDenyReasonSchema = exports.COMMONS_DENY_REASONS = exports.sessionStatusSchema = exports.publicApplicationSchema = exports.applicationTypeSchema = exports.safeParseContract = exports.resolveUserId = exports.deviceLinkedSessionsResponseSchema = exports.deviceLinkedSessionSchema = exports.currentUserResponseSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.themePreferenceSchema = exports.userRelationshipSchema = exports.userNameSchema = exports.createAccountRequestSchema = exports.organizationCategorySchema = exports.ORGANIZATION_CATEGORIES = void 0;
15
- exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.isFullReputationBalance = exports.reverseReputationTransactionSchema = exports.upsertReputationRuleSchema = exports.resolveReputationDisputeSchema = exports.createReputationDisputeSchema = exports.awardReputationSchema = exports.reverseReputationTransactionResultSchema = exports.reputationInfluenceResultSchema = exports.reputationLeaderboardEntrySchema = exports.reputationLeaderboardUserSchema = exports.reputationRuleSchema = exports.reputationDisputeSchema = exports.reputationBalanceSchema = exports.reputationBalanceSummarySchema = exports.reputationReliabilitySchema = exports.reputationInfluenceSchema = exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema = exports.reputationInfluenceContextSchema = exports.reputationDisputeStatusSchema = exports.reputationTargetEntityTypeSchema = exports.trustTierSchema = exports.reputationTransactionStatusSchema = exports.reputationCategorySchema = exports.REPUTATION_INFLUENCE_CONTEXTS = exports.REPUTATION_DISPUTE_STATUSES = exports.REPUTATION_TARGET_ENTITY_TYPES = exports.TRUST_TIERS = exports.REPUTATION_TRANSACTION_STATUSES = exports.REPUTATION_CATEGORIES = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = 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 = void 0;
16
- exports.webauthnRegisterVerifyRequestSchema = exports.webauthnLoginOptionsRequestSchema = exports.webauthnRegisterOptionsRequestSchema = exports.updateRolloutPatchSchema = exports.promoteRequestSchema = exports.rollbackToEmbeddedRequestSchema = exports.rollbackRequestSchema = exports.updateListResponseSchema = exports.channelListResponseSchema = exports.channelSchema = exports.rollbackToEmbeddedEntrySchema = exports.createUpdateResponseSchema = exports.updateSchema = exports.createUpdateRequestSchema = exports.updateAssetRefSchema = exports.assetCompleteResponseSchema = exports.assetCompleteResultItemSchema = exports.assetCompleteRequestSchema = exports.assetInitResponseSchema = exports.assetUploadTicketSchema = exports.assetInitRequestSchema = exports.assetInitItemSchema = exports.rolloutPercentSchema = exports.runtimeVersionSchema = exports.channelNameSchema = exports.sha256HexSchema = exports.updateAssetStatusSchema = exports.updateStatusSchema = exports.updatePlatformSchema = exports.backupStatusResponseSchema = exports.backupUploadRequestSchema = exports.encryptedBackupEnvelopeSchema = exports.backupLookupIdSchema = exports.rotateKeyCompleteResponseSchema = exports.rotateKeyCompleteRequestSchema = exports.rotateKeyChallengeResponseSchema = exports.loginResultSchema = exports.sessionAccountsChangedEventSchema = exports.sessionAccountsChangedReasonSchema = exports.SESSION_ACCOUNTS_CHANGED_EVENT = exports.deviceBackgroundTokenResponseSchema = exports.deviceBackgroundTokenRequestSchema = exports.deviceBackgroundCredentialResponseSchema = exports.deviceTokenMintResponseSchema = exports.deviceTokenMintRequestSchema = exports.deviceSessionSyncSchema = exports.activeTokenSchema = exports.deviceSessionStateSchema = exports.sessionAccountSchema = exports.linkPreviewResponseSchema = void 0;
17
- exports.transparencyCheckpointListSchema = exports.transparencyInclusionProofSchema = exports.transparencyCheckpointSchema = exports.transparencyAnchorSchema = exports.transparencyCheckpointSignatureSchema = exports.deviceTransferDenyResponseSchema = exports.deviceTransferApproveResponseSchema = exports.deviceTransferApproveRequestSchema = exports.deviceTransferInfoResponseSchema = exports.deviceTransferInitResponseSchema = exports.deviceTransferInitRequestSchema = exports.devicePairingStatusSchema = exports.webauthnLoginVerifyRequestSchema = void 0;
14
+ exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = exports.appAffinityEventsIngestSchema = exports.appAffinityEventSchema = exports.appAffinityEventTypeSchema = exports.appUserSignalIngestSchema = exports.appInterestInputSchema = exports.appEndorsementInputSchema = exports.recommendationResponseSchema = exports.recommendationItemSchema = exports.recommendationCountSchema = exports.recommendationRequestSchema = exports.recommendationSignalWeightsSchema = exports.recommendationBoostSchema = exports.recommendationExcludeTypeSchema = exports.oxyUserInvalidationEventSchema = exports.isPublishedOxyUserChangeReason = exports.OXY_PUBLISHED_USER_CHANGE_REASONS = exports.OXY_USER_CHANGE_REASONS = exports.OXY_USER_INVALIDATION_CHANNEL = exports.inboxEmailPushDataSchema = exports.INBOX_EMAIL_PUSH_TYPE = exports.INBOX_EMAIL_PUSH_CHANNEL = exports.IDENTITY_APPROVAL_PUSH_CHANNEL = exports.commonsDenyReasonSchema = exports.COMMONS_DENY_REASONS = exports.sessionStatusSchema = exports.publicApplicationSchema = exports.applicationTypeSchema = exports.safeParseContract = exports.resolveUserId = exports.deviceLinkedSessionsResponseSchema = exports.deviceLinkedSessionSchema = exports.currentUserResponseSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.themePreferenceSchema = exports.userRelationshipSchema = exports.userNameSchema = exports.createAccountRequestSchema = exports.organizationCategorySchema = exports.ORGANIZATION_CATEGORIES = exports.isActAsEligibleKind = exports.isAccountKind = exports.childAccountKindSchema = exports.CHILD_ACCOUNT_KINDS = exports.accountKindSchema = exports.ACCOUNT_KINDS = void 0;
15
+ exports.reputationLeaderboardEntrySchema = exports.reputationLeaderboardUserSchema = exports.reputationRuleSchema = exports.reputationDisputeSchema = exports.reputationBalanceSchema = exports.reputationBalanceSummarySchema = exports.reputationReliabilitySchema = exports.reputationInfluenceSchema = exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema = exports.reputationInfluenceContextSchema = exports.reputationDisputeStatusSchema = exports.reputationTargetEntityTypeSchema = exports.trustTierSchema = exports.reputationTransactionStatusSchema = exports.reputationCategorySchema = exports.REPUTATION_INFLUENCE_CONTEXTS = exports.REPUTATION_DISPUTE_STATUSES = exports.REPUTATION_TARGET_ENTITY_TYPES = exports.TRUST_TIERS = exports.REPUTATION_TRANSACTION_STATUSES = exports.REPUTATION_CATEGORIES = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = 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.logPageResponseSchema = exports.chainHeadResponseSchema = exports.oxySignedRecordTypeSchema = exports.exportBundleSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = void 0;
16
+ exports.reputationConductSchema = exports.reputationContributionSchema = exports.reputationPersonhoodSchema = exports.identityBindingSchema = exports.registerIdentityBindingSchema = exports.reverseModerationEffectResultSchema = exports.applyModerationDecisionResultSchema = exports.moderationEffectSchema = exports.reverseModerationEffectSchema = exports.finalizeModerationDecisionSchema = exports.moderationDecisionEventSchema = exports.moderationPolicyVersionsSchema = exports.moderationDecisionEventSubjectSchema = exports.moderationFindingSchema = exports.applicationModerationStandingSchema = exports.identityBindingStatusSchema = exports.identityBindingTypeSchema = exports.personhoodStatusSchema = exports.contributionTierSchema = exports.conductStandingSchema = exports.conductStrikeStatusSchema = exports.moderationEffectSkipReasonSchema = exports.moderationEffectStatusSchema = exports.moderationEffectTypeSchema = exports.moderationDecisionStatusSchema = exports.moderationAttributionSchema = exports.moderationFindingScopeSchema = exports.moderationSeveritySchema = exports.APPLICATION_MODERATION_STANDINGS = exports.IDENTITY_BINDING_STATUSES = exports.IDENTITY_BINDING_TYPES = exports.PERSONHOOD_STATUSES = exports.CONTRIBUTION_TIERS = exports.CONDUCT_STANDINGS = exports.CONDUCT_STRIKE_STATUSES = exports.MODERATION_EFFECT_SKIP_REASONS = exports.MODERATION_EFFECT_STATUSES = exports.MODERATION_EFFECT_TYPES = exports.MODERATION_DECISION_STATUSES = exports.MODERATION_ATTRIBUTIONS = exports.MODERATION_FINDING_SCOPES = exports.MODERATION_SEVERITIES = exports.isFullReputationBalance = exports.reverseReputationTransactionSchema = exports.upsertReputationRuleSchema = exports.resolveReputationDisputeSchema = exports.createReputationDisputeSchema = exports.awardReputationSchema = exports.reverseReputationTransactionResultSchema = exports.reputationInfluenceResultSchema = void 0;
17
+ exports.updateListResponseSchema = exports.channelListResponseSchema = exports.channelSchema = exports.rollbackToEmbeddedEntrySchema = exports.createUpdateResponseSchema = exports.updateSchema = exports.createUpdateRequestSchema = exports.updateAssetRefSchema = exports.assetCompleteResponseSchema = exports.assetCompleteResultItemSchema = exports.assetCompleteRequestSchema = exports.assetInitResponseSchema = exports.assetUploadTicketSchema = exports.assetInitRequestSchema = exports.assetInitItemSchema = exports.rolloutPercentSchema = exports.runtimeVersionSchema = exports.channelNameSchema = exports.sha256HexSchema = exports.updateAssetStatusSchema = exports.updateStatusSchema = exports.updatePlatformSchema = exports.backupStatusResponseSchema = exports.backupUploadRequestSchema = exports.encryptedBackupEnvelopeSchema = exports.backupLookupIdSchema = exports.rotateKeyCompleteResponseSchema = exports.rotateKeyCompleteRequestSchema = exports.rotateKeyChallengeResponseSchema = exports.loginResultSchema = exports.sessionAccountsChangedEventSchema = exports.sessionAccountsChangedReasonSchema = exports.SESSION_ACCOUNTS_CHANGED_EVENT = exports.deviceBackgroundTokenResponseSchema = exports.deviceBackgroundTokenRequestSchema = exports.deviceBackgroundCredentialResponseSchema = exports.deviceTokenMintResponseSchema = exports.deviceTokenMintRequestSchema = exports.deviceSessionSyncSchema = exports.activeTokenSchema = exports.deviceSessionStateSchema = exports.sessionAccountSchema = exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.applicationModerationTrustSchema = exports.reputationContextualInfluenceSchema = exports.reputationReviewingSchema = exports.reputationReportingSchema = void 0;
18
+ exports.transparencyCheckpointListSchema = exports.transparencyInclusionProofSchema = exports.transparencyCheckpointSchema = exports.transparencyAnchorSchema = exports.transparencyCheckpointSignatureSchema = exports.deviceTransferDenyResponseSchema = exports.deviceTransferApproveResponseSchema = exports.deviceTransferApproveRequestSchema = exports.deviceTransferInfoResponseSchema = exports.deviceTransferInitResponseSchema = exports.deviceTransferInitRequestSchema = exports.devicePairingStatusSchema = exports.webauthnLoginVerifyRequestSchema = exports.webauthnRegisterVerifyRequestSchema = exports.webauthnLoginOptionsRequestSchema = exports.webauthnRegisterOptionsRequestSchema = exports.updateRolloutPatchSchema = exports.promoteRequestSchema = exports.rollbackToEmbeddedRequestSchema = exports.rollbackRequestSchema = void 0;
18
19
  var accountGraph_1 = require("./accountGraph");
20
+ Object.defineProperty(exports, "ACCOUNT_KINDS", { enumerable: true, get: function () { return accountGraph_1.ACCOUNT_KINDS; } });
21
+ Object.defineProperty(exports, "accountKindSchema", { enumerable: true, get: function () { return accountGraph_1.accountKindSchema; } });
22
+ Object.defineProperty(exports, "CHILD_ACCOUNT_KINDS", { enumerable: true, get: function () { return accountGraph_1.CHILD_ACCOUNT_KINDS; } });
23
+ Object.defineProperty(exports, "childAccountKindSchema", { enumerable: true, get: function () { return accountGraph_1.childAccountKindSchema; } });
24
+ Object.defineProperty(exports, "isAccountKind", { enumerable: true, get: function () { return accountGraph_1.isAccountKind; } });
25
+ Object.defineProperty(exports, "isActAsEligibleKind", { enumerable: true, get: function () { return accountGraph_1.isActAsEligibleKind; } });
19
26
  Object.defineProperty(exports, "ORGANIZATION_CATEGORIES", { enumerable: true, get: function () { return accountGraph_1.ORGANIZATION_CATEGORIES; } });
20
27
  Object.defineProperty(exports, "organizationCategorySchema", { enumerable: true, get: function () { return accountGraph_1.organizationCategorySchema; } });
21
28
  Object.defineProperty(exports, "createAccountRequestSchema", { enumerable: true, get: function () { return accountGraph_1.createAccountRequestSchema; } });
@@ -48,6 +55,12 @@ var inboxPush_1 = require("./inboxPush");
48
55
  Object.defineProperty(exports, "INBOX_EMAIL_PUSH_CHANNEL", { enumerable: true, get: function () { return inboxPush_1.INBOX_EMAIL_PUSH_CHANNEL; } });
49
56
  Object.defineProperty(exports, "INBOX_EMAIL_PUSH_TYPE", { enumerable: true, get: function () { return inboxPush_1.INBOX_EMAIL_PUSH_TYPE; } });
50
57
  Object.defineProperty(exports, "inboxEmailPushDataSchema", { enumerable: true, get: function () { return inboxPush_1.inboxEmailPushDataSchema; } });
58
+ var userInvalidation_1 = require("./userInvalidation");
59
+ Object.defineProperty(exports, "OXY_USER_INVALIDATION_CHANNEL", { enumerable: true, get: function () { return userInvalidation_1.OXY_USER_INVALIDATION_CHANNEL; } });
60
+ Object.defineProperty(exports, "OXY_USER_CHANGE_REASONS", { enumerable: true, get: function () { return userInvalidation_1.OXY_USER_CHANGE_REASONS; } });
61
+ Object.defineProperty(exports, "OXY_PUBLISHED_USER_CHANGE_REASONS", { enumerable: true, get: function () { return userInvalidation_1.OXY_PUBLISHED_USER_CHANGE_REASONS; } });
62
+ Object.defineProperty(exports, "isPublishedOxyUserChangeReason", { enumerable: true, get: function () { return userInvalidation_1.isPublishedOxyUserChangeReason; } });
63
+ Object.defineProperty(exports, "oxyUserInvalidationEventSchema", { enumerable: true, get: function () { return userInvalidation_1.oxyUserInvalidationEventSchema; } });
51
64
  var recommendations_1 = require("./recommendations");
52
65
  // Schemas
53
66
  Object.defineProperty(exports, "recommendationExcludeTypeSchema", { enumerable: true, get: function () { return recommendations_1.recommendationExcludeTypeSchema; } });
@@ -142,6 +155,58 @@ Object.defineProperty(exports, "upsertReputationRuleSchema", { enumerable: true,
142
155
  Object.defineProperty(exports, "reverseReputationTransactionSchema", { enumerable: true, get: function () { return reputation_1.reverseReputationTransactionSchema; } });
143
156
  // Narrows the two balance views apart at runtime.
144
157
  Object.defineProperty(exports, "isFullReputationBalance", { enumerable: true, get: function () { return reputation_1.isFullReputationBalance; } });
158
+ var moderationReputation_1 = require("./moderationReputation");
159
+ // Closed value sets — the moderation reputation bridge (CrowdSource → Oxy Trust).
160
+ Object.defineProperty(exports, "MODERATION_SEVERITIES", { enumerable: true, get: function () { return moderationReputation_1.MODERATION_SEVERITIES; } });
161
+ Object.defineProperty(exports, "MODERATION_FINDING_SCOPES", { enumerable: true, get: function () { return moderationReputation_1.MODERATION_FINDING_SCOPES; } });
162
+ Object.defineProperty(exports, "MODERATION_ATTRIBUTIONS", { enumerable: true, get: function () { return moderationReputation_1.MODERATION_ATTRIBUTIONS; } });
163
+ Object.defineProperty(exports, "MODERATION_DECISION_STATUSES", { enumerable: true, get: function () { return moderationReputation_1.MODERATION_DECISION_STATUSES; } });
164
+ Object.defineProperty(exports, "MODERATION_EFFECT_TYPES", { enumerable: true, get: function () { return moderationReputation_1.MODERATION_EFFECT_TYPES; } });
165
+ Object.defineProperty(exports, "MODERATION_EFFECT_STATUSES", { enumerable: true, get: function () { return moderationReputation_1.MODERATION_EFFECT_STATUSES; } });
166
+ Object.defineProperty(exports, "MODERATION_EFFECT_SKIP_REASONS", { enumerable: true, get: function () { return moderationReputation_1.MODERATION_EFFECT_SKIP_REASONS; } });
167
+ Object.defineProperty(exports, "CONDUCT_STRIKE_STATUSES", { enumerable: true, get: function () { return moderationReputation_1.CONDUCT_STRIKE_STATUSES; } });
168
+ Object.defineProperty(exports, "CONDUCT_STANDINGS", { enumerable: true, get: function () { return moderationReputation_1.CONDUCT_STANDINGS; } });
169
+ Object.defineProperty(exports, "CONTRIBUTION_TIERS", { enumerable: true, get: function () { return moderationReputation_1.CONTRIBUTION_TIERS; } });
170
+ Object.defineProperty(exports, "PERSONHOOD_STATUSES", { enumerable: true, get: function () { return moderationReputation_1.PERSONHOOD_STATUSES; } });
171
+ Object.defineProperty(exports, "IDENTITY_BINDING_TYPES", { enumerable: true, get: function () { return moderationReputation_1.IDENTITY_BINDING_TYPES; } });
172
+ Object.defineProperty(exports, "IDENTITY_BINDING_STATUSES", { enumerable: true, get: function () { return moderationReputation_1.IDENTITY_BINDING_STATUSES; } });
173
+ Object.defineProperty(exports, "APPLICATION_MODERATION_STANDINGS", { enumerable: true, get: function () { return moderationReputation_1.APPLICATION_MODERATION_STANDINGS; } });
174
+ // Schemas — closed value sets
175
+ Object.defineProperty(exports, "moderationSeveritySchema", { enumerable: true, get: function () { return moderationReputation_1.moderationSeveritySchema; } });
176
+ Object.defineProperty(exports, "moderationFindingScopeSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationFindingScopeSchema; } });
177
+ Object.defineProperty(exports, "moderationAttributionSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationAttributionSchema; } });
178
+ Object.defineProperty(exports, "moderationDecisionStatusSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationDecisionStatusSchema; } });
179
+ Object.defineProperty(exports, "moderationEffectTypeSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationEffectTypeSchema; } });
180
+ Object.defineProperty(exports, "moderationEffectStatusSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationEffectStatusSchema; } });
181
+ Object.defineProperty(exports, "moderationEffectSkipReasonSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationEffectSkipReasonSchema; } });
182
+ Object.defineProperty(exports, "conductStrikeStatusSchema", { enumerable: true, get: function () { return moderationReputation_1.conductStrikeStatusSchema; } });
183
+ Object.defineProperty(exports, "conductStandingSchema", { enumerable: true, get: function () { return moderationReputation_1.conductStandingSchema; } });
184
+ Object.defineProperty(exports, "contributionTierSchema", { enumerable: true, get: function () { return moderationReputation_1.contributionTierSchema; } });
185
+ Object.defineProperty(exports, "personhoodStatusSchema", { enumerable: true, get: function () { return moderationReputation_1.personhoodStatusSchema; } });
186
+ Object.defineProperty(exports, "identityBindingTypeSchema", { enumerable: true, get: function () { return moderationReputation_1.identityBindingTypeSchema; } });
187
+ Object.defineProperty(exports, "identityBindingStatusSchema", { enumerable: true, get: function () { return moderationReputation_1.identityBindingStatusSchema; } });
188
+ Object.defineProperty(exports, "applicationModerationStandingSchema", { enumerable: true, get: function () { return moderationReputation_1.applicationModerationStandingSchema; } });
189
+ // Schemas — the event and its receipt
190
+ Object.defineProperty(exports, "moderationFindingSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationFindingSchema; } });
191
+ Object.defineProperty(exports, "moderationDecisionEventSubjectSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationDecisionEventSubjectSchema; } });
192
+ Object.defineProperty(exports, "moderationPolicyVersionsSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationPolicyVersionsSchema; } });
193
+ Object.defineProperty(exports, "moderationDecisionEventSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationDecisionEventSchema; } });
194
+ Object.defineProperty(exports, "finalizeModerationDecisionSchema", { enumerable: true, get: function () { return moderationReputation_1.finalizeModerationDecisionSchema; } });
195
+ Object.defineProperty(exports, "reverseModerationEffectSchema", { enumerable: true, get: function () { return moderationReputation_1.reverseModerationEffectSchema; } });
196
+ Object.defineProperty(exports, "moderationEffectSchema", { enumerable: true, get: function () { return moderationReputation_1.moderationEffectSchema; } });
197
+ Object.defineProperty(exports, "applyModerationDecisionResultSchema", { enumerable: true, get: function () { return moderationReputation_1.applyModerationDecisionResultSchema; } });
198
+ Object.defineProperty(exports, "reverseModerationEffectResultSchema", { enumerable: true, get: function () { return moderationReputation_1.reverseModerationEffectResultSchema; } });
199
+ // Schemas — identity binding
200
+ Object.defineProperty(exports, "registerIdentityBindingSchema", { enumerable: true, get: function () { return moderationReputation_1.registerIdentityBindingSchema; } });
201
+ Object.defineProperty(exports, "identityBindingSchema", { enumerable: true, get: function () { return moderationReputation_1.identityBindingSchema; } });
202
+ // Schemas — the derived V2 axes
203
+ Object.defineProperty(exports, "reputationPersonhoodSchema", { enumerable: true, get: function () { return moderationReputation_1.reputationPersonhoodSchema; } });
204
+ Object.defineProperty(exports, "reputationContributionSchema", { enumerable: true, get: function () { return moderationReputation_1.reputationContributionSchema; } });
205
+ Object.defineProperty(exports, "reputationConductSchema", { enumerable: true, get: function () { return moderationReputation_1.reputationConductSchema; } });
206
+ Object.defineProperty(exports, "reputationReportingSchema", { enumerable: true, get: function () { return moderationReputation_1.reputationReportingSchema; } });
207
+ Object.defineProperty(exports, "reputationReviewingSchema", { enumerable: true, get: function () { return moderationReputation_1.reputationReviewingSchema; } });
208
+ Object.defineProperty(exports, "reputationContextualInfluenceSchema", { enumerable: true, get: function () { return moderationReputation_1.reputationContextualInfluenceSchema; } });
209
+ Object.defineProperty(exports, "applicationModerationTrustSchema", { enumerable: true, get: function () { return moderationReputation_1.applicationModerationTrustSchema; } });
145
210
  var links_1 = require("./links");
146
211
  // Schemas
147
212
  Object.defineProperty(exports, "linkPreviewSchema", { enumerable: true, get: function () { return links_1.linkPreviewSchema; } });
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ /**
3
+ * Oxy Trust — the moderation reputation bridge (CrowdSource → Oxy Trust).
4
+ *
5
+ * SINGLE SOURCE OF TRUTH for the wire shapes crossing the one-way boundary
6
+ * between a participatory-moderation service and the Oxy reputation ledger.
7
+ *
8
+ * The direction is not negotiable: a moderation service NEVER writes reputation.
9
+ * It emits an authenticated internal event describing a decision it published,
10
+ * and Oxy's own consequence engine validates that event and derives the effect.
11
+ * Everything in this module is therefore either (a) the event, (b) the receipt
12
+ * the engine returns, or (c) the derived state the engine publishes back to the
13
+ * subject.
14
+ *
15
+ * Design anchors, all load-bearing:
16
+ *
17
+ * - **Conduct is a separate axis from contribution.** A conduct penalty raises
18
+ * `activeRisk` and creates a strike; positive contribution points can never
19
+ * cancel a strike, because standing is derived from active risk and not from
20
+ * the point total. See {@link ReputationConduct}.
21
+ * - **The reporting axis carries only reporting signals.** `abuseScore` on the
22
+ * legacy reliability block conflated rejected reports with every negative
23
+ * transaction; {@link ReputationReporting} exists so a conduct penalty can
24
+ * never inflate a report-abuse figure.
25
+ * - **No binding proof, no effect.** {@link ModerationDecisionEventSubject}
26
+ * requires a `bindingProofId`, and the engine rejects an event whose binding
27
+ * does not resolve to the claimed principal at or before `occurredAt`. An
28
+ * application cannot move a reputation figure by naming a user id.
29
+ * - **One penalty per incident.** The idempotency key is
30
+ * `moderation:<incidentId>:<decisionRevision>:<effectType>`; a hundred
31
+ * reports about the same material produce one effect.
32
+ * - **Every effect carries the policy version it was decided under**, so a
33
+ * consequence can be recomputed under the original policy rather than under
34
+ * whatever the current tuning happens to be.
35
+ *
36
+ * Platform-agnostic — zod only. ESM-safe (no `require()`).
37
+ */
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.applicationModerationTrustSchema = exports.reputationContextualInfluenceSchema = exports.reputationReviewingSchema = exports.reputationReportingSchema = exports.reputationConductSchema = exports.reputationContributionSchema = exports.reputationPersonhoodSchema = exports.identityBindingSchema = exports.registerIdentityBindingSchema = exports.reverseModerationEffectResultSchema = exports.applyModerationDecisionResultSchema = exports.moderationEffectSchema = exports.reverseModerationEffectSchema = exports.finalizeModerationDecisionSchema = exports.moderationDecisionEventSchema = exports.moderationPolicyVersionsSchema = exports.moderationDecisionEventSubjectSchema = exports.moderationFindingSchema = exports.moderationEffectSkipReasonSchema = exports.MODERATION_EFFECT_SKIP_REASONS = exports.applicationModerationStandingSchema = exports.APPLICATION_MODERATION_STANDINGS = exports.identityBindingStatusSchema = exports.IDENTITY_BINDING_STATUSES = exports.identityBindingTypeSchema = exports.IDENTITY_BINDING_TYPES = exports.personhoodStatusSchema = exports.PERSONHOOD_STATUSES = exports.contributionTierSchema = exports.CONTRIBUTION_TIERS = exports.conductStandingSchema = exports.CONDUCT_STANDINGS = exports.conductStrikeStatusSchema = exports.CONDUCT_STRIKE_STATUSES = exports.moderationEffectStatusSchema = exports.MODERATION_EFFECT_STATUSES = exports.moderationEffectTypeSchema = exports.MODERATION_EFFECT_TYPES = exports.moderationDecisionStatusSchema = exports.MODERATION_DECISION_STATUSES = exports.moderationAttributionSchema = exports.MODERATION_ATTRIBUTIONS = exports.moderationFindingScopeSchema = exports.MODERATION_FINDING_SCOPES = exports.moderationSeveritySchema = exports.MODERATION_SEVERITIES = void 0;
40
+ const zod_1 = require("zod");
41
+ /* -------------------------------------------------------------------------- */
42
+ /* Closed value sets */
43
+ /* -------------------------------------------------------------------------- */
44
+ /**
45
+ * Severity band of a moderation finding, lowest → highest.
46
+ *
47
+ * The band — not the taxonomy code — is what the consequence engine consumes:
48
+ * points, active risk and expiry are all keyed by severity in the versioned
49
+ * conduct policy, so a new taxonomy code needs no engine change and no
50
+ * intimate category ever reaches the ledger.
51
+ */
52
+ exports.MODERATION_SEVERITIES = ['low', 'medium', 'high', 'critical'];
53
+ exports.moderationSeveritySchema = zod_1.z.enum(exports.MODERATION_SEVERITIES);
54
+ /**
55
+ * How far a finding reaches.
56
+ *
57
+ * - `application_local` — the application enforces locally; Oxy Trust is NOT
58
+ * touched. Emitted for completeness; the engine rejects the effect.
59
+ * - `oxy_network` — conduct against the Oxy network as a whole.
60
+ * - `identity_integrity` — impersonation, sybil behaviour, credential abuse.
61
+ *
62
+ * Only `oxy_network` and `identity_integrity` can produce a global effect.
63
+ */
64
+ exports.MODERATION_FINDING_SCOPES = [
65
+ 'application_local',
66
+ 'oxy_network',
67
+ 'identity_integrity',
68
+ ];
69
+ exports.moderationFindingScopeSchema = zod_1.z.enum(exports.MODERATION_FINDING_SCOPES);
70
+ /** Which participant in the reported material the finding attributes to. */
71
+ exports.MODERATION_ATTRIBUTIONS = ['author', 'sharer', 'reporter', 'reviewer'];
72
+ exports.moderationAttributionSchema = zod_1.z.enum(exports.MODERATION_ATTRIBUTIONS);
73
+ /**
74
+ * Lifecycle of the decision the event describes.
75
+ *
76
+ * `inconclusive` is its own outcome and never collapses into "no violation";
77
+ * it simply produces no effect. `superseded` and `corrected` describe a
78
+ * revision that a later one replaced — an event in either state is rejected,
79
+ * because applying it would resurrect a consequence the appeal removed.
80
+ */
81
+ exports.MODERATION_DECISION_STATUSES = [
82
+ 'provisional',
83
+ 'final',
84
+ 'inconclusive',
85
+ 'superseded',
86
+ 'corrected',
87
+ ];
88
+ exports.moderationDecisionStatusSchema = zod_1.z.enum(exports.MODERATION_DECISION_STATUSES);
89
+ /**
90
+ * The kind of consequence an effect carries. Each is its own axis, and the
91
+ * idempotency key includes it — one incident may legitimately produce a conduct
92
+ * effect for the author AND a report-abuse effect for a malicious reporter.
93
+ */
94
+ exports.MODERATION_EFFECT_TYPES = [
95
+ 'conduct_penalty',
96
+ 'report_abuse_penalty',
97
+ 'review_abuse_penalty',
98
+ ];
99
+ exports.moderationEffectTypeSchema = zod_1.z.enum(exports.MODERATION_EFFECT_TYPES);
100
+ /** Lifecycle of a stored effect. */
101
+ exports.MODERATION_EFFECT_STATUSES = ['applied', 'reversed'];
102
+ exports.moderationEffectStatusSchema = zod_1.z.enum(exports.MODERATION_EFFECT_STATUSES);
103
+ /** Lifecycle of a conduct strike. Only `active` strikes carry active risk. */
104
+ exports.CONDUCT_STRIKE_STATUSES = ['active', 'expired', 'reversed'];
105
+ exports.conductStrikeStatusSchema = zod_1.z.enum(exports.CONDUCT_STRIKE_STATUSES);
106
+ /**
107
+ * Conduct standing, derived from ACTIVE RISK and nothing else.
108
+ *
109
+ * Deliberately independent of the point total: a person may hold a high
110
+ * contribution tier and a `limited` standing at the same time, and earning
111
+ * points cannot move standing back toward `good`. Only expiry or reversal can.
112
+ */
113
+ exports.CONDUCT_STANDINGS = ['good', 'watch', 'limited', 'restricted'];
114
+ exports.conductStandingSchema = zod_1.z.enum(exports.CONDUCT_STANDINGS);
115
+ /** Contribution tier, derived from contribution points only. */
116
+ exports.CONTRIBUTION_TIERS = ['new', 'trusted', 'high_trust'];
117
+ exports.contributionTierSchema = zod_1.z.enum(exports.CONTRIBUTION_TIERS);
118
+ /** Personhood status. Being a real person proves neither conduct nor competence. */
119
+ exports.PERSONHOOD_STATUSES = ['unknown', 'probable', 'verified'];
120
+ exports.personhoodStatusSchema = zod_1.z.enum(exports.PERSONHOOD_STATUSES);
121
+ /**
122
+ * How an Oxy identity was bound to the actor an application reported.
123
+ *
124
+ * - `oauth_grant` — the user authorized the application through Oxy's own
125
+ * OAuth flow. Oxy wrote the record; the application asserts nothing.
126
+ * - `session_proof` — the application presented the USER'S OWN Oxy access
127
+ * token alongside its service credential, proving the user was present in
128
+ * that application under a named local principal id.
129
+ * - `commons_signature` — a DID-verifiable signature over a server-issued nonce.
130
+ * - `federated_actor` — a resolvable, authorized federated actor link.
131
+ */
132
+ exports.IDENTITY_BINDING_TYPES = [
133
+ 'oauth_grant',
134
+ 'session_proof',
135
+ 'commons_signature',
136
+ 'federated_actor',
137
+ ];
138
+ exports.identityBindingTypeSchema = zod_1.z.enum(exports.IDENTITY_BINDING_TYPES);
139
+ /** Binding lifecycle. A revoked binding proves nothing about a later action. */
140
+ exports.IDENTITY_BINDING_STATUSES = ['active', 'revoked'];
141
+ exports.identityBindingStatusSchema = zod_1.z.enum(exports.IDENTITY_BINDING_STATUSES);
142
+ /**
143
+ * An application's own moderation standing. An external application can abuse
144
+ * the system too, so it carries standing exactly like a person does.
145
+ *
146
+ * `sandbox` applications moderate locally and produce NO global effect.
147
+ */
148
+ exports.APPLICATION_MODERATION_STANDINGS = ['sandbox', 'trusted', 'restricted'];
149
+ exports.applicationModerationStandingSchema = zod_1.z.enum(exports.APPLICATION_MODERATION_STANDINGS);
150
+ /**
151
+ * Why the engine declined to apply an effect.
152
+ *
153
+ * Returned rather than thrown for the cases that are a legitimate outcome of a
154
+ * well-formed event (a sandboxed application, a local-only finding, an
155
+ * inconclusive decision): the emitter must be able to record "delivered, no
156
+ * effect" and stop retrying. Malformed or unauthorized events are HTTP errors,
157
+ * not skip reasons.
158
+ */
159
+ exports.MODERATION_EFFECT_SKIP_REASONS = [
160
+ 'no_binding_proof',
161
+ 'binding_after_action',
162
+ 'binding_principal_mismatch',
163
+ 'binding_revoked',
164
+ 'decision_not_effective',
165
+ 'decision_superseded',
166
+ 'finding_scope_local',
167
+ 'finding_not_in_policy',
168
+ 'application_not_permitted',
169
+ 'no_effective_finding',
170
+ ];
171
+ exports.moderationEffectSkipReasonSchema = zod_1.z.enum(exports.MODERATION_EFFECT_SKIP_REASONS);
172
+ exports.moderationFindingSchema = zod_1.z.object({
173
+ code: zod_1.z.string().trim().min(1).max(200),
174
+ severity: exports.moderationSeveritySchema,
175
+ scope: exports.moderationFindingScopeSchema,
176
+ attribution: exports.moderationAttributionSchema,
177
+ family: zod_1.z.string().trim().min(1).max(100),
178
+ });
179
+ exports.moderationDecisionEventSubjectSchema = zod_1.z.object({
180
+ principalType: zod_1.z.literal('oxy_user'),
181
+ principalId: zod_1.z.string().trim().min(1),
182
+ bindingProofId: zod_1.z.string().trim().min(1),
183
+ });
184
+ exports.moderationPolicyVersionsSchema = zod_1.z.object({
185
+ universal: zod_1.z.string().trim().min(1).max(100),
186
+ application: zod_1.z.string().trim().min(1).max(100),
187
+ oxyConduct: zod_1.z.string().trim().min(1).max(100),
188
+ });
189
+ exports.moderationDecisionEventSchema = zod_1.z.object({
190
+ eventId: zod_1.z.string().trim().min(1).max(200),
191
+ reportedApplicationId: zod_1.z.string().trim().min(1).max(200),
192
+ type: zod_1.z.string().trim().min(1).max(200),
193
+ caseId: zod_1.z.string().trim().min(1).max(200),
194
+ incidentId: zod_1.z.string().trim().min(1).max(200),
195
+ decisionId: zod_1.z.string().trim().min(1).max(200),
196
+ decisionRevision: zod_1.z.number().int().min(1),
197
+ subject: exports.moderationDecisionEventSubjectSchema,
198
+ findings: zod_1.z.array(exports.moderationFindingSchema).min(1).max(20),
199
+ decisionStatus: exports.moderationDecisionStatusSchema,
200
+ policyVersions: exports.moderationPolicyVersionsSchema,
201
+ occurredAt: zod_1.z.string().trim().min(1),
202
+ proofHash: zod_1.z.string().trim().min(1).max(200),
203
+ });
204
+ exports.finalizeModerationDecisionSchema = zod_1.z.object({
205
+ decisionId: zod_1.z.string().trim().min(1).max(200),
206
+ decisionRevision: zod_1.z.number().int().min(1),
207
+ });
208
+ exports.reverseModerationEffectSchema = zod_1.z.object({
209
+ decisionId: zod_1.z.string().trim().min(1).max(200),
210
+ decisionRevision: zod_1.z.number().int().min(1),
211
+ reason: zod_1.z.string().trim().min(1).max(500),
212
+ });
213
+ exports.moderationEffectSchema = zod_1.z.object({
214
+ id: zod_1.z.string(),
215
+ incidentId: zod_1.z.string(),
216
+ caseId: zod_1.z.string(),
217
+ decisionId: zod_1.z.string(),
218
+ decisionRevision: zod_1.z.number(),
219
+ principalId: zod_1.z.string(),
220
+ effectType: exports.moderationEffectTypeSchema,
221
+ status: exports.moderationEffectStatusSchema,
222
+ points: zod_1.z.number(),
223
+ activeRisk: zod_1.z.number(),
224
+ severity: exports.moderationSeveritySchema,
225
+ repetitionMultiplier: zod_1.z.number(),
226
+ multiFindingMultiplier: zod_1.z.number(),
227
+ idempotencyKey: zod_1.z.string(),
228
+ transactionId: zod_1.z.string(),
229
+ strikeId: zod_1.z.string().optional(),
230
+ reversalTransactionId: zod_1.z.string().optional(),
231
+ policyVersions: exports.moderationPolicyVersionsSchema,
232
+ appliedAt: zod_1.z.string(),
233
+ reversedAt: zod_1.z.string().optional(),
234
+ });
235
+ exports.applyModerationDecisionResultSchema = zod_1.z.object({
236
+ applied: zod_1.z.boolean(),
237
+ effect: exports.moderationEffectSchema.optional(),
238
+ skipReason: exports.moderationEffectSkipReasonSchema.optional(),
239
+ idempotent: zod_1.z.boolean(),
240
+ });
241
+ exports.reverseModerationEffectResultSchema = zod_1.z.object({
242
+ reversed: zod_1.z.array(exports.moderationEffectSchema),
243
+ idempotent: zod_1.z.boolean(),
244
+ });
245
+ exports.registerIdentityBindingSchema = zod_1.z.object({
246
+ localPrincipalId: zod_1.z.string().trim().min(1).max(200),
247
+ userProofToken: zod_1.z.string().trim().min(1),
248
+ });
249
+ exports.identityBindingSchema = zod_1.z.object({
250
+ id: zod_1.z.string(),
251
+ applicationId: zod_1.z.string(),
252
+ userId: zod_1.z.string(),
253
+ localPrincipalId: zod_1.z.string(),
254
+ bindingType: exports.identityBindingTypeSchema,
255
+ status: exports.identityBindingStatusSchema,
256
+ verifiedAt: zod_1.z.string(),
257
+ createdAt: zod_1.z.string(),
258
+ });
259
+ exports.reputationPersonhoodSchema = zod_1.z.object({
260
+ status: exports.personhoodStatusSchema,
261
+ score: zod_1.z.number(),
262
+ });
263
+ exports.reputationContributionSchema = zod_1.z.object({
264
+ points: zod_1.z.number(),
265
+ tier: exports.contributionTierSchema,
266
+ });
267
+ exports.reputationConductSchema = zod_1.z.object({
268
+ standing: exports.conductStandingSchema,
269
+ activeRisk: zod_1.z.number(),
270
+ activeStrikes: zod_1.z.number(),
271
+ nextExpiryAt: zod_1.z.string().optional(),
272
+ });
273
+ exports.reputationReportingSchema = zod_1.z.object({
274
+ reliability: zod_1.z.number(),
275
+ confidence: zod_1.z.number(),
276
+ confirmed: zod_1.z.number(),
277
+ rejected: zod_1.z.number(),
278
+ malicious: zod_1.z.number(),
279
+ });
280
+ exports.reputationReviewingSchema = zod_1.z.object({
281
+ globalReliability: zod_1.z.number(),
282
+ categoryReliability: zod_1.z.record(zod_1.z.number()),
283
+ languageReliability: zod_1.z.record(zod_1.z.number()),
284
+ });
285
+ exports.reputationContextualInfluenceSchema = zod_1.z.object({
286
+ reportPriorityWeight: zod_1.z.number(),
287
+ reviewSelectionWeight: zod_1.z.number(),
288
+ rankingWeight: zod_1.z.number(),
289
+ });
290
+ exports.applicationModerationTrustSchema = zod_1.z.object({
291
+ applicationId: zod_1.z.string(),
292
+ standing: exports.applicationModerationStandingSchema,
293
+ evidenceIntegrity: zod_1.z.number(),
294
+ identityBindingReliability: zod_1.z.number(),
295
+ decisionOverturnRate: zod_1.z.number(),
296
+ policyQuality: zod_1.z.number(),
297
+ globalReputationEffectsAllowed: zod_1.z.boolean(),
298
+ });
@@ -45,6 +45,7 @@ exports.reverseReputationTransactionSchema = exports.upsertReputationRuleSchema
45
45
  exports.isFullReputationBalance = isFullReputationBalance;
46
46
  const zod_1 = require("zod");
47
47
  const userResponse_1 = require("./userResponse");
48
+ const moderationReputation_1 = require("./moderationReputation");
48
49
  /* -------------------------------------------------------------------------- */
49
50
  /* Closed value sets */
50
51
  /* -------------------------------------------------------------------------- */
@@ -181,11 +182,22 @@ exports.reputationBalanceSchema = zod_1.z.object({
181
182
  reliability: exports.reputationReliabilitySchema,
182
183
  recalculatedAt: zod_1.z.string(),
183
184
  updatedAt: zod_1.z.string(),
185
+ personhood: moderationReputation_1.reputationPersonhoodSchema.optional(),
186
+ contribution: moderationReputation_1.reputationContributionSchema.optional(),
187
+ conduct: moderationReputation_1.reputationConductSchema.optional(),
188
+ reporting: moderationReputation_1.reputationReportingSchema.optional(),
189
+ reviewing: moderationReputation_1.reputationReviewingSchema.optional(),
190
+ contextualInfluence: moderationReputation_1.reputationContextualInfluenceSchema.optional(),
184
191
  });
185
192
  /**
186
- * Every field the full {@link ReputationBalance} carries beyond the public
187
- * {@link ReputationBalanceSummary}. The runtime discriminant between the two
188
- * views the API sends this set all-or-nothing.
193
+ * The fields the full {@link ReputationBalance} carries beyond the public
194
+ * {@link ReputationBalanceSummary} that the API sends ALL-OR-NOTHING. The
195
+ * runtime discriminant between the two views.
196
+ *
197
+ * The V2 blocks (`conduct`, `contribution`, …) are deliberately NOT listed:
198
+ * they are optional on the wire, so requiring them here would make a balance
199
+ * from a server that predates them fail to narrow, hiding the whole private
200
+ * view. Read a V2 block by checking that block.
189
201
  */
190
202
  const FULL_BALANCE_FIELDS = [
191
203
  'positive',