@oxy.so/contracts 6.10.0 → 6.11.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.
@@ -25,6 +25,16 @@ exports.IDENTITY_PROOF_ACTIONS = {
25
25
  * (ADR 0029 D3).
26
26
  */
27
27
  link: 'link_identity',
28
+ /**
29
+ * Give an organization its first identity key (ADR 0061 D4). Signed by the
30
+ * acting owner's or admin's own root and by the new key.
31
+ */
32
+ organizationKeyCreate: 'organization_key_create',
33
+ /**
34
+ * Replace an organization's identity key (ADR 0061 D7). Signed by the actor's
35
+ * root and the new key, and by the current key when the device holds it.
36
+ */
37
+ organizationKeyReplace: 'organization_key_replace',
28
38
  };
29
39
  exports.IDENTITY_PROOF_ACTION_VALUES = Object.values(exports.IDENTITY_PROOF_ACTIONS);
30
40
  exports.HEX_DIGEST = /^[0-9a-f]{64}$/;
@@ -30,11 +30,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
30
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.signedRecordEnvelopeCheck = exports.externalIdentityReferenceCheck = exports.loginResultCheck = exports.isLoopbackOrigin = exports.executeAgentKeyOperationCheck = exports.agentVerifyRequestCheck = exports.agentProofClaimsCheck = exports.agentKeyOperationResultCheck = exports.agentKeyOperationCheck = exports.agentKeyOperationChallengeCheck = exports.agentKeyListResponseCheck = exports.agentChallengeRequestCheck = exports.AGENT_PROOF_TTL_MS = exports.AGENT_PROOF_AUDIENCE = exports.AGENT_PROOF_ACTIONS = exports.ACCOUNT_AUTH_METHODS = exports.emailVerificationStartResponseCheck = exports.emailVerificationConfirmResponseCheck = exports.emailTicketCheck = exports.emailAddressCheck = exports.EMAIL_VERIFICATION_PURPOSES = exports.EMAIL_VERIFICATION_ERROR_CODES = exports.EMAIL_TICKET_TTL_MS = exports.EMAIL_CODE_TTL_MS = exports.EMAIL_CODE_MAX_ATTEMPTS = exports.EMAIL_CODE_LENGTH = exports.isPlainTextTitle = exports.accountTitleCheck = exports.accountNamePolicyForKind = exports.ACCOUNT_TITLE_MAX_LENGTH = exports.ACCOUNT_TITLE_DISALLOWED_SOURCE = exports.ACCOUNT_NAME_POLICY_BY_KIND = exports.newlyAddedRetiredCategories = exports.kindAcceptsAccountCategories = exports.isSelectableAccountCategoryId = exports.isOperatorSwitchTargetKind = exports.isMemberOperatedKind = exports.isDelegatedActAsEligibleKind = exports.isAccountKind = exports.SELECTABLE_ACCOUNT_CATEGORY_IDS = exports.RETIRED_ACCOUNT_CATEGORY_IDS = exports.MAX_ACCOUNT_CATEGORIES = exports.CHILD_ACCOUNT_KINDS = exports.ACCOUNT_KINDS = exports.ACCOUNT_CATEGORY_KINDS = exports.ACCOUNT_CATEGORY_IDS = exports.parseContract = exports.formatCheckPath = exports.checkContract = exports.ContractCheckError = void 0;
34
- 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 = 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.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 = void 0;
35
- 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 = 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 = void 0;
36
- 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.PROFILE_LINK_TITLE_MAX = exports.PROFILE_LINKS_MAX = exports.userNameCheck = exports.usernameCheckForAccountKind = 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 = 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.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 = void 0;
33
+ exports.ORGANIZATION_KEY_PROOF_ACTION_VALUES = exports.ORGANIZATION_KEY_PROOF_ACTIONS = exports.ORGANIZATION_KEY_OPERATIONS = exports.ORGANIZATION_KEY_ERROR_CODES = exports.executeAgentKeyOperationCheck = exports.agentVerifyRequestCheck = exports.agentProofClaimsCheck = exports.agentKeyOperationResultCheck = exports.agentKeyOperationCheck = exports.agentKeyOperationChallengeCheck = exports.agentKeyListResponseCheck = exports.agentChallengeRequestCheck = exports.AGENT_PROOF_TTL_MS = exports.AGENT_PROOF_AUDIENCE = exports.AGENT_PROOF_ACTIONS = exports.ACCOUNT_AUTH_METHODS = exports.emailVerificationStartResponseCheck = exports.emailVerificationConfirmResponseCheck = exports.emailTicketCheck = exports.emailAddressCheck = exports.EMAIL_VERIFICATION_PURPOSES = exports.EMAIL_VERIFICATION_ERROR_CODES = exports.EMAIL_TICKET_TTL_MS = exports.EMAIL_CODE_TTL_MS = exports.EMAIL_CODE_MAX_ATTEMPTS = exports.EMAIL_CODE_LENGTH = exports.isPlainTextTitle = exports.accountTitleCheck = exports.accountNamePolicyForKind = exports.ACCOUNT_TITLE_MAX_LENGTH = exports.ACCOUNT_TITLE_DISALLOWED_SOURCE = exports.ACCOUNT_NAME_POLICY_BY_KIND = exports.newlyAddedRetiredCategories = exports.kindAcceptsAccountCategories = exports.isSelectableAccountCategoryId = exports.isOperatorSwitchTargetKind = exports.isMemberOperatedKind = exports.isDelegatedActAsEligibleKind = exports.isAccountKind = exports.SELECTABLE_ACCOUNT_CATEGORY_IDS = exports.RETIRED_ACCOUNT_CATEGORY_IDS = exports.MAX_ACCOUNT_CATEGORIES = exports.CHILD_ACCOUNT_KINDS = exports.ACCOUNT_KINDS = exports.ACCOUNT_CATEGORY_KINDS = exports.ACCOUNT_CATEGORY_IDS = exports.parseContract = exports.formatCheckPath = exports.checkContract = exports.ContractCheckError = void 0;
34
+ exports.ORGANIZATION_STATUSES = exports.ORGANIZATION_NAME_MAX_LENGTH = 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.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
+ exports.supervisionContactsResponseCheck = exports.supervisionContactInputCheck = 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 = void 0;
36
+ exports.userNameCheck = exports.usernameCheckForAccountKind = 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 = 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.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.PROFILE_LINK_TITLE_MAX = exports.PROFILE_LINKS_MAX = void 0;
38
38
  var check_1 = require("./check");
