@oxy.so/contracts 6.10.0 → 6.12.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.
@@ -20,6 +20,16 @@ export const IDENTITY_PROOF_ACTIONS = {
20
20
  * (ADR 0029 D3).
21
21
  */
22
22
  link: 'link_identity',
23
+ /**
24
+ * Give an organization its first identity key (ADR 0061 D4). Signed by the
25
+ * acting owner's or admin's own root and by the new key.
26
+ */
27
+ organizationKeyCreate: 'organization_key_create',
28
+ /**
29
+ * Replace an organization's identity key (ADR 0061 D7). Signed by the actor's
30
+ * root and the new key, and by the current key when the device holds it.
31
+ */
32
+ organizationKeyReplace: 'organization_key_replace',
23
33
  };
24
34
  export const IDENTITY_PROOF_ACTION_VALUES = Object.values(IDENTITY_PROOF_ACTIONS);
25
35
  export const HEX_DIGEST = /^[0-9a-f]{64}$/;
@@ -19,6 +19,7 @@ export { ACCOUNT_CATEGORY_IDS, ACCOUNT_CATEGORY_KINDS, ACCOUNT_KINDS, CHILD_ACCO
19
19
  export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_TITLE_MAX_LENGTH, accountNamePolicyForKind, accountTitleCheck, isPlainTextTitle, } from './accountName.js';
20
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';
21
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';
22
+ export { ORGANIZATION_KEY_ERROR_CODES, ORGANIZATION_KEY_OPERATIONS, ORGANIZATION_KEY_PROOF_ACTIONS, ORGANIZATION_KEY_PROOF_ACTION_VALUES, organizationIdentityKeyStateCheck, organizationKeyApplyRequestCheck, organizationKeyChallengeCheck, organizationKeyChallengeRequestCheck, organizationKeyPayload, organizationKeyProofClaims, } from './organizationIdentityKey.js';
22
23
  export { isLoopbackOrigin } from '../capabilityBindings.js';
23
24
  export { loginResultCheck } from './deviceBoot.js';
24
25
  export { externalIdentityReferenceCheck } from './externalIdentity.js';
@@ -26,6 +27,7 @@ export { signedRecordEnvelopeCheck } from './identity.js';
26
27
  export { DOMAIN_NAME_MAX_LENGTH, normalizeDomainName } from './domainName.js';
27
28
  export { deviceActivateResponseCheck, deviceDirectoryCheck, deviceDirectorySyncCheck, } from './deviceDirectory.js';
28
29
  export { SESSION_ACCOUNTS_CHANGED_EVENT, activeTokenCheck, deviceBackgroundCredentialResponseCheck, deviceContextTokenV1RequestCheck, deviceContextTokenV1ResponseCheck, holderContextEvidenceV1RequestCheck, holderContextEvidenceV1ResponseCheck, deviceJoinCodeResponseCheck, deviceJoinResponseCheck, deviceRegisterResponseCheck, deviceSessionStateCheck, deviceSessionSyncCheck, deviceTokenMintResponseCheck, sessionAccountsChangedEventCheck, } from './deviceSession.js';
30
+ export { identityKeyHistoryCheck } from './identityKeyHistory.js';
29
31
  export { IDENTITY_LINK_QR_PREFIX, IDENTITY_LINK_STATUSES, buildIdentityLinkQrPayload, identityLinkCreateResponseCheck, identityLinkStateCheck, parseIdentityLinkQrPayload, } from './identityLink.js';
30
32
  export { IDENTITY_ERROR_CODES, IDENTITY_PROOF_ACTIONS, IDENTITY_PROOF_ACTION_VALUES, IDENTITY_PROOF_AUDIENCE, IDENTITY_PROOF_CHALLENGE_TTL_MS, IDENTITY_PROOF_DOMAIN, IDENTITY_PROOF_VERSION, buildIdentityProofMessage, canonicalJson, } from './identityProof.js';
31
33
  export { ORGANIZATION_ALIAS_KINDS, ORGANIZATION_CLAIM_DECISIONS, ORGANIZATION_CLAIM_STATUSES, ORGANIZATION_ERROR_CODES, ORGANIZATION_NAME_MAX_LENGTH, ORGANIZATION_STATUSES, ORGANIZATION_TYPES, createOrganizationCheck, organizationBatchCheck, organizationCheck, organizationClaimCheck, organizationClaimDetailCheck, organizationClaimInputCheck, organizationClaimListCheck, organizationClaimReviewCheck, organizationCurationResultCheck, organizationExternalCheck, organizationExternalResolutionCheck, organizationImportBatchResultCheck, organizationListCheck, organizationNameCheck, updateOrganizationCheck, } from './organizations.js';
@@ -38,6 +40,7 @@ export { CONSOLE_TERMS_VERSION, CONSOLE_USE_CASES, } from './consoleOnboarding.j
38
40
  export { EMAIL_ACCOUNTS_MAX, EMAIL_SIGNIN_CHOICE_TTL_MS, EMAIL_SIGNIN_LINK_TTL_MS, EMAIL_SIGNIN_LONG_CODE_ALPHABET, EMAIL_SIGNIN_LONG_CODE_LENGTH, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, REAUTH_ACTIONS, SECOND_FACTOR_CODE_MAX_LENGTH, SIGN_IN_IDENTIFIER_MAX_LENGTH, SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS, SIGNIN_SECOND_FACTOR_TTL_MS, SIGN_IN_ERROR_CODES, TOTP_BACKUP_CODE_COUNT, TOTP_DIGITS, TOTP_PERIOD_SECONDS, emailSignInChooseAccountCheck, emailSignInLinkResponseCheck, emailSignInPendingCheck, emailSignInStartResponseCheck, isEmailSignInChooseAccount, isSecondFactorRequired, normalizeEmailSignInCode, reauthProofCheck, secondFactorRequiredCheck, signInMethodsCheck, totpBackupCodesResponseCheck, totpEnrollResponseCheck, } from './signIn.js';
