@oxy.so/contracts 6.18.0 → 6.20.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.
@@ -35,6 +35,12 @@ exports.IDENTITY_PROOF_ACTIONS = {
35
35
  * root and the new key, and by the current key when the device holds it.
36
36
  */
37
37
  organizationKeyReplace: 'organization_key_replace',
38
+ /**
39
+ * Reset the account's Oxy Keychain (`DELETE /keychain`, ADR 0063 D6) on an
40
+ * account whose root is linked: it has no email or password to re-verify
41
+ * with, so its root confirms the reset. The payload is `{ vaultId }`.
42
+ */
43
+ keychainReset: 'keychain_reset',
38
44
  };
39
45
  exports.IDENTITY_PROOF_ACTION_VALUES = Object.values(exports.IDENTITY_PROOF_ACTIONS);
40
46
  exports.HEX_DIGEST = /^[0-9a-f]{64}$/;
@@ -135,4 +141,14 @@ exports.IDENTITY_ERROR_CODES = {
135
141
  * person deleted (owner's decision, 2026-11-07).
136
142
  */
137
143
  backupOptedOut: 'IDENTITY_BACKUP_OPTED_OUT',
144
+ /**
145
+ * `POST /identity/backup`: the account has no backup on record (never made
146
+ * one, or deleted it before deletions were recorded) and the upload is not
147
+ * the person's explicit choice to create one (`optIn`). Only re-sealing a
148
+ * backup the account HAS (current or superseded) needs no opt-in, so a
149
+ * client too old to send it (Commons 1.12 or older) never creates one
150
+ * silently after a key rotation; the message asks the person to update
151
+ * Commons (owner's decision, 2026-11-07).
152
+ */
153
+ backupOptInRequired: 'IDENTITY_BACKUP_OPT_IN_REQUIRED',
138
154
  };
@@ -34,7 +34,8 @@ exports.ORGANIZATION_KEY_PROOF_ACTION_VALUES = exports.ORGANIZATION_KEY_PROOF_AC
34
34
  exports.ORGANIZATION_ERROR_CODES = exports.ORGANIZATION_CLAIM_STATUSES = exports.ORGANIZATION_CLAIM_DECISIONS = exports.ORGANIZATION_ALIAS_KINDS = exports.canonicalJson = exports.buildIdentityProofMessage = exports.IDENTITY_PROOF_VERSION = exports.IDENTITY_PROOF_DOMAIN = exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = exports.IDENTITY_PROOF_AUDIENCE = exports.IDENTITY_PROOF_ACTION_VALUES = exports.IDENTITY_PROOF_ACTIONS = exports.IDENTITY_ERROR_CODES = exports.parseIdentityLinkQrPayload = exports.identityLinkStateCheck = exports.identityLinkCreateResponseCheck = exports.buildIdentityLinkQrPayload = exports.IDENTITY_LINK_STATUSES = exports.IDENTITY_LINK_QR_PREFIX = exports.identityKeyHistoryCheck = exports.IDENTITY_KEY_HISTORY_CLAIM_ACTION = exports.sessionAccountsChangedEventCheck = exports.deviceTokenMintResponseCheck = exports.deviceSessionSyncCheck = exports.deviceSessionStateCheck = exports.deviceRegisterResponseCheck = exports.deviceJoinResponseCheck = exports.deviceJoinCodeResponseCheck = exports.holderContextEvidenceV1ResponseCheck = exports.holderContextEvidenceV1RequestCheck = exports.deviceContextTokenV1ResponseCheck = exports.deviceContextTokenV1RequestCheck = exports.deviceBackgroundCredentialResponseCheck = exports.activeTokenCheck = exports.SESSION_ACCOUNTS_CHANGED_EVENT = exports.deviceDirectorySyncCheck = exports.deviceDirectoryCheck = exports.deviceActivateResponseCheck = exports.normalizeDomainName = exports.DOMAIN_NAME_MAX_LENGTH = exports.signedRecordEnvelopeCheck = exports.externalIdentityReferenceCheck = exports.loginResultCheck = exports.isLoopbackOrigin = exports.organizationKeyProofClaims = exports.organizationKeyPayload = exports.organizationKeyChallengeRequestCheck = exports.organizationKeyChallengeCheck = exports.organizationKeyApplyRequestCheck = exports.organizationIdentityKeyStateCheck = void 0;
35
35
  exports.supervisionAcceptInputCheck = exports.safetyPeopleResponseCheck = exports.safetyPeopleInputCheck = exports.safetyOrganizationsResponseCheck = exports.safetyOrganizationsInputCheck = exports.purchaseReviewInputCheck = exports.purchaseApprovalListCheck = exports.purchaseApprovalCheck = exports.profileAccessInputCheck = exports.profileAccessDecisionCheck = exports.SUPERVISION_STATUSES = exports.SUPERVISION_INVITATION_STATUSES = exports.SUPERVISION_CONSENT_VERSION = exports.SUPERVISION_CHANGED_EVENT = exports.SUPERVISED_ACTIONS = exports.SAFETY_POLICY_VERSION = exports.PURCHASE_APPROVAL_STATUSES = exports.isFullReputationBalance = exports.recommendationRequestCheck = exports.subscriptionCreditGrantsResponseCheck = exports.subjectProductAccessQueryCheck = exports.subjectProductAccessCheck = exports.productSubscriptionsResponseCheck = exports.productSubscriptionPortalResponseCheck = exports.productSubscriptionPortalRequestCheck = exports.productSubscriptionCancellationResultCheck = exports.productPlanCheckoutRequestCheck = exports.productPlanCatalogueCheck = exports.personalPlanCheckoutResultCheck = exports.personalPlanCheckoutRequestCheck = exports.personalPlanCatalogueCheck = exports.cancelProductSubscriptionCheck = exports.updateOrganizationCheck = exports.organizationNameCheck = exports.organizationListCheck = exports.organizationImportBatchResultCheck = exports.organizationExternalResolutionCheck = exports.organizationExternalCheck = exports.organizationCurationResultCheck = exports.organizationClaimReviewCheck = exports.organizationClaimListCheck = exports.organizationClaimInputCheck = exports.organizationClaimDetailCheck = exports.organizationClaimCheck = exports.organizationCheck = exports.organizationBatchCheck = exports.createOrganizationCheck = exports.ORGANIZATION_TYPES = exports.ORGANIZATION_STATUSES = exports.ORGANIZATION_NAME_MAX_LENGTH = void 0;
36
36
  exports.usernameCheck = exports.stripDisallowedUsernameCharacters = exports.botUsernameCheck = exports.applyBotUsernameSuffix = exports.USERNAME_PATTERN_SOURCE = exports.USERNAME_MIN_LENGTH = exports.USERNAME_MAX_LENGTH = exports.USERNAME_INVALID_MESSAGE = exports.RESERVED_USERNAME_MESSAGE = exports.RESERVED_USERNAMES = exports.NUMERIC_USERNAME_MESSAGE = exports.BOT_USERNAME_SUFFIX = exports.BOT_USERNAME_INVALID_MESSAGE = exports.totpEnrollResponseCheck = exports.totpBackupCodesResponseCheck = exports.signInMethodsCheck = exports.secondFactorRequiredCheck = exports.reauthProofCheck = exports.normalizeEmailSignInCode = exports.isSecondFactorRequired = exports.isEmailSignInChooseAccount = exports.emailSignInStartResponseCheck = exports.emailSignInPendingCheck = exports.emailSignInLinkResponseCheck = exports.emailSignInChooseAccountCheck = exports.TOTP_PERIOD_SECONDS = exports.TOTP_DIGITS = exports.TOTP_BACKUP_CODE_COUNT = exports.SIGN_IN_ERROR_CODES = exports.SIGNIN_SECOND_FACTOR_TTL_MS = exports.SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = exports.SIGN_IN_IDENTIFIER_MAX_LENGTH = exports.SECOND_FACTOR_CODE_MAX_LENGTH = exports.REAUTH_ACTIONS = exports.PASSWORD_MIN_LENGTH = exports.PASSWORD_MAX_LENGTH = exports.EMAIL_SIGNIN_LONG_CODE_LENGTH = exports.EMAIL_SIGNIN_LONG_CODE_ALPHABET = exports.EMAIL_SIGNIN_LINK_TTL_MS = exports.EMAIL_SIGNIN_CHOICE_TTL_MS = exports.EMAIL_ACCOUNTS_MAX = exports.CONSOLE_USE_CASES = exports.CONSOLE_TERMS_VERSION = exports.publicApplicationCheck = exports.supervisionStateCheck = exports.supervisionReviewInputCheck = exports.supervisionInviteInputCheck = exports.supervisionInvitationCheck = exports.supervisionContactsResponseCheck = exports.supervisionContactInputCheck = void 0;
37
- exports.isLanguageTag = exports.hasCampaignControlCharacters = exports.CAMPAIGN_CLICK_ID_MAX_LENGTH = exports.CAMPAIGN_LABEL_MAX_LENGTH = exports.FREE_USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLORS = exports.deviceAppTokenResponseCheck = exports.PLATFORM_HOSTS = exports.OXYOS_DESKTOP_ENTRY_ID_PATTERN = exports.DEVICE_APP_TOKEN_TTL_SECONDS = exports.DEVICE_APP_TOKEN_ERROR_CODES = exports.APP_TOKEN_DEVICE_ACCESS_DENIED = exports.appAttestKeyResponseCheck = exports.appAssertionResponseCheck = exports.appAssertionChallengeResponseCheck = exports.OXY_APP_ASSERTION_TYPE = exports.OXY_APP_ASSERTION_TTL_SECONDS = exports.OXY_APP_ASSERTION_HEADER = exports.OXY_APP_ASSERTION_AUDIENCE = exports.APP_ASSERTION_PLATFORMS = exports.APP_ASSERTION_ERROR_CODES = exports.APP_ASSERTION_CHALLENGE_PURPOSES = exports.isRightsClaim = exports.isErasureRequest = exports.OPEN_CONTENT_CLAIM_STATES = exports.ERASURE_REQUEST_DEADLINE_DAYS = exports.COUNTER_NOTICE_STATEMENTS = exports.COUNTER_NOTICE_STATEMENT_VERSION = exports.CONTENT_CLAIM_STATES = exports.CONTENT_CLAIM_REFERENCE_PATTERN = exports.CONTENT_CLAIM_LIMITS = exports.CONTENT_CLAIM_KINDS = exports.CONTENT_CLAIM_ERROR_CODES = exports.CONTENT_CLAIM_COUNTER_NOTICE_LIMITS = exports.CLOSED_CONTENT_CLAIM_STATES = exports.CLAIMANT_RELATIONSHIPS = exports.PRONOUNS = exports.PROFILE_LINK_TITLE_MAX = exports.PROFILE_LINKS_MAX = exports.userNameCheck = exports.usernameCheckForAccountKind = void 0;
37
+ exports.KEYCHAIN_ID_PATTERN = exports.KEYCHAIN_ERROR_CODES = exports.KEYCHAIN_LIMITS = exports.KEYCHAIN_DOMAINS = exports.KEYCHAIN_RECOVERY = exports.KEYCHAIN_ENROLLMENT_STATUSES = exports.KEYCHAIN_ROSTER_OPS = exports.KEYCHAIN_PLATFORMS = exports.isLanguageTag = exports.hasCampaignControlCharacters = exports.CAMPAIGN_CLICK_ID_MAX_LENGTH = exports.CAMPAIGN_LABEL_MAX_LENGTH = exports.FREE_USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLORS = exports.deviceAppTokenResponseCheck = exports.PLATFORM_HOSTS = exports.OXYOS_DESKTOP_ENTRY_ID_PATTERN = exports.DEVICE_APP_TOKEN_TTL_SECONDS = exports.DEVICE_APP_TOKEN_ERROR_CODES = exports.APP_TOKEN_DEVICE_ACCESS_DENIED = exports.appAttestKeyResponseCheck = exports.appAssertionResponseCheck = exports.appAssertionChallengeResponseCheck = exports.OXY_APP_ASSERTION_TYPE = exports.OXY_APP_ASSERTION_TTL_SECONDS = exports.OXY_APP_ASSERTION_HEADER = exports.OXY_APP_ASSERTION_AUDIENCE = exports.APP_ASSERTION_PLATFORMS = exports.APP_ASSERTION_ERROR_CODES = exports.APP_ASSERTION_CHALLENGE_PURPOSES = exports.isRightsClaim = exports.isErasureRequest = exports.OPEN_CONTENT_CLAIM_STATES = exports.ERASURE_REQUEST_DEADLINE_DAYS = exports.COUNTER_NOTICE_STATEMENTS = exports.COUNTER_NOTICE_STATEMENT_VERSION = exports.CONTENT_CLAIM_STATES = exports.CONTENT_CLAIM_REFERENCE_PATTERN = exports.CONTENT_CLAIM_LIMITS = exports.CONTENT_CLAIM_KINDS = exports.CONTENT_CLAIM_ERROR_CODES = exports.CONTENT_CLAIM_COUNTER_NOTICE_LIMITS = exports.CLOSED_CONTENT_CLAIM_STATES = exports.CLAIMANT_RELATIONSHIPS = exports.PRONOUNS = exports.PROFILE_LINK_TITLE_MAX = exports.PROFILE_LINKS_MAX = exports.userNameCheck = exports.usernameCheckForAccountKind = void 0;
38
+ exports.keychainItemsResponseCheck = exports.keychainItemResponseCheck = exports.keychainEnrollmentsResponseCheck = exports.keychainEnrollmentResponseCheck = exports.keychainWrapResponseCheck = exports.keychainStateResponseCheck = exports.KEYCHAIN_TIMESTAMP_PATTERN = exports.KEYCHAIN_HASH_PATTERN = exports.KEYCHAIN_BASE64URL_PATTERN = exports.KEYCHAIN_SIGNATURE_PATTERN = exports.KEYCHAIN_NONCE_PATTERN = exports.KEYCHAIN_BYTES32_PATTERN = void 0;
38
39
  var check_1 = require("./check");
39
40
  Object.defineProperty(exports, "ContractCheckError", { enumerable: true, get: function () { return check_1.ContractCheckError; } });
40
41
  Object.defineProperty(exports, "checkContract", { enumerable: true, get: function () { return check_1.checkContract; } });
@@ -311,3 +312,24 @@ Object.defineProperty(exports, "CAMPAIGN_CLICK_ID_MAX_LENGTH", { enumerable: tru
311
312
  Object.defineProperty(exports, "hasCampaignControlCharacters", { enumerable: true, get: function () { return campaignAttribution_1.hasCampaignControlCharacters; } });
312
313
  var language_1 = require("./language");
313
314
  Object.defineProperty(exports, "isLanguageTag", { enumerable: true, get: function () { return language_1.isLanguageTag; } });
315
+ var keychain_1 = require("./keychain");
316
+ Object.defineProperty(exports, "KEYCHAIN_PLATFORMS", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_PLATFORMS; } });
317
+ Object.defineProperty(exports, "KEYCHAIN_ROSTER_OPS", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_ROSTER_OPS; } });
318
+ Object.defineProperty(exports, "KEYCHAIN_ENROLLMENT_STATUSES", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_ENROLLMENT_STATUSES; } });
319
+ Object.defineProperty(exports, "KEYCHAIN_RECOVERY", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_RECOVERY; } });
320
+ Object.defineProperty(exports, "KEYCHAIN_DOMAINS", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_DOMAINS; } });
321
+ Object.defineProperty(exports, "KEYCHAIN_LIMITS", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_LIMITS; } });
322
+ Object.defineProperty(exports, "KEYCHAIN_ERROR_CODES", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_ERROR_CODES; } });
323
+ Object.defineProperty(exports, "KEYCHAIN_ID_PATTERN", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_ID_PATTERN; } });
324
+ Object.defineProperty(exports, "KEYCHAIN_BYTES32_PATTERN", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_BYTES32_PATTERN; } });
325
+ Object.defineProperty(exports, "KEYCHAIN_NONCE_PATTERN", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_NONCE_PATTERN; } });
326
+ Object.defineProperty(exports, "KEYCHAIN_SIGNATURE_PATTERN", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_SIGNATURE_PATTERN; } });
327
+ Object.defineProperty(exports, "KEYCHAIN_BASE64URL_PATTERN", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_BASE64URL_PATTERN; } });
328
+ Object.defineProperty(exports, "KEYCHAIN_HASH_PATTERN", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_HASH_PATTERN; } });
329
+ Object.defineProperty(exports, "KEYCHAIN_TIMESTAMP_PATTERN", { enumerable: true, get: function () { return keychain_1.KEYCHAIN_TIMESTAMP_PATTERN; } });
330
+ Object.defineProperty(exports, "keychainStateResponseCheck", { enumerable: true, get: function () { return keychain_1.keychainStateResponseCheck; } });
331
+ Object.defineProperty(exports, "keychainWrapResponseCheck", { enumerable: true, get: function () { return keychain_1.keychainWrapResponseCheck; } });
332
+ Object.defineProperty(exports, "keychainEnrollmentResponseCheck", { enumerable: true, get: function () { return keychain_1.keychainEnrollmentResponseCheck; } });
333
+ Object.defineProperty(exports, "keychainEnrollmentsResponseCheck", { enumerable: true, get: function () { return keychain_1.keychainEnrollmentsResponseCheck; } });
334
+ Object.defineProperty(exports, "keychainItemResponseCheck", { enumerable: true, get: function () { return keychain_1.keychainItemResponseCheck; } });
335
+ Object.defineProperty(exports, "keychainItemsResponseCheck", { enumerable: true, get: function () { return keychain_1.keychainItemsResponseCheck; } });
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ /**
3
+ * The Oxy Keychain's wire contract, without Zod (ADR 0063,
4
+ * `docs/identity/keychain.md`). Schemas: `../keychain.ts`.
5
+ *
6
+ * Oxy stores only ciphertext, public keys, signatures and counters. Every
7
+ * binary value is base64url WITHOUT padding, in its one canonical spelling
8
+ * (the unused low bits of the last character are zero), so no two strings name
9
+ * the same bytes.
10
+ *
11
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.keychainItemsResponseCheck = exports.keychainItemResponseCheck = exports.keychainEnrollmentsResponseCheck = exports.keychainEnrollmentResponseCheck = exports.keychainWrapResponseCheck = exports.keychainStateResponseCheck = exports.KEYCHAIN_HASH_PATTERN = exports.KEYCHAIN_BASE64URL_PATTERN = exports.KEYCHAIN_SIGNATURE_PATTERN = exports.KEYCHAIN_NONCE_PATTERN = exports.KEYCHAIN_BYTES32_PATTERN = exports.KEYCHAIN_TIMESTAMP_PATTERN = exports.KEYCHAIN_ID_PATTERN = exports.KEYCHAIN_ERROR_CODES = exports.KEYCHAIN_LIMITS = exports.KEYCHAIN_DOMAINS = exports.KEYCHAIN_RECOVERY = exports.KEYCHAIN_ENROLLMENT_STATUSES = exports.KEYCHAIN_ROSTER_OPS = exports.KEYCHAIN_PLATFORMS = void 0;
15
+ const check_1 = require("./check");
16
+ /* -------------------------------------------------------------------------- */
17
+ /* Closed sets and constants */
18
+ /* -------------------------------------------------------------------------- */
19
+ /** The platforms a member may name: a closed set, for display only (ADR 0063 D3). */
20
+ exports.KEYCHAIN_PLATFORMS = [
21
+ 'oxyos',
22
+ 'ios',
23
+ 'android',
24
+ 'macos',
25
+ 'windows',
26
+ 'linux',
27
+ 'web',
28
+ ];
29
+ /** The roster's operations (ADR 0063 D3). */
30
+ exports.KEYCHAIN_ROSTER_OPS = ['genesis', 'add', 'remove', 'generation', 'recovery'];
31
+ /** An enrollment's states. An expired pending one is answered `410`, never served as pending. */
32
+ exports.KEYCHAIN_ENROLLMENT_STATUSES = ['pending', 'approved', 'denied'];
33
+ /**
34
+ * The recipient of the recovery wrap, and the signer named by a signature made
35
+ * with the recovery signing key.
36
+ */
37
+ exports.KEYCHAIN_RECOVERY = 'recovery';
38
+ /**
39
+ * Every domain string (ADR 0063 D8). Each signing input, AAD and derivation
40
+ * starts with one, so nothing signed or sealed as one kind can be replayed as
41
+ * another.
42
+ */
43
+ exports.KEYCHAIN_DOMAINS = {
44
+ roster: 'oxy.keychain.roster.v1',
45
+ wrap: 'oxy.keychain.wrap.v1',
46
+ item: 'oxy.keychain.item.v1',
47
+ seal: 'oxy.keychain.seal.v1',
48
+ enrollCommit: 'oxy.keychain.enroll.commit.v1',
49
+ enrollCode: 'oxy.keychain.enroll.code.v1',
50
+ recovery: 'oxy.keychain.recovery.v1',
51
+ };
52
+ /** The server's limits (`docs/identity/keychain.md`). */
53
+ exports.KEYCHAIN_LIMITS = {
54
+ /** Live (non-deleted) items in one vault. */
55
+ maxLiveItems: 10000,
56
+ /** An item's or a wrap's ciphertext, in base64url characters (64 KiB). */
57
+ maxCiphertextLength: 65536,
58
+ /** Entries in one roster, genesis included. */
59
+ maxRosterEntries: 1000,
60
+ /** Members not removed. */
61
+ maxLiveMembers: 32,
62
+ /** Unexpired pending enrollments per vault. */
63
+ maxPendingEnrollments: 4,
64
+ /** How long an enrollment waits for its approval. */
65
+ enrollmentTtlMs: 10 * 60 * 1000,
66
+ /** Items in one `GET /keychain/items` page. */
67
+ maxItemsPage: 500,
68
+ /** Entries in one roster append. */
69
+ maxEntriesPerAppend: 64,
70
+ /** One roster entry's `body`, in characters. */
71
+ maxEntryBodyLength: 4096,
72
+ /** A member's display name, in bytes of UTF-8 (at least 1; any characters). */
73
+ maxMemberNameBytes: 256,
74
+ };
75
+ /**
76
+ * Stable error codes the `/keychain` routes answer with (`error` in the API's
77
+ * error body). Clients map these through their localization, never the English
78
+ * message.
79
+ */
80
+ exports.KEYCHAIN_ERROR_CODES = {
81
+ /** Not a personal account acting as itself. */
82
+ notAvailable: 'KEYCHAIN_NOT_AVAILABLE',
83
+ /** The bearer carries no device session, which a member is bound to. */
84
+ deviceRequired: 'KEYCHAIN_DEVICE_REQUIRED',
85
+ /** `POST /keychain`: the account already has a vault. */
86
+ exists: 'KEYCHAIN_EXISTS',
87
+ /** The account has no vault. */
88
+ notFound: 'KEYCHAIN_NOT_FOUND',
89
+ /** The caller's device session is bound to no live member of the vault. */
90
+ notMember: 'KEYCHAIN_NOT_MEMBER',
91
+ /** The caller's device session is already bound to a live member. */
92
+ alreadyMember: 'KEYCHAIN_ALREADY_MEMBER',
93
+ /** The entries do not continue the roster's head (a fork, a race, a stale head). */
94
+ rosterConflict: 'KEYCHAIN_ROSTER_CONFLICT',
95
+ /** An entry is malformed, non-canonical, badly signed, or breaks a roster rule. */
96
+ rosterInvalid: 'KEYCHAIN_ROSTER_INVALID',
97
+ /** A wrap is malformed, badly signed, or not the one the entries require. */
98
+ wrapInvalid: 'KEYCHAIN_WRAP_INVALID',
99
+ /**
100
+ * A `remove` without its `generation`, or a `generation` without a wrap at
101
+ * that generation for every remaining member and `recovery`.
102
+ */
103
+ rotationIncomplete: 'KEYCHAIN_ROTATION_INCOMPLETE',
104
+ /** A limit of `KEYCHAIN_LIMITS` would be exceeded. */
105
+ limitReached: 'KEYCHAIN_LIMIT_REACHED',
106
+ /** No such enrollment for this vault. */
107
+ enrollmentNotFound: 'KEYCHAIN_ENROLLMENT_NOT_FOUND',
108
+ /** The enrollment's ten minutes are over. */
109
+ enrollmentExpired: 'KEYCHAIN_ENROLLMENT_EXPIRED',
110
+ /** The enrollment is not at the step this request takes (or was decided). */
111
+ enrollmentState: 'KEYCHAIN_ENROLLMENT_STATE',
112
+ /** The revealed device nonce does not open the commitment; the enrollment is denied. */
113
+ commitmentMismatch: 'KEYCHAIN_COMMITMENT_MISMATCH',
114
+ /** No such item, or it is deleted. */
115
+ itemNotFound: 'KEYCHAIN_ITEM_NOT_FOUND',
116
+ /** `baseRevision` is not the item's stored revision: re-read, merge, retry. */
117
+ itemConflict: 'KEYCHAIN_ITEM_CONFLICT',
118
+ /** An item's generation is not between 1 and the vault's. */
119
+ generationInvalid: 'KEYCHAIN_GENERATION_INVALID',
120
+ /** `DELETE /keychain` on an account with a linked root: a root proof is required. */
121
+ resetProofRequired: 'KEYCHAIN_RESET_PROOF_REQUIRED',
122
+ };
123
+ /* -------------------------------------------------------------------------- */
124
+ /* Encodings */
125
+ /* -------------------------------------------------------------------------- */
126
+ /** A lowercase uuid in its 8-4-4-4-12 form, any version: vault, member, item and enrollment ids. */
127
+ exports.KEYCHAIN_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
128
+ /** A roster timestamp in its one spelling: UTC with milliseconds, as `Date#toISOString` writes it. */
129
+ exports.KEYCHAIN_TIMESTAMP_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
130
+ /** 32 bytes, canonical base64url (43 characters): keys, enrollment nonces, commitments. */
131
+ exports.KEYCHAIN_BYTES32_PATTERN = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
132
+ /** 24 bytes, base64url (32 characters): an XChaCha20-Poly1305 nonce. */
133
+ exports.KEYCHAIN_NONCE_PATTERN = /^[A-Za-z0-9_-]{32}$/;
134
+ /** 64 bytes, canonical base64url (86 characters): an Ed25519 signature. */
135
+ exports.KEYCHAIN_SIGNATURE_PATTERN = /^[A-Za-z0-9_-]{85}[AQgw]$/;
136
+ /** Any length of canonical base64url without padding. */
137
+ exports.KEYCHAIN_BASE64URL_PATTERN = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}[AEIMQUYcgkosw048]|[A-Za-z0-9_-][AQgw])?$/;
138
+ /** A roster entry's hash: lowercase hex SHA-256. */
139
+ exports.KEYCHAIN_HASH_PATTERN = /^[0-9a-f]{64}$/;
140
+ /* -------------------------------------------------------------------------- */
141
+ /* Response checks */
142
+ /* -------------------------------------------------------------------------- */
143
+ const counter = (0, check_1.number)(check_1.int, check_1.nonnegative);
144
+ const generation = (0, check_1.number)(check_1.int, check_1.positive);
145
+ const entryCheck = (0, check_1.object)({
146
+ body: (0, check_1.string)(),
147
+ signatures: (0, check_1.array)((0, check_1.object)({ signer: (0, check_1.string)(), signature: (0, check_1.string)() })),
148
+ });
149
+ const wrapCheck = (0, check_1.object)({
150
+ recipient: (0, check_1.string)(),
151
+ generation,
152
+ epk: (0, check_1.string)(),
153
+ nonce: (0, check_1.string)(),
154
+ ciphertext: (0, check_1.string)(),
155
+ signer: (0, check_1.string)(),
156
+ signature: (0, check_1.string)(),
157
+ });
158
+ const memberCheck = (0, check_1.object)({
159
+ id: (0, check_1.string)(),
160
+ name: (0, check_1.string)(),
161
+ platform: (0, check_1.oneOf)(exports.KEYCHAIN_PLATFORMS),
162
+ signingKey: (0, check_1.string)(),
163
+ boxKey: (0, check_1.string)(),
164
+ });
165
+ const enrollmentCheck = (0, check_1.object)({
166
+ id: (0, check_1.string)(),
167
+ vaultId: (0, check_1.string)(),
168
+ member: memberCheck,
169
+ commitment: (0, check_1.string)(),
170
+ approverNonce: (0, check_1.nullable)((0, check_1.string)()),
171
+ approverMemberId: (0, check_1.nullable)((0, check_1.string)()),
172
+ deviceNonce: (0, check_1.nullable)((0, check_1.string)()),
173
+ status: (0, check_1.oneOf)(exports.KEYCHAIN_ENROLLMENT_STATUSES),
174
+ expiresAt: (0, check_1.string)(),
175
+ createdAt: (0, check_1.string)(),
176
+ });
177
+ const itemCheck = (0, check_1.object)({
178
+ id: (0, check_1.string)(),
179
+ revision: counter,
180
+ generation,
181
+ nonce: (0, check_1.nullable)((0, check_1.string)()),
182
+ ciphertext: (0, check_1.nullable)((0, check_1.string)()),
183
+ deletedAt: (0, check_1.nullable)((0, check_1.string)()),
184
+ updatedAt: (0, check_1.string)(),
185
+ });
186
+ exports.keychainStateResponseCheck = (0, check_1.exact)()((0, check_1.object)({
187
+ vault: (0, check_1.nullable)((0, check_1.object)({
188
+ id: (0, check_1.string)(),
189
+ genesisHash: (0, check_1.string)(),
190
+ rosterSeq: counter,
191
+ rosterHead: (0, check_1.string)(),
192
+ generation,
193
+ revision: counter,
194
+ })),
195
+ roster: (0, check_1.array)(entryCheck),
196
+ members: (0, check_1.array)((0, check_1.object)({ id: (0, check_1.string)(), orphaned: check_1.boolean, removed: check_1.boolean })),
197
+ self: (0, check_1.nullable)((0, check_1.string)()),
198
+ }));
199
+ exports.keychainWrapResponseCheck = (0, check_1.exact)()((0, check_1.object)({ wrap: wrapCheck }));
200
+ exports.keychainEnrollmentResponseCheck = (0, check_1.exact)()((0, check_1.object)({ enrollment: enrollmentCheck }));
201
+ exports.keychainEnrollmentsResponseCheck = (0, check_1.exact)()((0, check_1.object)({ enrollments: (0, check_1.array)(enrollmentCheck) }));
202
+ exports.keychainItemResponseCheck = (0, check_1.exact)()((0, check_1.object)({ item: itemCheck }));
203
+ exports.keychainItemsResponseCheck = (0, check_1.exact)()((0, check_1.object)({ items: (0, check_1.array)(itemCheck), revision: counter, more: check_1.boolean }));
@@ -77,6 +77,8 @@ exports.REAUTH_ACTIONS = [
77
77
  'credentials_manage',
78
78
  'supervision',
79
79
  'supervision_purchase',
80
+ /** `DELETE /keychain`: reset the Oxy Keychain, deleting every item (ADR 0063 D6). */
81
+ 'reset_keychain',
80
82
  ];
