@oxy.so/contracts 5.2.0 → 5.4.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/accountGraph.js +8 -5
- package/dist/cjs/accountName.js +20 -0
- package/dist/cjs/accountSubject.js +4 -2
- package/dist/cjs/client/accountGraph.js +2 -0
- package/dist/cjs/client/accountName.js +56 -0
- package/dist/cjs/client/index.js +12 -4
- package/dist/cjs/client/organizations.js +5 -4
- package/dist/cjs/index.js +31 -15
- package/dist/cjs/organizations.js +3 -7
- package/dist/cjs/sessionRevocation.js +89 -0
- package/dist/esm/accountGraph.js +9 -6
- package/dist/esm/accountName.js +12 -0
- package/dist/esm/accountSubject.js +4 -2
- package/dist/esm/client/accountGraph.js +2 -0
- package/dist/esm/client/accountName.js +51 -0
- package/dist/esm/client/index.js +1 -0
- package/dist/esm/client/organizations.js +5 -4
- package/dist/esm/index.js +2 -0
- package/dist/esm/organizations.js +4 -8
- package/dist/esm/sessionRevocation.js +86 -0
- package/dist/types/accountAccess.d.ts +5 -5
- package/dist/types/accountGraph.d.ts +12 -12
- package/dist/types/accountName.d.ts +5 -0
- package/dist/types/accountSubject.d.ts +3 -2
- package/dist/types/agency.d.ts +28 -28
- package/dist/types/client/accountGraph.d.ts +12 -6
- package/dist/types/client/accountName.d.ts +48 -0
- package/dist/types/client/deviceDirectory.d.ts +3 -3
- package/dist/types/client/index.d.ts +1 -0
- package/dist/types/client/organizations.d.ts +8 -7
- package/dist/types/client/safety.d.ts +2 -2
- package/dist/types/deviceDirectory.d.ts +33 -33
- package/dist/types/externalIdentity.d.ts +14 -14
- package/dist/types/index.d.ts +4 -0
- package/dist/types/inference/economics.d.ts +2 -2
- package/dist/types/inference/providerConnection.d.ts +4 -4
- package/dist/types/notifications.d.ts +4 -4
- package/dist/types/organizations.d.ts +41 -40
- package/dist/types/safety.d.ts +22 -22
- package/dist/types/sessionRevocation.d.ts +100 -0
- package/dist/types/stickers.d.ts +9 -9
- package/dist/types/userResponse.d.ts +42 -42
- package/package.json +1 -1
package/dist/esm/accountGraph.js
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { avatarCharacterSchema } from './avatarCharacter.js';
|
|
11
|
-
import {
|
|
11
|
+
import { accountTitleSchema } from './accountName.js';
|
|
12
|
+
import { ACCOUNT_TITLE_MAX_LENGTH } from './client/accountName.js';
|
|
13
|
+
import { ORGANIZATION_TYPES } from './organizations.js';
|
|
12
14
|
import { usernameSchema, usernameSchemaForAccountKind } from './username.js';
|
|
13
15
|
// The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
|
|
14
16
|
// it is re-exported here so the root entry is unchanged.
|
|
@@ -69,7 +71,7 @@ export const accountNameSchema = z
|
|
|
69
71
|
.object({
|
|
70
72
|
first: z.string().trim().max(100).optional(),
|
|
71
73
|
last: z.string().trim().max(100).optional(),
|
|
72
|
-
displayName: z.string().trim().max(
|
|
74
|
+
displayName: z.string().trim().max(ACCOUNT_TITLE_MAX_LENGTH).optional(),
|
|
73
75
|
})
|
|
74
76
|
.optional();
|
|
75
77
|
/**
|
|
@@ -81,7 +83,7 @@ export const accountNameSchema = z
|
|
|
81
83
|
* this route. The refinement the single-valued predecessor needed disappeared
|
|
82
84
|
* along with the restriction that made it necessary. A child kind that does NOT
|
|
83
85
|
* accept categories would break that reasoning silently, so
|
|
84
|
-
* `__tests__/accountGraph.test.ts` asserts
|
|
86
|
+
* `__tests__/accountGraph.test.ts` asserts every child kind is a category kind.
|
|
85
87
|
*/
|
|
86
88
|
export const createAccountRequestSchema = z
|
|
87
89
|
.object({
|
|
@@ -182,9 +184,10 @@ export const createAccountRequestSchema = z
|
|
|
182
184
|
}
|
|
183
185
|
const displayName = request.name?.displayName;
|
|
184
186
|
if (displayName) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
// A child kind is never `personal`, so every child is named by the
|
|
188
|
+
// title policy; the person policy's character classes live in
|
|
189
|
+
// `@oxy.so/core`, which this package cannot import.
|
|
190
|
+
const parsedName = accountTitleSchema.safeParse(displayName);
|
|
188
191
|
if (!parsedName.success) {
|
|
189
192
|
for (const issue of parsedName.error.issues) {
|
|
190
193
|
ctx.addIssue({ ...issue, path: ['name', 'displayName', ...issue.path] });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
|
|
3
|
+
// it is re-exported here so the root entry carries the whole policy.
|
|
4
|
+
import { ACCOUNT_TITLE_MAX_LENGTH, isPlainTextTitle } from './client/accountName.js';
|
|
5
|
+
export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_TITLE_MAX_LENGTH, accountNamePolicyForKind, isPlainTextTitle, } from './client/accountName.js';
|
|
6
|
+
/** A non-personal account's title — see `./client/accountName.ts` for the policy. */
|
|
7
|
+
export const accountTitleSchema = z
|
|
8
|
+
.string()
|
|
9
|
+
.trim()
|
|
10
|
+
.min(1)
|
|
11
|
+
.max(ACCOUNT_TITLE_MAX_LENGTH)
|
|
12
|
+
.refine(isPlainTextTitle, 'Name must be plain text');
|
|
@@ -44,8 +44,9 @@ export const ACCOUNT_SUBJECT_CONTRACT_VERSION = 1;
|
|
|
44
44
|
* - `person` — a human; a personal account is its own actor.
|
|
45
45
|
* - `agent` — an AI agent; a bot is its own actor (ADR 0018 `ActorRef`
|
|
46
46
|
* `{type:'agent'}`), and audit records the bot, never the human who owns it.
|
|
47
|
-
* - `operated` — never its own actor. An organization, project
|
|
48
|
-
* acts through a member, and that
|
|
47
|
+
* - `operated` — never its own actor. An organization, project, channel or
|
|
48
|
+
* community only acts through a member (a community's moderators), and that
|
|
49
|
+
* member is the actor.
|
|
49
50
|
*/
|
|
50
51
|
export const ACCOUNT_ACTOR_NATURES = ['person', 'agent', 'operated'];
|
|
51
52
|
export const accountActorNatureSchema = z.enum(ACCOUNT_ACTOR_NATURES);
|
|
@@ -59,6 +60,7 @@ const ACTOR_NATURE_BY_KIND = {
|
|
|
59
60
|
organization: 'operated',
|
|
60
61
|
project: 'operated',
|
|
61
62
|
channel: 'operated',
|
|
63
|
+
community: 'operated',
|
|
62
64
|
};
|
|
63
65
|
/** `null` for a value that is not an account kind. Never a guess. */
|
|
64
66
|
export function accountKindActorNature(kind) {
|
|
@@ -21,6 +21,7 @@ export const ACCOUNT_KINDS = [
|
|
|
21
21
|
'project',
|
|
22
22
|
'bot',
|
|
23
23
|
'channel',
|
|
24
|
+
'community',
|
|
24
25
|
];
|
|
25
26
|
export const CHILD_ACCOUNT_KINDS = [
|
|
26
27
|
'organization',
|
|
@@ -301,6 +302,7 @@ export const ACCOUNT_CATEGORY_KINDS = [
|
|
|
301
302
|
'project',
|
|
302
303
|
'bot',
|
|
303
304
|
'channel',
|
|
305
|
+
'community',
|
|
304
306
|
];
|
|
305
307
|
/**
|
|
306
308
|
* Whether an account of this kind may carry categories.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The account-name policy, without Zod. Schema: `../accountName.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
5
|
+
*
|
|
6
|
+
* An account's name follows ONE of two policies, chosen by its `kind` and by
|
|
7
|
+
* nothing else — not by which route wrote it, nor by whether it is native or
|
|
8
|
+
* federated:
|
|
9
|
+
*
|
|
10
|
+
* - `person`: a human name. Letters of the allowlisted scripts, combining
|
|
11
|
+
* marks, spaces, the apostrophe and letter-flanked name separators; no
|
|
12
|
+
* digits. The character classes are generated data and live in
|
|
13
|
+
* `@oxy.so/core` (`isValidDisplayName`), which applies this table through
|
|
14
|
+
* `isValidAccountName`.
|
|
15
|
+
* - `title`: what an organization, project, bot, channel or community is called. Plain
|
|
16
|
+
* text — digits and punctuation are part of real titles ("Studio 54",
|
|
17
|
+
* "Blink-182") — without markup or control characters. Defined here, once.
|
|
18
|
+
*/
|
|
19
|
+
import { maxLength, minLength, refine, string, trim } from './check.js';
|
|
20
|
+
/**
|
|
21
|
+
* The policy for each kind. A `Record` over the whole union, so adding a kind
|
|
22
|
+
* fails this file's typecheck until someone decides how it is named.
|
|
23
|
+
*/
|
|
24
|
+
export const ACCOUNT_NAME_POLICY_BY_KIND = {
|
|
25
|
+
personal: 'person',
|
|
26
|
+
organization: 'title',
|
|
27
|
+
project: 'title',
|
|
28
|
+
bot: 'title',
|
|
29
|
+
channel: 'title',
|
|
30
|
+
community: 'title',
|
|
31
|
+
};
|
|
32
|
+
/** A missing kind is `personal`, the `users.kind` column default. */
|
|
33
|
+
export function accountNamePolicyForKind(kind) {
|
|
34
|
+
return ACCOUNT_NAME_POLICY_BY_KIND[kind ?? 'personal'];
|
|
35
|
+
}
|
|
36
|
+
/** Longest title, in UTF-16 code units after trimming. */
|
|
37
|
+
export const ACCOUNT_TITLE_MAX_LENGTH = 300;
|
|
38
|
+
/**
|
|
39
|
+
* Source of the characters a title may not contain: `<`, `>`, the C0 controls
|
|
40
|
+
* and DEL. A class of literal code points — no property escapes — so it
|
|
41
|
+
* compiles on Hermes. The probe below rejects with it; the API compiles it with
|
|
42
|
+
* `g` to strip untrusted titles, so the gate and the strip cannot disagree.
|
|
43
|
+
*/
|
|
44
|
+
export const ACCOUNT_TITLE_DISALLOWED_SOURCE = '[<>\\u0000-\\u001F\\u007F]';
|
|
45
|
+
const TITLE_DISALLOWED_PROBE = new RegExp(ACCOUNT_TITLE_DISALLOWED_SOURCE, 'u');
|
|
46
|
+
/** Whether `value` holds no character the title policy disallows. */
|
|
47
|
+
export function isPlainTextTitle(value) {
|
|
48
|
+
return !TITLE_DISALLOWED_PROBE.test(value);
|
|
49
|
+
}
|
|
50
|
+
/** The twin of `accountTitleSchema`. */
|
|
51
|
+
export const accountTitleCheck = refine(string(trim, minLength(1), maxLength(ACCOUNT_TITLE_MAX_LENGTH)), isPlainTextTitle, 'Name must be plain text');
|
package/dist/esm/client/index.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
export { ContractCheckError, checkContract, formatCheckPath, parseContract, } from './check.js';
|
|
18
18
|
export { ACCOUNT_CATEGORY_IDS, ACCOUNT_CATEGORY_KINDS, ACCOUNT_KINDS, CHILD_ACCOUNT_KINDS, MAX_ACCOUNT_CATEGORIES, RETIRED_ACCOUNT_CATEGORY_IDS, SELECTABLE_ACCOUNT_CATEGORY_IDS, isAccountKind, isDelegatedActAsEligibleKind, isOperatorSwitchTargetKind, isSelectableAccountCategoryId, kindAcceptsAccountCategories, newlyAddedRetiredCategories, } from './accountGraph.js';
|
|
19
|
+
export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_TITLE_MAX_LENGTH, accountNamePolicyForKind, accountTitleCheck, isPlainTextTitle, } from './accountName.js';
|
|
19
20
|
export { EMAIL_CODE_LENGTH, EMAIL_CODE_MAX_ATTEMPTS, EMAIL_CODE_TTL_MS, EMAIL_TICKET_TTL_MS, EMAIL_VERIFICATION_ERROR_CODES, EMAIL_VERIFICATION_PURPOSES, emailAddressCheck, emailTicketCheck, emailVerificationConfirmResponseCheck, emailVerificationStartResponseCheck, } from './accountEmail.js';
|
|
20
21
|
export { ACCOUNT_AUTH_METHODS, AGENT_PROOF_ACTIONS, AGENT_PROOF_AUDIENCE, AGENT_PROOF_TTL_MS, agentChallengeRequestCheck, agentKeyListResponseCheck, agentKeyOperationChallengeCheck, agentKeyOperationCheck, agentKeyOperationResultCheck, agentProofClaimsCheck, agentVerifyRequestCheck, executeAgentKeyOperationCheck, } from './agentKeys.js';
|
|
21
22
|
export { isLoopbackOrigin } from '../capabilityBindings.js';
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
5
5
|
*/
|
|
6
|
+
import { ACCOUNT_TITLE_MAX_LENGTH, accountTitleCheck } from './accountName.js';
|
|
6
7
|
import { array, boolean, datetime, exact, maxItems, maxLength, minLength, nullable, oneOf, optional, pattern, refine, strictObject, string, trim, url, } from './check.js';
|
|
7
8
|
/** Real-world identity classification, independent of account topics and permissions. */
|
|
8
9
|
export const ORGANIZATION_TYPES = [
|
|
@@ -22,7 +23,8 @@ export const ORGANIZATION_ALIAS_KINDS = [
|
|
|
22
23
|
'misspelling',
|
|
23
24
|
];
|
|
24
25
|
export const ORGANIZATION_CLAIM_DECISIONS = ['pending', 'approved', 'rejected'];
|
|
25
|
-
|
|
26
|
+
/** An organization's name is a title; the cap is the title policy's. */
|
|
27
|
+
export const ORGANIZATION_NAME_MAX_LENGTH = ACCOUNT_TITLE_MAX_LENGTH;
|
|
26
28
|
export const ORGANIZATION_ERROR_CODES = [
|
|
27
29
|
'bad_request',
|
|
28
30
|
'unauthorized',
|
|
@@ -47,9 +49,8 @@ const organizationAlias = strictObject({
|
|
|
47
49
|
kind: oneOf(ORGANIZATION_ALIAS_KINDS),
|
|
48
50
|
language: optional(string(minLength(2), maxLength(35))),
|
|
49
51
|
});
|
|
50
|
-
/** The twin of `organizationNameSchema
|
|
51
|
-
export const organizationNameCheck =
|
|
52
|
-
Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127), 'Organization name must be plain text');
|
|
52
|
+
/** The twin of `organizationNameSchema`: the title policy (`./accountName.ts`). */
|
|
53
|
+
export const organizationNameCheck = accountTitleCheck;
|
|
53
54
|
const organizationFields = {
|
|
54
55
|
name: organizationNameCheck,
|
|
55
56
|
organizationType: oneOf(ORGANIZATION_TYPES),
|
package/dist/esm/index.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* expo, no `require()` in the ESM build.
|
|
11
11
|
*/
|
|
12
12
|
export { ACCOUNT_KINDS, accountKindSchema, CHILD_ACCOUNT_KINDS, childAccountKindSchema, isAccountKind, isDelegatedActAsEligibleKind, isOperatorSwitchTargetKind, ACCOUNT_CATEGORY_IDS, ACCOUNT_CATEGORY_KINDS, accountCategoriesSchema, accountCategoryIdSchema, isSelectableAccountCategoryId, kindAcceptsAccountCategories, MAX_ACCOUNT_CATEGORIES, newlyAddedRetiredCategories, RETIRED_ACCOUNT_CATEGORY_IDS, SELECTABLE_ACCOUNT_CATEGORY_IDS, createAccountRequestSchema, accountNameSchema, } from './accountGraph.js';
|
|
13
|
+
export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_TITLE_MAX_LENGTH, accountNamePolicyForKind, accountTitleSchema, isPlainTextTitle, } from './accountName.js';
|
|
13
14
|
export { AVATAR_EYE_SPACING, AVATAR_PICKABLE_COLORS, AVATAR_PICKABLE_SHAPES, avatarCharacterFor, avatarCharacterSchema, parseAvatarCharacter, } from './avatarCharacter.js';
|
|
14
15
|
export { ACCOUNT_ACTOR_NATURES, ACCOUNT_SUBJECT_CONTRACT_VERSION, FINANCIAL_EFFECT_DIRECTIONS, KIND_INDEPENDENT_ACCOUNT_DIMENSIONS, accountActorChainFromSession, accountActorChainSchema, accountActorNatureSchema, accountKindActorNature, accountKindActsAsItself, attributeFinancialEffect, financialEffectAttributionSchema, } from './accountSubject.js';
|
|
15
16
|
export { usernameSchema, usernameSchemaForAccountKind, isValidUsername, stripDisallowedUsernameCharacters, applyBotUsernameSuffix, USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH, USERNAME_INVALID_MESSAGE, BOT_USERNAME_INVALID_MESSAGE, RESERVED_USERNAME_MESSAGE, NUMERIC_USERNAME_MESSAGE, } from './username.js';
|
|
@@ -28,6 +29,7 @@ export {
|
|
|
28
29
|
COMMONS_DENY_REASONS, commonsDenyReasonSchema, IDENTITY_APPROVAL_PUSH_CHANNEL, } from './commonsSignIn.js';
|
|
29
30
|
export { INBOX_EMAIL_PUSH_CHANNEL, INBOX_EMAIL_PUSH_TYPE, inboxEmailPushDataSchema, } from './inboxPush.js';
|
|
30
31
|
export { OXY_USER_INVALIDATION_CHANNEL, OXY_USER_CHANGE_REASONS, OXY_PUBLISHED_USER_CHANGE_REASONS, isPublishedOxyUserChangeReason, oxyUserInvalidationEventSchema, } from './userInvalidation.js';
|
|
32
|
+
export { OXY_SERVICE_EVENTS_NAMESPACE, OXY_SESSION_REVOKED_EVENT, OXY_SERVICE_EVENTS_HEARTBEAT_EVENT, OXY_SERVICE_EVENTS_HEARTBEAT_MS, OXY_SERVICE_EVENTS_STALE_AFTER_MS, OXY_SERVICE_EVENTS_FORBIDDEN, oxySessionRevocationEventSchema, oxyServiceEventsHeartbeatSchema, } from './sessionRevocation.js';
|
|
31
33
|
export {
|
|
32
34
|
// Schemas
|
|
33
35
|
recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, appAffinityEventTypeSchema, appAffinityEventSchema, appAffinityEventsIngestSchema, } from './recommendations.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { accountTitleSchema } from './accountName.js';
|
|
2
3
|
// The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
|
|
3
4
|
// it is re-exported here so the root entry is unchanged.
|
|
4
|
-
import { ORGANIZATION_TYPES, ORGANIZATION_STATUSES, ORGANIZATION_CLAIM_STATUSES, ORGANIZATION_ALIAS_KINDS, ORGANIZATION_CLAIM_DECISIONS,
|
|
5
|
+
import { ORGANIZATION_TYPES, ORGANIZATION_STATUSES, ORGANIZATION_CLAIM_STATUSES, ORGANIZATION_ALIAS_KINDS, ORGANIZATION_CLAIM_DECISIONS, ORGANIZATION_ERROR_CODES, } from './client/organizations.js';
|
|
5
6
|
export { ORGANIZATION_TYPES, ORGANIZATION_STATUSES, ORGANIZATION_CLAIM_STATUSES, ORGANIZATION_ALIAS_KINDS, ORGANIZATION_CLAIM_DECISIONS, ORGANIZATION_NAME_MAX_LENGTH, ORGANIZATION_ERROR_CODES, } from './client/organizations.js';
|
|
6
7
|
const id = z.string().min(1).max(128);
|
|
7
8
|
const optionalText = (max) => z.string().trim().min(1).max(max).nullable().optional();
|
|
@@ -12,13 +13,8 @@ export const organizationAliasSchema = z
|
|
|
12
13
|
language: z.string().min(2).max(35).optional(),
|
|
13
14
|
})
|
|
14
15
|
.strict();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.trim()
|
|
18
|
-
.min(1)
|
|
19
|
-
.max(ORGANIZATION_NAME_MAX_LENGTH)
|
|
20
|
-
.refine((value) => !/[<>]/.test(value) &&
|
|
21
|
-
Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127), 'Organization name must be plain text');
|
|
16
|
+
/** An organization is named by the title policy every non-personal account uses. */
|
|
17
|
+
export const organizationNameSchema = accountTitleSchema;
|
|
22
18
|
export const createOrganizationSchema = z
|
|
23
19
|
.object({
|
|
24
20
|
name: organizationNameSchema,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical contract for the session-revocation feed: oxy-api telling every
|
|
3
|
+
* connected Oxy backend that a session stopped being valid.
|
|
4
|
+
*
|
|
5
|
+
* WHY IT EXISTS. `@oxy.so/core/server` reuses a successful bearer validation on
|
|
6
|
+
* a backend for a short TTL, because an app backend cannot verify a user access
|
|
7
|
+
* token itself (HS256 under a secret only oxy-api holds) and asking Oxy on every
|
|
8
|
+
* request put ~300 ms on every authenticated route. A cache like that is only
|
|
9
|
+
* safe if it hears about revocations the moment they happen. This feed is how it
|
|
10
|
+
* hears: oxy-api announces every session it ends — logout, sign-out-all, device
|
|
11
|
+
* removal, an account switched away from, an admin or operator revocation, a
|
|
12
|
+
* credential change that ends sessions, account deletion or archive — and the
|
|
13
|
+
* SDK drops what it cached for that session or user.
|
|
14
|
+
*
|
|
15
|
+
* THE TRANSPORT IS THE SDK's. A backend opens no Redis client and wires nothing:
|
|
16
|
+
* `OxyServer` connects to the {@link OXY_SERVICE_EVENTS_NAMESPACE} Socket.IO
|
|
17
|
+
* namespace on oxy-api with its own service token, and uses its validation cache
|
|
18
|
+
* ONLY while that connection is live (connected, and a
|
|
19
|
+
* {@link OXY_SERVICE_EVENTS_HEARTBEAT_EVENT} seen within
|
|
20
|
+
* {@link OXY_SERVICE_EVENTS_STALE_AFTER_MS}). Disconnected, stale or never
|
|
21
|
+
* connected, it validates every request against Oxy. So a lost connection costs
|
|
22
|
+
* latency, never correctness.
|
|
23
|
+
*
|
|
24
|
+
* DELIVERY. A revocation is announced after the write that ended the session
|
|
25
|
+
* committed. Between oxy-api tasks it rides Valkey pub/sub, which is
|
|
26
|
+
* at-most-once; the heartbeat is what makes a silent loss of the path visible —
|
|
27
|
+
* a task emits it only while its own Valkey round trip works — so a consumer
|
|
28
|
+
* stops trusting its cache when the path stops working, instead of trusting it
|
|
29
|
+
* forever.
|
|
30
|
+
*
|
|
31
|
+
* PRIVACY — the payload carries ids and a timestamp only. Only Oxy's own
|
|
32
|
+
* (internal-tier) services may join the namespace, and even so nothing a
|
|
33
|
+
* consumer could render is ever placed on it.
|
|
34
|
+
*
|
|
35
|
+
* Platform-agnostic — zod only, no react/react-native/expo.
|
|
36
|
+
*/
|
|
37
|
+
import { z } from 'zod';
|
|
38
|
+
/** The Socket.IO namespace on oxy-api that carries service events. */
|
|
39
|
+
export const OXY_SERVICE_EVENTS_NAMESPACE = '/service-events';
|
|
40
|
+
/** One session (or every session of one user) stopped being valid. */
|
|
41
|
+
export const OXY_SESSION_REVOKED_EVENT = 'session:revoked';
|
|
42
|
+
/**
|
|
43
|
+
* Emitted on connect and then every {@link OXY_SERVICE_EVENTS_HEARTBEAT_MS}
|
|
44
|
+
* while the emitting oxy-api task can still hear revocations (its Valkey
|
|
45
|
+
* subscription round-trips). Carries `{ at }`, the task's epoch-ms clock.
|
|
46
|
+
*/
|
|
47
|
+
export const OXY_SERVICE_EVENTS_HEARTBEAT_EVENT = 'heartbeat';
|
|
48
|
+
/** How often a live oxy-api task sends {@link OXY_SERVICE_EVENTS_HEARTBEAT_EVENT}. */
|
|
49
|
+
export const OXY_SERVICE_EVENTS_HEARTBEAT_MS = 5000;
|
|
50
|
+
/**
|
|
51
|
+
* How long a consumer keeps trusting the feed after the last heartbeat. Past
|
|
52
|
+
* this the feed counts as down: every cached validation is dropped and nothing
|
|
53
|
+
* is cached until heartbeats resume.
|
|
54
|
+
*/
|
|
55
|
+
export const OXY_SERVICE_EVENTS_STALE_AFTER_MS = 12000;
|
|
56
|
+
/**
|
|
57
|
+
* The `connect_error` message oxy-api answers a caller that may never join the
|
|
58
|
+
* namespace (not a service token, or not an internal-tier application). A
|
|
59
|
+
* consumer stops retrying quickly on it; any other refusal is retried.
|
|
60
|
+
*/
|
|
61
|
+
export const OXY_SERVICE_EVENTS_FORBIDDEN = 'service_events_forbidden';
|
|
62
|
+
/**
|
|
63
|
+
* A session revocation.
|
|
64
|
+
*
|
|
65
|
+
* - With `sessionId`: that one session ended. `userId` is the account it spoke
|
|
66
|
+
* as.
|
|
67
|
+
* - Without `sessionId`: every session of `userId` ended, or may have — the
|
|
68
|
+
* account was deleted or archived, or signed out everywhere. A consumer drops
|
|
69
|
+
* everything it holds for that account, including sessions it operated as a
|
|
70
|
+
* delegate.
|
|
71
|
+
*
|
|
72
|
+
* `at` is the publisher's epoch-ms clock: diagnostic only (propagation delay),
|
|
73
|
+
* never used for ordering — the event says "ask Oxy again", which is idempotent.
|
|
74
|
+
*/
|
|
75
|
+
export const oxySessionRevocationEventSchema = z.object({
|
|
76
|
+
/** The session that ended; absent for a revocation of every session of `userId`. */
|
|
77
|
+
sessionId: z.string().min(1).max(256).optional(),
|
|
78
|
+
/** The account the session (or sessions) spoke as. */
|
|
79
|
+
userId: z.string().min(1).max(256),
|
|
80
|
+
/** Publisher's epoch-ms timestamp. Diagnostic only. */
|
|
81
|
+
at: z.number().int().nonnegative(),
|
|
82
|
+
});
|
|
83
|
+
/** The heartbeat payload. */
|
|
84
|
+
export const oxyServiceEventsHeartbeatSchema = z.object({
|
|
85
|
+
at: z.number().int().nonnegative(),
|
|
86
|
+
});
|
|
@@ -69,7 +69,7 @@ export type AccountAccessGrant = z.infer<typeof accountAccessGrantSchema>;
|
|
|
69
69
|
export declare const accountAccessVerdictSchema: z.ZodEffects<z.ZodObject<{
|
|
70
70
|
accountId: z.ZodString;
|
|
71
71
|
/** `null` when no such account exists. */
|
|
72
|
-
kind: z.ZodNullable<z.ZodEnum<["personal", "organization", "project", "bot", "channel"]>>;
|
|
72
|
+
kind: z.ZodNullable<z.ZodEnum<["personal", "organization", "project", "bot", "channel", "community"]>>;
|
|
73
73
|
/** `null` means: this person may not act for this account. */
|
|
74
74
|
access: z.ZodNullable<z.ZodObject<{
|
|
75
75
|
role: z.ZodString;
|
|
@@ -89,7 +89,7 @@ export declare const accountAccessVerdictSchema: z.ZodEffects<z.ZodObject<{
|
|
|
89
89
|
source: "self" | "direct" | "inherited";
|
|
90
90
|
}>>;
|
|
91
91
|
}, "strip", z.ZodTypeAny, {
|
|
92
|
-
kind: "
|
|
92
|
+
kind: "personal" | "organization" | "project" | "bot" | "channel" | "community" | null;
|
|
93
93
|
accountId: string;
|
|
94
94
|
access: {
|
|
95
95
|
status: "active";
|
|
@@ -98,7 +98,7 @@ export declare const accountAccessVerdictSchema: z.ZodEffects<z.ZodObject<{
|
|
|
98
98
|
source: "self" | "direct" | "inherited";
|
|
99
99
|
} | null;
|
|
100
100
|
}, {
|
|
101
|
-
kind: "
|
|
101
|
+
kind: "personal" | "organization" | "project" | "bot" | "channel" | "community" | null;
|
|
102
102
|
accountId: string;
|
|
103
103
|
access: {
|
|
104
104
|
status: "active";
|
|
@@ -107,7 +107,7 @@ export declare const accountAccessVerdictSchema: z.ZodEffects<z.ZodObject<{
|
|
|
107
107
|
source: "self" | "direct" | "inherited";
|
|
108
108
|
} | null;
|
|
109
109
|
}>, {
|
|
110
|
-
kind: "
|
|
110
|
+
kind: "personal" | "organization" | "project" | "bot" | "channel" | "community" | null;
|
|
111
111
|
accountId: string;
|
|
112
112
|
access: {
|
|
113
113
|
status: "active";
|
|
@@ -116,7 +116,7 @@ export declare const accountAccessVerdictSchema: z.ZodEffects<z.ZodObject<{
|
|
|
116
116
|
source: "self" | "direct" | "inherited";
|
|
117
117
|
} | null;
|
|
118
118
|
}, {
|
|
119
|
-
kind: "
|
|
119
|
+
kind: "personal" | "organization" | "project" | "bot" | "channel" | "community" | null;
|
|
120
120
|
accountId: string;
|
|
121
121
|
access: {
|
|
122
122
|
status: "active";
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
export { ACCOUNT_KINDS, CHILD_ACCOUNT_KINDS, isDelegatedActAsEligibleKind, isOperatorSwitchTargetKind, isAccountKind, ACCOUNT_CATEGORY_IDS, RETIRED_ACCOUNT_CATEGORY_IDS, isSelectableAccountCategoryId, SELECTABLE_ACCOUNT_CATEGORY_IDS, newlyAddedRetiredCategories, MAX_ACCOUNT_CATEGORIES, ACCOUNT_CATEGORY_KINDS, kindAcceptsAccountCategories, } from './client/accountGraph';
|
|
11
11
|
export type { AccountKind, AccountKindGap, ChildAccountKind, ChildAccountKindGap, AccountCategoryId, AccountCategoryKind, } from './client/accountGraph';
|
|
12
|
-
export declare const accountKindSchema: z.ZodEnum<["personal", "organization", "project", "bot", "channel"]>;
|
|
12
|
+
export declare const accountKindSchema: z.ZodEnum<["personal", "organization", "project", "bot", "channel", "community"]>;
|
|
13
13
|
export declare const childAccountKindSchema: z.ZodEnum<["organization", "project", "bot", "channel"]>;
|
|
14
14
|
/**
|
|
15
15
|
* Accepts EVERY id, withdrawn ones included — see rule 3.
|
|
@@ -30,7 +30,7 @@ export declare const accountCategoryIdSchema: z.ZodEnum<["news", "politics", "bu
|
|
|
30
30
|
* property the list exists to carry. A duplicate only ever comes from a client
|
|
31
31
|
* bug, and a 400 naming the index is how that bug gets found.
|
|
32
32
|
*/
|
|
33
|
-
export declare const accountCategoriesSchema: z.ZodEffects<z.ZodArray<z.ZodEnum<["news", "politics", "business", "startup", "finance", "crypto", "marketplace", "retail", "real_estate", "agency", "landlord", "cooperative", "architecture", "technology", "software", "ai", "security", "automation", "science", "education", "books", "health", "fitness", "sports", "gaming", "music", "film", "podcast", "art", "photography", "comedy", "food", "travel", "fashion", "home_garden", "diy", "automotive", "animals", "family", "nonprofit", "government", "community", "activism", "environment", "religion", "other"]>, "many">, ("
|
|
33
|
+
export declare const accountCategoriesSchema: z.ZodEffects<z.ZodArray<z.ZodEnum<["news", "politics", "business", "startup", "finance", "crypto", "marketplace", "retail", "real_estate", "agency", "landlord", "cooperative", "architecture", "technology", "software", "ai", "security", "automation", "science", "education", "books", "health", "fitness", "sports", "gaming", "music", "film", "podcast", "art", "photography", "comedy", "food", "travel", "fashion", "home_garden", "diy", "automotive", "animals", "family", "nonprofit", "government", "community", "activism", "environment", "religion", "other"]>, "many">, ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[], ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[]>;
|
|
34
34
|
/**
|
|
35
35
|
* An account's name on the create/update wire.
|
|
36
36
|
*
|
|
@@ -67,7 +67,7 @@ export declare const accountNameSchema: z.ZodOptional<z.ZodObject<{
|
|
|
67
67
|
* this route. The refinement the single-valued predecessor needed disappeared
|
|
68
68
|
* along with the restriction that made it necessary. A child kind that does NOT
|
|
69
69
|
* accept categories would break that reasoning silently, so
|
|
70
|
-
* `__tests__/accountGraph.test.ts` asserts
|
|
70
|
+
* `__tests__/accountGraph.test.ts` asserts every child kind is a category kind.
|
|
71
71
|
*/
|
|
72
72
|
export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
73
73
|
parentAccountId: z.ZodOptional<z.ZodString>;
|
|
@@ -118,7 +118,7 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
118
118
|
*/
|
|
119
119
|
color: z.ZodOptional<z.ZodString>;
|
|
120
120
|
/** Ordered, PRIMARY FIRST — see rule 2 above {@link ACCOUNT_CATEGORY_IDS}. */
|
|
121
|
-
accountCategories: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodEnum<["news", "politics", "business", "startup", "finance", "crypto", "marketplace", "retail", "real_estate", "agency", "landlord", "cooperative", "architecture", "technology", "software", "ai", "security", "automation", "science", "education", "books", "health", "fitness", "sports", "gaming", "music", "film", "podcast", "art", "photography", "comedy", "food", "travel", "fashion", "home_garden", "diy", "automotive", "animals", "family", "nonprofit", "government", "community", "activism", "environment", "religion", "other"]>, "many">, ("
|
|
121
|
+
accountCategories: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodEnum<["news", "politics", "business", "startup", "finance", "crypto", "marketplace", "retail", "real_estate", "agency", "landlord", "cooperative", "architecture", "technology", "software", "ai", "security", "automation", "science", "education", "books", "health", "fitness", "sports", "gaming", "music", "film", "podcast", "art", "photography", "comedy", "food", "travel", "fashion", "home_garden", "diy", "automotive", "animals", "family", "nonprofit", "government", "community", "activism", "environment", "religion", "other"]>, "many">, ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[], ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[]>>;
|
|
122
122
|
organizationType: z.ZodOptional<z.ZodEnum<["business", "nonprofit", "public_body", "community", "other"]>>;
|
|
123
123
|
/**
|
|
124
124
|
* Create the account already opted OUT of discovery.
|
|
@@ -177,12 +177,12 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
177
177
|
last?: string | undefined;
|
|
178
178
|
displayName?: string | undefined;
|
|
179
179
|
} | undefined;
|
|
180
|
-
organizationType?: "
|
|
180
|
+
organizationType?: "community" | "business" | "nonprofit" | "other" | "public_body" | undefined;
|
|
181
181
|
avatar?: string | undefined;
|
|
182
182
|
parentAccountId?: string | undefined;
|
|
183
183
|
bio?: string | undefined;
|
|
184
184
|
description?: string | undefined;
|
|
185
|
-
accountCategories?: ("
|
|
185
|
+
accountCategories?: ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[] | undefined;
|
|
186
186
|
isPrivateAccount?: boolean | undefined;
|
|
187
187
|
character?: import("./avatarCharacter").AvatarCharacter | undefined;
|
|
188
188
|
}, {
|
|
@@ -194,12 +194,12 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
194
194
|
last?: string | undefined;
|
|
195
195
|
displayName?: string | undefined;
|
|
196
196
|
} | undefined;
|
|
197
|
-
organizationType?: "
|
|
197
|
+
organizationType?: "community" | "business" | "nonprofit" | "other" | "public_body" | undefined;
|
|
198
198
|
avatar?: string | undefined;
|
|
199
199
|
parentAccountId?: string | undefined;
|
|
200
200
|
bio?: string | undefined;
|
|
201
201
|
description?: string | undefined;
|
|
202
|
-
accountCategories?: ("
|
|
202
|
+
accountCategories?: ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[] | undefined;
|
|
203
203
|
isPrivateAccount?: boolean | undefined;
|
|
204
204
|
character?: unknown;
|
|
205
205
|
}>, {
|
|
@@ -211,12 +211,12 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
211
211
|
last?: string | undefined;
|
|
212
212
|
displayName?: string | undefined;
|
|
213
213
|
} | undefined;
|
|
214
|
-
organizationType?: "
|
|
214
|
+
organizationType?: "community" | "business" | "nonprofit" | "other" | "public_body" | undefined;
|
|
215
215
|
avatar?: string | undefined;
|
|
216
216
|
parentAccountId?: string | undefined;
|
|
217
217
|
bio?: string | undefined;
|
|
218
218
|
description?: string | undefined;
|
|
219
|
-
accountCategories?: ("
|
|
219
|
+
accountCategories?: ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[] | undefined;
|
|
220
220
|
isPrivateAccount?: boolean | undefined;
|
|
221
221
|
character?: import("./avatarCharacter").AvatarCharacter | undefined;
|
|
222
222
|
}, {
|
|
@@ -228,12 +228,12 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
228
228
|
last?: string | undefined;
|
|
229
229
|
displayName?: string | undefined;
|
|
230
230
|
} | undefined;
|
|
231
|
-
organizationType?: "
|
|
231
|
+
organizationType?: "community" | "business" | "nonprofit" | "other" | "public_body" | undefined;
|
|
232
232
|
avatar?: string | undefined;
|
|
233
233
|
parentAccountId?: string | undefined;
|
|
234
234
|
bio?: string | undefined;
|
|
235
235
|
description?: string | undefined;
|
|
236
|
-
accountCategories?: ("
|
|
236
|
+
accountCategories?: ("community" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "security" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "activism" | "environment" | "religion" | "other")[] | undefined;
|
|
237
237
|
isPrivateAccount?: boolean | undefined;
|
|
238
238
|
character?: unknown;
|
|
239
239
|
}>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_TITLE_MAX_LENGTH, accountNamePolicyForKind, isPlainTextTitle, } from './client/accountName';
|
|
3
|
+
export type { AccountNamePolicy } from './client/accountName';
|
|
4
|
+
/** A non-personal account's title — see `./client/accountName.ts` for the policy. */
|
|
5
|
+
export declare const accountTitleSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -41,8 +41,9 @@ export declare const ACCOUNT_SUBJECT_CONTRACT_VERSION: 1;
|
|
|
41
41
|
* - `person` — a human; a personal account is its own actor.
|
|
42
42
|
* - `agent` — an AI agent; a bot is its own actor (ADR 0018 `ActorRef`
|
|
43
43
|
* `{type:'agent'}`), and audit records the bot, never the human who owns it.
|
|
44
|
-
* - `operated` — never its own actor. An organization, project
|
|
45
|
-
* acts through a member, and that
|
|
44
|
+
* - `operated` — never its own actor. An organization, project, channel or
|
|
45
|
+
* community only acts through a member (a community's moderators), and that
|
|
46
|
+
* member is the actor.
|
|
46
47
|
*/
|
|
47
48
|
export declare const ACCOUNT_ACTOR_NATURES: readonly ["person", "agent", "operated"];
|
|
48
49
|
export type AccountActorNature = (typeof ACCOUNT_ACTOR_NATURES)[number];
|