39
41
  export { BOT_USERNAME_INVALID_MESSAGE, BOT_USERNAME_SUFFIX, NUMERIC_USERNAME_MESSAGE, RESERVED_USERNAMES, RESERVED_USERNAME_MESSAGE, USERNAME_INVALID_MESSAGE, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, applyBotUsernameSuffix, botUsernameCheck, stripDisallowedUsernameCharacters, usernameCheck, usernameCheckForAccountKind, } from './username.js';
40
42
  export { userNameCheck, PROFILE_LINKS_MAX, PROFILE_LINK_TITLE_MAX } from './userResponse.js';
43
+ export { PRONOUNS } from './userResponse.js';
41
44
  export { CLAIMANT_RELATIONSHIPS, CLOSED_CONTENT_CLAIM_STATES, CONTENT_CLAIM_COUNTER_NOTICE_LIMITS, CONTENT_CLAIM_ERROR_CODES, CONTENT_CLAIM_KINDS, CONTENT_CLAIM_LIMITS, CONTENT_CLAIM_REFERENCE_PATTERN, CONTENT_CLAIM_STATES, COUNTER_NOTICE_STATEMENT_VERSION, COUNTER_NOTICE_STATEMENTS, ERASURE_REQUEST_DEADLINE_DAYS, OPEN_CONTENT_CLAIM_STATES, isErasureRequest, isRightsClaim, } from './contentClaims.js';
42
45
  export { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, appAssertionChallengeResponseCheck, appAssertionResponseCheck, appAttestKeyResponseCheck, } from './appAssertions.js';
43
46
  export { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS, FREE_USER_PROFILE_COLOR_PRESETS, } from '../profileColors.generated.js';