39
39
  Object.defineProperty(exports, "ContractCheckError", { enumerable: true, get: function () { return check_1.ContractCheckError; } });
40
40
  Object.defineProperty(exports, "checkContract", { enumerable: true, get: function () { return check_1.checkContract; } });
@@ -86,6 +86,17 @@ Object.defineProperty(exports, "agentKeyOperationResultCheck", { enumerable: tru
86
86
  Object.defineProperty(exports, "agentProofClaimsCheck", { enumerable: true, get: function () { return agentKeys_1.agentProofClaimsCheck; } });
87
87
  Object.defineProperty(exports, "agentVerifyRequestCheck", { enumerable: true, get: function () { return agentKeys_1.agentVerifyRequestCheck; } });
88
88
  Object.defineProperty(exports, "executeAgentKeyOperationCheck", { enumerable: true, get: function () { return agentKeys_1.executeAgentKeyOperationCheck; } });
89
+ var organizationIdentityKey_1 = require("./organizationIdentityKey");
90
+ Object.defineProperty(exports, "ORGANIZATION_KEY_ERROR_CODES", { enumerable: true, get: function () { return organizationIdentityKey_1.ORGANIZATION_KEY_ERROR_CODES; } });
91
+ Object.defineProperty(exports, "ORGANIZATION_KEY_OPERATIONS", { enumerable: true, get: function () { return organizationIdentityKey_1.ORGANIZATION_KEY_OPERATIONS; } });
92
+ Object.defineProperty(exports, "ORGANIZATION_KEY_PROOF_ACTIONS", { enumerable: true, get: function () { return organizationIdentityKey_1.ORGANIZATION_KEY_PROOF_ACTIONS; } });
93
+ Object.defineProperty(exports, "ORGANIZATION_KEY_PROOF_ACTION_VALUES", { enumerable: true, get: function () { return organizationIdentityKey_1.ORGANIZATION_KEY_PROOF_ACTION_VALUES; } });
94
+ Object.defineProperty(exports, "organizationIdentityKeyStateCheck", { enumerable: true, get: function () { return organizationIdentityKey_1.organizationIdentityKeyStateCheck; } });
95
+ Object.defineProperty(exports, "organizationKeyApplyRequestCheck", { enumerable: true, get: function () { return organizationIdentityKey_1.organizationKeyApplyRequestCheck; } });
96
+ Object.defineProperty(exports, "organizationKeyChallengeCheck", { enumerable: true, get: function () { return organizationIdentityKey_1.organizationKeyChallengeCheck; } });
97
+ Object.defineProperty(exports, "organizationKeyChallengeRequestCheck", { enumerable: true, get: function () { return organizationIdentityKey_1.organizationKeyChallengeRequestCheck; } });
98
+ Object.defineProperty(exports, "organizationKeyPayload", { enumerable: true, get: function () { return organizationIdentityKey_1.organizationKeyPayload; } });
99
+ Object.defineProperty(exports, "organizationKeyProofClaims", { enumerable: true, get: function () { return organizationIdentityKey_1.organizationKeyProofClaims; } });
89
100
  var capabilityBindings_1 = require("../capabilityBindings");
90
101
  Object.defineProperty(exports, "isLoopbackOrigin", { enumerable: true, get: function () { return capabilityBindings_1.isLoopbackOrigin; } });
91
102
  var deviceBoot_1 = require("./deviceBoot");
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ /**
3
+ * An organization's identity key (ADR 0061), without Zod. Schemas:
4
+ * `../organizationIdentityKey.ts`.
5
+ *
6
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
7
+ *
8
+ * An organization's key is its DID `#key-1`: the key Peable derives the
9
+ * organization's FairCoin receive addresses from. It is created in Commons by an
10
+ * owner or admin and never signs anybody in. A change is ONE identity proof
11
+ * ceremony (ADR 0024 D7): the server's challenge, then the same claims signed by
12
+ * the actor's own root, by the new key and (to replace) by the current key when
13
+ * the device holds it. The claims differ only in `rootPublicKey`, so no
14
+ * signature can stand in for another.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.organizationIdentityKeyStateCheck = exports.organizationKeyApplyRequestCheck = exports.organizationKeyChallengeCheck = exports.organizationKeyChallengeRequestCheck = exports.ORGANIZATION_KEY_ERROR_CODES = exports.ORGANIZATION_KEY_PROOF_ACTION_VALUES = exports.ORGANIZATION_KEY_PROOF_ACTIONS = exports.ORGANIZATION_KEY_OPERATIONS = void 0;
18
+ exports.organizationKeyPayload = organizationKeyPayload;
19
+ exports.organizationKeyProofClaims = organizationKeyProofClaims;
20
+ const check_1 = require("./check");
21
+ const identityProof_1 = require("./identityProof");
22
+ /** `create`: an organization without a key gets one. `replace`: a new key takes the current one's place. */
23
+ exports.ORGANIZATION_KEY_OPERATIONS = ['create', 'replace'];
24
+ /** The identity-proof action each operation is signed under. */
25
+ exports.ORGANIZATION_KEY_PROOF_ACTIONS = {
26
+ create: identityProof_1.IDENTITY_PROOF_ACTIONS.organizationKeyCreate,
27
+ replace: identityProof_1.IDENTITY_PROOF_ACTIONS.organizationKeyReplace,
28
+ };
29
+ exports.ORGANIZATION_KEY_PROOF_ACTION_VALUES = [
30
+ exports.ORGANIZATION_KEY_PROOF_ACTIONS.create,
31
+ exports.ORGANIZATION_KEY_PROOF_ACTIONS.replace,
32
+ ];
33
+ /**
34
+ * Stable error codes of the organization-key routes (`error.code`). The proof,
35
+ * key-in-use and already-linked refusals use `IDENTITY_ERROR_CODES`.
36
+ */
37
+ exports.ORGANIZATION_KEY_ERROR_CODES = {
38
+ /** The caller is not an owner or admin of a claimed, active organization. */
39
+ forbidden: 'ORGANIZATION_KEY_FORBIDDEN',
40
+ /** The signing person has no root of their own (only a Commons account can do this). */
41
+ actorRootRequired: 'ORGANIZATION_KEY_ACTOR_ROOT_REQUIRED',
42
+ /** `replace` on an organization without a key. */
43
+ noKey: 'ORGANIZATION_KEY_MISSING',
44
+ /** The key was already used, by this or another account, and is never reused. */
45
+ keyUsed: 'ORGANIZATION_KEY_USED',
46
+ };
47
+ /**
48
+ * The payload whose digest every signature of one operation binds. Both sides
49
+ * build it here, so the client and the verifier digest the same object.
50
+ */
51
+ function organizationKeyPayload(input) {
52
+ return {
53
+ operation: input.operation,
54
+ accountId: input.accountId,
55
+ publicKey: input.publicKey,
56
+ previousPublicKey: input.previousPublicKey,
57
+ };
58
+ }
59
+ /** The claims one signer (`rootPublicKey`) signs for `challenge`. */
60
+ function organizationKeyProofClaims(challenge, rootPublicKey) {
61
+ return {
62
+ action: challenge.action,
63
+ subject: challenge.accountId,
64
+ actor: challenge.actorId,
65
+ rootPublicKey,
66
+ payloadDigest: challenge.payloadDigest,
67
+ expectedRevision: null,
68
+ audience: challenge.audience,
69
+ challenge: challenge.challenge,
70
+ expiresAt: challenge.expiresAt,
71
+ };
72
+ }
73
+ /* -------------------------------------------------------------------------- */
74
+ /* Checks */
75
+ /* -------------------------------------------------------------------------- */
76
+ const publicKey = (0, check_1.string)(check_1.trim, (0, check_1.minLength)(1), (0, check_1.maxLength)(130));
77
+ const signature = (0, check_1.string)(check_1.trim, (0, check_1.minLength)(1), (0, check_1.maxLength)(512));
78
+ const challengeHex = (0, check_1.string)((0, check_1.pattern)(identityProof_1.CHALLENGE));
79
+ const timestamp = (0, check_1.number)(check_1.int, check_1.positive);
80
+ exports.organizationKeyChallengeRequestCheck = (0, check_1.exact)()((0, check_1.strictObject)({ operation: (0, check_1.oneOf)(exports.ORGANIZATION_KEY_OPERATIONS), publicKey }));
81
+ exports.organizationKeyChallengeCheck = (0, check_1.exact)()((0, check_1.strictObject)({
82
+ operation: (0, check_1.oneOf)(exports.ORGANIZATION_KEY_OPERATIONS),
83
+ action: (0, check_1.oneOf)(exports.ORGANIZATION_KEY_PROOF_ACTION_VALUES),
84
+ accountId: (0, check_1.string)((0, check_1.minLength)(1)),
85
+ actorId: (0, check_1.string)((0, check_1.minLength)(1)),
86
+ actorPublicKey: (0, check_1.string)((0, check_1.minLength)(1)),
87
+ publicKey: (0, check_1.string)((0, check_1.minLength)(1)),
88
+ previousPublicKey: (0, check_1.nullable)((0, check_1.string)((0, check_1.minLength)(1))),
89
+ payloadDigest: (0, check_1.string)((0, check_1.pattern)(identityProof_1.HEX_DIGEST)),
90
+ audience: (0, check_1.literal)(identityProof_1.IDENTITY_PROOF_AUDIENCE),
91
+ challenge: challengeHex,
92
+ expiresAt: timestamp,
93
+ }));
94
+ exports.organizationKeyApplyRequestCheck = (0, check_1.exact)()((0, check_1.strictObject)({
95
+ operation: (0, check_1.oneOf)(exports.ORGANIZATION_KEY_OPERATIONS),
96
+ publicKey,
97
+ challenge: challengeHex,
98
+ expiresAt: timestamp,
99
+ actorSignature: signature,
100
+ keySignature: signature,
101
+ previousKeySignature: (0, check_1.optional)(signature),
102
+ }));
103
+ exports.organizationIdentityKeyStateCheck = (0, check_1.exact)()((0, check_1.strictObject)({
104
+ accountId: (0, check_1.string)((0, check_1.minLength)(1)),
105
+ publicKey: (0, check_1.nullable)((0, check_1.string)((0, check_1.minLength)(1))),
106
+ keys: (0, check_1.array)((0, check_1.strictObject)({
107
+ publicKey: (0, check_1.string)((0, check_1.minLength)(1)),
108
+ method: (0, check_1.oneOf)(exports.ORGANIZATION_KEY_OPERATIONS),
109
+ linkedByUserId: (0, check_1.nullable)((0, check_1.string)()),
110
+ previousKeyProven: check_1.boolean,
111
+ linkedAt: (0, check_1.string)(check_1.datetime),
112
+ retiredAt: (0, check_1.nullable)((0, check_1.string)(check_1.datetime)),
113
+ })),
114
+ }));
package/dist/cjs/index.js CHANGED
@@ -889,6 +889,7 @@ Object.defineProperty(exports, "canonicalCapabilityJson", { enumerable: true, ge
889
889
  Object.defineProperty(exports, "inputSatisfiesCapabilityLimits", { enumerable: true, get: function () { return capabilityBindings_1.inputSatisfiesCapabilityLimits; } });
890
890
  Object.defineProperty(exports, "isLoopbackOrigin", { enumerable: true, get: function () { return capabilityBindings_1.isLoopbackOrigin; } });
891
891
  __exportStar(require("./agentKeys"), exports);
892
+ __exportStar(require("./organizationIdentityKey"), exports);
892
893
  var billing_1 = require("./products/billing");
893
894
  Object.defineProperty(exports, "productSubscriptionSummarySchema", { enumerable: true, get: function () { return billing_1.productSubscriptionSummarySchema; } });
894
895
  Object.defineProperty(exports, "productSubscriptionsResponseSchema", { enumerable: true, get: function () { return billing_1.productSubscriptionsResponseSchema; } });
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.organizationIdentityKeyStateSchema = exports.organizationKeyApplyRequestSchema = exports.organizationKeyChallengeSchema = exports.organizationKeyChallengeRequestSchema = exports.organizationKeyProofClaims = exports.organizationKeyPayload = exports.ORGANIZATION_KEY_ERROR_CODES = exports.ORGANIZATION_KEY_PROOF_ACTION_VALUES = exports.ORGANIZATION_KEY_PROOF_ACTIONS = exports.ORGANIZATION_KEY_OPERATIONS = void 0;
4
+ const numberChecks_1 = require("./numberChecks");
5
+ const stringChecks_1 = require("./stringChecks");
6
+ /**
7
+ * An organization's identity key (ADR 0061): its DID `#key-1`, created in
8
+ * Commons by an owner or admin, and the key Peable derives the organization's
9
+ * FairCoin receive addresses from.
10
+ *
11
+ * - `GET /accounts/:id/identity-key` the current key and its history
12
+ * - `POST /accounts/:id/identity-key/challenge` a one-use challenge for one change
13
+ * - `POST /accounts/:id/identity-key` apply it with the signatures
14
+ *
15
+ * No private key or phrase crosses this contract.
16
+ */
17
+ const zod_1 = require("zod");
18
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
19
+ // it is re-exported here so the root entry is unchanged.
20
+ const organizationIdentityKey_1 = require("./client/organizationIdentityKey");
21
+ const identityProof_1 = require("./client/identityProof");
22
+ var organizationIdentityKey_2 = require("./client/organizationIdentityKey");
23
+ Object.defineProperty(exports, "ORGANIZATION_KEY_OPERATIONS", { enumerable: true, get: function () { return organizationIdentityKey_2.ORGANIZATION_KEY_OPERATIONS; } });
24
+ Object.defineProperty(exports, "ORGANIZATION_KEY_PROOF_ACTIONS", { enumerable: true, get: function () { return organizationIdentityKey_2.ORGANIZATION_KEY_PROOF_ACTIONS; } });
25
+ Object.defineProperty(exports, "ORGANIZATION_KEY_PROOF_ACTION_VALUES", { enumerable: true, get: function () { return organizationIdentityKey_2.ORGANIZATION_KEY_PROOF_ACTION_VALUES; } });
26
+ Object.defineProperty(exports, "ORGANIZATION_KEY_ERROR_CODES", { enumerable: true, get: function () { return organizationIdentityKey_2.ORGANIZATION_KEY_ERROR_CODES; } });
27
+ Object.defineProperty(exports, "organizationKeyPayload", { enumerable: true, get: function () { return organizationIdentityKey_2.organizationKeyPayload; } });
28
+ Object.defineProperty(exports, "organizationKeyProofClaims", { enumerable: true, get: function () { return organizationIdentityKey_2.organizationKeyProofClaims; } });
29
+ const publicKey = zod_1.z.string().trim().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(130));
30
+ const signature = zod_1.z.string().trim().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(512));
31
+ /** `POST /accounts/:id/identity-key/challenge` */
32
+ exports.organizationKeyChallengeRequestSchema = zod_1.z
33
+ .object({ operation: zod_1.z.enum(organizationIdentityKey_1.ORGANIZATION_KEY_OPERATIONS), publicKey })
34
+ .strict();
35
+ /**
36
+ * The challenge and every claim the signers sign
37
+ * (`organizationKeyProofClaims(challenge, signerPublicKey)`).
38
+ */
39
+ exports.organizationKeyChallengeSchema = zod_1.z
40
+ .object({
41
+ operation: zod_1.z.enum(organizationIdentityKey_1.ORGANIZATION_KEY_OPERATIONS),
42
+ action: zod_1.z.enum(organizationIdentityKey_1.ORGANIZATION_KEY_PROOF_ACTION_VALUES),
43
+ /** The organization (the proof's `subject`). */
44
+ accountId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
45
+ /** The signed-in person performing it (the proof's `actor`). */
46
+ actorId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
47
+ /** The actor's own root, which signs `actorSignature`. */
48
+ actorPublicKey: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
49
+ /** The new key, canonical (lowercase, uncompressed). */
50
+ publicKey: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
51
+ /** The key it replaces, or `null` for `create`. */
52
+ previousPublicKey: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)).nullable(),
53
+ payloadDigest: zod_1.z.string().regex(identityProof_1.HEX_DIGEST),
54
+ audience: zod_1.z.literal(identityProof_1.IDENTITY_PROOF_AUDIENCE),
55
+ challenge: zod_1.z.string().regex(identityProof_1.CHALLENGE),
56
+ /** Unix milliseconds. */
57
+ expiresAt: zod_1.z.number().check((0, numberChecks_1.integerCheck)()).positive(),
58
+ })
59
+ .strict();
60
+ /** `POST /accounts/:id/identity-key` */
61
+ exports.organizationKeyApplyRequestSchema = zod_1.z
62
+ .object({
63
+ operation: zod_1.z.enum(organizationIdentityKey_1.ORGANIZATION_KEY_OPERATIONS),
64
+ publicKey,
65
+ challenge: zod_1.z.string().regex(identityProof_1.CHALLENGE),
66
+ expiresAt: zod_1.z.number().check((0, numberChecks_1.integerCheck)()).positive(),
67
+ /** By the actor's own root. */
68
+ actorSignature: signature,
69
+ /** By the new key: proof of possession. */
70
+ keySignature: signature,
71
+ /** By the current key, when replacing and the device holds it. */
72
+ previousKeySignature: signature.optional(),
73
+ })
74
+ .strict();
75
+ /**
76
+ * `GET /accounts/:id/identity-key`, and the answer of a change: the current
77
+ * key (`null` for an organization without one) and every key it has had,
78
+ * oldest first. A retired key is never used again by any account.
79
+ */
80
+ exports.organizationIdentityKeyStateSchema = zod_1.z
81
+ .object({
82
+ accountId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
83
+ publicKey: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)).nullable(),
84
+ keys: zod_1.z.array(zod_1.z
85
+ .object({
86
+ publicKey: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
87
+ method: zod_1.z.enum(organizationIdentityKey_1.ORGANIZATION_KEY_OPERATIONS),
88
+ linkedByUserId: zod_1.z.string().nullable(),
89
+ /** Whether a `replace` was also signed by the key it replaced. */
90
+ previousKeyProven: zod_1.z.boolean(),
91
+ linkedAt: zod_1.z.string().check((0, stringChecks_1.isoDateTime)()),
92
+ retiredAt: zod_1.z.string().check((0, stringChecks_1.isoDateTime)()).nullable(),
93
+ })
94
+ .strict()),
95
+ })
96
+ .strict();
@@ -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';
@@ -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
+ }));
package/dist/esm/index.js CHANGED
@@ -199,6 +199,7 @@ export { productDefinitionSchema, subjectProductAccessQuerySchema, productBenefi
199
199
  export { meteredGenerationSchema } from './inference/economics.js';
200
200
  export { canonicalCapabilityJson, inputSatisfiesCapabilityLimits, isLoopbackOrigin, } from './capabilityBindings.js';
201
201
  export * from './agentKeys.js';
202
+ export * from './organizationIdentityKey.js';
202
203
  export { productSubscriptionSummarySchema, productSubscriptionsResponseSchema, subscriptionCreditGrantSchema, subscriptionCreditGrantsResponseSchema, cancelProductSubscriptionSchema, productSubscriptionCancellationResultSchema, } from './products/billing.js';
203
204
  export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, productPlanCatalogueSchema, } from './products/plans.js';
