@oxy.so/contracts 4.16.0 → 4.21.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.
- package/dist/cjs/accountAccess.js +72 -0
- package/dist/cjs/accountEmail.js +12 -34
- package/dist/cjs/accountGraph.js +22 -320
- package/dist/cjs/agency.js +112 -1
- package/dist/cjs/agentKeys.js +11 -13
- package/dist/cjs/applicationRoles.js +211 -0
- package/dist/cjs/client/accountEmail.js +48 -0
- package/dist/cjs/client/accountGraph.js +323 -0
- package/dist/cjs/client/agentKeys.js +77 -0
- package/dist/cjs/client/check.js +475 -0
- package/dist/cjs/client/deviceBoot.js +22 -0
- package/dist/cjs/client/deviceDirectory.js +51 -0
- package/dist/cjs/client/deviceSession.js +63 -0
- package/dist/cjs/client/externalIdentity.js +19 -0
- package/dist/cjs/client/identity.js +45 -0
- package/dist/cjs/client/identityLink.js +55 -0
- package/dist/cjs/client/identityProof.js +109 -0
- package/dist/cjs/client/index.js +211 -0
- package/dist/cjs/client/organizations.js +114 -0
- package/dist/cjs/client/products.js +153 -0
- package/dist/cjs/client/recommendations.js +33 -0
- package/dist/cjs/client/reputation.js +41 -0
- package/dist/cjs/client/safety.js +196 -0
- package/dist/cjs/client/sessionStatus.js +23 -0
- package/dist/cjs/client/signIn.js +159 -0
- package/dist/cjs/client/userResponse.js +15 -0
- package/dist/cjs/client/username.js +173 -0
- package/dist/cjs/deviceSession.js +3 -16
- package/dist/cjs/identityLink.js +13 -34
- package/dist/cjs/identityProof.js +18 -106
- package/dist/cjs/index.js +13 -3
- package/dist/cjs/organizations.js +21 -41
- package/dist/cjs/reputation.js +3 -34
- package/dist/cjs/safety.js +430 -1
- package/dist/cjs/serviceToken.js +14 -0
- package/dist/cjs/signIn.js +33 -111
- package/dist/cjs/username.js +23 -158
- package/dist/esm/accountAccess.js +69 -0
- package/dist/esm/accountEmail.js +4 -32
- package/dist/esm/accountGraph.js +4 -309
- package/dist/esm/agency.js +111 -0
- package/dist/esm/agentKeys.js +4 -10
- package/dist/esm/applicationRoles.js +207 -0
- package/dist/esm/client/accountEmail.js +45 -0
- package/dist/esm/client/accountGraph.js +314 -0
- package/dist/esm/client/agentKeys.js +74 -0
- package/dist/esm/client/check.js +436 -0
- package/dist/esm/client/deviceBoot.js +19 -0
- package/dist/esm/client/deviceDirectory.js +48 -0
- package/dist/esm/client/deviceSession.js +60 -0
- package/dist/esm/client/externalIdentity.js +16 -0
- package/dist/esm/client/identity.js +42 -0
- package/dist/esm/client/identityLink.js +50 -0
- package/dist/esm/client/identityProof.js +104 -0
- package/dist/esm/client/index.js +37 -0
- package/dist/esm/client/organizations.js +111 -0
- package/dist/esm/client/products.js +150 -0
- package/dist/esm/client/recommendations.js +30 -0
- package/dist/esm/client/reputation.js +37 -0
- package/dist/esm/client/safety.js +193 -0
- package/dist/esm/client/sessionStatus.js +20 -0
- package/dist/esm/client/signIn.js +153 -0
- package/dist/esm/client/userResponse.js +12 -0
- package/dist/esm/client/username.js +167 -0
- package/dist/esm/deviceSession.js +1 -15
- package/dist/esm/identityLink.js +4 -27
- package/dist/esm/identityProof.js +4 -99
- package/dist/esm/index.js +4 -1
- package/dist/esm/organizations.js +4 -31
- package/dist/esm/reputation.js +1 -32
- package/dist/esm/safety.js +423 -0
- package/dist/esm/serviceToken.js +11 -0
- package/dist/esm/signIn.js +4 -96
- package/dist/esm/username.js +4 -148
- package/dist/types/accountAccess.d.ts +128 -0
- package/dist/types/accountEmail.d.ts +4 -36
- package/dist/types/accountGraph.d.ts +12 -208
- package/dist/types/agency.d.ts +351 -26
- package/dist/types/agentKeys.d.ts +14 -12
- package/dist/types/applicationRoles.d.ts +438 -0
- package/dist/types/client/accountEmail.d.ts +44 -0
- package/dist/types/client/accountGraph.d.ts +203 -0
- package/dist/types/client/agentKeys.d.ts +113 -0
- package/dist/types/client/check.d.ts +187 -0
- package/dist/types/client/deviceBoot.d.ts +6 -0
- package/dist/types/client/deviceDirectory.d.ts +134 -0
- package/dist/types/client/deviceSession.d.ts +91 -0
- package/dist/types/client/externalIdentity.d.ts +14 -0
- package/dist/types/client/identity.d.ts +8 -0
- package/dist/types/client/identityLink.d.ts +21 -0
- package/dist/types/client/identityProof.d.ts +73 -0
- package/dist/types/client/index.d.ts +37 -0
- package/dist/types/client/organizations.d.ts +167 -0
- package/dist/types/client/products.d.ts +145 -0
- package/dist/types/client/recommendations.d.ts +27 -0
- package/dist/types/client/reputation.d.ts +28 -0
- package/dist/types/client/safety.d.ts +213 -0
- package/dist/types/client/sessionStatus.d.ts +19 -0
- package/dist/types/client/signIn.d.ts +107 -0
- package/dist/types/client/userResponse.d.ts +7 -0
- package/dist/types/client/username.d.ts +126 -0
- package/dist/types/deviceDirectory.d.ts +28 -28
- package/dist/types/deviceSession.d.ts +5 -16
- package/dist/types/email/messages.d.ts +2 -2
- package/dist/types/externalIdentity.d.ts +15 -15
- package/dist/types/identityLink.d.ts +3 -11
- package/dist/types/identityProof.d.ts +2 -65
- package/dist/types/index.d.ts +5 -2
- package/dist/types/inference/accountBilling.d.ts +2 -2
- package/dist/types/inference/catalogue.d.ts +22 -22
- package/dist/types/inference/decisions.d.ts +10 -10
- package/dist/types/inference/embeddings.d.ts +16 -16
- package/dist/types/inference/errors.d.ts +8 -8
- package/dist/types/inference/inbox.d.ts +8 -8
- package/dist/types/inference/privateAutoExecution.d.ts +6 -6
- package/dist/types/inference/providerConnection.d.ts +4 -4
- package/dist/types/inference/realtime.d.ts +92 -92
- package/dist/types/inference/request.d.ts +48 -48
- package/dist/types/inference/streamEvents.d.ts +16 -16
- package/dist/types/inference/usage.d.ts +4 -4
- package/dist/types/oauth.d.ts +2 -2
- package/dist/types/organizations.d.ts +8 -10
- package/dist/types/products/access.d.ts +4 -4
- package/dist/types/products/billing.d.ts +3 -0
- package/dist/types/reputation.d.ts +1 -11
- package/dist/types/safety.d.ts +2374 -2
- package/dist/types/serviceToken.d.ts +11 -0
- package/dist/types/sessionStatus.d.ts +2 -2
- package/dist/types/signIn.d.ts +11 -94
- package/dist/types/userResponse.d.ts +22 -22
- package/dist/types/username.d.ts +1 -96
- package/package.json +24 -20
- package/dist/cjs/.tsbuildinfo +0 -1
- package/dist/esm/.tsbuildinfo +0 -1
- package/dist/types/.tsbuildinfo +0 -1
package/dist/cjs/reputation.js
CHANGED
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
* `require()`).
|
|
41
41
|
*/
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.awardReputationSchema = exports.reputationInfluenceResultSchema = exports.reputationLeaderboardEntrySchema = exports.reputationLeaderboardUserSchema = exports.reputationRulesResponseSchema = exports.reputationRuleSchema = exports.reputationBalanceSchema = exports.reputationBalanceSummarySchema = exports.reputationReliabilitySchema = exports.reputationInfluenceSchema = exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema = exports.reputationInfluenceContextSchema = exports.REPUTATION_INFLUENCE_CONTEXTS = exports.reputationTargetEntityTypeSchema = exports.REPUTATION_TARGET_ENTITY_TYPES = exports.trustTierSchema = exports.TRUST_TIERS = exports.reputationTransactionStatusSchema = exports.REPUTATION_TRANSACTION_STATUSES = exports.reputationCategorySchema = exports.REPUTATION_CATEGORIES = void 0;
|
|
44
|
-
exports.isFullReputationBalance = isFullReputationBalance;
|
|
43
|
+
exports.awardReputationSchema = exports.reputationInfluenceResultSchema = exports.reputationLeaderboardEntrySchema = exports.reputationLeaderboardUserSchema = exports.reputationRulesResponseSchema = exports.reputationRuleSchema = exports.reputationBalanceSchema = exports.reputationBalanceSummarySchema = exports.reputationReliabilitySchema = exports.reputationInfluenceSchema = exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema = exports.reputationInfluenceContextSchema = exports.REPUTATION_INFLUENCE_CONTEXTS = exports.reputationTargetEntityTypeSchema = exports.REPUTATION_TARGET_ENTITY_TYPES = exports.trustTierSchema = exports.TRUST_TIERS = exports.reputationTransactionStatusSchema = exports.REPUTATION_TRANSACTION_STATUSES = exports.reputationCategorySchema = exports.REPUTATION_CATEGORIES = exports.isFullReputationBalance = void 0;
|
|
45
44
|
const zod_1 = require("zod");
|
|
46
45
|
const userResponse_1 = require("./userResponse");
|
|
47
46
|
const moderationReputation_1 = require("./moderationReputation");
|
|
47
|
+
var reputation_1 = require("./client/reputation");
|
|
48
|
+
Object.defineProperty(exports, "isFullReputationBalance", { enumerable: true, get: function () { return reputation_1.isFullReputationBalance; } });
|
|
48
49
|
/* -------------------------------------------------------------------------- */
|
|
49
50
|
/* Closed value sets */
|
|
50
51
|
/* -------------------------------------------------------------------------- */
|
|
@@ -174,38 +175,6 @@ exports.reputationBalanceSchema = zod_1.z.object({
|
|
|
174
175
|
reviewing: moderationReputation_1.reputationReviewingSchema.optional(),
|
|
175
176
|
contextualInfluence: moderationReputation_1.reputationContextualInfluenceSchema.optional(),
|
|
176
177
|
});
|
|
177
|
-
/**
|
|
178
|
-
* The fields the full {@link ReputationBalance} carries beyond the public
|
|
179
|
-
* {@link ReputationBalanceSummary} that the API sends ALL-OR-NOTHING. The
|
|
180
|
-
* runtime discriminant between the two views.
|
|
181
|
-
*
|
|
182
|
-
* The V2 blocks (`conduct`, `contribution`, …) are deliberately NOT listed:
|
|
183
|
-
* they are optional on the wire, so requiring them here would make a balance
|
|
184
|
-
* from a server that predates them fail to narrow, hiding the whole private
|
|
185
|
-
* view. Read a V2 block by checking that block.
|
|
186
|
-
*/
|
|
187
|
-
const FULL_BALANCE_FIELDS = [
|
|
188
|
-
'positive',
|
|
189
|
-
'negative',
|
|
190
|
-
'breakdown',
|
|
191
|
-
'influence',
|
|
192
|
-
'reliability',
|
|
193
|
-
'recalculatedAt',
|
|
194
|
-
'updatedAt',
|
|
195
|
-
];
|
|
196
|
-
/**
|
|
197
|
-
* Whether a balance came back as the SUBJECT view, and so carries the
|
|
198
|
-
* breakdown / influence / reliability blocks.
|
|
199
|
-
*
|
|
200
|
-
* Checks every extra field rather than one representative: the point of the
|
|
201
|
-
* guard is that the caller then dereferences those blocks, so a partial payload
|
|
202
|
-
* must not narrow.
|
|
203
|
-
*
|
|
204
|
-
* @param balance - A balance from `getReputationBalance`.
|
|
205
|
-
*/
|
|
206
|
-
function isFullReputationBalance(balance) {
|
|
207
|
-
return FULL_BALANCE_FIELDS.every((field) => field in balance);
|
|
208
|
-
}
|
|
209
178
|
exports.reputationRuleSchema = zod_1.z.object({
|
|
210
179
|
actionType: zod_1.z.string(),
|
|
211
180
|
points: zod_1.z.number(),
|
package/dist/cjs/safety.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.profileAccessDecisionSchema = exports.profileAccessInputSchema = void 0;
|
|
3
|
+
exports.supervisionInviteInputSchema = exports.safetyErrorSchema = exports.SAFETY_ERROR_CODES = exports.cancelPurchaseSchema = exports.confirmPurchaseSchema = exports.reservePurchaseSchema = exports.purchaseApprovalListSchema = exports.purchaseApprovalSummarySchema = exports.purchaseApprovalSchema = exports.purchaseEffectsSchema = exports.purchaseApprovalLineSchema = exports.supervisionContactsResponseSchema = exports.supervisionStateSchema = exports.supervisionContactSchema = exports.supervisionInvitationSchema = exports.supervisionSchema = exports.safetyRequesterSchema = exports.messagingSessionsResponseSchema = exports.messagingSessionsInputSchema = exports.messageAccessBatchResponseSchema = exports.deliveryAccessBatchInputSchema = exports.messageAccessBatchInputSchema = exports.deliveryAccessInputSchema = exports.contentAccessBatchResponseSchema = exports.contentAccessBatchInputSchema = exports.publicationPoliciesResponseSchema = exports.publicationPoliciesInputSchema = exports.publicationPolicySchema = exports.contentAccessInputSchema = exports.CONTENT_CLASSIFICATIONS = exports.contactAccessResponseSchema = exports.contactAccessInputSchema = exports.messageAccessInputSchema = exports.MESSAGE_ACCESS_MAX_INPUT_BYTES = exports.MESSAGE_ACCESS_MAX_PARTICIPANT_SLOTS = exports.MESSAGE_ACCESS_MAX_SUPERVISED_PARTICIPANTS = exports.MESSAGE_ACCESS_MAX_PARTICIPANTS = exports.MESSAGE_ACCESS_MAX_RESOURCES = exports.profileAccessBatchResponseSchema = exports.profileAccessBatchInputSchema = exports.safetyDecisionSchema = exports.SAFETY_DECISION_REASONS = exports.profileAccessDecisionSchema = exports.profileAccessInputSchema = exports.SUPERVISION_STATUSES = exports.SUPERVISION_INVITATION_STATUSES = exports.SUPERVISION_CONSENT_VERSION = exports.SUPERVISED_ACTIONS = exports.SAFETY_POLICY_VERSION = exports.PURCHASE_APPROVAL_STATUSES = void 0;
|
|
4
|
+
exports.safetyOrganizationsResponseSchema = exports.safetyOrganizationsInputSchema = exports.safetyOrganizationIdentitySchema = exports.safetyPeopleResponseSchema = exports.safetyPeopleInputSchema = exports.safetyPersonSchema = exports.safetySessionValidationSchema = exports.safetySessionInputSchema = exports.purchaseReviewInputSchema = exports.supervisionReviewInputSchema = exports.supervisionContactInputSchema = exports.supervisionAcceptInputSchema = void 0;
|
|
4
5
|
const zod_1 = require("zod");
|
|
6
|
+
const accountSubject_1 = require("./accountSubject");
|
|
7
|
+
// The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
|
|
8
|
+
// its vocabularies are re-exported here so the root entry is unchanged.
|
|
9
|
+
const safety_1 = require("./client/safety");
|
|
10
|
+
Object.defineProperty(exports, "PURCHASE_APPROVAL_STATUSES", { enumerable: true, get: function () { return safety_1.PURCHASE_APPROVAL_STATUSES; } });
|
|
11
|
+
Object.defineProperty(exports, "SAFETY_POLICY_VERSION", { enumerable: true, get: function () { return safety_1.SAFETY_POLICY_VERSION; } });
|
|
12
|
+
Object.defineProperty(exports, "SUPERVISED_ACTIONS", { enumerable: true, get: function () { return safety_1.SUPERVISED_ACTIONS; } });
|
|
13
|
+
Object.defineProperty(exports, "SUPERVISION_CONSENT_VERSION", { enumerable: true, get: function () { return safety_1.SUPERVISION_CONSENT_VERSION; } });
|
|
14
|
+
Object.defineProperty(exports, "SUPERVISION_INVITATION_STATUSES", { enumerable: true, get: function () { return safety_1.SUPERVISION_INVITATION_STATUSES; } });
|
|
15
|
+
Object.defineProperty(exports, "SUPERVISION_STATUSES", { enumerable: true, get: function () { return safety_1.SUPERVISION_STATUSES; } });
|
|
16
|
+
const organizations_1 = require("./organizations");
|
|
17
|
+
const signIn_1 = require("./signIn");
|
|
18
|
+
const userResponse_1 = require("./userResponse");
|
|
5
19
|
/** The requester is authenticated by the bearer; applications cannot submit viewer IDs. */
|
|
6
20
|
exports.profileAccessInputSchema = zod_1.z
|
|
7
21
|
.object({ subjectAccountId: zod_1.z.string().min(1).max(128) })
|
|
@@ -13,3 +27,418 @@ exports.profileAccessDecisionSchema = zod_1.z
|
|
|
13
27
|
policyVersion: zod_1.z.literal('1'),
|
|
14
28
|
})
|
|
15
29
|
.strict();
|
|
30
|
+
exports.SAFETY_DECISION_REASONS = [
|
|
31
|
+
'allowed',
|
|
32
|
+
'owner',
|
|
33
|
+
'public',
|
|
34
|
+
'private',
|
|
35
|
+
'blocked',
|
|
36
|
+
'unavailable',
|
|
37
|
+
'unsupported_consumer',
|
|
38
|
+
'contact_not_approved',
|
|
39
|
+
'mature_content',
|
|
40
|
+
'unrated_content',
|
|
41
|
+
'approval_required',
|
|
42
|
+
];
|
|
43
|
+
const accountId = zod_1.z.string().min(1).max(128);
|
|
44
|
+
const resourceId = zod_1.z.string().trim().min(1).max(256);
|
|
45
|
+
const uniqueIds = (max, min = 1) => zod_1.z
|
|
46
|
+
.array(accountId)
|
|
47
|
+
.min(min)
|
|
48
|
+
.max(max)
|
|
49
|
+
.refine((ids) => new Set(ids).size === ids.length, 'Account IDs must be unique');
|
|
50
|
+
exports.safetyDecisionSchema = zod_1.z
|
|
51
|
+
.object({
|
|
52
|
+
allowed: zod_1.z.boolean(),
|
|
53
|
+
reason: zod_1.z.enum(exports.SAFETY_DECISION_REASONS),
|
|
54
|
+
policyVersion: zod_1.z.literal(safety_1.SAFETY_POLICY_VERSION),
|
|
55
|
+
})
|
|
56
|
+
.strict();
|
|
57
|
+
exports.profileAccessBatchInputSchema = zod_1.z
|
|
58
|
+
.object({ subjectAccountIds: uniqueIds(100) })
|
|
59
|
+
.strict();
|
|
60
|
+
exports.profileAccessBatchResponseSchema = zod_1.z
|
|
61
|
+
.object({
|
|
62
|
+
items: zod_1.z
|
|
63
|
+
.array(zod_1.z
|
|
64
|
+
.object({
|
|
65
|
+
subjectAccountId: accountId,
|
|
66
|
+
decision: exports.safetyDecisionSchema,
|
|
67
|
+
})
|
|
68
|
+
.strict())
|
|
69
|
+
.max(100),
|
|
70
|
+
})
|
|
71
|
+
.strict();
|
|
72
|
+
exports.MESSAGE_ACCESS_MAX_RESOURCES = 100;
|
|
73
|
+
exports.MESSAGE_ACCESS_MAX_PARTICIPANTS = 1024;
|
|
74
|
+
exports.MESSAGE_ACCESS_MAX_SUPERVISED_PARTICIPANTS = 256;
|
|
75
|
+
exports.MESSAGE_ACCESS_MAX_PARTICIPANT_SLOTS = 4096;
|
|
76
|
+
/** Leaves room for the original requester proof in a 512 KiB request. */
|
|
77
|
+
exports.MESSAGE_ACCESS_MAX_INPUT_BYTES = 448 * 1024;
|
|
78
|
+
exports.messageAccessInputSchema = zod_1.z
|
|
79
|
+
.object({ participantAccountIds: uniqueIds(exports.MESSAGE_ACCESS_MAX_PARTICIPANTS), resourceId })
|
|
80
|
+
.strict();
|
|
81
|
+
exports.contactAccessInputSchema = zod_1.z.object({ targetAccountIds: uniqueIds(1000) }).strict();
|
|
82
|
+
exports.contactAccessResponseSchema = zod_1.z
|
|
83
|
+
.object({
|
|
84
|
+
items: zod_1.z
|
|
85
|
+
.array(zod_1.z
|
|
86
|
+
.object({
|
|
87
|
+
targetAccountId: accountId,
|
|
88
|
+
decision: exports.safetyDecisionSchema,
|
|
89
|
+
})
|
|
90
|
+
.strict())
|
|
91
|
+
.max(1000),
|
|
92
|
+
})
|
|
93
|
+
.strict();
|
|
94
|
+
exports.CONTENT_CLASSIFICATIONS = ['general', 'mature', 'unrated'];
|
|
95
|
+
exports.contentAccessInputSchema = zod_1.z
|
|
96
|
+
.object({
|
|
97
|
+
resourceId,
|
|
98
|
+
classification: zod_1.z.enum(exports.CONTENT_CLASSIFICATIONS),
|
|
99
|
+
authorAccountId: accountId.optional(),
|
|
100
|
+
audience: zod_1.z.enum(['public', 'private', 'followers']).optional(),
|
|
101
|
+
applicationAudienceAllowed: zod_1.z.boolean().optional(),
|
|
102
|
+
applicationResourceGrant: zod_1.z.boolean().optional(),
|
|
103
|
+
operation: zod_1.z.enum(['read', 'manage_own']).optional(),
|
|
104
|
+
})
|
|
105
|
+
.strict()
|
|
106
|
+
.refine((item) => !item.audience ||
|
|
107
|
+
item.audience === 'public' ||
|
|
108
|
+
(!!item.authorAccountId && item.applicationAudienceAllowed !== undefined), 'Nonpublic content requires its authoritative author and application audience decision')
|
|
109
|
+
.refine((item) => item.operation !== 'manage_own' || !!item.authorAccountId, 'Own management requires its authoritative author');
|
|
110
|
+
exports.publicationPolicySchema = zod_1.z
|
|
111
|
+
.object({
|
|
112
|
+
publicationAllowed: zod_1.z.boolean(),
|
|
113
|
+
requiredAudience: zod_1.z.literal('private').nullable(),
|
|
114
|
+
collaborationAllowed: zod_1.z.boolean(),
|
|
115
|
+
federationAllowed: zod_1.z.boolean(),
|
|
116
|
+
policyVersion: zod_1.z.literal(safety_1.SAFETY_POLICY_VERSION),
|
|
117
|
+
})
|
|
118
|
+
.strict();
|
|
119
|
+
exports.publicationPoliciesInputSchema = zod_1.z
|
|
120
|
+
.object({
|
|
121
|
+
authorAccountIds: zod_1.z
|
|
122
|
+
.array(accountId)
|
|
123
|
+
.min(1)
|
|
124
|
+
.max(100)
|
|
125
|
+
.refine((ids) => new Set(ids).size === ids.length, 'Author IDs must be unique'),
|
|
126
|
+
})
|
|
127
|
+
.strict();
|
|
128
|
+
exports.publicationPoliciesResponseSchema = zod_1.z
|
|
129
|
+
.object({
|
|
130
|
+
items: zod_1.z
|
|
131
|
+
.array(zod_1.z.object({ authorAccountId: accountId, policy: exports.publicationPolicySchema }).strict())
|
|
132
|
+
.max(100),
|
|
133
|
+
})
|
|
134
|
+
.strict();
|
|
135
|
+
exports.contentAccessBatchInputSchema = zod_1.z
|
|
136
|
+
.object({
|
|
137
|
+
items: zod_1.z
|
|
138
|
+
.array(exports.contentAccessInputSchema)
|
|
139
|
+
.min(1)
|
|
140
|
+
.max(100)
|
|
141
|
+
.refine((items) => new Set(items.map((item) => item.resourceId)).size === items.length, 'Resource IDs must be unique'),
|
|
142
|
+
})
|
|
143
|
+
.strict();
|
|
144
|
+
exports.contentAccessBatchResponseSchema = zod_1.z
|
|
145
|
+
.object({
|
|
146
|
+
items: zod_1.z
|
|
147
|
+
.array(zod_1.z
|
|
148
|
+
.object({
|
|
149
|
+
resourceId,
|
|
150
|
+
decision: exports.safetyDecisionSchema,
|
|
151
|
+
})
|
|
152
|
+
.strict())
|
|
153
|
+
.max(100),
|
|
154
|
+
})
|
|
155
|
+
.strict();
|
|
156
|
+
/** A reviewed background consumer may decide delivery, but never authenticate as the sender. */
|
|
157
|
+
exports.deliveryAccessInputSchema = exports.messageAccessInputSchema
|
|
158
|
+
.extend({ senderAccountId: accountId })
|
|
159
|
+
.strict();
|
|
160
|
+
/** Count repeated participants across resources too: this bounds both graph and pair evaluations. */
|
|
161
|
+
const messageBatch = (schema) => zod_1.z
|
|
162
|
+
.object({ items: zod_1.z.array(schema).min(1).max(exports.MESSAGE_ACCESS_MAX_RESOURCES) })
|
|
163
|
+
.strict()
|
|
164
|
+
.refine((value) => new Set(value.items.map((item) => item.resourceId)).size === value.items.length, 'Resource IDs must be unique')
|
|
165
|
+
.refine((value) => value.items.reduce((total, item) => total + item.participantAccountIds.length, 0) <=
|
|
166
|
+
exports.MESSAGE_ACCESS_MAX_PARTICIPANT_SLOTS, 'Participant budget exceeded')
|
|
167
|
+
.refine((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <=
|
|
168
|
+
exports.MESSAGE_ACCESS_MAX_INPUT_BYTES, 'Message batch byte budget exceeded');
|
|
169
|
+
exports.messageAccessBatchInputSchema = messageBatch(exports.messageAccessInputSchema);
|
|
170
|
+
exports.deliveryAccessBatchInputSchema = messageBatch(exports.deliveryAccessInputSchema);
|
|
171
|
+
exports.messageAccessBatchResponseSchema = exports.contentAccessBatchResponseSchema;
|
|
172
|
+
/** Live socket-recipient proof; a request ID correlates the result and never identifies an account. */
|
|
173
|
+
exports.messagingSessionsInputSchema = zod_1.z
|
|
174
|
+
.object({
|
|
175
|
+
items: zod_1.z
|
|
176
|
+
.array(zod_1.z
|
|
177
|
+
.object({
|
|
178
|
+
requestId: resourceId,
|
|
179
|
+
accessToken: zod_1.z.string().min(1).max(16384),
|
|
180
|
+
})
|
|
181
|
+
.strict())
|
|
182
|
+
.min(1)
|
|
183
|
+
.max(100),
|
|
184
|
+
})
|
|
185
|
+
.strict()
|
|
186
|
+
.refine((value) => new Set(value.items.map((item) => item.requestId)).size === value.items.length, 'Request IDs must be unique')
|
|
187
|
+
.refine((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= exports.MESSAGE_ACCESS_MAX_INPUT_BYTES, 'Session proof byte budget exceeded');
|
|
188
|
+
exports.messagingSessionsResponseSchema = zod_1.z
|
|
189
|
+
.object({
|
|
190
|
+
items: zod_1.z
|
|
191
|
+
.array(zod_1.z.discriminatedUnion('allowed', [
|
|
192
|
+
zod_1.z.object({ requestId: resourceId, allowed: zod_1.z.literal(true), accountId }).strict(),
|
|
193
|
+
zod_1.z.object({ requestId: resourceId, allowed: zod_1.z.literal(false) }).strict(),
|
|
194
|
+
]))
|
|
195
|
+
.max(100),
|
|
196
|
+
})
|
|
197
|
+
.strict();
|
|
198
|
+
exports.safetyRequesterSchema = zod_1.z.union([
|
|
199
|
+
zod_1.z.object({ accessToken: zod_1.z.string().min(1).max(16384).nullable() }).strict(),
|
|
200
|
+
zod_1.z.object({ connectionToken: zod_1.z.string().min(1).max(16384) }).strict(),
|
|
201
|
+
]);
|
|
202
|
+
exports.supervisionSchema = zod_1.z
|
|
203
|
+
.object({
|
|
204
|
+
childAccountId: accountId,
|
|
205
|
+
guardianAccountId: accountId.nullable(),
|
|
206
|
+
status: zod_1.z.enum(safety_1.SUPERVISION_STATUSES),
|
|
207
|
+
policyVersion: zod_1.z.literal(safety_1.SAFETY_POLICY_VERSION),
|
|
208
|
+
consentVersion: zod_1.z.literal(safety_1.SUPERVISION_CONSENT_VERSION),
|
|
209
|
+
createdAt: zod_1.z.string().datetime(),
|
|
210
|
+
})
|
|
211
|
+
.strict();
|
|
212
|
+
exports.supervisionInvitationSchema = zod_1.z
|
|
213
|
+
.object({
|
|
214
|
+
id: accountId,
|
|
215
|
+
childAccountId: accountId,
|
|
216
|
+
guardianAccountId: accountId,
|
|
217
|
+
status: zod_1.z.enum(safety_1.SUPERVISION_INVITATION_STATUSES),
|
|
218
|
+
expiresAt: zod_1.z.string().datetime(),
|
|
219
|
+
consentVersion: zod_1.z.literal(safety_1.SUPERVISION_CONSENT_VERSION),
|
|
220
|
+
createdAt: zod_1.z.string().datetime(),
|
|
221
|
+
})
|
|
222
|
+
.strict();
|
|
223
|
+
exports.supervisionContactSchema = zod_1.z
|
|
224
|
+
.object({
|
|
225
|
+
childAccountId: accountId,
|
|
226
|
+
contactAccountId: accountId,
|
|
227
|
+
approvedAt: zod_1.z.string().datetime(),
|
|
228
|
+
})
|
|
229
|
+
.strict();
|
|
230
|
+
exports.supervisionStateSchema = zod_1.z
|
|
231
|
+
.object({
|
|
232
|
+
self: exports.supervisionSchema.nullable(),
|
|
233
|
+
children: zod_1.z.array(exports.supervisionSchema).max(100),
|
|
234
|
+
invitations: zod_1.z.array(exports.supervisionInvitationSchema).max(100),
|
|
235
|
+
})
|
|
236
|
+
.strict();
|
|
237
|
+
exports.supervisionContactsResponseSchema = zod_1.z
|
|
238
|
+
.object({ items: zod_1.z.array(exports.supervisionContactSchema).max(1000) })
|
|
239
|
+
.strict();
|
|
240
|
+
const fingerprint = zod_1.z.string().regex(/^[a-f0-9]{64}$/);
|
|
241
|
+
const minorUnits = zod_1.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
242
|
+
exports.purchaseApprovalLineSchema = zod_1.z
|
|
243
|
+
.object({
|
|
244
|
+
itemReference: resourceId,
|
|
245
|
+
title: zod_1.z.string().trim().min(1).max(300),
|
|
246
|
+
optionsText: zod_1.z.string().trim().max(300),
|
|
247
|
+
merchantAccountId: accountId,
|
|
248
|
+
quantity: zod_1.z.number().int().min(1).max(1000000),
|
|
249
|
+
unitAmountMinor: minorUnits,
|
|
250
|
+
lineAmountMinor: minorUnits,
|
|
251
|
+
})
|
|
252
|
+
.strict();
|
|
253
|
+
const purchaseEffectsObject = zod_1.z
|
|
254
|
+
.object({
|
|
255
|
+
operationId: resourceId,
|
|
256
|
+
resourceId,
|
|
257
|
+
cartFingerprint: fingerprint,
|
|
258
|
+
summary: zod_1.z.string().trim().min(1).max(300),
|
|
259
|
+
merchantAccountIds: zod_1.z
|
|
260
|
+
.array(accountId)
|
|
261
|
+
.min(1)
|
|
262
|
+
.max(100)
|
|
263
|
+
.refine((ids) => new Set(ids).size === ids.length, 'Merchant accounts must be unique')
|
|
264
|
+
.transform((ids) => [...ids].sort()),
|
|
265
|
+
lineItems: zod_1.z.array(exports.purchaseApprovalLineSchema).min(1).max(200),
|
|
266
|
+
shippingMinor: minorUnits,
|
|
267
|
+
taxMinor: minorUnits,
|
|
268
|
+
discountMinor: minorUnits,
|
|
269
|
+
roundingAdjustmentMinor: zod_1.z
|
|
270
|
+
.number()
|
|
271
|
+
.int()
|
|
272
|
+
.min(-Number.MAX_SAFE_INTEGER)
|
|
273
|
+
.max(Number.MAX_SAFE_INTEGER),
|
|
274
|
+
paymentFingerprint: fingerprint,
|
|
275
|
+
amountMinor: minorUnits,
|
|
276
|
+
currency: zod_1.z.string().regex(/^[A-Z]{3}$/),
|
|
277
|
+
expiresAt: zod_1.z.string().datetime(),
|
|
278
|
+
})
|
|
279
|
+
.strict();
|
|
280
|
+
function validatePurchaseEvidence(value, ctx) {
|
|
281
|
+
const merchants = new Set(value.merchantAccountIds);
|
|
282
|
+
const references = new Set();
|
|
283
|
+
for (const line of value.lineItems) {
|
|
284
|
+
const key = `${line.merchantAccountId}:${line.itemReference}`;
|
|
285
|
+
if (!merchants.has(line.merchantAccountId) || references.has(key))
|
|
286
|
+
ctx.addIssue({
|
|
287
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
288
|
+
message: 'Purchase lines must name an included merchant and unique item reference',
|
|
289
|
+
});
|
|
290
|
+
references.add(key);
|
|
291
|
+
}
|
|
292
|
+
if (merchants.size !== new Set(value.lineItems.map((line) => line.merchantAccountId)).size)
|
|
293
|
+
ctx.addIssue({
|
|
294
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
295
|
+
message: 'Every merchant must have an approval line',
|
|
296
|
+
});
|
|
297
|
+
const total = value.lineItems.reduce((sum, line) => sum + BigInt(line.lineAmountMinor), 0n) +
|
|
298
|
+
BigInt(value.shippingMinor) +
|
|
299
|
+
BigInt(value.taxMinor) -
|
|
300
|
+
BigInt(value.discountMinor) +
|
|
301
|
+
BigInt(value.roundingAdjustmentMinor);
|
|
302
|
+
if (total < 0n || total > BigInt(Number.MAX_SAFE_INTEGER) || total !== BigInt(value.amountMinor))
|
|
303
|
+
ctx.addIssue({
|
|
304
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
305
|
+
message: 'Approval evidence must equal the exact payment total',
|
|
306
|
+
});
|
|
307
|
+
if (Math.abs(value.roundingAdjustmentMinor) >
|
|
308
|
+
value.lineItems.length + 3 * value.merchantAccountIds.length)
|
|
309
|
+
ctx.addIssue({
|
|
310
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
311
|
+
message: 'Rounding adjustment exceeds the bounded conversion stages',
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
exports.purchaseEffectsSchema = purchaseEffectsObject.superRefine(validatePurchaseEvidence);
|
|
315
|
+
const purchaseApprovalFields = {
|
|
316
|
+
id: accountId,
|
|
317
|
+
childAccountId: accountId,
|
|
318
|
+
applicationId: accountId,
|
|
319
|
+
status: zod_1.z.enum(safety_1.PURCHASE_APPROVAL_STATUSES),
|
|
320
|
+
createdAt: zod_1.z.string().datetime(),
|
|
321
|
+
receiptReference: zod_1.z.string().max(512).nullable(),
|
|
322
|
+
};
|
|
323
|
+
exports.purchaseApprovalSchema = purchaseEffectsObject
|
|
324
|
+
.extend(purchaseApprovalFields)
|
|
325
|
+
.strict()
|
|
326
|
+
.superRefine(validatePurchaseEvidence);
|
|
327
|
+
exports.purchaseApprovalSummarySchema = purchaseEffectsObject
|
|
328
|
+
.omit({ lineItems: true })
|
|
329
|
+
.extend(purchaseApprovalFields)
|
|
330
|
+
.strict();
|
|
331
|
+
exports.purchaseApprovalListSchema = zod_1.z
|
|
332
|
+
.object({
|
|
333
|
+
items: zod_1.z.array(exports.purchaseApprovalSummarySchema).max(100),
|
|
334
|
+
nextCursor: zod_1.z.string().nullable(),
|
|
335
|
+
})
|
|
336
|
+
.strict();
|
|
337
|
+
exports.reservePurchaseSchema = purchaseEffectsObject
|
|
338
|
+
.extend({ approvalId: accountId })
|
|
339
|
+
.strict()
|
|
340
|
+
.superRefine(validatePurchaseEvidence);
|
|
341
|
+
exports.confirmPurchaseSchema = zod_1.z
|
|
342
|
+
.object({
|
|
343
|
+
approvalId: accountId,
|
|
344
|
+
operationId: resourceId,
|
|
345
|
+
receiptReference: zod_1.z.string().trim().min(1).max(512),
|
|
346
|
+
})
|
|
347
|
+
.strict();
|
|
348
|
+
exports.cancelPurchaseSchema = exports.confirmPurchaseSchema.omit({ receiptReference: true });
|
|
349
|
+
exports.SAFETY_ERROR_CODES = [
|
|
350
|
+
'bad_request',
|
|
351
|
+
'validation_failed',
|
|
352
|
+
'unauthorized',
|
|
353
|
+
'forbidden',
|
|
354
|
+
'not_found',
|
|
355
|
+
'conflict',
|
|
356
|
+
'reauth_required',
|
|
357
|
+
'limit_reached',
|
|
358
|
+
'service_unavailable',
|
|
359
|
+
'rate_limited',
|
|
360
|
+
];
|
|
361
|
+
exports.safetyErrorSchema = zod_1.z
|
|
362
|
+
.object({ error: zod_1.z.object({ code: zod_1.z.enum(exports.SAFETY_ERROR_CODES), message: zod_1.z.string() }).strict() })
|
|
363
|
+
.strict();
|
|
364
|
+
exports.supervisionInviteInputSchema = zod_1.z
|
|
365
|
+
.object({
|
|
366
|
+
guardianAccountId: accountId,
|
|
367
|
+
consentVersion: zod_1.z.literal(safety_1.SUPERVISION_CONSENT_VERSION),
|
|
368
|
+
reauth: signIn_1.reauthProofSchema,
|
|
369
|
+
})
|
|
370
|
+
.strict();
|
|
371
|
+
exports.supervisionAcceptInputSchema = zod_1.z
|
|
372
|
+
.object({ consentVersion: zod_1.z.literal(safety_1.SUPERVISION_CONSENT_VERSION), reauth: signIn_1.reauthProofSchema })
|
|
373
|
+
.strict();
|
|
374
|
+
exports.supervisionContactInputSchema = zod_1.z
|
|
375
|
+
.object({ childAccountId: accountId, contactAccountId: accountId, reauth: signIn_1.reauthProofSchema })
|
|
376
|
+
.strict();
|
|
377
|
+
exports.supervisionReviewInputSchema = zod_1.z
|
|
378
|
+
.object({
|
|
379
|
+
childAccountId: accountId,
|
|
380
|
+
action: zod_1.z.enum(['end', 'transfer']),
|
|
381
|
+
guardianAccountId: accountId.optional(),
|
|
382
|
+
evidenceReference: zod_1.z.string().trim().min(1).max(2048),
|
|
383
|
+
reauth: signIn_1.reauthProofSchema,
|
|
384
|
+
})
|
|
385
|
+
.strict();
|
|
386
|
+
exports.purchaseReviewInputSchema = zod_1.z
|
|
387
|
+
.object({ decision: zod_1.z.enum(['approved', 'rejected']), reauth: signIn_1.reauthProofSchema })
|
|
388
|
+
.strict();
|
|
389
|
+
exports.safetySessionInputSchema = zod_1.z
|
|
390
|
+
.object({
|
|
391
|
+
sessionId: accountId,
|
|
392
|
+
accessToken: zod_1.z.string().min(1).max(16384),
|
|
393
|
+
action: zod_1.z.enum(safety_1.SUPERVISED_ACTIONS),
|
|
394
|
+
})
|
|
395
|
+
.strict();
|
|
396
|
+
exports.safetySessionValidationSchema = zod_1.z
|
|
397
|
+
.object({
|
|
398
|
+
valid: zod_1.z.literal(true),
|
|
399
|
+
sessionId: accountId,
|
|
400
|
+
expiresAt: zod_1.z.string().datetime(),
|
|
401
|
+
lastActivity: zod_1.z.string().datetime(),
|
|
402
|
+
user: userResponse_1.userResponseSchema,
|
|
403
|
+
actor: accountSubject_1.accountActorChainSchema,
|
|
404
|
+
})
|
|
405
|
+
.strict();
|
|
406
|
+
/** Minimal identity for the authenticated account's supervision management, never profile details. */
|
|
407
|
+
exports.safetyPersonSchema = zod_1.z
|
|
408
|
+
.object({ accountId, username: zod_1.z.string().nullable(), displayName: zod_1.z.string().nullable() })
|
|
409
|
+
.strict();
|
|
410
|
+
exports.safetyPeopleInputSchema = zod_1.z.union([
|
|
411
|
+
zod_1.z.object({ query: zod_1.z.string().trim().min(2).max(100) }).strict(),
|
|
412
|
+
zod_1.z.object({ accountIds: uniqueIds(100) }).strict(),
|
|
413
|
+
]);
|
|
414
|
+
exports.safetyPeopleResponseSchema = zod_1.z
|
|
415
|
+
.object({ items: zod_1.z.array(exports.safetyPersonSchema).max(100) })
|
|
416
|
+
.strict();
|
|
417
|
+
/** Existing public employer identity only; never directory content or management authority. */
|
|
418
|
+
exports.safetyOrganizationIdentitySchema = zod_1.z
|
|
419
|
+
.object({
|
|
420
|
+
accountId,
|
|
421
|
+
username: zod_1.z.string().nullable(),
|
|
422
|
+
name: zod_1.z.string(),
|
|
423
|
+
organizationType: zod_1.z.enum(organizations_1.ORGANIZATION_TYPES),
|
|
424
|
+
})
|
|
425
|
+
.strict();
|
|
426
|
+
exports.safetyOrganizationsInputSchema = zod_1.z.union([
|
|
427
|
+
zod_1.z
|
|
428
|
+
.object({
|
|
429
|
+
query: zod_1.z.string().trim().min(1).max(100),
|
|
430
|
+
limit: zod_1.z.number().int().min(1).max(20).optional(),
|
|
431
|
+
})
|
|
432
|
+
.strict(),
|
|
433
|
+
zod_1.z.object({ ids: uniqueIds(100) }).strict(),
|
|
434
|
+
]);
|
|
435
|
+
exports.safetyOrganizationsResponseSchema = zod_1.z
|
|
436
|
+
.object({
|
|
437
|
+
items: zod_1.z
|
|
438
|
+
.array(zod_1.z
|
|
439
|
+
.object({ requestedAccountId: accountId, organization: exports.safetyOrganizationIdentitySchema })
|
|
440
|
+
.strict())
|
|
441
|
+
.max(100),
|
|
442
|
+
missingIds: zod_1.z.array(accountId).max(100),
|
|
443
|
+
})
|
|
444
|
+
.strict();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serviceTokenOptionsSchema = exports.serviceTokenScopesSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/** Omitted means the existing grant; an explicit set only narrows that authority. */
|
|
6
|
+
exports.serviceTokenScopesSchema = zod_1.z
|
|
7
|
+
.array(zod_1.z.string().trim().min(1).max(128))
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(100)
|
|
10
|
+
.refine((scopes) => new Set(scopes).size === scopes.length, 'Requested scopes must be unique')
|
|
11
|
+
.transform((scopes) => [...scopes].sort());
|
|
12
|
+
exports.serviceTokenOptionsSchema = zod_1.z
|
|
13
|
+
.object({ scopes: exports.serviceTokenScopesSchema.optional() })
|
|
14
|
+
.strict();
|