@@ -0,0 +1,109 @@
1
+ /**
2
+ * An organization's identity key (ADR 0061), without Zod. Schemas:
3
+ * `../organizationIdentityKey.ts`.
4
+ *
5
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
6
+ *
7
+ * An organization's key is its DID `#key-1`: the key Peable derives the
8
+ * organization's FairCoin receive addresses from. It is created in Commons by an
9
+ * owner or admin and never signs anybody in. A change is ONE identity proof
10
+ * ceremony (ADR 0024 D7): the server's challenge, then the same claims signed by
11
+ * the actor's own root, by the new key and (to replace) by the current key when
12
+ * the device holds it. The claims differ only in `rootPublicKey`, so no
13
+ * signature can stand in for another.
14
+ */
15
+ import { array, boolean, datetime, exact, int, literal, maxLength, minLength, nullable, number, oneOf, optional, pattern, positive, strictObject, string, trim, } from './check.js';
16
+ import { CHALLENGE, HEX_DIGEST, IDENTITY_PROOF_ACTIONS, IDENTITY_PROOF_AUDIENCE, } from './identityProof.js';
17
+ /** `create`: an organization without a key gets one. `replace`: a new key takes the current one's place. */
18
+ export const ORGANIZATION_KEY_OPERATIONS = ['create', 'replace'];
19
+ /** The identity-proof action each operation is signed under. */
20
+ export const ORGANIZATION_KEY_PROOF_ACTIONS = {
21
+ create: IDENTITY_PROOF_ACTIONS.organizationKeyCreate,
22
+ replace: IDENTITY_PROOF_ACTIONS.organizationKeyReplace,
23
+ };
24
+ export const ORGANIZATION_KEY_PROOF_ACTION_VALUES = [
25
+ ORGANIZATION_KEY_PROOF_ACTIONS.create,
26
+ ORGANIZATION_KEY_PROOF_ACTIONS.replace,
27
+ ];
28
+ /**
29
+ * Stable error codes of the organization-key routes (`error.code`). The proof,
30
+ * key-in-use and already-linked refusals use `IDENTITY_ERROR_CODES`.
31
+ */
32
+ export const ORGANIZATION_KEY_ERROR_CODES = {
33
+ /** The caller is not an owner or admin of a claimed, active organization. */
34
+ forbidden: 'ORGANIZATION_KEY_FORBIDDEN',
35
+ /** The signing person has no root of their own (only a Commons account can do this). */
36
+ actorRootRequired: 'ORGANIZATION_KEY_ACTOR_ROOT_REQUIRED',
37
+ /** `replace` on an organization without a key. */
38
+ noKey: 'ORGANIZATION_KEY_MISSING',
39
+ /** The key was already used, by this or another account, and is never reused. */
40
+ keyUsed: 'ORGANIZATION_KEY_USED',
41
+ };
42
+ /**
43
+ * The payload whose digest every signature of one operation binds. Both sides
44
+ * build it here, so the client and the verifier digest the same object.
45
+ */
46
+ export function organizationKeyPayload(input) {
47
+ return {
48
+ operation: input.operation,
49
+ accountId: input.accountId,
50
+ publicKey: input.publicKey,
51
+ previousPublicKey: input.previousPublicKey,
52
+ };
53
+ }
54
+ /** The claims one signer (`rootPublicKey`) signs for `challenge`. */
55
+ export function organizationKeyProofClaims(challenge, rootPublicKey) {
56
+ return {
57
+ action: challenge.action,
58
+ subject: challenge.accountId,
59
+ actor: challenge.actorId,
60
+ rootPublicKey,
61
+ payloadDigest: challenge.payloadDigest,
62
+ expectedRevision: null,
63
+ audience: challenge.audience,
64
+ challenge: challenge.challenge,
65
+ expiresAt: challenge.expiresAt,
66
+ };
67
+ }
68
+ /* -------------------------------------------------------------------------- */
69
+ /* Checks */
70
+ /* -------------------------------------------------------------------------- */
71
+ const publicKey = string(trim, minLength(1), maxLength(130));
72
+ const signature = string(trim, minLength(1), maxLength(512));
73
+ const challengeHex = string(pattern(CHALLENGE));
74
+ const timestamp = number(int, positive);
75
+ export const organizationKeyChallengeRequestCheck = exact()(strictObject({ operation: oneOf(ORGANIZATION_KEY_OPERATIONS), publicKey }));
76
+ export const organizationKeyChallengeCheck = exact()(strictObject({
77
+ operation: oneOf(ORGANIZATION_KEY_OPERATIONS),
78
+ action: oneOf(ORGANIZATION_KEY_PROOF_ACTION_VALUES),
79
+ accountId: string(minLength(1)),
80
+ actorId: string(minLength(1)),
81
+ actorPublicKey: string(minLength(1)),
82
+ publicKey: string(minLength(1)),
83
+ previousPublicKey: nullable(string(minLength(1))),
84
+ payloadDigest: string(pattern(HEX_DIGEST)),
85
+ audience: literal(IDENTITY_PROOF_AUDIENCE),
86
+ challenge: challengeHex,
87
+ expiresAt: timestamp,
88
+ }));
89
+ export const organizationKeyApplyRequestCheck = exact()(strictObject({
90
+ operation: oneOf(ORGANIZATION_KEY_OPERATIONS),
91
+ publicKey,
92
+ challenge: challengeHex,
93
+ expiresAt: timestamp,
94
+ actorSignature: signature,
95
+ keySignature: signature,
96
+ previousKeySignature: optional(signature),
97
+ }));
98
+ export const organizationIdentityKeyStateCheck = exact()(strictObject({
99
+ accountId: string(minLength(1)),
100
+ publicKey: nullable(string(minLength(1))),
101
+ keys: array(strictObject({
102
+ publicKey: string(minLength(1)),
103
+ method: oneOf(ORGANIZATION_KEY_OPERATIONS),
104
+ linkedByUserId: nullable(string()),
105
+ previousKeyProven: boolean,
106
+ linkedAt: string(datetime),
107
+ retiredAt: nullable(string(datetime)),
108
+ })),
109
+ }));
@@ -14,6 +14,20 @@ export const userNameCheck = exact()(looseObject({
14
14
  * Most links a profile may show. Enforced by the server on every write that
15
15
  * carries `linksMetadata` (see `user.service.ts`), and by the editor.
16
16
  */
17
+ /**
18
+ * How an account names its pronouns: one of a closed list, never free text. A
19
+ * federated account's source value is mapped onto it; a value that maps to none
20
+ * of these is `unspecified`.
21
+ */
22
+ export const PRONOUNS = [
23
+ 'unspecified',
24
+ 'he_him',
25
+ 'she_her',
26
+ 'they_them',
27
+ 'he_they',
28
+ 'she_they',
29
+ 'it_its',
30
+ ];
17
31
  export const PROFILE_LINKS_MAX = 10;
18
32
  /**
19
33
  * Longest title an editor may give a profile link, in characters. Not enforced
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A personal account's key history: `GET /identity/key-history`.
3
+ *
4
+ * The current root (`null` without one) and every root a rotation replaced,
5
+ * oldest first. Commons reads it to accept a previous recovery phrase only when
6
+ * it derives a key that WAS this account's root, and keeps that key to spend
7
+ * what it received. A retired root is never any account's again (ADR 0061 D2).
8
+ *
9
+ * Keys are canonical: uncompressed, lowercase (`04` + 128 hex). No private key
10
+ * or phrase crosses this contract.
11
+ *
12
+ * The Zod-free check is `./client/identityKeyHistory.ts`.
13
+ */
14
+ import { z } from 'zod';
15
+ import { isoDateTime } from './stringChecks.js';
16
+ const canonicalPublicKey = z.string().regex(/^04[0-9a-f]{128}$/);
17
+ export const identityKeyHistorySchema = z
18
+ .object({
19
+ publicKey: canonicalPublicKey.nullable(),
20
+ retired: z.array(z
21
+ .object({
22
+ publicKey: canonicalPublicKey,
23
+ retiredAt: z.string().check(isoDateTime()),
24
+ })
25
+ .strict()),
26
+ })
27
+ .strict();
package/dist/esm/index.js CHANGED
@@ -14,7 +14,7 @@ export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_T
14
14
  export { AVATAR_EYE_SPACING, AVATAR_PICKABLE_COLORS, AVATAR_PICKABLE_SHAPES, avatarCharacterFor, avatarCharacterSchema, parseAvatarCharacter, } from './avatarCharacter.js';
15
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';
16
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';
17
- export { PROFILE_LINKS_MAX, PROFILE_LINK_TITLE_MAX } from './client/userResponse.js';
17
+ export { PRONOUNS, PROFILE_LINKS_MAX, PROFILE_LINK_TITLE_MAX } from './client/userResponse.js';
18
18
  export {
19
19
  // Schemas
20
20
  userNameSchema, userRelationshipSchema, themePreferenceSchema, dateOfBirthSchema, userResponseSchema, userProfileUpdateSchema, currentUserResponseSchema, deviceLinkedSessionSchema, deviceLinkedSessionsResponseSchema,
@@ -81,6 +81,8 @@ loginResultSchema, } from './deviceBoot.js';
81
81
  export {
82
82
  // Schemas
83
83
  rotateKeyChallengeResponseSchema, rotateKeyCompleteRequestSchema, rotateKeyCompleteResponseSchema, } from './keyRotation.js';
84
+ // A personal account's current root and the roots rotation replaced
85
+ export { identityKeyHistorySchema } from './identityKeyHistory.js';
84
86
  export {
85
87
  // Schemas — encrypted off-device identity backup (b3 Feature 1)
86
88
  backupLookupIdSchema, encryptedBackupEnvelopeSchema, backupUploadRequestSchema, backupStatusResponseSchema, } from './keyRecovery.js';
@@ -199,6 +201,7 @@ export { productDefinitionSchema, subjectProductAccessQuerySchema, productBenefi
199
201
  export { meteredGenerationSchema } from './inference/economics.js';
200
202
  export { canonicalCapabilityJson, inputSatisfiesCapabilityLimits, isLoopbackOrigin, } from './capabilityBindings.js';
201
203
  export * from './agentKeys.js';
204
+ export * from './organizationIdentityKey.js';
202
205
  export { productSubscriptionSummarySchema, productSubscriptionsResponseSchema, subscriptionCreditGrantSchema, subscriptionCreditGrantsResponseSchema, cancelProductSubscriptionSchema, productSubscriptionCancellationResultSchema, } from './products/billing.js';
203
206
  export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, productPlanCatalogueSchema, } from './products/plans.js';
204
207
  export * from './products/checkout.js';
@@ -0,0 +1,87 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
3
+ /**
4
+ * An organization's identity key (ADR 0061): its DID `#key-1`, created in
5
+ * Commons by an owner or admin, and the key Peable derives the organization's
6
+ * FairCoin receive addresses from.
7
+ *
8
+ * - `GET /accounts/:id/identity-key` the current key and its history
9
+ * - `POST /accounts/:id/identity-key/challenge` a one-use challenge for one change
10
+ * - `POST /accounts/:id/identity-key` apply it with the signatures
11
+ *
12
+ * No private key or phrase crosses this contract.
13
+ */
14
+ import { z } from 'zod';
15
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
16
+ // it is re-exported here so the root entry is unchanged.
17
+ import { ORGANIZATION_KEY_OPERATIONS, ORGANIZATION_KEY_PROOF_ACTION_VALUES, } from './client/organizationIdentityKey.js';
18
+ import { CHALLENGE, HEX_DIGEST, IDENTITY_PROOF_AUDIENCE } from './client/identityProof.js';
19
+ export { ORGANIZATION_KEY_OPERATIONS, ORGANIZATION_KEY_PROOF_ACTIONS, ORGANIZATION_KEY_PROOF_ACTION_VALUES, ORGANIZATION_KEY_ERROR_CODES, organizationKeyPayload, organizationKeyProofClaims, } from './client/organizationIdentityKey.js';
20
+ const publicKey = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(130));
21
+ const signature = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(512));
22
+ /** `POST /accounts/:id/identity-key/challenge` */
23
+ export const organizationKeyChallengeRequestSchema = z
24
+ .object({ operation: z.enum(ORGANIZATION_KEY_OPERATIONS), publicKey })
25
+ .strict();
26
+ /**
27
+ * The challenge and every claim the signers sign
28
+ * (`organizationKeyProofClaims(challenge, signerPublicKey)`).
29
+ */
30
+ export const organizationKeyChallengeSchema = z
31
+ .object({
32
+ operation: z.enum(ORGANIZATION_KEY_OPERATIONS),
33
+ action: z.enum(ORGANIZATION_KEY_PROOF_ACTION_VALUES),
34
+ /** The organization (the proof's `subject`). */
35
+ accountId: z.string().check(utf16MinLength(1)),
36
+ /** The signed-in person performing it (the proof's `actor`). */
37
+ actorId: z.string().check(utf16MinLength(1)),
38
+ /** The actor's own root, which signs `actorSignature`. */
39
+ actorPublicKey: z.string().check(utf16MinLength(1)),
40
+ /** The new key, canonical (lowercase, uncompressed). */
41
+ publicKey: z.string().check(utf16MinLength(1)),
42
+ /** The key it replaces, or `null` for `create`. */
43
+ previousPublicKey: z.string().check(utf16MinLength(1)).nullable(),
44
+ payloadDigest: z.string().regex(HEX_DIGEST),
45
+ audience: z.literal(IDENTITY_PROOF_AUDIENCE),
46
+ challenge: z.string().regex(CHALLENGE),
47
+ /** Unix milliseconds. */
48
+ expiresAt: z.number().check(integerCheck()).positive(),
49
+ })
50
+ .strict();
51
+ /** `POST /accounts/:id/identity-key` */
52
+ export const organizationKeyApplyRequestSchema = z
53
+ .object({
54
+ operation: z.enum(ORGANIZATION_KEY_OPERATIONS),
55
+ publicKey,
56
+ challenge: z.string().regex(CHALLENGE),
57
+ expiresAt: z.number().check(integerCheck()).positive(),
58
+ /** By the actor's own root. */
59
+ actorSignature: signature,
60
+ /** By the new key: proof of possession. */
61
+ keySignature: signature,
62
+ /** By the current key, when replacing and the device holds it. */
63
+ previousKeySignature: signature.optional(),
64
+ })
65
+ .strict();
66
+ /**
67
+ * `GET /accounts/:id/identity-key`, and the answer of a change: the current
68
+ * key (`null` for an organization without one) and every key it has had,
69
+ * oldest first. A retired key is never used again by any account.
70
+ */
71
+ export const organizationIdentityKeyStateSchema = z
72
+ .object({
73
+ accountId: z.string().check(utf16MinLength(1)),
74
+ publicKey: z.string().check(utf16MinLength(1)).nullable(),
75
+ keys: z.array(z
76
+ .object({
77
+ publicKey: z.string().check(utf16MinLength(1)),
78
+ method: z.enum(ORGANIZATION_KEY_OPERATIONS),
79
+ linkedByUserId: z.string().nullable(),
80
+ /** Whether a `replace` was also signed by the key it replaced. */
81
+ previousKeyProven: z.boolean(),
82
+ linkedAt: z.string().check(isoDateTime()),
83
+ retiredAt: z.string().check(isoDateTime()).nullable(),
84
+ })
85
+ .strict()),
86
+ })
87
+ .strict();
@@ -30,7 +30,7 @@ import { isoDateTime } from './stringChecks.js';
30
30
  * `require()`).