81
83
  /**
82
84
  * Stable error codes (`error.code` in the API error body). Clients map these
package/dist/cjs/index.js CHANGED
@@ -939,3 +939,4 @@ Object.defineProperty(exports, "applicationAccountRegistrationRequestSchema", {
939
939
  Object.defineProperty(exports, "applicationAccountRegistrationResponseSchema", { enumerable: true, get: function () { return applicationAccounts_1.applicationAccountRegistrationResponseSchema; } });
940
940
  Object.defineProperty(exports, "applicationAccountTotalSchema", { enumerable: true, get: function () { return applicationAccounts_1.applicationAccountTotalSchema; } });
941
941
  __exportStar(require("./postalAddresses"), exports);
942
+ __exportStar(require("./keychain"), exports);
@@ -117,13 +117,17 @@ exports.backupUploadRequestSchema = backupEnvelopeFields.extend({
117
117
  replacesLookupId: exports.backupLookupIdSchema.optional(),
118
118
  /**
119
119
  * The person's explicit choice to have a backup (owner's decision,
120
- * 2026-11-07). A person who deleted their backup (`status.optedOut`) gets a
121
- * new one only with it: an upload without it is refused (409
122
- * `IDENTITY_BACKUP_OPTED_OUT`), so a key rotation, a re-seal or another
123
- * device never re-uploads silently. An accepted upload with it clears the
124
- * deletion in the same transaction. Ignored when the person never deleted
125
- * one. Clients send it only from a control the person pressed ("Create
126
- * backup", or the rotation's "Create a backup" choice).
120
+ * 2026-11-07). Required whenever the account has NO backup row: a person
121
+ * who deleted theirs (`status.optedOut`; refused without it, 409
122
+ * `IDENTITY_BACKUP_OPTED_OUT`) and a person with none on record (never
123
+ * made one, or deleted it before deletions were recorded; 409
124
+ * `IDENTITY_BACKUP_OPT_IN_REQUIRED`), so a key rotation, a re-seal, another
125
+ * device or an older client never creates one silently. An accepted upload
126
+ * with it clears a recorded deletion in the same transaction. Not needed to
127
+ * re-seal a backup the account has (current, or superseded with
128
+ * `replacesLookupId`). Clients send it only from a control the person
129
+ * pressed ("Create backup", or the rotation's "Create an encrypted backup"
130
+ * choice).
127
131
  */
128
132
  optIn: zod_1.z.boolean().optional(),
129
133
  });