204
205
  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();
@@ -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';
@@ -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
+ }>;
@@ -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>;
@@ -128,6 +128,7 @@ export type { ProductDefinition, SubjectProductAccessQuery, SubjectProductGrantS
128
128
  export { meteredGenerationSchema, type MeteredGeneration } from './inference/economics';
129
129
  export { canonicalCapabilityJson, inputSatisfiesCapabilityLimits, isLoopbackOrigin, } from './capabilityBindings';
130
130
  export * from './agentKeys';
131
+ export * from './organizationIdentityKey';
131
132
  export { productSubscriptionSummarySchema, productSubscriptionsResponseSchema, subscriptionCreditGrantSchema, subscriptionCreditGrantsResponseSchema, cancelProductSubscriptionSchema, productSubscriptionCancellationResultSchema, type ProductSubscriptionSummary, type SubscriptionCreditGrant, type ProductSubscriptionCancellationResult, } from './products/billing';
132
133
  export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, productPlanCatalogueSchema, type ProductPlanCatalogue, type PersonalPlanCatalogue, } from './products/plans';
133
134
  export * from './products/checkout';
@@ -0,0 +1,82 @@
1
+ /**
2
+ * An organization's identity key (ADR 0061): its DID `#key-1`, created in
3
+ * Commons by an owner or admin, and the key Peable derives the organization's
4
+ * FairCoin receive addresses from.
5
+ *
6
+ * - `GET /accounts/:id/identity-key` the current key and its history
7
+ * - `POST /accounts/:id/identity-key/challenge` a one-use challenge for one change
8
+ * - `POST /accounts/:id/identity-key` apply it with the signatures
9
+ *
10
+ * No private key or phrase crosses this contract.
11
+ */
12
+ import { z } from 'zod';
13
+ export { ORGANIZATION_KEY_OPERATIONS, ORGANIZATION_KEY_PROOF_ACTIONS, ORGANIZATION_KEY_PROOF_ACTION_VALUES, ORGANIZATION_KEY_ERROR_CODES, organizationKeyPayload, organizationKeyProofClaims, } from './client/organizationIdentityKey';
14
+ export type { OrganizationKeyOperation, OrganizationKeyProofAction, OrganizationKeyErrorCode, } from './client/organizationIdentityKey';
15
+ /** `POST /accounts/:id/identity-key/challenge` */
16
+ export declare const organizationKeyChallengeRequestSchema: z.ZodObject<{
17
+ operation: z.ZodEnum<{
18
+ replace: "replace";
19
+ create: "create";
20
+ }>;
21
+ publicKey: z.ZodString;
22
+ }, z.core.$strict>;
23
+ export type OrganizationKeyChallengeRequest = z.infer<typeof organizationKeyChallengeRequestSchema>;
24
+ /**
25
+ * The challenge and every claim the signers sign
26
+ * (`organizationKeyProofClaims(challenge, signerPublicKey)`).
27
+ */
28
+ export declare const organizationKeyChallengeSchema: z.ZodObject<{
29
+ operation: z.ZodEnum<{
30
+ replace: "replace";
31
+ create: "create";
32
+ }>;
33
+ action: z.ZodEnum<{
34
+ organization_key_create: "organization_key_create";
35
+ organization_key_replace: "organization_key_replace";
36
+ }>;
37
+ accountId: z.ZodString;
38
+ actorId: z.ZodString;
39
+ actorPublicKey: z.ZodString;
40
+ publicKey: z.ZodString;
41
+ previousPublicKey: z.ZodNullable<z.ZodString>;
42
+ payloadDigest: z.ZodString;
43
+ audience: z.ZodLiteral<"oxy-api/identity">;
44
+ challenge: z.ZodString;
45
+ expiresAt: z.ZodNumber;
46
+ }, z.core.$strict>;
47
+ export type OrganizationKeyChallenge = z.infer<typeof organizationKeyChallengeSchema>;
48
+ /** `POST /accounts/:id/identity-key` */
49
+ export declare const organizationKeyApplyRequestSchema: z.ZodObject<{
50
+ operation: z.ZodEnum<{
51
+ replace: "replace";
52
+ create: "create";
53
+ }>;
54
+ publicKey: z.ZodString;
55
+ challenge: z.ZodString;
56
+ expiresAt: z.ZodNumber;
57
+ actorSignature: z.ZodString;
58
+ keySignature: z.ZodString;
59
+ previousKeySignature: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strict>;
61
+ export type OrganizationKeyApplyRequest = z.infer<typeof organizationKeyApplyRequestSchema>;
62
+ /**
63
+ * `GET /accounts/:id/identity-key`, and the answer of a change: the current
64
+ * key (`null` for an organization without one) and every key it has had,
65
+ * oldest first. A retired key is never used again by any account.
66
+ */
67
+ export declare const organizationIdentityKeyStateSchema: z.ZodObject<{
68
+ accountId: z.ZodString;
69
+ publicKey: z.ZodNullable<z.ZodString>;
70
+ keys: z.ZodArray<z.ZodObject<{
71
+ publicKey: z.ZodString;
72
+ method: z.ZodEnum<{
73
+ replace: "replace";
74
+ create: "create";
75
+ }>;
76
+ linkedByUserId: z.ZodNullable<z.ZodString>;
77
+ previousKeyProven: z.ZodBoolean;
78
+ linkedAt: z.ZodString;
79
+ retiredAt: z.ZodNullable<z.ZodString>;
80
+ }, z.core.$strict>>;
81
+ }, z.core.$strict>;
82
+ export type OrganizationIdentityKeyState = z.infer<typeof organizationIdentityKeyStateSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/contracts",
3
- "version": "6.10.0",
3
+ "version": "6.11.0",
4
4
  "description": "OxyHQ API contracts — single source of truth for request/response Zod schemas and inferred types, shared by the backend and the client SDKs",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",