31
31
  */
32
32
  import { z } from 'zod';
33
- import { PROFILE_LINKS_MAX } from './client/userResponse.js';
33
+ import { PRONOUNS, PROFILE_LINKS_MAX } from './client/userResponse.js';
34
34
  import { verifiedDomainSchema } from './identity.js';
35
35
  import { accountCategoriesSchema, accountKindSchema } from './accountGraph.js';
36
36
  import { avatarCharacterSchema } from './avatarCharacter.js';
@@ -243,6 +243,7 @@ export const userResponseSchema = z
243
243
  .optional(),
244
244
  })
245
245
  .passthrough();
246
+ export const pronounsSchema = z.enum(PRONOUNS);
246
247
  export const userProfileUpdateSchema = z
247
248
  .object({
248
249
  name: z
@@ -262,6 +263,7 @@ export const userProfileUpdateSchema = z
262
263
  avatar: z.string().optional(),
263
264
  color: z.string().nullable().optional(),
264
265
  bio: z.string().optional(),
266
+ pronouns: pronounsSchema.optional(),
265
267
  description: z.string().optional(),
266
268
  phone: z.string().optional(),
267
269
  address: z.string().optional(),
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A personal account's key history (`GET /identity/key-history`), without Zod.
3
+ * Schema: `../identityKeyHistory.ts`.
4
+ *
5
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
6
+ */
7
+ export declare const identityKeyHistoryCheck: import("./check").Check<{
8
+ publicKey: string | null;
9
+ retired: {
10
+ publicKey: string;
11
+ retiredAt: string;
12
+ }[];
13
+ }>;
@@ -20,6 +20,16 @@ export declare const IDENTITY_PROOF_ACTIONS: {
20
20
  * (ADR 0029 D3).
21
21
  */
22
22
  readonly link: "link_identity";
23
+ /**
24
+ * Give an organization its first identity key (ADR 0061 D4). Signed by the
25
+ * acting owner's or admin's own root and by the new key.
26
+ */
27
+ readonly organizationKeyCreate: "organization_key_create";
28
+ /**
29
+ * Replace an organization's identity key (ADR 0061 D7). Signed by the actor's
30
+ * root and the new key, and by the current key when the device holds it.
31
+ */
32
+ readonly organizationKeyReplace: "organization_key_replace";
23
33
  };
24
34
  export type IdentityProofAction = (typeof IDENTITY_PROOF_ACTIONS)[keyof typeof IDENTITY_PROOF_ACTIONS];
25
35
  export declare const IDENTITY_PROOF_ACTION_VALUES: [IdentityProofAction, ...IdentityProofAction[]];
@@ -19,6 +19,8 @@ export { ACCOUNT_CATEGORY_IDS, ACCOUNT_CATEGORY_KINDS, ACCOUNT_KINDS, CHILD_ACCO
19
19
  export { ACCOUNT_NAME_POLICY_BY_KIND, ACCOUNT_TITLE_DISALLOWED_SOURCE, ACCOUNT_TITLE_MAX_LENGTH, accountNamePolicyForKind, accountTitleCheck, isPlainTextTitle, } from './accountName';
20
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';
21
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';
22
+ export { ORGANIZATION_KEY_ERROR_CODES, ORGANIZATION_KEY_OPERATIONS, ORGANIZATION_KEY_PROOF_ACTIONS, ORGANIZATION_KEY_PROOF_ACTION_VALUES, organizationIdentityKeyStateCheck, organizationKeyApplyRequestCheck, organizationKeyChallengeCheck, organizationKeyChallengeRequestCheck, organizationKeyPayload, organizationKeyProofClaims, } from './organizationIdentityKey';
23
+ export type { OrganizationKeyErrorCode, OrganizationKeyOperation, OrganizationKeyProofAction, } from './organizationIdentityKey';
22
24
  export { isLoopbackOrigin } from '../capabilityBindings';
23
25
  export { loginResultCheck } from './deviceBoot';
24
26
  export { externalIdentityReferenceCheck } from './externalIdentity';
@@ -26,6 +28,8 @@ export { signedRecordEnvelopeCheck } from './identity';
26
28
  export { DOMAIN_NAME_MAX_LENGTH, normalizeDomainName } from './domainName';
27
29
  export { deviceActivateResponseCheck, deviceDirectoryCheck, deviceDirectorySyncCheck, } from './deviceDirectory';
28
30
  export { SESSION_ACCOUNTS_CHANGED_EVENT, activeTokenCheck, deviceBackgroundCredentialResponseCheck, deviceContextTokenV1RequestCheck, deviceContextTokenV1ResponseCheck, holderContextEvidenceV1RequestCheck, holderContextEvidenceV1ResponseCheck, deviceJoinCodeResponseCheck, deviceJoinResponseCheck, deviceRegisterResponseCheck, deviceSessionStateCheck, deviceSessionSyncCheck, deviceTokenMintResponseCheck, sessionAccountsChangedEventCheck, } from './deviceSession';
31
+ export { identityKeyHistoryCheck } from './identityKeyHistory';
32
+ export type { IdentityKeyHistory } from '../identityKeyHistory';
29
33
  export { IDENTITY_LINK_QR_PREFIX, IDENTITY_LINK_STATUSES, buildIdentityLinkQrPayload, identityLinkCreateResponseCheck, identityLinkStateCheck, parseIdentityLinkQrPayload, } from './identityLink';
30
34
  export { IDENTITY_ERROR_CODES, IDENTITY_PROOF_ACTIONS, IDENTITY_PROOF_ACTION_VALUES, IDENTITY_PROOF_AUDIENCE, IDENTITY_PROOF_CHALLENGE_TTL_MS, IDENTITY_PROOF_DOMAIN, IDENTITY_PROOF_VERSION, buildIdentityProofMessage, canonicalJson, } from './identityProof';
31
35
  export { ORGANIZATION_ALIAS_KINDS, ORGANIZATION_CLAIM_DECISIONS, ORGANIZATION_CLAIM_STATUSES, ORGANIZATION_ERROR_CODES, ORGANIZATION_NAME_MAX_LENGTH, ORGANIZATION_STATUSES, ORGANIZATION_TYPES, createOrganizationCheck, organizationBatchCheck, organizationCheck, organizationClaimCheck, organizationClaimDetailCheck, organizationClaimInputCheck, organizationClaimListCheck, organizationClaimReviewCheck, organizationCurationResultCheck, organizationExternalCheck, organizationExternalResolutionCheck, organizationImportBatchResultCheck, organizationListCheck, organizationNameCheck, updateOrganizationCheck, } from './organizations';
@@ -38,6 +42,8 @@ export { CONSOLE_TERMS_VERSION, CONSOLE_USE_CASES, type ConsoleUseCaseId, } from
38
42
  export { EMAIL_ACCOUNTS_MAX, EMAIL_SIGNIN_CHOICE_TTL_MS, EMAIL_SIGNIN_LINK_TTL_MS, EMAIL_SIGNIN_LONG_CODE_ALPHABET, EMAIL_SIGNIN_LONG_CODE_LENGTH, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, REAUTH_ACTIONS, SECOND_FACTOR_CODE_MAX_LENGTH, SIGN_IN_IDENTIFIER_MAX_LENGTH, SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS, SIGNIN_SECOND_FACTOR_TTL_MS, SIGN_IN_ERROR_CODES, TOTP_BACKUP_CODE_COUNT, TOTP_DIGITS, TOTP_PERIOD_SECONDS, emailSignInChooseAccountCheck, emailSignInLinkResponseCheck, emailSignInPendingCheck, emailSignInStartResponseCheck, isEmailSignInChooseAccount, isSecondFactorRequired, normalizeEmailSignInCode, reauthProofCheck, secondFactorRequiredCheck, signInMethodsCheck, totpBackupCodesResponseCheck, totpEnrollResponseCheck, } from './signIn';
39
43
  export { BOT_USERNAME_INVALID_MESSAGE, BOT_USERNAME_SUFFIX, NUMERIC_USERNAME_MESSAGE, RESERVED_USERNAMES, RESERVED_USERNAME_MESSAGE, USERNAME_INVALID_MESSAGE, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, applyBotUsernameSuffix, botUsernameCheck, stripDisallowedUsernameCharacters, usernameCheck, usernameCheckForAccountKind, } from './username';
40
44
  export { userNameCheck, PROFILE_LINKS_MAX, PROFILE_LINK_TITLE_MAX } from './userResponse';
45
+ export { PRONOUNS } from './userResponse';
46
+ export type { Pronouns } from './userResponse';
41
47
  export { CLAIMANT_RELATIONSHIPS, CLOSED_CONTENT_CLAIM_STATES, CONTENT_CLAIM_COUNTER_NOTICE_LIMITS, CONTENT_CLAIM_ERROR_CODES, CONTENT_CLAIM_KINDS, CONTENT_CLAIM_LIMITS, CONTENT_CLAIM_REFERENCE_PATTERN, CONTENT_CLAIM_STATES, COUNTER_NOTICE_STATEMENT_VERSION, COUNTER_NOTICE_STATEMENTS, ERASURE_REQUEST_DEADLINE_DAYS, OPEN_CONTENT_CLAIM_STATES, isErasureRequest, isRightsClaim, } from './contentClaims';
42
48
  export { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, appAssertionChallengeResponseCheck, appAssertionResponseCheck, appAttestKeyResponseCheck, } from './appAssertions';
43
49
  export { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS, FREE_USER_PROFILE_COLOR_PRESETS, } from '../profileColors.generated';
@@ -0,0 +1,96 @@
1
+ /**
2
+ * An organization's identity key (ADR 0061), without Zod. Schemas:
3
+ * `../organizationIdentityKey.ts`.
4
+ *
5
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
6
+ *
7
+ * An organization's key is its DID `#key-1`: the key Peable derives the
8
+ * organization's FairCoin receive addresses from. It is created in Commons by an
9
+ * owner or admin and never signs anybody in. A change is ONE identity proof
10
+ * ceremony (ADR 0024 D7): the server's challenge, then the same claims signed by
11
+ * the actor's own root, by the new key and (to replace) by the current key when
12
+ * the device holds it. The claims differ only in `rootPublicKey`, so no
13
+ * signature can stand in for another.
14
+ */
15
+ import type { OrganizationKeyChallenge } from '../organizationIdentityKey';
16
+ import { type IdentityProofClaims } from './identityProof';
17
+ /** `create`: an organization without a key gets one. `replace`: a new key takes the current one's place. */
18
+ export declare const ORGANIZATION_KEY_OPERATIONS: readonly ["create", "replace"];
19
+ export type OrganizationKeyOperation = (typeof ORGANIZATION_KEY_OPERATIONS)[number];
20
+ /** The identity-proof action each operation is signed under. */
21
+ export declare const ORGANIZATION_KEY_PROOF_ACTIONS: {
22
+ readonly create: "organization_key_create";
23
+ readonly replace: "organization_key_replace";
24
+ };
25
+ export declare const ORGANIZATION_KEY_PROOF_ACTION_VALUES: readonly ["organization_key_create", "organization_key_replace"];
26
+ export type OrganizationKeyProofAction = (typeof ORGANIZATION_KEY_PROOF_ACTION_VALUES)[number];
27
+ /**
28
+ * Stable error codes of the organization-key routes (`error.code`). The proof,
29
+ * key-in-use and already-linked refusals use `IDENTITY_ERROR_CODES`.
30
+ */
31
+ export declare const ORGANIZATION_KEY_ERROR_CODES: {
32
+ /** The caller is not an owner or admin of a claimed, active organization. */
33
+ readonly forbidden: "ORGANIZATION_KEY_FORBIDDEN";
34
+ /** The signing person has no root of their own (only a Commons account can do this). */
35
+ readonly actorRootRequired: "ORGANIZATION_KEY_ACTOR_ROOT_REQUIRED";
36
+ /** `replace` on an organization without a key. */
37
+ readonly noKey: "ORGANIZATION_KEY_MISSING";
38
+ /** The key was already used, by this or another account, and is never reused. */
39
+ readonly keyUsed: "ORGANIZATION_KEY_USED";
40
+ };
41
+ export type OrganizationKeyErrorCode = (typeof ORGANIZATION_KEY_ERROR_CODES)[keyof typeof ORGANIZATION_KEY_ERROR_CODES];
42
+ /**
43
+ * The payload whose digest every signature of one operation binds. Both sides
44
+ * build it here, so the client and the verifier digest the same object.
45
+ */
46
+ export declare function organizationKeyPayload(input: {
47
+ operation: OrganizationKeyOperation;
48
+ accountId: string;
49
+ publicKey: string;
50
+ previousPublicKey: string | null;
51
+ }): {
52
+ operation: OrganizationKeyOperation;
53
+ accountId: string;
54
+ publicKey: string;
55
+ previousPublicKey: string | null;
56
+ };
57
+ /** The claims one signer (`rootPublicKey`) signs for `challenge`. */
58
+ export declare function organizationKeyProofClaims(challenge: OrganizationKeyChallenge, rootPublicKey: string): IdentityProofClaims;
59
+ export declare const organizationKeyChallengeRequestCheck: import("./check").Check<{
60
+ operation: "replace" | "create";
61
+ publicKey: string;
62
+ }>;
63
+ export declare const organizationKeyChallengeCheck: import("./check").Check<{
64
+ operation: "replace" | "create";
65
+ action: "organization_key_create" | "organization_key_replace";
66
+ accountId: string;
67
+ actorId: string;
68
+ actorPublicKey: string;
69
+ publicKey: string;
70
+ previousPublicKey: string | null;
71
+ payloadDigest: string;
72
+ audience: "oxy-api/identity";
73
+ challenge: string;
74
+ expiresAt: number;
75
+ }>;
76
+ export declare const organizationKeyApplyRequestCheck: import("./check").Check<{
77
+ operation: "replace" | "create";
78
+ publicKey: string;
79
+ challenge: string;
80
+ expiresAt: number;
81
+ actorSignature: string;
82
+ keySignature: string;
83
+ previousKeySignature?: string | undefined;
84
+ }>;
85
+ export declare const organizationIdentityKeyStateCheck: import("./check").Check<{
86
+ accountId: string;
87
+ publicKey: string | null;
88
+ keys: {
89
+ publicKey: string;
90
+ method: "replace" | "create";
91
+ linkedByUserId: string | null;
92
+ previousKeyProven: boolean;
93
+ linkedAt: string;
94
+ retiredAt: string | null;
95
+ }[];
96
+ }>;
@@ -9,6 +9,13 @@ export declare const userNameCheck: import("./check").Check<UserNameResponse>;
9
9
  * Most links a profile may show. Enforced by the server on every write that
10
10
  * carries `linksMetadata` (see `user.service.ts`), and by the editor.
11
11
  */
12
+ /**
13
+ * How an account names its pronouns: one of a closed list, never free text. A
14
+ * federated account's source value is mapped onto it; a value that maps to none
15
+ * of these is `unspecified`.
16
+ */
17
+ export declare const PRONOUNS: readonly ["unspecified", "he_him", "she_her", "they_them", "he_they", "she_they", "it_its"];
18
+ export type Pronouns = (typeof PRONOUNS)[number];
12
19
  export declare const PROFILE_LINKS_MAX = 10;
13
20
  /**
14
21
  * Longest title an editor may give a profile link, in characters. Not enforced
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A personal account's key history: `GET /identity/key-history`.
3
+ *
4
+ * The current root (`null` without one) and every root a rotation replaced,
5
+ * oldest first. Commons reads it to accept a previous recovery phrase only when
6
+ * it derives a key that WAS this account's root, and keeps that key to spend
7
+ * what it received. A retired root is never any account's again (ADR 0061 D2).
8
+ *
9
+ * Keys are canonical: uncompressed, lowercase (`04` + 128 hex). No private key
10
+ * or phrase crosses this contract.
11
+ *
12
+ * The Zod-free check is `./client/identityKeyHistory.ts`.
13
+ */
14
+ import { z } from 'zod';
15
+ export declare const identityKeyHistorySchema: z.ZodObject<{
16
+ publicKey: z.ZodNullable<z.ZodString>;
17
+ retired: z.ZodArray<z.ZodObject<{
18
+ publicKey: z.ZodString;
19
+ retiredAt: z.ZodString;
20
+ }, z.core.$strict>>;
21
+ }, z.core.$strict>;
22
+ export type IdentityKeyHistory = z.infer<typeof identityKeyHistorySchema>;
@@ -30,6 +30,8 @@ export type IdentityProof = z.infer<typeof identityProofSchema>;
30
30
  export declare const identityProofChallengeRequestSchema: z.ZodObject<{
31
31
  action: z.ZodEnum<{
32
32
  link_identity: "link_identity";
33
+ organization_key_create: "organization_key_create";
34
+ organization_key_replace: "organization_key_replace";
33
35
  }>;
34
36
  }, z.core.$strip>;
35
37
  export type IdentityProofChallengeRequest = z.infer<typeof identityProofChallengeRequestSchema>;
@@ -18,7 +18,8 @@ export type { AvatarCharacter } from './avatarCharacter';
18
18
  export { ACCOUNT_ACTOR_NATURES, ACCOUNT_SUBJECT_CONTRACT_VERSION, FINANCIAL_EFFECT_DIRECTIONS, KIND_INDEPENDENT_ACCOUNT_DIMENSIONS, accountActorChainFromSession, accountActorChainSchema, accountActorNatureSchema, accountKindActorNature, accountKindActsAsItself, attributeFinancialEffect, financialEffectAttributionSchema, } from './accountSubject';
19
19
  export type { AccountActorChain, AccountActorNature, FinancialEffectAttribution, FinancialEffectDirection, KindIndependentAccountDimension, } from './accountSubject';
20
20
  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';
21
- export { PROFILE_LINKS_MAX, PROFILE_LINK_TITLE_MAX } from './client/userResponse';
21
+ export { PRONOUNS, PROFILE_LINKS_MAX, PROFILE_LINK_TITLE_MAX } from './client/userResponse';
22
+ export type { Pronouns } from './client/userResponse';
22
23
  export { userNameSchema, userRelationshipSchema, themePreferenceSchema, dateOfBirthSchema, userResponseSchema, userProfileUpdateSchema, currentUserResponseSchema, deviceLinkedSessionSchema, deviceLinkedSessionsResponseSchema, resolveUserId, safeParseContract, } from './userResponse';
23
24
  export type { UserNameResponse, UserRelationship, ThemePreference, UserResponse, UserProfileUpdate, CurrentUserResponseContract, DeviceLinkedSessionResponse, DeviceLinkedSessionsResponseContract, } from './userResponse';
24
25
  export { applicationTypeSchema, publicApplicationSchema, sessionStatusSchema, } from './sessionStatus';
@@ -56,6 +57,8 @@ export { loginResultSchema, } from './deviceBoot';
56
57
  export type { LoginSessionResult, LoginResult, SecurityAlert, SecurityAlertAnomaly, } from './deviceBoot';
57
58
  export { rotateKeyChallengeResponseSchema, rotateKeyCompleteRequestSchema, rotateKeyCompleteResponseSchema, } from './keyRotation';
58
59
  export type { RotateKeyChallengeResponse, RotateKeyCompleteRequest, RotateKeyCompleteResponse, } from './keyRotation';
60
+ export { identityKeyHistorySchema } from './identityKeyHistory';
61
+ export type { IdentityKeyHistory } from './identityKeyHistory';
59
62
  export { backupLookupIdSchema, encryptedBackupEnvelopeSchema, backupUploadRequestSchema, backupStatusResponseSchema, } from './keyRecovery';
60
63
  export type { EncryptedBackupEnvelope, BackupUploadRequest, BackupStatusResponse, } from './keyRecovery';
61
64
  export { IDENTITY_PROOF_VERSION, IDENTITY_PROOF_DOMAIN, IDENTITY_PROOF_AUDIENCE, IDENTITY_PROOF_CHALLENGE_TTL_MS, IDENTITY_PROOF_ACTIONS, IDENTITY_PROOF_ACTION_VALUES, IDENTITY_ERROR_CODES, canonicalJson, buildIdentityProofMessage, identityProofSchema, identityProofChallengeRequestSchema, identityProofChallengeResponseSchema, identityRootStatusSchema, } from './identityProof';
@@ -128,6 +131,7 @@ export type { ProductDefinition, SubjectProductAccessQuery, SubjectProductGrantS
128
131
  export { meteredGenerationSchema, type MeteredGeneration } from './inference/economics';
129
132
  export { canonicalCapabilityJson, inputSatisfiesCapabilityLimits, isLoopbackOrigin, } from './capabilityBindings';
130
133
  export * from './agentKeys';
134
+ export * from './organizationIdentityKey';
131
135
  export { productSubscriptionSummarySchema, productSubscriptionsResponseSchema, subscriptionCreditGrantSchema, subscriptionCreditGrantsResponseSchema, cancelProductSubscriptionSchema, productSubscriptionCancellationResultSchema, type ProductSubscriptionSummary, type SubscriptionCreditGrant, type ProductSubscriptionCancellationResult, } from './products/billing';
132
136
  export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, productPlanCatalogueSchema, type ProductPlanCatalogue, type PersonalPlanCatalogue, } from './products/plans';
133
137
  export * from './products/checkout';