@tearleads/client-sdk 0.1.248 → 0.1.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/organizations/index.js +5 -3
- package/client/organizations/index.js.map +1 -1
- package/client/organizations/organizationGroupPresentation.d.ts +1 -1
- package/client/organizations/organizationGroupPresentation.js.map +1 -1
- package/client/organizations/organizationLeaveRequestVerifier.js +21 -0
- package/client/organizations/organizationLeaveRequestVerifier.js.map +1 -0
- package/client/organizations/{organizationReadModels.d.ts → organizationReadModelCoordinator.d.ts} +18 -16
- package/client/organizations/organizationReadModelCoordinator.js +2 -0
- package/client/organizations/organizationReadModelCoordinator.js.map +1 -0
- package/client/organizations/organizationReadModelPresentation.js +51 -0
- package/client/organizations/organizationReadModelPresentation.js.map +1 -0
- package/client/organizations/organizationReadModelScopes.js +37 -0
- package/client/organizations/organizationReadModelScopes.js.map +1 -0
- package/client/organizations/organizationReadModels.js +131 -88
- package/client/organizations/organizationReadModels.js.map +1 -1
- package/client/organizations/organizationsTypes.d.ts +13 -5
- package/client/organizations/organizationsTypes.js.map +1 -1
- package/client/organizations/principalMutations.d.ts +18 -2
- package/client/organizations/principalMutations.js +29 -15
- package/client/organizations/principalMutations.js.map +1 -1
- package/client/runtime/principalMutationApi.d.ts +2 -0
- package/client/runtime/principalMutationApi.js +2 -0
- package/client/runtime/principalMutationApi.js.map +1 -1
- package/client/runtime/principalMutationDispatch.js +47 -10
- package/client/runtime/principalMutationDispatch.js.map +1 -1
- package/client/runtime/workflowRuntime.js +5 -4
- package/client/runtime/workflowRuntime.js.map +1 -1
- package/data/containers/shared/mutationRequestOptions.d.ts +2 -0
- package/data/containers/shared/mutationRequestOptions.js.map +1 -1
- package/data/containers/shared/types.d.ts +12 -2
- package/data/containers/shared/types.js.map +1 -1
- package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js +1 -4
- package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelRepository.js +20 -2
- package/data/persistence/organizations/organizationReadModelRepository.js.map +1 -1
- package/data/persistence/principalPolicy/heldOrganizationDirectories.js +6 -1
- package/data/persistence/principalPolicy/heldOrganizationDirectories.js.map +1 -1
- package/data/persistence/principalPolicy/principalPolicyBundleIntegrity.js +1 -1
- package/data/persistence/principalPolicy/principalPolicyBundleIntegrity.js.map +1 -1
- package/data/persistence/principalPolicy/verifiedPrincipalPolicyCurrent.js +1 -5
- package/data/persistence/principalPolicy/verifiedPrincipalPolicyCurrent.js.map +1 -1
- package/data/principals/organizationGroupDirectoryRequest.js +0 -2
- package/data/principals/organizationGroupDirectoryRequest.js.map +1 -1
- package/data/principals/organizationPolicyRequest.js +0 -2
- package/data/principals/organizationPolicyRequest.js.map +1 -1
- package/data/principals/principalPolicyRequest.js +0 -2
- package/data/principals/principalPolicyRequest.js.map +1 -1
- package/internal/api-client/ApiClient.d.ts +4 -59
- package/internal/api-client/client/apiClientContext.d.ts +0 -30
- package/internal/api-client/client/containerMutations.d.ts +2 -2
- package/internal/api-client/client/containerMutations.js +2 -1
- package/internal/api-client/client/containerMutations.js.map +1 -1
- package/internal/api-client/client/documents.d.ts +0 -12
- package/internal/api-client/client/principalPolicies.d.ts +3 -18
- package/internal/api-client/client/writerProjections.d.ts +0 -12
- package/internal/api-client/heldDirectoryCitations.d.ts +8 -4
- package/internal/api-client/heldDirectoryCitations.js +6 -10
- package/internal/api-client/heldDirectoryCitations.js.map +1 -1
- package/internal/api-client/organizationPolicyHistory.d.ts +0 -6
- package/internal/api-client/principalPolicyRequests.d.ts +2 -18
- package/internal/api-client/principalPolicyRequests.js +6 -4
- package/internal/api-client/principalPolicyRequests.js.map +1 -1
- package/internal/api-client/routes/containers/mutations.js +3 -3
- package/internal/api-client/routes/containers/mutations.js.map +1 -1
- package/internal/api-client/routes/organizations/createGroup.js +3 -5
- package/internal/api-client/routes/organizations/createGroup.js.map +1 -1
- package/internal/api-client/routes/principals/policy.js +2 -5
- package/internal/api-client/routes/principals/policy.js.map +1 -1
- package/internal/api-client/types.d.ts +6 -0
- package/internal/api-client/types.js.map +1 -1
- package/internal/api-client/verifiedManifestCitations.js +3 -3
- package/internal/api-client/verifiedManifestCitations.js.map +1 -1
- package/internal/crypto/index.d.ts +1 -1
- package/internal/crypto/index.js.map +1 -1
- package/internal/crypto/keying/principalPolicyPayload.js +2 -12
- package/internal/crypto/keying/principalPolicyPayload.js.map +1 -1
- package/internal/crypto/keying/principalPolicyTypes.d.ts +5 -6
- package/internal/crypto/keying/principalPolicyTypes.js.map +1 -1
- package/internal/crypto/principalState.d.ts +1 -1
- package/internal/crypto/principalState.js.map +1 -1
- package/internal/crypto/principalStateTypes.d.ts +0 -1
- package/internal/crypto/principalStateTypes.js.map +1 -1
- package/internal/validators/operation/auth.d.ts +0 -24
- package/internal/validators/operation/containerMutations.d.ts +20 -3
- package/internal/validators/operation/containerMutations.js +18 -20
- package/internal/validators/operation/containerMutations.js.map +1 -1
- package/internal/validators/operation/documentMutations.d.ts +0 -48
- package/internal/validators/operation/index.d.ts +1 -1
- package/internal/validators/operation/index.js +1 -1
- package/internal/validators/operation/index.js.map +1 -1
- package/internal/validators/operation/organizationPolicyHistory.d.ts +0 -24
- package/internal/validators/operation/organizations.d.ts +17 -49
- package/internal/validators/operation/organizations.js +4 -2
- package/internal/validators/operation/organizations.js.map +1 -1
- package/internal/validators/operation/principals.d.ts +17 -57
- package/internal/validators/operation/principals.js +5 -2
- package/internal/validators/operation/principals.js.map +1 -1
- package/internal/validators/operation/writerProjections.d.ts +0 -48
- package/internal/validators/request/index.d.ts +1 -1
- package/internal/validators/request/index.js +1 -1
- package/internal/validators/request/index.js.map +1 -1
- package/internal/validators/request/organization.d.ts +15 -32
- package/internal/validators/request/organization.js +8 -0
- package/internal/validators/request/organization.js.map +1 -1
- package/internal/validators/request/organizationProvisioning.d.ts +0 -72
- package/internal/validators/request/principal.d.ts +4 -48
- package/internal/validators/request/principal.js +4 -2
- package/internal/validators/request/principal.js.map +1 -1
- package/internal/validators/request/registration.d.ts +0 -24
- package/internal/validators/response/areas/organizations.d.ts +3 -2
- package/internal/validators/response/areas/organizations.js +3 -2
- package/internal/validators/response/areas/organizations.js.map +1 -1
- package/internal/validators/response/areas/principals.d.ts +1 -1
- package/internal/validators/response/areas/principals.js +1 -1
- package/internal/validators/response/areas/principals.js.map +1 -1
- package/internal/validators/response/committedReadModel.d.ts +697 -0
- package/internal/validators/response/committedReadModel.js +52 -0
- package/internal/validators/response/committedReadModel.js.map +1 -0
- package/internal/validators/response/container.d.ts +52 -48
- package/internal/validators/response/container.js +3 -3
- package/internal/validators/response/container.js.map +1 -1
- package/internal/validators/response/documentMutation.d.ts +0 -96
- package/internal/validators/response/organization.d.ts +0 -191
- package/internal/validators/response/organization.js +0 -7
- package/internal/validators/response/organization.js.map +1 -1
- package/internal/validators/response/organizationPolicyHistory.d.ts +0 -24
- package/internal/validators/response/organizationReadModel.d.ts +167 -0
- package/internal/validators/response/organizationReadModel.js +5 -0
- package/internal/validators/response/organizationReadModel.js.map +1 -1
- package/internal/validators/response/policyEvidenceWire.d.ts +5 -3
- package/internal/validators/response/policyEvidenceWire.js +6 -4
- package/internal/validators/response/policyEvidenceWire.js.map +1 -1
- package/internal/validators/response/principal.d.ts +0 -451
- package/internal/validators/response/principal.js +0 -8
- package/internal/validators/response/principal.js.map +1 -1
- package/internal/validators/response/principalPolicyPage.d.ts +0 -48
- package/internal/validators/response/principalSnapshot.d.ts +4 -24
- package/internal/validators/response/principalSnapshot.js +4 -6
- package/internal/validators/response/principalSnapshot.js.map +1 -1
- package/internal/validators/response/projectionPolicyEvidence.d.ts +0 -48
- package/package.json +1 -1
- package/workflows/container-contents/container-state/organizationHost.d.ts +9 -0
- package/workflows/container-contents/container-state/organizationHost.js.map +1 -1
- package/workflows/container-contents/container-state/remote.js +6 -0
- package/workflows/container-contents/container-state/remote.js.map +1 -1
- package/workflows/containers/child/share/index.d.ts +4 -2
- package/workflows/containers/child/share/index.js +37 -20
- package/workflows/containers/child/share/index.js.map +1 -1
- package/workflows/organizations/containerContentsHost.js +20 -1
- package/workflows/organizations/containerContentsHost.js.map +1 -1
- package/workflows/organizations/groupPolicy/commitCurrentGroupPolicyMutation.js +5 -1
- package/workflows/organizations/groupPolicy/commitCurrentGroupPolicyMutation.js.map +1 -1
- package/workflows/organizations/groupPolicy/currentPolicyMutationAcknowledgement.js +1 -6
- package/workflows/organizations/groupPolicy/currentPolicyMutationAcknowledgement.js.map +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyMutationAcknowledgement.js +1 -6
- package/workflows/organizations/groupPolicy/groupPolicyMutationAcknowledgement.js.map +1 -1
- package/workflows/organizations/groups/createCurrentOrganizationGroup.js +8 -1
- package/workflows/organizations/groups/createCurrentOrganizationGroup.js.map +1 -1
- package/workflows/organizations/index.d.ts +1 -0
- package/workflows/organizations/index.js +1 -0
- package/workflows/organizations/index.js.map +1 -1
- package/workflows/organizations/policyHistory/organizationPolicyHistoryVerification.js +4 -6
- package/workflows/organizations/policyHistory/organizationPolicyHistoryVerification.js.map +1 -1
- package/workflows/organizations/principalPolicy/principalPolicyReceiptArtifacts.js +1 -7
- package/workflows/organizations/principalPolicy/principalPolicyReceiptArtifacts.js.map +1 -1
- package/workflows/organizations/readModel/committedReadModel.d.ts +66 -0
- package/workflows/organizations/readModel/committedReadModel.js +150 -0
- package/workflows/organizations/readModel/committedReadModel.js.map +1 -0
- package/workflows/organizations/readModel/readModelProjection.d.ts +15 -2
- package/workflows/organizations/readModel/readModelProjection.js +26 -4
- package/workflows/organizations/readModel/readModelProjection.js.map +1 -1
- package/workflows/principals/policyCache/principalPolicyCacheValidation.js +0 -13
- package/workflows/principals/policyCache/principalPolicyCacheValidation.js.map +1 -1
- package/workflows/principals/publicHistory/publicProjectionDirectory.js +4 -5
- package/workflows/principals/publicHistory/publicProjectionDirectory.js.map +1 -1
- package/workflows/registration/provisioningBootstrapBuilders.d.ts +0 -6
- package/workflows/registration/registrationPrincipalPolicyPersistence.js +1 -7
- package/workflows/registration/registrationPrincipalPolicyPersistence.js.map +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ManagedRecipientPrincipalType, PrincipalProjectionMember, PrincipalProjectionRole, PrincipalStateHeaderInput, PrincipalStateMember, PrincipalStateSigningInput, SignedPrincipalState, UnsignedPrincipalState } from "./principalStateTypes.js";
|
|
2
|
-
export type { ManagedRecipientPrincipalType, PrincipalContainerGrant, PrincipalContainerGrantAccessLevel, PrincipalProjectionMember, PrincipalProjectionRole, PrincipalStateExternalAuthority, PrincipalStateHeaderInput, PrincipalStateMember, PrincipalStateMemberEnvelope, PrincipalStateMembershipMode,
|
|
2
|
+
export type { ManagedRecipientPrincipalType, PrincipalContainerGrant, PrincipalContainerGrantAccessLevel, PrincipalProjectionMember, PrincipalProjectionRole, PrincipalStateExternalAuthority, PrincipalStateHeaderInput, PrincipalStateMember, PrincipalStateMemberEnvelope, PrincipalStateMembershipMode, PrincipalStateSigningInput, SignedPrincipalState, UnsignedPrincipalState, } from "./principalStateTypes.js";
|
|
3
3
|
export declare function encodeUnsignedPrincipalState(state: UnsignedPrincipalState): Uint8Array;
|
|
4
4
|
export declare function toUnsignedPrincipalState(state: UnsignedPrincipalState): UnsignedPrincipalState;
|
|
5
5
|
export declare function normalizeUnsignedPrincipalState(state: UnsignedPrincipalState): Promise<UnsignedPrincipalState>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"principalState.js","sourceRoot":"","sources":["principalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kCAAkC,E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M,eAAe,GAAG,MAAM,+BAA+B,CAC3D,wBAAwB,CAAC,KAAK,CAAC,CAChC,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,CACpB,4BAA4B,CAAC,eAAe,CAAC,EAC7C,SAAS,CACV,CAAC;IAEF,OAAO;QACL,GAAG,eAAe;QAClB,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC;KACpC,CAAC;AACJ,CAAC","sourcesContent":["import { base64ToBytes, bytesToBase64 } from \"@tearleads/encoding\";\nimport {\n isCanonicalSignedAt,\n SIGNED_AT_CONTRACT,\n} from \"@tearleads/validators/util\";\nimport { ML_KEM1024_PUBLIC_KEY_BYTES } from \"./encapsulation/generateKeyPair\";\nimport { toFingerprint } from \"./fingerprint\";\nimport { computePrincipalContainerGrantRoot } from \"./principalContainerGrants\";\nimport { computePrincipalMemberEnvelopesRoot } from \"./principalMemberEnvelopes\";\nimport { throwPrincipalPolicyValidationError } from \"./principalPolicyValidationError\";\nimport {\n comparePrincipalProjectionMembers,\n comparePrincipalStateMembers,\n hasDuplicateNormalizedPrincipalProjectionMembers,\n hasDuplicateNormalizedPrincipalStateMembers,\n} from \"./principalStateMembers\";\nimport type {\n ManagedRecipientPrincipalType,\n PrincipalProjectionMember,\n PrincipalProjectionRole,\n PrincipalStateExternalAuthority,\n PrincipalStateHeaderInput,\n PrincipalStateMember,\n PrincipalStateMembershipMode,\n PrincipalStateSigningInput,\n SignedPrincipalState,\n UnsignedPrincipalState,\n} from \"./principalStateTypes\";\nimport { sign } from \"./signing/sign\";\n\nconst TEXT_ENCODER = new TextEncoder();\nconst TEXT_DECODER = new TextDecoder();\n\nexport type {\n ManagedRecipientPrincipalType,\n PrincipalContainerGrant,\n PrincipalContainerGrantAccessLevel,\n PrincipalProjectionMember,\n PrincipalProjectionRole,\n PrincipalStateExternalAuthority,\n PrincipalStateHeaderInput,\n PrincipalStateMember,\n PrincipalStateMemberEnvelope,\n PrincipalStateMembershipMode,\n PrincipalStatePayloadCipherSuite,\n PrincipalStateSigningInput,\n SignedPrincipalState,\n UnsignedPrincipalState,\n} from \"./principalStateTypes\";\n\nfunction isValidPositiveInteger(value: number): boolean {\n return Number.isSafeInteger(value) && value > 0;\n}\n\nfunction isValidNonNegativeInteger(value: number): boolean {\n return Number.isInteger(value) && value >= 0;\n}\n\nfunction encodeNormalizedPrincipalStateMembers(\n normalizedMembers: ReadonlyArray<PrincipalStateMember>,\n): Uint8Array {\n return TEXT_ENCODER.encode(\n JSON.stringify(\n normalizedMembers.map((member) => ({\n userId: member.userId,\n })),\n ),\n );\n}\n\nfunction encodeNormalizedPrincipalProjectionMembers(\n normalizedMembers: ReadonlyArray<PrincipalProjectionMember>,\n): Uint8Array {\n return TEXT_ENCODER.encode(\n JSON.stringify(\n normalizedMembers.map((member) => ({\n userId: member.userId,\n role: member.role,\n identityBundleFingerprint: member.identityBundleFingerprint,\n })),\n ),\n );\n}\n\nexport function encodeUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): Uint8Array {\n return TEXT_ENCODER.encode(\n JSON.stringify({\n domain: \"tearleads.principal-state\",\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n prevStateHash: state.prevStateHash,\n keyEpoch: state.keyEpoch,\n encapsulationPublicKey: state.encapsulationPublicKey,\n keyFingerprint: state.keyFingerprint,\n membershipMode: state.membershipMode,\n membershipRoot: state.membershipRoot,\n memberEnvelopesRoot: state.memberEnvelopesRoot,\n projectionRoot: state.projectionRoot,\n grantRoot: state.grantRoot,\n payloadCiphertextHash: state.payloadCiphertextHash,\n memberCount: state.memberCount,\n grantCount: state.grantCount,\n externalAuthority: state.externalAuthority,\n signedAt: state.signedAt,\n signerUserId: state.signerUserId,\n signerUserKeyFingerprint: state.signerUserKeyFingerprint,\n }),\n );\n}\n\nexport function toUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): UnsignedPrincipalState {\n return {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n prevStateHash: state.prevStateHash,\n keyEpoch: state.keyEpoch,\n encapsulationPublicKey: state.encapsulationPublicKey,\n keyFingerprint: state.keyFingerprint,\n membershipMode: state.membershipMode,\n membershipRoot: state.membershipRoot,\n memberEnvelopesRoot: state.memberEnvelopesRoot,\n projectionRoot: state.projectionRoot,\n grantRoot: state.grantRoot,\n payloadCiphertextHash: state.payloadCiphertextHash,\n memberCount: state.memberCount,\n grantCount: state.grantCount,\n externalAuthority: state.externalAuthority,\n signedAt: state.signedAt,\n signerUserId: state.signerUserId,\n signerUserKeyFingerprint: state.signerUserKeyFingerprint,\n };\n}\n\nfunction isMembershipMode(\n value: string,\n): value is PrincipalStateMembershipMode {\n return value === \"projection\";\n}\n\nfunction validatePrincipalStateIdentityFields(\n state: UnsignedPrincipalState,\n): void {\n // Versions are counters, not a lifetime history budget. Keep every value\n // exact across JSON, JavaScript arithmetic, and the database number mapping.\n if (!Number.isSafeInteger(state.version) || state.version < 1) {\n throw new Error(\"Principal state version must be a positive safe integer\");\n }\n\n if (!isValidPositiveInteger(state.keyEpoch)) {\n throw new Error(\n \"Principal state key epoch must be a positive safe integer\",\n );\n }\n\n if (state.principalId.length === 0) {\n throw new Error(\"Principal state principalId cannot be empty\");\n }\n\n if (state.encapsulationPublicKey.length === 0) {\n throw new Error(\"Principal state encapsulationPublicKey cannot be empty\");\n }\n\n if (state.keyFingerprint.length === 0) {\n throw new Error(\"Principal state keyFingerprint cannot be empty\");\n }\n\n if (state.signerUserId.length === 0) {\n throw new Error(\"Principal state signerUserId cannot be empty\");\n }\n\n if (state.signerUserKeyFingerprint.length === 0) {\n throw new Error(\"Principal state signerUserKeyFingerprint cannot be empty\");\n }\n\n if (!isCanonicalSignedAt(state.signedAt)) {\n throw new Error(`Principal state signedAt must be ${SIGNED_AT_CONTRACT}`);\n }\n}\n\nfunction resolveMembershipMode(\n membershipMode: string | undefined,\n): PrincipalStateMembershipMode {\n if (!membershipMode || !isMembershipMode(membershipMode)) {\n throw new Error(\"Principal state membershipMode is unsupported\");\n }\n return membershipMode;\n}\n\nfunction requireNonEmptyHeaderString(\n value: string | undefined,\n message: string,\n): string {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new Error(message);\n }\n return value;\n}\n\nfunction resolveMemberCount(state: UnsignedPrincipalState): number {\n if (\n typeof state.memberCount !== \"number\" ||\n !isValidNonNegativeInteger(state.memberCount)\n ) {\n throw new Error(\n \"Principal state memberCount must be a non-negative integer\",\n );\n }\n\n return state.memberCount;\n}\n\nfunction normalizeExternalAuthority(\n authority: PrincipalStateExternalAuthority | null,\n): PrincipalStateExternalAuthority | null {\n if (authority === null) {\n return null;\n }\n\n if (\n authority.principalType !== \"group\" ||\n authority.principalId.length === 0 ||\n !Number.isSafeInteger(authority.version) ||\n authority.version < 1 ||\n !isValidPositiveInteger(authority.keyEpoch) ||\n authority.stateHash.length === 0 ||\n authority.keyFingerprint.length === 0\n ) {\n throw new Error(\"Principal state externalAuthority is invalid\");\n }\n\n return {\n principalType: \"group\",\n principalId: authority.principalId,\n version: authority.version,\n keyEpoch: authority.keyEpoch,\n stateHash: authority.stateHash,\n keyFingerprint: authority.keyFingerprint,\n };\n}\n\nasync function validatePrincipalEncapsulationKey(\n state: UnsignedPrincipalState,\n): Promise<void> {\n let publicKey: Uint8Array;\n try {\n publicKey = base64ToBytes(state.encapsulationPublicKey);\n } catch {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n \"Principal state encapsulationPublicKey must use canonical base64 encoding\",\n );\n }\n\n if (bytesToBase64(publicKey) !== state.encapsulationPublicKey) {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n \"Principal state encapsulationPublicKey must use canonical base64 encoding\",\n );\n }\n\n if (publicKey.length !== ML_KEM1024_PUBLIC_KEY_BYTES) {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n `Principal state encapsulationPublicKey must contain exactly ${ML_KEM1024_PUBLIC_KEY_BYTES} bytes`,\n );\n }\n\n const publicKeyFingerprint = await toFingerprint(publicKey);\n if (publicKeyFingerprint !== state.keyFingerprint) {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n \"Principal state keyFingerprint does not match encapsulationPublicKey\",\n );\n }\n}\n\nexport async function normalizeUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): Promise<UnsignedPrincipalState> {\n validatePrincipalStateIdentityFields(state);\n\n const membershipMode = resolveMembershipMode(state.membershipMode);\n const resolvedMembershipRoot = requireNonEmptyHeaderString(\n state.membershipRoot,\n \"Principal state membershipRoot is required\",\n );\n const resolvedProjectionRoot = requireNonEmptyHeaderString(\n state.projectionRoot,\n \"Principal state projectionRoot is required\",\n );\n const resolvedGrantRoot = requireNonEmptyHeaderString(\n state.grantRoot,\n \"Principal state grantRoot is required\",\n );\n const resolvedMemberEnvelopesRoot = requireNonEmptyHeaderString(\n state.memberEnvelopesRoot,\n \"Principal state memberEnvelopesRoot is required\",\n );\n const resolvedPayloadCiphertextHash = requireNonEmptyHeaderString(\n state.payloadCiphertextHash,\n \"Principal state payloadCiphertextHash is required\",\n );\n const memberCount = resolveMemberCount(state);\n if (!isValidNonNegativeInteger(state.grantCount)) {\n throw new Error(\n \"Principal state grantCount must be a non-negative integer\",\n );\n }\n\n await validatePrincipalEncapsulationKey(state);\n\n return {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n prevStateHash: state.prevStateHash,\n keyEpoch: state.keyEpoch,\n encapsulationPublicKey: state.encapsulationPublicKey,\n keyFingerprint: state.keyFingerprint,\n membershipMode,\n membershipRoot: resolvedMembershipRoot,\n memberEnvelopesRoot: resolvedMemberEnvelopesRoot,\n projectionRoot: resolvedProjectionRoot,\n grantRoot: resolvedGrantRoot,\n payloadCiphertextHash: resolvedPayloadCiphertextHash,\n memberCount,\n grantCount: state.grantCount,\n externalAuthority: normalizeExternalAuthority(state.externalAuthority),\n signedAt: state.signedAt,\n signerUserId: state.signerUserId,\n signerUserKeyFingerprint: state.signerUserKeyFingerprint,\n };\n}\n\nexport function isManagedRecipientPrincipalType(\n value: string,\n): value is ManagedRecipientPrincipalType {\n return value === \"group\" || value === \"organization\";\n}\n\nexport function isPrincipalProjectionRole(\n value: string,\n): value is PrincipalProjectionRole {\n return value === \"member\" || value === \"admin\";\n}\n\nexport function normalizePrincipalStateMembers(\n members: ReadonlyArray<PrincipalStateMember>,\n): PrincipalStateMember[] {\n return members\n .map((member) => ({ userId: member.userId }))\n .sort(comparePrincipalStateMembers);\n}\n\nexport function derivePrincipalProjectionMembers(\n members: ReadonlyArray<\n Pick<PrincipalProjectionMember, \"userId\" | \"identityBundleFingerprint\">\n >,\n): PrincipalProjectionMember[] {\n return normalizePrincipalProjectionMembers(\n members.map((member) => ({ ...member, role: \"member\" })),\n );\n}\n\nexport function normalizePrincipalProjectionMembers(\n members: ReadonlyArray<PrincipalProjectionMember>,\n): PrincipalProjectionMember[] {\n return members\n .map((member) => {\n if (\n typeof member.identityBundleFingerprint !== \"string\" ||\n !/^[a-f0-9]{64}$/u.test(member.identityBundleFingerprint)\n ) {\n throwPrincipalPolicyValidationError(\n \"invalid_shape\",\n \"Principal projection identity bundle fingerprint must be lowercase SHA-256\",\n );\n }\n return {\n userId: member.userId,\n role: member.role,\n identityBundleFingerprint: member.identityBundleFingerprint,\n };\n })\n .sort(comparePrincipalProjectionMembers);\n}\n\nexport async function computePrincipalMembershipRoot(\n members: ReadonlyArray<PrincipalStateMember>,\n): Promise<string> {\n const normalizedMembers = normalizePrincipalStateMembers(members);\n\n if (hasDuplicateNormalizedPrincipalStateMembers(normalizedMembers)) {\n throw new Error(\"Principal state cannot contain duplicate members\");\n }\n\n return toFingerprint(\n encodeNormalizedPrincipalStateMembers(normalizedMembers),\n );\n}\n\nexport async function computePrincipalProjectionRoot(\n members: ReadonlyArray<PrincipalProjectionMember>,\n): Promise<string> {\n const normalizedMembers = normalizePrincipalProjectionMembers(members);\n\n if (hasDuplicateNormalizedPrincipalProjectionMembers(normalizedMembers)) {\n throw new Error(\n \"Principal state projection cannot contain duplicate members\",\n );\n }\n\n return toFingerprint(\n encodeNormalizedPrincipalProjectionMembers(normalizedMembers),\n );\n}\n\nexport async function computePrincipalStatePayloadCiphertextHash(\n ciphertext: string,\n): Promise<string> {\n return toFingerprint(TEXT_ENCODER.encode(ciphertext));\n}\n\nexport async function buildPrincipalStateSigningInput(\n input: PrincipalStateHeaderInput,\n): Promise<PrincipalStateSigningInput> {\n return {\n principalType: input.principalType,\n principalId: input.principalId,\n version: input.version,\n prevStateHash: input.prevStateHash,\n keyEpoch: input.keyEpoch,\n encapsulationPublicKey: input.encapsulationPublicKey,\n keyFingerprint: input.keyFingerprint,\n membershipMode: \"projection\",\n membershipRoot: await computePrincipalMembershipRoot(input.members),\n memberEnvelopesRoot: await computePrincipalMemberEnvelopesRoot(\n input.memberEnvelopes,\n ),\n projectionRoot: await computePrincipalProjectionRoot(input.projection),\n grantRoot: await computePrincipalContainerGrantRoot(input.grants),\n payloadCiphertextHash: await computePrincipalStatePayloadCiphertextHash(\n input.payloadCiphertext,\n ),\n memberCount: input.projection.length,\n grantCount: input.grants.length,\n externalAuthority: input.externalAuthority,\n signedAt: input.signedAt,\n signerUserId: input.signerUserId,\n signerUserKeyFingerprint: input.signerUserKeyFingerprint,\n };\n}\n\nexport async function serializeUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): Promise<string> {\n const normalizedState = await normalizeUnsignedPrincipalState(state);\n return TEXT_DECODER.decode(encodeUnsignedPrincipalState(normalizedState));\n}\n\nexport async function computePrincipalStateHash(\n state: UnsignedPrincipalState,\n): Promise<string> {\n const normalizedState = await normalizeUnsignedPrincipalState(state);\n return toFingerprint(encodeUnsignedPrincipalState(normalizedState));\n}\n\nexport async function signPrincipalState(\n state: PrincipalStateSigningInput,\n secretKey: Uint8Array,\n): Promise<SignedPrincipalState> {\n const normalizedState = await normalizeUnsignedPrincipalState(\n toUnsignedPrincipalState(state),\n );\n const signature = sign(\n encodeUnsignedPrincipalState(normalizedState),\n secretKey,\n );\n\n return {\n ...normalizedState,\n signature: bytesToBase64(signature),\n };\n}\n"]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AAC,MAAM,CAAC,4BAA4B,CAAC,eAAe,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,KAA6B;IAE7B,MAAM,eAAe,GAAG,MAAM,+BAA+B,CAAC,KAAK,CAAC,CAAC;IACrE,OAAO,aAAa,CAAC,4BAA4B,CAAC,eAAe,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAiC,EACjC,SAAqB;IAErB,MAAM,eAAe,GAAG,MAAM,+BAA+B,CAC3D,wBAAwB,CAAC,KAAK,CAAC,CAChC,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,CACpB,4BAA4B,CAAC,eAAe,CAAC,EAC7C,SAAS,CACV,CAAC;IAEF,OAAO;QACL,GAAG,eAAe;QAClB,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC;KACpC,CAAC;AACJ,CAAC","sourcesContent":["import { base64ToBytes, bytesToBase64 } from \"@tearleads/encoding\";\nimport {\n isCanonicalSignedAt,\n SIGNED_AT_CONTRACT,\n} from \"@tearleads/validators/util\";\nimport { ML_KEM1024_PUBLIC_KEY_BYTES } from \"./encapsulation/generateKeyPair\";\nimport { toFingerprint } from \"./fingerprint\";\nimport { computePrincipalContainerGrantRoot } from \"./principalContainerGrants\";\nimport { computePrincipalMemberEnvelopesRoot } from \"./principalMemberEnvelopes\";\nimport { throwPrincipalPolicyValidationError } from \"./principalPolicyValidationError\";\nimport {\n comparePrincipalProjectionMembers,\n comparePrincipalStateMembers,\n hasDuplicateNormalizedPrincipalProjectionMembers,\n hasDuplicateNormalizedPrincipalStateMembers,\n} from \"./principalStateMembers\";\nimport type {\n ManagedRecipientPrincipalType,\n PrincipalProjectionMember,\n PrincipalProjectionRole,\n PrincipalStateExternalAuthority,\n PrincipalStateHeaderInput,\n PrincipalStateMember,\n PrincipalStateMembershipMode,\n PrincipalStateSigningInput,\n SignedPrincipalState,\n UnsignedPrincipalState,\n} from \"./principalStateTypes\";\nimport { sign } from \"./signing/sign\";\n\nconst TEXT_ENCODER = new TextEncoder();\nconst TEXT_DECODER = new TextDecoder();\n\nexport type {\n ManagedRecipientPrincipalType,\n PrincipalContainerGrant,\n PrincipalContainerGrantAccessLevel,\n PrincipalProjectionMember,\n PrincipalProjectionRole,\n PrincipalStateExternalAuthority,\n PrincipalStateHeaderInput,\n PrincipalStateMember,\n PrincipalStateMemberEnvelope,\n PrincipalStateMembershipMode,\n PrincipalStateSigningInput,\n SignedPrincipalState,\n UnsignedPrincipalState,\n} from \"./principalStateTypes\";\n\nfunction isValidPositiveInteger(value: number): boolean {\n return Number.isSafeInteger(value) && value > 0;\n}\n\nfunction isValidNonNegativeInteger(value: number): boolean {\n return Number.isInteger(value) && value >= 0;\n}\n\nfunction encodeNormalizedPrincipalStateMembers(\n normalizedMembers: ReadonlyArray<PrincipalStateMember>,\n): Uint8Array {\n return TEXT_ENCODER.encode(\n JSON.stringify(\n normalizedMembers.map((member) => ({\n userId: member.userId,\n })),\n ),\n );\n}\n\nfunction encodeNormalizedPrincipalProjectionMembers(\n normalizedMembers: ReadonlyArray<PrincipalProjectionMember>,\n): Uint8Array {\n return TEXT_ENCODER.encode(\n JSON.stringify(\n normalizedMembers.map((member) => ({\n userId: member.userId,\n role: member.role,\n identityBundleFingerprint: member.identityBundleFingerprint,\n })),\n ),\n );\n}\n\nexport function encodeUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): Uint8Array {\n return TEXT_ENCODER.encode(\n JSON.stringify({\n domain: \"tearleads.principal-state\",\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n prevStateHash: state.prevStateHash,\n keyEpoch: state.keyEpoch,\n encapsulationPublicKey: state.encapsulationPublicKey,\n keyFingerprint: state.keyFingerprint,\n membershipMode: state.membershipMode,\n membershipRoot: state.membershipRoot,\n memberEnvelopesRoot: state.memberEnvelopesRoot,\n projectionRoot: state.projectionRoot,\n grantRoot: state.grantRoot,\n payloadCiphertextHash: state.payloadCiphertextHash,\n memberCount: state.memberCount,\n grantCount: state.grantCount,\n externalAuthority: state.externalAuthority,\n signedAt: state.signedAt,\n signerUserId: state.signerUserId,\n signerUserKeyFingerprint: state.signerUserKeyFingerprint,\n }),\n );\n}\n\nexport function toUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): UnsignedPrincipalState {\n return {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n prevStateHash: state.prevStateHash,\n keyEpoch: state.keyEpoch,\n encapsulationPublicKey: state.encapsulationPublicKey,\n keyFingerprint: state.keyFingerprint,\n membershipMode: state.membershipMode,\n membershipRoot: state.membershipRoot,\n memberEnvelopesRoot: state.memberEnvelopesRoot,\n projectionRoot: state.projectionRoot,\n grantRoot: state.grantRoot,\n payloadCiphertextHash: state.payloadCiphertextHash,\n memberCount: state.memberCount,\n grantCount: state.grantCount,\n externalAuthority: state.externalAuthority,\n signedAt: state.signedAt,\n signerUserId: state.signerUserId,\n signerUserKeyFingerprint: state.signerUserKeyFingerprint,\n };\n}\n\nfunction isMembershipMode(\n value: string,\n): value is PrincipalStateMembershipMode {\n return value === \"projection\";\n}\n\nfunction validatePrincipalStateIdentityFields(\n state: UnsignedPrincipalState,\n): void {\n // Versions are counters, not a lifetime history budget. Keep every value\n // exact across JSON, JavaScript arithmetic, and the database number mapping.\n if (!Number.isSafeInteger(state.version) || state.version < 1) {\n throw new Error(\"Principal state version must be a positive safe integer\");\n }\n\n if (!isValidPositiveInteger(state.keyEpoch)) {\n throw new Error(\n \"Principal state key epoch must be a positive safe integer\",\n );\n }\n\n if (state.principalId.length === 0) {\n throw new Error(\"Principal state principalId cannot be empty\");\n }\n\n if (state.encapsulationPublicKey.length === 0) {\n throw new Error(\"Principal state encapsulationPublicKey cannot be empty\");\n }\n\n if (state.keyFingerprint.length === 0) {\n throw new Error(\"Principal state keyFingerprint cannot be empty\");\n }\n\n if (state.signerUserId.length === 0) {\n throw new Error(\"Principal state signerUserId cannot be empty\");\n }\n\n if (state.signerUserKeyFingerprint.length === 0) {\n throw new Error(\"Principal state signerUserKeyFingerprint cannot be empty\");\n }\n\n if (!isCanonicalSignedAt(state.signedAt)) {\n throw new Error(`Principal state signedAt must be ${SIGNED_AT_CONTRACT}`);\n }\n}\n\nfunction resolveMembershipMode(\n membershipMode: string | undefined,\n): PrincipalStateMembershipMode {\n if (!membershipMode || !isMembershipMode(membershipMode)) {\n throw new Error(\"Principal state membershipMode is unsupported\");\n }\n return membershipMode;\n}\n\nfunction requireNonEmptyHeaderString(\n value: string | undefined,\n message: string,\n): string {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new Error(message);\n }\n return value;\n}\n\nfunction resolveMemberCount(state: UnsignedPrincipalState): number {\n if (\n typeof state.memberCount !== \"number\" ||\n !isValidNonNegativeInteger(state.memberCount)\n ) {\n throw new Error(\n \"Principal state memberCount must be a non-negative integer\",\n );\n }\n\n return state.memberCount;\n}\n\nfunction normalizeExternalAuthority(\n authority: PrincipalStateExternalAuthority | null,\n): PrincipalStateExternalAuthority | null {\n if (authority === null) {\n return null;\n }\n\n if (\n authority.principalType !== \"group\" ||\n authority.principalId.length === 0 ||\n !Number.isSafeInteger(authority.version) ||\n authority.version < 1 ||\n !isValidPositiveInteger(authority.keyEpoch) ||\n authority.stateHash.length === 0 ||\n authority.keyFingerprint.length === 0\n ) {\n throw new Error(\"Principal state externalAuthority is invalid\");\n }\n\n return {\n principalType: \"group\",\n principalId: authority.principalId,\n version: authority.version,\n keyEpoch: authority.keyEpoch,\n stateHash: authority.stateHash,\n keyFingerprint: authority.keyFingerprint,\n };\n}\n\nasync function validatePrincipalEncapsulationKey(\n state: UnsignedPrincipalState,\n): Promise<void> {\n let publicKey: Uint8Array;\n try {\n publicKey = base64ToBytes(state.encapsulationPublicKey);\n } catch {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n \"Principal state encapsulationPublicKey must use canonical base64 encoding\",\n );\n }\n\n if (bytesToBase64(publicKey) !== state.encapsulationPublicKey) {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n \"Principal state encapsulationPublicKey must use canonical base64 encoding\",\n );\n }\n\n if (publicKey.length !== ML_KEM1024_PUBLIC_KEY_BYTES) {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n `Principal state encapsulationPublicKey must contain exactly ${ML_KEM1024_PUBLIC_KEY_BYTES} bytes`,\n );\n }\n\n const publicKeyFingerprint = await toFingerprint(publicKey);\n if (publicKeyFingerprint !== state.keyFingerprint) {\n throwPrincipalPolicyValidationError(\n \"invalid_artifact\",\n \"Principal state keyFingerprint does not match encapsulationPublicKey\",\n );\n }\n}\n\nexport async function normalizeUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): Promise<UnsignedPrincipalState> {\n validatePrincipalStateIdentityFields(state);\n\n const membershipMode = resolveMembershipMode(state.membershipMode);\n const resolvedMembershipRoot = requireNonEmptyHeaderString(\n state.membershipRoot,\n \"Principal state membershipRoot is required\",\n );\n const resolvedProjectionRoot = requireNonEmptyHeaderString(\n state.projectionRoot,\n \"Principal state projectionRoot is required\",\n );\n const resolvedGrantRoot = requireNonEmptyHeaderString(\n state.grantRoot,\n \"Principal state grantRoot is required\",\n );\n const resolvedMemberEnvelopesRoot = requireNonEmptyHeaderString(\n state.memberEnvelopesRoot,\n \"Principal state memberEnvelopesRoot is required\",\n );\n const resolvedPayloadCiphertextHash = requireNonEmptyHeaderString(\n state.payloadCiphertextHash,\n \"Principal state payloadCiphertextHash is required\",\n );\n const memberCount = resolveMemberCount(state);\n if (!isValidNonNegativeInteger(state.grantCount)) {\n throw new Error(\n \"Principal state grantCount must be a non-negative integer\",\n );\n }\n\n await validatePrincipalEncapsulationKey(state);\n\n return {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n prevStateHash: state.prevStateHash,\n keyEpoch: state.keyEpoch,\n encapsulationPublicKey: state.encapsulationPublicKey,\n keyFingerprint: state.keyFingerprint,\n membershipMode,\n membershipRoot: resolvedMembershipRoot,\n memberEnvelopesRoot: resolvedMemberEnvelopesRoot,\n projectionRoot: resolvedProjectionRoot,\n grantRoot: resolvedGrantRoot,\n payloadCiphertextHash: resolvedPayloadCiphertextHash,\n memberCount,\n grantCount: state.grantCount,\n externalAuthority: normalizeExternalAuthority(state.externalAuthority),\n signedAt: state.signedAt,\n signerUserId: state.signerUserId,\n signerUserKeyFingerprint: state.signerUserKeyFingerprint,\n };\n}\n\nexport function isManagedRecipientPrincipalType(\n value: string,\n): value is ManagedRecipientPrincipalType {\n return value === \"group\" || value === \"organization\";\n}\n\nexport function isPrincipalProjectionRole(\n value: string,\n): value is PrincipalProjectionRole {\n return value === \"member\" || value === \"admin\";\n}\n\nexport function normalizePrincipalStateMembers(\n members: ReadonlyArray<PrincipalStateMember>,\n): PrincipalStateMember[] {\n return members\n .map((member) => ({ userId: member.userId }))\n .sort(comparePrincipalStateMembers);\n}\n\nexport function derivePrincipalProjectionMembers(\n members: ReadonlyArray<\n Pick<PrincipalProjectionMember, \"userId\" | \"identityBundleFingerprint\">\n >,\n): PrincipalProjectionMember[] {\n return normalizePrincipalProjectionMembers(\n members.map((member) => ({ ...member, role: \"member\" })),\n );\n}\n\nexport function normalizePrincipalProjectionMembers(\n members: ReadonlyArray<PrincipalProjectionMember>,\n): PrincipalProjectionMember[] {\n return members\n .map((member) => {\n if (\n typeof member.identityBundleFingerprint !== \"string\" ||\n !/^[a-f0-9]{64}$/u.test(member.identityBundleFingerprint)\n ) {\n throwPrincipalPolicyValidationError(\n \"invalid_shape\",\n \"Principal projection identity bundle fingerprint must be lowercase SHA-256\",\n );\n }\n return {\n userId: member.userId,\n role: member.role,\n identityBundleFingerprint: member.identityBundleFingerprint,\n };\n })\n .sort(comparePrincipalProjectionMembers);\n}\n\nexport async function computePrincipalMembershipRoot(\n members: ReadonlyArray<PrincipalStateMember>,\n): Promise<string> {\n const normalizedMembers = normalizePrincipalStateMembers(members);\n\n if (hasDuplicateNormalizedPrincipalStateMembers(normalizedMembers)) {\n throw new Error(\"Principal state cannot contain duplicate members\");\n }\n\n return toFingerprint(\n encodeNormalizedPrincipalStateMembers(normalizedMembers),\n );\n}\n\nexport async function computePrincipalProjectionRoot(\n members: ReadonlyArray<PrincipalProjectionMember>,\n): Promise<string> {\n const normalizedMembers = normalizePrincipalProjectionMembers(members);\n\n if (hasDuplicateNormalizedPrincipalProjectionMembers(normalizedMembers)) {\n throw new Error(\n \"Principal state projection cannot contain duplicate members\",\n );\n }\n\n return toFingerprint(\n encodeNormalizedPrincipalProjectionMembers(normalizedMembers),\n );\n}\n\nexport async function computePrincipalStatePayloadCiphertextHash(\n ciphertext: string,\n): Promise<string> {\n return toFingerprint(TEXT_ENCODER.encode(ciphertext));\n}\n\nexport async function buildPrincipalStateSigningInput(\n input: PrincipalStateHeaderInput,\n): Promise<PrincipalStateSigningInput> {\n return {\n principalType: input.principalType,\n principalId: input.principalId,\n version: input.version,\n prevStateHash: input.prevStateHash,\n keyEpoch: input.keyEpoch,\n encapsulationPublicKey: input.encapsulationPublicKey,\n keyFingerprint: input.keyFingerprint,\n membershipMode: \"projection\",\n membershipRoot: await computePrincipalMembershipRoot(input.members),\n memberEnvelopesRoot: await computePrincipalMemberEnvelopesRoot(\n input.memberEnvelopes,\n ),\n projectionRoot: await computePrincipalProjectionRoot(input.projection),\n grantRoot: await computePrincipalContainerGrantRoot(input.grants),\n payloadCiphertextHash: await computePrincipalStatePayloadCiphertextHash(\n input.payloadCiphertext,\n ),\n memberCount: input.projection.length,\n grantCount: input.grants.length,\n externalAuthority: input.externalAuthority,\n signedAt: input.signedAt,\n signerUserId: input.signerUserId,\n signerUserKeyFingerprint: input.signerUserKeyFingerprint,\n };\n}\n\nexport async function serializeUnsignedPrincipalState(\n state: UnsignedPrincipalState,\n): Promise<string> {\n const normalizedState = await normalizeUnsignedPrincipalState(state);\n return TEXT_DECODER.decode(encodeUnsignedPrincipalState(normalizedState));\n}\n\nexport async function computePrincipalStateHash(\n state: UnsignedPrincipalState,\n): Promise<string> {\n const normalizedState = await normalizeUnsignedPrincipalState(state);\n return toFingerprint(encodeUnsignedPrincipalState(normalizedState));\n}\n\nexport async function signPrincipalState(\n state: PrincipalStateSigningInput,\n secretKey: Uint8Array,\n): Promise<SignedPrincipalState> {\n const normalizedState = await normalizeUnsignedPrincipalState(\n toUnsignedPrincipalState(state),\n );\n const signature = sign(\n encodeUnsignedPrincipalState(normalizedState),\n secretKey,\n );\n\n return {\n ...normalizedState,\n signature: bytesToBase64(signature),\n };\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export type ManagedRecipientPrincipalType = "group" | "organization";
|
|
2
2
|
export type PrincipalProjectionRole = "member" | "admin";
|
|
3
3
|
export type PrincipalStateMembershipMode = "projection";
|
|
4
|
-
export type PrincipalStatePayloadCipherSuite = "aes-256-gcm";
|
|
5
4
|
export type PrincipalContainerGrantAccessLevel = "admin" | "read" | "write";
|
|
6
5
|
/**
|
|
7
6
|
* Principals contain users only — never other groups.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"principalStateTypes.js","sourceRoot":"","sources":["principalStateTypes.ts"],"names":[],"mappings":"","sourcesContent":["export type ManagedRecipientPrincipalType = \"group\" | \"organization\";\nexport type PrincipalProjectionRole = \"member\" | \"admin\";\nexport type PrincipalStateMembershipMode = \"projection\";\nexport type
|
|
1
|
+
{"version":3,"file":"principalStateTypes.js","sourceRoot":"","sources":["principalStateTypes.ts"],"names":[],"mappings":"","sourcesContent":["export type ManagedRecipientPrincipalType = \"group\" | \"organization\";\nexport type PrincipalProjectionRole = \"member\" | \"admin\";\nexport type PrincipalStateMembershipMode = \"projection\";\nexport type PrincipalContainerGrantAccessLevel = \"admin\" | \"read\" | \"write\";\n\n/**\n * Principals contain users only — never other groups.\n *\n * Group nesting was removed deliberately. It was the sole source of unbounded\n * cost when a principal rotates: re-wrapping a containing group's member\n * envelope changes that group's `memberEnvelopesRoot`, which is inside its\n * SIGNED state, so the container needs a new state — and so does anything\n * containing it, with no depth limit. Removing one member from a deeply nested\n * group therefore had no bounded cost.\n *\n * The member type is gone rather than pinned to `\"user\"`: a field that can only\n * hold one value still has to be encoded, hashed, stored, and read everywhere,\n * and it invites the branch back. Membership is now a set of user ids, and\n * reachability is a lookup rather than a graph walk.\n */\nexport interface PrincipalStateMember {\n userId: string;\n}\n\nexport interface PrincipalProjectionMember {\n userId: string;\n role: PrincipalProjectionRole;\n /** Complete tearleads.identity-link.v1 identity, committed by projectionRoot. */\n identityBundleFingerprint: string;\n}\n\n/** Complete direct-container grant set committed by a managed principal. */\nexport interface PrincipalContainerGrant {\n containerId: string;\n accessLevel: PrincipalContainerGrantAccessLevel;\n}\n\nexport interface PrincipalStateMemberEnvelope {\n userId: string;\n memberKeyFingerprint: string;\n kemCipherText: string;\n wrappedKey: string;\n}\n\n/**\n * Exact signed head of the external principal policy that authorized a state.\n * Organization-scoped group policies use the reserved Admins group here.\n */\nexport interface PrincipalStateExternalAuthority {\n principalType: \"group\";\n principalId: string;\n version: number;\n keyEpoch: number;\n stateHash: string;\n keyFingerprint: string;\n}\n\nexport interface UnsignedPrincipalState {\n principalType: ManagedRecipientPrincipalType;\n principalId: string;\n version: number;\n prevStateHash: string | null;\n keyEpoch: number;\n encapsulationPublicKey: string;\n keyFingerprint: string;\n membershipMode: PrincipalStateMembershipMode;\n membershipRoot: string;\n memberEnvelopesRoot: string;\n projectionRoot: string;\n grantRoot: string;\n payloadCiphertextHash: string;\n memberCount: number;\n grantCount: number;\n externalAuthority: PrincipalStateExternalAuthority | null;\n signedAt: string;\n signerUserId: string;\n signerUserKeyFingerprint: string;\n}\n\nexport type PrincipalStateSigningInput = UnsignedPrincipalState;\n\nexport interface PrincipalStateHeaderInput {\n principalType: ManagedRecipientPrincipalType;\n principalId: string;\n version: number;\n prevStateHash: string | null;\n keyEpoch: number;\n encapsulationPublicKey: string;\n keyFingerprint: string;\n members: PrincipalStateMember[];\n memberEnvelopes: PrincipalStateMemberEnvelope[];\n projection: PrincipalProjectionMember[];\n grants: PrincipalContainerGrant[];\n payloadCiphertext: string;\n externalAuthority: PrincipalStateExternalAuthority | null;\n signedAt: string;\n signerUserId: string;\n signerUserKeyFingerprint: string;\n}\n\nexport interface SignedPrincipalState extends UnsignedPrincipalState {\n signature: string;\n}\n"]}
|
|
@@ -458,9 +458,7 @@ export declare const registerOperation: Omit<{
|
|
|
458
458
|
groupId: string;
|
|
459
459
|
initialGroupPolicy: {
|
|
460
460
|
encryptedPayload: {
|
|
461
|
-
cipherSuite: "aes-256-gcm";
|
|
462
461
|
ciphertext: string;
|
|
463
|
-
ciphertextHash: string;
|
|
464
462
|
};
|
|
465
463
|
grants: {
|
|
466
464
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -553,9 +551,7 @@ export declare const registerOperation: Omit<{
|
|
|
553
551
|
groupId: string;
|
|
554
552
|
initialGroupPolicy: {
|
|
555
553
|
encryptedPayload: {
|
|
556
|
-
cipherSuite: "aes-256-gcm";
|
|
557
554
|
ciphertext: string;
|
|
558
|
-
ciphertextHash: string;
|
|
559
555
|
};
|
|
560
556
|
grants: {
|
|
561
557
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -838,9 +834,7 @@ export declare const registerOperation: Omit<{
|
|
|
838
834
|
};
|
|
839
835
|
initialOrganizationPolicy: {
|
|
840
836
|
encryptedPayload: {
|
|
841
|
-
cipherSuite: "aes-256-gcm";
|
|
842
837
|
ciphertext: string;
|
|
843
|
-
ciphertextHash: string;
|
|
844
838
|
};
|
|
845
839
|
grants: {
|
|
846
840
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1807,9 +1801,7 @@ export declare const registerOperation: Omit<{
|
|
|
1807
1801
|
groupId: string;
|
|
1808
1802
|
initialGroupPolicy: {
|
|
1809
1803
|
encryptedPayload: {
|
|
1810
|
-
cipherSuite: "aes-256-gcm";
|
|
1811
1804
|
ciphertext: string;
|
|
1812
|
-
ciphertextHash: string;
|
|
1813
1805
|
};
|
|
1814
1806
|
grants: {
|
|
1815
1807
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1902,9 +1894,7 @@ export declare const registerOperation: Omit<{
|
|
|
1902
1894
|
groupId: string;
|
|
1903
1895
|
initialGroupPolicy: {
|
|
1904
1896
|
encryptedPayload: {
|
|
1905
|
-
cipherSuite: "aes-256-gcm";
|
|
1906
1897
|
ciphertext: string;
|
|
1907
|
-
ciphertextHash: string;
|
|
1908
1898
|
};
|
|
1909
1899
|
grants: {
|
|
1910
1900
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -2187,9 +2177,7 @@ export declare const registerOperation: Omit<{
|
|
|
2187
2177
|
};
|
|
2188
2178
|
initialOrganizationPolicy: {
|
|
2189
2179
|
encryptedPayload: {
|
|
2190
|
-
cipherSuite: "aes-256-gcm";
|
|
2191
2180
|
ciphertext: string;
|
|
2192
|
-
ciphertextHash: string;
|
|
2193
2181
|
};
|
|
2194
2182
|
grants: {
|
|
2195
2183
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -3156,9 +3144,7 @@ export declare const registerOperation: Omit<{
|
|
|
3156
3144
|
groupId: string;
|
|
3157
3145
|
initialGroupPolicy: {
|
|
3158
3146
|
encryptedPayload: {
|
|
3159
|
-
cipherSuite: "aes-256-gcm";
|
|
3160
3147
|
ciphertext: string;
|
|
3161
|
-
ciphertextHash: string;
|
|
3162
3148
|
};
|
|
3163
3149
|
grants: {
|
|
3164
3150
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -3251,9 +3237,7 @@ export declare const registerOperation: Omit<{
|
|
|
3251
3237
|
groupId: string;
|
|
3252
3238
|
initialGroupPolicy: {
|
|
3253
3239
|
encryptedPayload: {
|
|
3254
|
-
cipherSuite: "aes-256-gcm";
|
|
3255
3240
|
ciphertext: string;
|
|
3256
|
-
ciphertextHash: string;
|
|
3257
3241
|
};
|
|
3258
3242
|
grants: {
|
|
3259
3243
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -3536,9 +3520,7 @@ export declare const registerOperation: Omit<{
|
|
|
3536
3520
|
};
|
|
3537
3521
|
initialOrganizationPolicy: {
|
|
3538
3522
|
encryptedPayload: {
|
|
3539
|
-
cipherSuite: "aes-256-gcm";
|
|
3540
3523
|
ciphertext: string;
|
|
3541
|
-
ciphertextHash: string;
|
|
3542
3524
|
};
|
|
3543
3525
|
grants: {
|
|
3544
3526
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -4505,9 +4487,7 @@ export declare const registerOperation: Omit<{
|
|
|
4505
4487
|
groupId: string;
|
|
4506
4488
|
initialGroupPolicy: {
|
|
4507
4489
|
encryptedPayload: {
|
|
4508
|
-
cipherSuite: "aes-256-gcm";
|
|
4509
4490
|
ciphertext: string;
|
|
4510
|
-
ciphertextHash: string;
|
|
4511
4491
|
};
|
|
4512
4492
|
grants: {
|
|
4513
4493
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -4600,9 +4580,7 @@ export declare const registerOperation: Omit<{
|
|
|
4600
4580
|
groupId: string;
|
|
4601
4581
|
initialGroupPolicy: {
|
|
4602
4582
|
encryptedPayload: {
|
|
4603
|
-
cipherSuite: "aes-256-gcm";
|
|
4604
4583
|
ciphertext: string;
|
|
4605
|
-
ciphertextHash: string;
|
|
4606
4584
|
};
|
|
4607
4585
|
grants: {
|
|
4608
4586
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -4885,9 +4863,7 @@ export declare const registerOperation: Omit<{
|
|
|
4885
4863
|
};
|
|
4886
4864
|
initialOrganizationPolicy: {
|
|
4887
4865
|
encryptedPayload: {
|
|
4888
|
-
cipherSuite: "aes-256-gcm";
|
|
4889
4866
|
ciphertext: string;
|
|
4890
|
-
ciphertextHash: string;
|
|
4891
4867
|
};
|
|
4892
4868
|
grants: {
|
|
4893
4869
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { isContainerCreateWithMetadataDocumentRequest, isContainerMutationRequest, isContainerRotationRequest } from "../request/index.js";
|
|
3
|
-
import { ErrorResponseSchema, isContainerCreateWithMetadataDocumentResponse, isContainerDeleteResponse, isContainerMutationResponse, isContainerRotationResponse } from "../response/index.js";
|
|
3
|
+
import { ErrorResponseSchema, isContainerCreateWithMetadataDocumentResponse, isContainerDeleteResponse, isContainerMutationResponse, isContainerRotationResponse, isContainerShareResponse } from "../response/index.js";
|
|
4
4
|
export declare const ContainerMutationPathParamsSchema: z.ZodObject<{
|
|
5
5
|
containerId: z.ZodString;
|
|
6
6
|
}, z.core.$strict>;
|
|
@@ -2000,13 +2000,22 @@ export declare const shareContainerOperation: Omit<{
|
|
|
2000
2000
|
};
|
|
2001
2001
|
readonly failureStatuses: readonly [400, 401, 402, 403, 404, 409, 500];
|
|
2002
2002
|
readonly id: "containers.share";
|
|
2003
|
-
readonly summary:
|
|
2004
|
-
readonly description:
|
|
2003
|
+
readonly summary: "Share a container";
|
|
2004
|
+
readonly description: "Adds or changes a user or group grant on a container through a signed `container.grant` event, wrapping the current container KEK to the new recipients. Requires admin access through the container's path. Cited heads must be current: a stale container head returns 409 `container_mutation_state_stale`, and a stale principal policy returns 409 `principal_policy_stale` with the current heads. When `readModelCursor` names the read-model head the share's grants stamp advanced from, the response carries the read-model delta a feed read from that cursor returns.";
|
|
2005
2005
|
readonly method: "POST";
|
|
2006
2006
|
readonly params: z.ZodObject<{
|
|
2007
2007
|
containerId: z.ZodString;
|
|
2008
2008
|
}, z.core.$strict>;
|
|
2009
2009
|
readonly path: "/containers/{containerId}/share";
|
|
2010
|
+
readonly query: z.ZodType<{
|
|
2011
|
+
readModelCursor?: string | undefined;
|
|
2012
|
+
}, {
|
|
2013
|
+
readModelCursor?: string | undefined;
|
|
2014
|
+
}, z.core.$ZodTypeInternals<{
|
|
2015
|
+
readModelCursor?: string | undefined;
|
|
2016
|
+
}, {
|
|
2017
|
+
readModelCursor?: string | undefined;
|
|
2018
|
+
}>>;
|
|
2010
2019
|
readonly responses: {
|
|
2011
2020
|
readonly 200: z.ZodType<{
|
|
2012
2021
|
containerKek: {
|
|
@@ -2028,6 +2037,7 @@ export declare const shareContainerOperation: Omit<{
|
|
|
2028
2037
|
organizationId: string;
|
|
2029
2038
|
parentId: string | null;
|
|
2030
2039
|
updatedAt: string;
|
|
2040
|
+
readModel?: unknown;
|
|
2031
2041
|
systemSlot?: string | null | undefined;
|
|
2032
2042
|
}, {
|
|
2033
2043
|
containerKek: {
|
|
@@ -2049,6 +2059,7 @@ export declare const shareContainerOperation: Omit<{
|
|
|
2049
2059
|
organizationId: string;
|
|
2050
2060
|
parentId: string | null;
|
|
2051
2061
|
updatedAt: string;
|
|
2062
|
+
readModel?: unknown;
|
|
2052
2063
|
systemSlot?: string | null | undefined;
|
|
2053
2064
|
}, z.core.$ZodTypeInternals<{
|
|
2054
2065
|
containerKek: {
|
|
@@ -2070,6 +2081,7 @@ export declare const shareContainerOperation: Omit<{
|
|
|
2070
2081
|
organizationId: string;
|
|
2071
2082
|
parentId: string | null;
|
|
2072
2083
|
updatedAt: string;
|
|
2084
|
+
readModel?: unknown;
|
|
2073
2085
|
systemSlot?: string | null | undefined;
|
|
2074
2086
|
}, {
|
|
2075
2087
|
containerKek: {
|
|
@@ -2091,12 +2103,16 @@ export declare const shareContainerOperation: Omit<{
|
|
|
2091
2103
|
organizationId: string;
|
|
2092
2104
|
parentId: string | null;
|
|
2093
2105
|
updatedAt: string;
|
|
2106
|
+
readModel?: unknown;
|
|
2094
2107
|
systemSlot?: string | null | undefined;
|
|
2095
2108
|
}>>;
|
|
2096
2109
|
};
|
|
2097
2110
|
readonly runtimeRefinements: readonly [{
|
|
2098
2111
|
readonly description: "a container response keyring is null exactly for container key epoch 1";
|
|
2099
2112
|
readonly id: "response.organization-provisioning-container-keyring";
|
|
2113
|
+
}, {
|
|
2114
|
+
readonly description: "read-model lanes match the response organization; grants and memberships are unambiguous; snapshot lanes are complete and contain no deletions";
|
|
2115
|
+
readonly id: "response.organization-read-model-consistency";
|
|
2100
2116
|
}];
|
|
2101
2117
|
}, "failureResponses" | "failureStatuses"> & {
|
|
2102
2118
|
readonly failureResponses: {
|
|
@@ -5120,6 +5136,7 @@ export declare const deleteContainerOperation: Omit<{
|
|
|
5120
5136
|
};
|
|
5121
5137
|
export declare const isContainerMutationOperationRequest: typeof isContainerMutationRequest;
|
|
5122
5138
|
export declare const isContainerMutationOperationResponse: typeof isContainerMutationResponse;
|
|
5139
|
+
export declare const isShareContainerOperationResponse: typeof isContainerShareResponse;
|
|
5123
5140
|
export declare const isContainerRotationOperationRequest: typeof isContainerRotationRequest;
|
|
5124
5141
|
export declare const isContainerRotationOperationResponse: typeof isContainerRotationResponse;
|
|
5125
5142
|
export declare const isCreateContainerWithMetadataDocumentOperationRequest: typeof isContainerCreateWithMetadataDocumentRequest;
|
|
@@ -2,8 +2,9 @@ import { z } from "zod";
|
|
|
2
2
|
import { containerCreateMetadataSeedRefinement } from "../documentCreateSeedRefinements.js";
|
|
3
3
|
import { documentSyncRequestRuntimeRefinements } from "../documentSyncRefinements.js";
|
|
4
4
|
import { organizationProvisioningContainerKeyringRefinement } from "../organizationProvisioningRefinements.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { organizationReadModelResponseRuntimeRefinements } from "../organizationReadModelRefinements.js";
|
|
6
|
+
import { ContainerCreateWithMetadataDocumentRequestSchema, ContainerMutationRequestSchema, ContainerReciteRequestSchema, ContainerRotationRequestSchema, isContainerCreateWithMetadataDocumentRequest, isContainerMutationRequest, isContainerRotationRequest, OrganizationReadModelHeldCursorQuerySchema, } from "../request/index.js";
|
|
7
|
+
import { ContainerCreateWithMetadataDocumentResponseSchema, ContainerDeleteResponseSchema, ContainerMutationFailureResponseSchema, ContainerMutationResponseSchema, ContainerNotFoundErrorResponseSchema, ContainerReciteResponseSchema, ContainerRotationResponseSchema, ContainerShareResponseSchema, ErrorResponseSchema, isContainerCreateWithMetadataDocumentResponse, isContainerDeleteResponse, isContainerMutationResponse, isContainerRotationResponse, isContainerShareResponse, PaymentRequiredErrorResponseSchema, SessionFailureResponseSchema, } from "../response/index.js";
|
|
7
8
|
import { defineJsonOperation } from "./definition.js";
|
|
8
9
|
const EmptyContainerMutationPathParamsSchema = z.strictObject({});
|
|
9
10
|
export const ContainerMutationPathParamsSchema = z.strictObject({
|
|
@@ -59,22 +60,6 @@ export const createContainerWithMetadataDocumentOperation = defineJsonOperation(
|
|
|
59
60
|
...documentSyncRequestRuntimeRefinements,
|
|
60
61
|
],
|
|
61
62
|
});
|
|
62
|
-
function defineContainerMutationOperation(input) {
|
|
63
|
-
return defineJsonOperation({
|
|
64
|
-
auth: "session",
|
|
65
|
-
body: ContainerMutationRequestSchema,
|
|
66
|
-
failureResponses: containerMutationFailureResponses,
|
|
67
|
-
failureStatuses: containerMutationFailureStatuses,
|
|
68
|
-
id: input.id,
|
|
69
|
-
summary: input.summary,
|
|
70
|
-
description: input.description,
|
|
71
|
-
method: "POST",
|
|
72
|
-
params: ContainerMutationPathParamsSchema,
|
|
73
|
-
path: input.path,
|
|
74
|
-
responses: { 200: ContainerMutationResponseSchema },
|
|
75
|
-
runtimeRefinements: containerMutationRuntimeRefinements,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
63
|
/**
|
|
79
64
|
* Rekey, revoke, and move mint a new key epoch, so they alone may carry the
|
|
80
65
|
* descendant rekeys that must commit with them.
|
|
@@ -95,11 +80,23 @@ function defineContainerRotationOperation(input) {
|
|
|
95
80
|
runtimeRefinements: containerMutationRuntimeRefinements,
|
|
96
81
|
});
|
|
97
82
|
}
|
|
98
|
-
export const shareContainerOperation =
|
|
83
|
+
export const shareContainerOperation = defineJsonOperation({
|
|
84
|
+
auth: "session",
|
|
85
|
+
body: ContainerMutationRequestSchema,
|
|
86
|
+
failureResponses: containerMutationFailureResponses,
|
|
87
|
+
failureStatuses: containerMutationFailureStatuses,
|
|
99
88
|
id: "containers.share",
|
|
100
89
|
summary: "Share a container",
|
|
101
|
-
description: "Adds or changes a user or group grant on a container through a signed `container.grant` event, wrapping the current container KEK to the new recipients. Requires admin access through the container's path. Cited heads must be current: a stale container head returns 409 `container_mutation_state_stale`, and a stale principal policy returns 409 `principal_policy_stale` with the current heads.",
|
|
90
|
+
description: "Adds or changes a user or group grant on a container through a signed `container.grant` event, wrapping the current container KEK to the new recipients. Requires admin access through the container's path. Cited heads must be current: a stale container head returns 409 `container_mutation_state_stale`, and a stale principal policy returns 409 `principal_policy_stale` with the current heads. When `readModelCursor` names the read-model head the share's grants stamp advanced from, the response carries the read-model delta a feed read from that cursor returns.",
|
|
91
|
+
method: "POST",
|
|
92
|
+
params: ContainerMutationPathParamsSchema,
|
|
102
93
|
path: "/containers/{containerId}/share",
|
|
94
|
+
query: OrganizationReadModelHeldCursorQuerySchema,
|
|
95
|
+
responses: { 200: ContainerShareResponseSchema },
|
|
96
|
+
runtimeRefinements: [
|
|
97
|
+
...containerMutationRuntimeRefinements,
|
|
98
|
+
...organizationReadModelResponseRuntimeRefinements,
|
|
99
|
+
],
|
|
103
100
|
});
|
|
104
101
|
export const reciteContainerOperation = defineJsonOperation({
|
|
105
102
|
auth: "session",
|
|
@@ -150,6 +147,7 @@ export const deleteContainerOperation = defineJsonOperation({
|
|
|
150
147
|
});
|
|
151
148
|
export const isContainerMutationOperationRequest = isContainerMutationRequest;
|
|
152
149
|
export const isContainerMutationOperationResponse = isContainerMutationResponse;
|
|
150
|
+
export const isShareContainerOperationResponse = isContainerShareResponse;
|
|
153
151
|
export const isContainerRotationOperationRequest = isContainerRotationRequest;
|
|
154
152
|
export const isContainerRotationOperationResponse = isContainerRotationResponse;
|
|
155
153
|
export const isCreateContainerWithMetadataDocumentOperationRequest = isContainerCreateWithMetadataDocumentRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerMutations.js","sourceRoot":"","sources":["containerMutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qCAAqC,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,qCAAqC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AC/C,MAAM,CAAC,MAAM,sDAAsD,GACjE,6CAA6C,CAAC;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,yBAAyB,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { containerCreateMetadataSeedRefinement } from \"../documentCreateSeedRefinements\";\nimport { documentSyncRequestRuntimeRefinements } from \"../documentSyncRefinements\";\nimport { organizationProvisioningContainerKeyringRefinement } from \"../organizationProvisioningRefinements\";\nimport {\n ContainerCreateWithMetadataDocumentRequestSchema,\n ContainerMutationRequestSchema,\n ContainerReciteRequestSchema,\n ContainerRotationRequestSchema,\n isContainerCreateWithMetadataDocumentRequest,\n isContainerMutationRequest,\n isContainerRotationRequest,\n} from \"../request\";\nimport {\n ContainerCreateWithMetadataDocumentResponseSchema,\n ContainerDeleteResponseSchema,\n ContainerMutationFailureResponseSchema,\n ContainerMutationResponseSchema,\n ContainerNotFoundErrorResponseSchema,\n ContainerReciteResponseSchema,\n ContainerRotationResponseSchema,\n ErrorResponseSchema,\n isContainerCreateWithMetadataDocumentResponse,\n isContainerDeleteResponse,\n isContainerMutationResponse,\n isContainerRotationResponse,\n PaymentRequiredErrorResponseSchema,\n SessionFailureResponseSchema,\n} from \"../response\";\nimport { defineJsonOperation } from \"./definition\";\n\nconst EmptyContainerMutationPathParamsSchema = z.strictObject({});\n\nexport const ContainerMutationPathParamsSchema = z.strictObject({\n containerId: z.string(),\n});\n\nexport type ContainerMutationPathParams = z.infer<\n typeof ContainerMutationPathParamsSchema\n>;\n\nconst containerMutationFailureResponses = {\n 400: ErrorResponseSchema,\n 401: SessionFailureResponseSchema,\n 402: PaymentRequiredErrorResponseSchema,\n 403: ErrorResponseSchema,\n 404: ErrorResponseSchema,\n 409: ContainerMutationFailureResponseSchema,\n 500: ErrorResponseSchema,\n} as const;\n\nconst containerMutationFailureStatuses = [\n 400, 401, 402, 403, 404, 409, 500,\n] as const;\n\nconst containerMutationRuntimeRefinements = [\n organizationProvisioningContainerKeyringRefinement,\n] as const;\n\nexport const createContainerOperation = defineJsonOperation({\n auth: \"session\",\n body: ContainerMutationRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: \"containers.create\",\n summary: \"Create a container\",\n description:\n \"Creates a container from a signed `container.create` event, the hash of the access manifest it derives, and the container KEK wrapped to its recipients. Requires write access to the parent container, or admin access for a system container. A retry of a create that already committed returns 409 `container_manifest_already_exists`, which lets the client adopt it; a stale parent returns 409 `container_mutation_state_stale`.\",\n method: \"POST\",\n params: EmptyContainerMutationPathParamsSchema,\n path: \"/containers\",\n responses: { 200: ContainerMutationResponseSchema },\n runtimeRefinements: containerMutationRuntimeRefinements,\n});\n\nexport const createContainerWithMetadataDocumentOperation = defineJsonOperation(\n {\n auth: \"session\",\n body: ContainerCreateWithMetadataDocumentRequestSchema,\n failureResponses: {\n ...containerMutationFailureResponses,\n 503: ErrorResponseSchema,\n },\n failureStatuses: [...containerMutationFailureStatuses, 503],\n id: \"containers.withMetadataDocument.create\",\n summary: \"Create a container with its metadata document\",\n description:\n \"Creates a container and its encrypted metadata document in one transaction, optionally seeding the document's first update. Authorization and conflicts are those of `POST /containers` and `POST /documents`; a 409 `document_manifest_already_exists` may have rolled the new container back, so clients treat it as terminal unless they verify both artifacts.\",\n method: \"POST\",\n params: EmptyContainerMutationPathParamsSchema,\n path: \"/containers/with-metadata-document\",\n responses: { 200: ContainerCreateWithMetadataDocumentResponseSchema },\n runtimeRefinements: [\n ...containerMutationRuntimeRefinements,\n containerCreateMetadataSeedRefinement,\n ...documentSyncRequestRuntimeRefinements,\n ],\n },\n);\n\nfunction defineContainerMutationOperation<\n const Id extends string,\n const Path extends `/${string}`,\n>(input: {\n readonly id: Id;\n readonly path: Path;\n readonly summary: string;\n readonly description: string;\n}) {\n return defineJsonOperation({\n auth: \"session\",\n body: ContainerMutationRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: input.id,\n summary: input.summary,\n description: input.description,\n method: \"POST\",\n params: ContainerMutationPathParamsSchema,\n path: input.path,\n responses: { 200: ContainerMutationResponseSchema },\n runtimeRefinements: containerMutationRuntimeRefinements,\n });\n}\n\n/**\n * Rekey, revoke, and move mint a new key epoch, so they alone may carry the\n * descendant rekeys that must commit with them.\n */\nfunction defineContainerRotationOperation<\n const Id extends string,\n const Path extends `/${string}`,\n>(input: {\n readonly id: Id;\n readonly path: Path;\n readonly summary: string;\n readonly description: string;\n}) {\n return defineJsonOperation({\n auth: \"session\",\n body: ContainerRotationRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: input.id,\n summary: input.summary,\n description: input.description,\n method: \"POST\",\n params: ContainerMutationPathParamsSchema,\n path: input.path,\n responses: { 200: ContainerRotationResponseSchema },\n runtimeRefinements: containerMutationRuntimeRefinements,\n });\n}\n\nexport const shareContainerOperation = defineContainerMutationOperation({\n id: \"containers.share\",\n summary: \"Share a container\",\n description:\n \"Adds or changes a user or group grant on a container through a signed `container.grant` event, wrapping the current container KEK to the new recipients. Requires admin access through the container's path. Cited heads must be current: a stale container head returns 409 `container_mutation_state_stale`, and a stale principal policy returns 409 `principal_policy_stale` with the current heads.\",\n path: \"/containers/{containerId}/share\",\n});\n\nexport const reciteContainerOperation = defineJsonOperation({\n auth: \"session\",\n body: ContainerReciteRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: \"containers.recite\",\n summary: \"Re-cite a held container's current ancestor path\",\n description:\n \"Advances a container's access manifest so it cites its ancestors' current heads, without changing grants, keys, or parent. Clients call it after changing an ancestor so descendants they already hold stop citing superseded heads. Requires admin access; after 512 epochs the container no longer accepts re-citations.\",\n method: \"POST\",\n params: ContainerMutationPathParamsSchema,\n path: \"/containers/{containerId}/recite\",\n responses: { 200: ContainerReciteResponseSchema },\n});\n\nexport const revokeContainerOperation = defineContainerRotationOperation({\n id: \"containers.revoke\",\n summary: \"Revoke a container grant\",\n description:\n \"Removes a grant from a container through a signed `container.revoke` event and rotates the container KEK so the removed principal cannot read later content. The request carries the new KEK epoch, its predecessor bridge, and the re-sealed container KEK keyring. Requires admin access; stale cited heads return 409.\",\n path: \"/containers/{containerId}/revoke\",\n});\n\nexport const rekeyContainerOperation = defineContainerRotationOperation({\n id: \"containers.rekey\",\n summary: \"Rekey a container\",\n description:\n \"Rotates a container's KEK to a new epoch without changing grants, carrying the predecessor bridge and the re-sealed container KEK keyring. Requires write access. Stale cited heads return 409, and epochs above 65536 are refused.\",\n path: \"/containers/{containerId}/rekey\",\n});\n\nexport const moveContainerOperation = defineContainerRotationOperation({\n id: \"containers.move\",\n summary: \"Move a container\",\n description:\n \"Moves a container under a new parent through a signed `container.move` event and rotates its container KEK. Requires admin access at the source and write access at the destination; root and system containers cannot move. Moving into Trash is an ordinary move and can be undone.\",\n path: \"/containers/{containerId}/move\",\n});\n\nexport const deleteContainerOperation = defineJsonOperation({\n auth: \"session\",\n failureResponses: {\n ...containerMutationFailureResponses,\n 404: ContainerNotFoundErrorResponseSchema,\n },\n failureStatuses: containerMutationFailureStatuses,\n id: \"containers.delete\",\n summary: \"Delete a container\",\n description:\n \"Deletes an empty folder: a container with no child containers and no linked user documents, along with its own metadata document. Requires admin access; root and system containers cannot be deleted. Peers learn of the deletion from a sync tombstone, and an unknown container returns 404 `container_not_found`.\",\n method: \"DELETE\",\n params: ContainerMutationPathParamsSchema,\n path: \"/containers/{containerId}\",\n query: z.strictObject({ requiredAncestorId: z.string().min(1).optional() }),\n responses: { 200: ContainerDeleteResponseSchema },\n});\n\nexport const isContainerMutationOperationRequest = isContainerMutationRequest;\nexport const isContainerMutationOperationResponse = isContainerMutationResponse;\nexport const isContainerRotationOperationRequest = isContainerRotationRequest;\nexport const isContainerRotationOperationResponse = isContainerRotationResponse;\nexport const isCreateContainerWithMetadataDocumentOperationRequest =\n isContainerCreateWithMetadataDocumentRequest;\nexport const isCreateContainerWithMetadataDocumentOperationResponse =\n isContainerCreateWithMetadataDocumentResponse;\nexport const isDeleteContainerOperationResponse = isContainerDeleteResponse;\n"]}
|
|
1
|
+
{"version":3,"file":"containerMutations.js","sourceRoot":"","sources":["containerMutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qCAAqC,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,kDAAkD,EAAE,MAAM,wCAAwC,CAAC;AAC5G,OAAO,EAAE,+CAA+C,EAAE,MAAM,qCAAqC,CAAC;AACtG,OAAO,EACL,gDAAgD,EAChD,8BAA8B,EAC9B,4BAA4B,EAC5B,8BAA8B,EAC9B,4CAA4C,EAC5C,0BAA0B,EAC1B,0BAA0B,EAC1B,0CAA0C,GAC3C,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iDAAiD,EACjD,6BAA6B,EAC7B,sCAAsC,EACtC,+BAA+B,EAC/B,oCAAoC,EACpC,6BAA6B,EAC7B,+BAA+B,EAC/B,4BAA4B,EAC5B,mBAAmB,EACnB,6CAA6C,EAC7C,yBAAyB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,kCAAkC,EAClC,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,sCAAsC,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,YAAY,CAAC;IAC9D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAMH,MAAM,iCAAiC,GAAG;IACxC,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,4BAA4B;IACjC,GAAG,EAAE,kCAAkC;IACvC,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,mBAAmB;IACxB,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,GAAG,2BAA2B,CAAC;AAChF,MAAM,CAAC,MAAM,iCAAiC,GAAG,wBAAwB,CAAC;AAC1E,MAAM,CAAC,MAAM,mCAAmC,GAAG,0BAA0B,CAAC;AAC9E,MAAM,CAAC,MAAM,oCAAoC,GAAG,2BAA2B,CAAC;AAChF,MAAM,CAAC,MAAM,qDAAqD,GAChE,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,sDAAsD,GACjE,6CAA6C,CAAC;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,yBAAyB,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { containerCreateMetadataSeedRefinement } from \"../documentCreateSeedRefinements\";\nimport { documentSyncRequestRuntimeRefinements } from \"../documentSyncRefinements\";\nimport { organizationProvisioningContainerKeyringRefinement } from \"../organizationProvisioningRefinements\";\nimport { organizationReadModelResponseRuntimeRefinements } from \"../organizationReadModelRefinements\";\nimport {\n ContainerCreateWithMetadataDocumentRequestSchema,\n ContainerMutationRequestSchema,\n ContainerReciteRequestSchema,\n ContainerRotationRequestSchema,\n isContainerCreateWithMetadataDocumentRequest,\n isContainerMutationRequest,\n isContainerRotationRequest,\n OrganizationReadModelHeldCursorQuerySchema,\n} from \"../request\";\nimport {\n ContainerCreateWithMetadataDocumentResponseSchema,\n ContainerDeleteResponseSchema,\n ContainerMutationFailureResponseSchema,\n ContainerMutationResponseSchema,\n ContainerNotFoundErrorResponseSchema,\n ContainerReciteResponseSchema,\n ContainerRotationResponseSchema,\n ContainerShareResponseSchema,\n ErrorResponseSchema,\n isContainerCreateWithMetadataDocumentResponse,\n isContainerDeleteResponse,\n isContainerMutationResponse,\n isContainerRotationResponse,\n isContainerShareResponse,\n PaymentRequiredErrorResponseSchema,\n SessionFailureResponseSchema,\n} from \"../response\";\nimport { defineJsonOperation } from \"./definition\";\n\nconst EmptyContainerMutationPathParamsSchema = z.strictObject({});\n\nexport const ContainerMutationPathParamsSchema = z.strictObject({\n containerId: z.string(),\n});\n\nexport type ContainerMutationPathParams = z.infer<\n typeof ContainerMutationPathParamsSchema\n>;\n\nconst containerMutationFailureResponses = {\n 400: ErrorResponseSchema,\n 401: SessionFailureResponseSchema,\n 402: PaymentRequiredErrorResponseSchema,\n 403: ErrorResponseSchema,\n 404: ErrorResponseSchema,\n 409: ContainerMutationFailureResponseSchema,\n 500: ErrorResponseSchema,\n} as const;\n\nconst containerMutationFailureStatuses = [\n 400, 401, 402, 403, 404, 409, 500,\n] as const;\n\nconst containerMutationRuntimeRefinements = [\n organizationProvisioningContainerKeyringRefinement,\n] as const;\n\nexport const createContainerOperation = defineJsonOperation({\n auth: \"session\",\n body: ContainerMutationRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: \"containers.create\",\n summary: \"Create a container\",\n description:\n \"Creates a container from a signed `container.create` event, the hash of the access manifest it derives, and the container KEK wrapped to its recipients. Requires write access to the parent container, or admin access for a system container. A retry of a create that already committed returns 409 `container_manifest_already_exists`, which lets the client adopt it; a stale parent returns 409 `container_mutation_state_stale`.\",\n method: \"POST\",\n params: EmptyContainerMutationPathParamsSchema,\n path: \"/containers\",\n responses: { 200: ContainerMutationResponseSchema },\n runtimeRefinements: containerMutationRuntimeRefinements,\n});\n\nexport const createContainerWithMetadataDocumentOperation = defineJsonOperation(\n {\n auth: \"session\",\n body: ContainerCreateWithMetadataDocumentRequestSchema,\n failureResponses: {\n ...containerMutationFailureResponses,\n 503: ErrorResponseSchema,\n },\n failureStatuses: [...containerMutationFailureStatuses, 503],\n id: \"containers.withMetadataDocument.create\",\n summary: \"Create a container with its metadata document\",\n description:\n \"Creates a container and its encrypted metadata document in one transaction, optionally seeding the document's first update. Authorization and conflicts are those of `POST /containers` and `POST /documents`; a 409 `document_manifest_already_exists` may have rolled the new container back, so clients treat it as terminal unless they verify both artifacts.\",\n method: \"POST\",\n params: EmptyContainerMutationPathParamsSchema,\n path: \"/containers/with-metadata-document\",\n responses: { 200: ContainerCreateWithMetadataDocumentResponseSchema },\n runtimeRefinements: [\n ...containerMutationRuntimeRefinements,\n containerCreateMetadataSeedRefinement,\n ...documentSyncRequestRuntimeRefinements,\n ],\n },\n);\n\n/**\n * Rekey, revoke, and move mint a new key epoch, so they alone may carry the\n * descendant rekeys that must commit with them.\n */\nfunction defineContainerRotationOperation<\n const Id extends string,\n const Path extends `/${string}`,\n>(input: {\n readonly id: Id;\n readonly path: Path;\n readonly summary: string;\n readonly description: string;\n}) {\n return defineJsonOperation({\n auth: \"session\",\n body: ContainerRotationRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: input.id,\n summary: input.summary,\n description: input.description,\n method: \"POST\",\n params: ContainerMutationPathParamsSchema,\n path: input.path,\n responses: { 200: ContainerRotationResponseSchema },\n runtimeRefinements: containerMutationRuntimeRefinements,\n });\n}\n\nexport const shareContainerOperation = defineJsonOperation({\n auth: \"session\",\n body: ContainerMutationRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: \"containers.share\",\n summary: \"Share a container\",\n description:\n \"Adds or changes a user or group grant on a container through a signed `container.grant` event, wrapping the current container KEK to the new recipients. Requires admin access through the container's path. Cited heads must be current: a stale container head returns 409 `container_mutation_state_stale`, and a stale principal policy returns 409 `principal_policy_stale` with the current heads. When `readModelCursor` names the read-model head the share's grants stamp advanced from, the response carries the read-model delta a feed read from that cursor returns.\",\n method: \"POST\",\n params: ContainerMutationPathParamsSchema,\n path: \"/containers/{containerId}/share\",\n query: OrganizationReadModelHeldCursorQuerySchema,\n responses: { 200: ContainerShareResponseSchema },\n runtimeRefinements: [\n ...containerMutationRuntimeRefinements,\n ...organizationReadModelResponseRuntimeRefinements,\n ],\n});\n\nexport const reciteContainerOperation = defineJsonOperation({\n auth: \"session\",\n body: ContainerReciteRequestSchema,\n failureResponses: containerMutationFailureResponses,\n failureStatuses: containerMutationFailureStatuses,\n id: \"containers.recite\",\n summary: \"Re-cite a held container's current ancestor path\",\n description:\n \"Advances a container's access manifest so it cites its ancestors' current heads, without changing grants, keys, or parent. Clients call it after changing an ancestor so descendants they already hold stop citing superseded heads. Requires admin access; after 512 epochs the container no longer accepts re-citations.\",\n method: \"POST\",\n params: ContainerMutationPathParamsSchema,\n path: \"/containers/{containerId}/recite\",\n responses: { 200: ContainerReciteResponseSchema },\n});\n\nexport const revokeContainerOperation = defineContainerRotationOperation({\n id: \"containers.revoke\",\n summary: \"Revoke a container grant\",\n description:\n \"Removes a grant from a container through a signed `container.revoke` event and rotates the container KEK so the removed principal cannot read later content. The request carries the new KEK epoch, its predecessor bridge, and the re-sealed container KEK keyring. Requires admin access; stale cited heads return 409.\",\n path: \"/containers/{containerId}/revoke\",\n});\n\nexport const rekeyContainerOperation = defineContainerRotationOperation({\n id: \"containers.rekey\",\n summary: \"Rekey a container\",\n description:\n \"Rotates a container's KEK to a new epoch without changing grants, carrying the predecessor bridge and the re-sealed container KEK keyring. Requires write access. Stale cited heads return 409, and epochs above 65536 are refused.\",\n path: \"/containers/{containerId}/rekey\",\n});\n\nexport const moveContainerOperation = defineContainerRotationOperation({\n id: \"containers.move\",\n summary: \"Move a container\",\n description:\n \"Moves a container under a new parent through a signed `container.move` event and rotates its container KEK. Requires admin access at the source and write access at the destination; root and system containers cannot move. Moving into Trash is an ordinary move and can be undone.\",\n path: \"/containers/{containerId}/move\",\n});\n\nexport const deleteContainerOperation = defineJsonOperation({\n auth: \"session\",\n failureResponses: {\n ...containerMutationFailureResponses,\n 404: ContainerNotFoundErrorResponseSchema,\n },\n failureStatuses: containerMutationFailureStatuses,\n id: \"containers.delete\",\n summary: \"Delete a container\",\n description:\n \"Deletes an empty folder: a container with no child containers and no linked user documents, along with its own metadata document. Requires admin access; root and system containers cannot be deleted. Peers learn of the deletion from a sync tombstone, and an unknown container returns 404 `container_not_found`.\",\n method: \"DELETE\",\n params: ContainerMutationPathParamsSchema,\n path: \"/containers/{containerId}\",\n query: z.strictObject({ requiredAncestorId: z.string().min(1).optional() }),\n responses: { 200: ContainerDeleteResponseSchema },\n});\n\nexport const isContainerMutationOperationRequest = isContainerMutationRequest;\nexport const isContainerMutationOperationResponse = isContainerMutationResponse;\nexport const isShareContainerOperationResponse = isContainerShareResponse;\nexport const isContainerRotationOperationRequest = isContainerRotationRequest;\nexport const isContainerRotationOperationResponse = isContainerRotationResponse;\nexport const isCreateContainerWithMetadataDocumentOperationRequest =\n isContainerCreateWithMetadataDocumentRequest;\nexport const isCreateContainerWithMetadataDocumentOperationResponse =\n isContainerCreateWithMetadataDocumentResponse;\nexport const isDeleteContainerOperationResponse = isContainerDeleteResponse;\n"]}
|
|
@@ -2086,13 +2086,7 @@ export declare const purgeDocumentOperation: Omit<{
|
|
|
2086
2086
|
version: number;
|
|
2087
2087
|
};
|
|
2088
2088
|
payload: {
|
|
2089
|
-
cipherSuite: "aes-256-gcm";
|
|
2090
2089
|
ciphertext: string;
|
|
2091
|
-
ciphertextHash: string;
|
|
2092
|
-
createdAt: string;
|
|
2093
|
-
principalId: string;
|
|
2094
|
-
principalType: "group" | "organization";
|
|
2095
|
-
stateHash: string;
|
|
2096
2090
|
};
|
|
2097
2091
|
}[];
|
|
2098
2092
|
groups: {
|
|
@@ -2188,13 +2182,7 @@ export declare const purgeDocumentOperation: Omit<{
|
|
|
2188
2182
|
version: number;
|
|
2189
2183
|
};
|
|
2190
2184
|
payload: {
|
|
2191
|
-
cipherSuite: "aes-256-gcm";
|
|
2192
2185
|
ciphertext: string;
|
|
2193
|
-
ciphertextHash: string;
|
|
2194
|
-
createdAt: string;
|
|
2195
|
-
principalId: string;
|
|
2196
|
-
principalType: "group" | "organization";
|
|
2197
|
-
stateHash: string;
|
|
2198
2186
|
};
|
|
2199
2187
|
}[];
|
|
2200
2188
|
groups: {
|
|
@@ -2290,13 +2278,7 @@ export declare const purgeDocumentOperation: Omit<{
|
|
|
2290
2278
|
version: number;
|
|
2291
2279
|
};
|
|
2292
2280
|
payload: {
|
|
2293
|
-
cipherSuite: "aes-256-gcm";
|
|
2294
2281
|
ciphertext: string;
|
|
2295
|
-
ciphertextHash: string;
|
|
2296
|
-
createdAt: string;
|
|
2297
|
-
principalId: string;
|
|
2298
|
-
principalType: "group" | "organization";
|
|
2299
|
-
stateHash: string;
|
|
2300
2282
|
};
|
|
2301
2283
|
}[];
|
|
2302
2284
|
groups: {
|
|
@@ -2392,13 +2374,7 @@ export declare const purgeDocumentOperation: Omit<{
|
|
|
2392
2374
|
version: number;
|
|
2393
2375
|
};
|
|
2394
2376
|
payload: {
|
|
2395
|
-
cipherSuite: "aes-256-gcm";
|
|
2396
2377
|
ciphertext: string;
|
|
2397
|
-
ciphertextHash: string;
|
|
2398
|
-
createdAt: string;
|
|
2399
|
-
principalId: string;
|
|
2400
|
-
principalType: "group" | "organization";
|
|
2401
|
-
stateHash: string;
|
|
2402
2378
|
};
|
|
2403
2379
|
}[];
|
|
2404
2380
|
groups: {
|
|
@@ -2695,13 +2671,7 @@ export declare const getDocumentPurgeProofOperation: Omit<{
|
|
|
2695
2671
|
version: number;
|
|
2696
2672
|
};
|
|
2697
2673
|
payload: {
|
|
2698
|
-
cipherSuite: "aes-256-gcm";
|
|
2699
2674
|
ciphertext: string;
|
|
2700
|
-
ciphertextHash: string;
|
|
2701
|
-
createdAt: string;
|
|
2702
|
-
principalId: string;
|
|
2703
|
-
principalType: "group" | "organization";
|
|
2704
|
-
stateHash: string;
|
|
2705
2675
|
};
|
|
2706
2676
|
}[];
|
|
2707
2677
|
groups: {
|
|
@@ -2796,13 +2766,7 @@ export declare const getDocumentPurgeProofOperation: Omit<{
|
|
|
2796
2766
|
version: number;
|
|
2797
2767
|
};
|
|
2798
2768
|
payload: {
|
|
2799
|
-
cipherSuite: "aes-256-gcm";
|
|
2800
2769
|
ciphertext: string;
|
|
2801
|
-
ciphertextHash: string;
|
|
2802
|
-
createdAt: string;
|
|
2803
|
-
principalId: string;
|
|
2804
|
-
principalType: "group" | "organization";
|
|
2805
|
-
stateHash: string;
|
|
2806
2770
|
};
|
|
2807
2771
|
}[];
|
|
2808
2772
|
groups: {
|
|
@@ -2897,13 +2861,7 @@ export declare const getDocumentPurgeProofOperation: Omit<{
|
|
|
2897
2861
|
version: number;
|
|
2898
2862
|
};
|
|
2899
2863
|
payload: {
|
|
2900
|
-
cipherSuite: "aes-256-gcm";
|
|
2901
2864
|
ciphertext: string;
|
|
2902
|
-
ciphertextHash: string;
|
|
2903
|
-
createdAt: string;
|
|
2904
|
-
principalId: string;
|
|
2905
|
-
principalType: "group" | "organization";
|
|
2906
|
-
stateHash: string;
|
|
2907
2865
|
};
|
|
2908
2866
|
}[];
|
|
2909
2867
|
groups: {
|
|
@@ -2998,13 +2956,7 @@ export declare const getDocumentPurgeProofOperation: Omit<{
|
|
|
2998
2956
|
version: number;
|
|
2999
2957
|
};
|
|
3000
2958
|
payload: {
|
|
3001
|
-
cipherSuite: "aes-256-gcm";
|
|
3002
2959
|
ciphertext: string;
|
|
3003
|
-
ciphertextHash: string;
|
|
3004
|
-
createdAt: string;
|
|
3005
|
-
principalId: string;
|
|
3006
|
-
principalType: "group" | "organization";
|
|
3007
|
-
stateHash: string;
|
|
3008
2960
|
};
|
|
3009
2961
|
}[];
|
|
3010
2962
|
groups: {
|