@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"principalPolicyRequest.js","sourceRoot":"","sources":["principalPolicyRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAE/B,0BAA0B,EAC1B,oBAAoB,EAEpB,yBAAyB,EACzB,iCAAiC,EACjC,mCAAmC,EAGnC,iBAAiB,EAEjB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAmBrG,SAAS,wBAAwB,CAC/B,UAA2D;IAE3D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,8BAA8B,CAAC,IAAY;IAClD,OAAO,uDAAuD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,CACL,IAAI;SACD,SAAS,CAAC,MAAM,CAAC;SACjB,OAAO,CAAC,kDAAkD,EAAE,EAAE,CAAC;SAC/D,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,IAAI,EAAE;SACN,iBAAiB,CAAC,OAAO,CAAC;QAC3B,wEAAwE;QACxE,8DAA8D;SAC7D,SAAS,CAAC,MAAM,CAAC,CACrB,CAAC;AACJ,CAAC;AAWD,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,MAA4B,EAC5B,iBAAyC;IAEzC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,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L,CAAC;YACJ,CAAC,CAAC,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACtE,CAAC,CAAC,EAAE,CAAC;IACX,MAAM,aAAa,GAAG,MAAM,wBAAwB,CAAC;QACnD,sBAAsB,EAAE,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;QACzD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAAI,IAAI;QAClD,QAAQ,EAAE,CAAC;QACX,cAAc,EAAE,MAAM,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;QACvD,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE;QAC1B,eAAe;QACf,iBAAiB;QACjB,WAAW,EAAE,KAAK,CAAC,OAAO;QAC1B,UAAU;QACV,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAClC,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,kBAAkB,EAAE,aAAa;KAClC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oCAAoC,CAAC,KAQ1D;IACC,OAAO,8BAA8B,CAAC;QACpC,GAAG,KAAK;QACR,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,SAAS;KACvB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n buildPrincipalStateSigningInput,\n type EncapsulationKeyPair,\n encodeBuiltinGroupMetadata,\n encryptGroupMetadata,\n type GroupMetadataKey,\n generateKemSeedAndKeyPair,\n normalizePrincipalContainerGrants,\n normalizePrincipalProjectionMembers,\n type PrincipalContainerGrant,\n type PrincipalPolicyExternalAuthority,\n readGroupMetadata,\n type SigningKeyPair,\n signPrincipalState,\n toFingerprint,\n wrapDekForRecipients,\n} from \"@tearleads/crypto\";\nimport { bytesToBase64 } from \"@tearleads/encoding\";\nimport type {\n CreateOrganizationGroupRequest,\n PrincipalMemberEnvelopeRequest,\n PrincipalProjectionMemberRequest,\n PutPrincipalPolicyRequest,\n} from \"@tearleads/validators/request\";\nimport type { PrincipalPolicyBundleResponse } from \"@tearleads/validators/response\";\nimport { createPrincipalProjectionMember } from \"../principalContracts/principalIdentityCommitments\";\n\ninterface BuildInitialGroupPolicyInput {\n readonly identityTrustDomain: string;\n readonly creatorEncapsulationKeyPair: EncapsulationKeyPair;\n readonly externalAuthority?:\n | PrincipalPolicyExternalAuthority[\"currentHead\"]\n | null;\n readonly groupId: string;\n readonly grants?: readonly PrincipalContainerGrant[] | undefined;\n readonly includeSignerAsAdmin?: boolean;\n readonly name: string;\n readonly metadataKey?: GroupMetadataKey;\n readonly builtinRole?: \"admins\" | \"members\";\n readonly signerUserId: string;\n readonly signingFingerprint: string;\n readonly signingKeyPair: SigningKeyPair;\n}\n\nfunction projectionToStateMembers(\n projection: ReadonlyArray<PrincipalProjectionMemberRequest>,\n) {\n return projection.map((member) => ({ userId: member.userId }));\n}\n\n/**\n * Code points that must never appear in a group name: control and format\n * characters (bidi overrides, zero-width joiners, newlines), lone surrogates\n * (re-encoded as U+FFFD when signed, so the signed name would no longer match\n * the one sent to the server), and every other default-ignorable code point\n * (Hangul fillers, variation selectors), which render as nothing and would\n * let one name pass for another. A group name is an identifier here, so this\n * deliberately refuses ZWJ emoji sequences as well. One predicate serves the\n * signing-time and the share-time refusal so the two cannot drift.\n */\nfunction hasForbiddenGroupNameCharacter(name: string): boolean {\n return /[\\p{Cc}\\p{Cf}\\p{Cs}\\p{Default_Ignorable_Code_Point}]/u.test(name);\n}\n\n/**\n * The comparison key for a group display name: width- and compatibility-\n * normalized, stripped of control, format, and default-ignorable characters,\n * whitespace-collapsed, and case-folded. Two names that a user cannot tell\n * apart in a picker must compare equal, or a look-alike name would slip past\n * the share-time binding. Cross-script homoglyphs (Latin \"A\" against Greek\n * \"Α\") are not folded: that needs the UTS #39 confusables table, and both\n * names would still have to be signed groups the organization's own admins\n * created.\n */\nexport function canonicalGroupNameKey(name: string): string {\n return (\n name\n .normalize(\"NFKC\")\n .replace(/[\\p{Cc}\\p{Cf}\\p{Default_Ignorable_Code_Point}]/gu, \"\")\n .replace(/\\s+/gu, \" \")\n .trim()\n .toLocaleLowerCase(\"en-US\")\n // Case folding can leave the string un-normalized (U+0130 lowercases to\n // \"i\" plus a combining dot), so normalize once more after it.\n .normalize(\"NFKC\")\n );\n}\n\ntype GroupPolicyNameInput = Pick<\n PrincipalPolicyBundleResponse,\n \"currentState\" | \"currentPayload\"\n>;\n\nexport type GroupPolicyNameReader = (\n bundle: GroupPolicyNameInput,\n) => Promise<string>;\n\n/** Read only after the policy and its organization-directory binding verify. */\nexport async function readGroupPolicyPayloadName(\n bundle: GroupPolicyNameInput,\n readEncryptedName?: GroupPolicyNameReader,\n): Promise<string> {\n const metadata = readGroupMetadata(bundle.currentPayload.ciphertext);\n if (\"role\" in metadata)\n return metadata.role === \"admins\" ? \"Admins\" : \"Members\";\n if (!readEncryptedName)\n throw new Error(\"Group metadata decryption context is unavailable\");\n return readEncryptedName(bundle);\n}\n\n/** One binding predicate for every operation selected by a read-model label. */\nexport async function groupPolicyNameMismatch(\n bundle: GroupPolicyNameInput,\n expectedGroupName: string,\n readEncryptedName?: GroupPolicyNameReader,\n): Promise<\"forbidden_characters\" | \"name_mismatch\" | null> {\n if (hasForbiddenGroupNameCharacter(expectedGroupName)) {\n return \"forbidden_characters\";\n }\n const signedName = await readGroupPolicyPayloadName(\n bundle,\n readEncryptedName,\n );\n if (hasForbiddenGroupNameCharacter(signedName)) return \"forbidden_characters\";\n return canonicalGroupNameKey(signedName) ===\n canonicalGroupNameKey(expectedGroupName)\n ? null\n : \"name_mismatch\";\n}\n\nexport async function signedGroupPolicyRequest(input: {\n readonly currentPolicy?: Pick<PrincipalPolicyBundleResponse, \"currentState\">;\n readonly encapsulationPublicKey: string;\n readonly externalAuthority:\n | PrincipalPolicyExternalAuthority[\"currentHead\"]\n | null;\n readonly keyEpoch: number;\n readonly keyFingerprint: string;\n readonly grants: ReadonlyArray<PrincipalContainerGrant>;\n readonly memberEnvelopes: ReadonlyArray<PrincipalMemberEnvelopeRequest>;\n readonly payloadCiphertext: string;\n readonly principalId: string;\n readonly projection: ReadonlyArray<PrincipalProjectionMemberRequest>;\n readonly signedAt: string;\n readonly signerUserId: string;\n readonly signingFingerprint: string;\n readonly signingKeyPair: SigningKeyPair;\n}): Promise<PutPrincipalPolicyRequest> {\n const projection = normalizePrincipalProjectionMembers(input.projection);\n const grants = normalizePrincipalContainerGrants(input.grants);\n const payloadCiphertext = input.payloadCiphertext;\n const state = await signPrincipalState(\n await buildPrincipalStateSigningInput({\n principalType: \"group\",\n principalId: input.principalId,\n version: input.currentPolicy\n ? input.currentPolicy.currentState.version + 1\n : 1,\n prevStateHash: input.currentPolicy?.currentState.stateHash ?? null,\n keyEpoch: input.keyEpoch,\n encapsulationPublicKey: input.encapsulationPublicKey,\n keyFingerprint: input.keyFingerprint,\n members: projectionToStateMembers(projection),\n memberEnvelopes: [...input.memberEnvelopes],\n projection,\n grants,\n payloadCiphertext,\n externalAuthority: input.externalAuthority,\n signedAt: input.signedAt,\n signerUserId: input.signerUserId,\n signerUserKeyFingerprint: input.signingFingerprint,\n }),\n input.signingKeyPair.signingPrivateKey,\n );\n\n return {\n state,\n encryptedPayload: {\n cipherSuite: \"aes-256-gcm\",\n ciphertext: payloadCiphertext,\n ciphertextHash: state.payloadCiphertextHash,\n },\n projection,\n grants,\n memberEnvelopes: [...input.memberEnvelopes],\n };\n}\n\nexport async function buildInitialGroupPolicyRequest(\n input: BuildInitialGroupPolicyInput,\n): Promise<CreateOrganizationGroupRequest> {\n const groupKem = generateKemSeedAndKeyPair();\n const withSigner = input.includeSignerAsAdmin ?? true;\n const projection = withSigner\n ? [\n await createPrincipalProjectionMember(\n {\n userId: input.signerUserId,\n identityTrustDomain: input.identityTrustDomain,\n signingPublicKey: input.signingKeyPair.signingPublicKey,\n encapsulationPublicKey: input.creatorEncapsulationKeyPair.publicKey,\n },\n \"admin\",\n ),\n ]\n : [];\n const memberEnvelopes: PrincipalMemberEnvelopeRequest[] = [];\n\n if (withSigner) {\n const creatorFingerprint = await toFingerprint(\n input.creatorEncapsulationKeyPair.publicKey,\n );\n const [creatorEnvelope] = await wrapDekForRecipients(groupKem.secretKey, [\n input.creatorEncapsulationKeyPair.publicKey,\n ]);\n\n if (!creatorEnvelope) {\n throw new Error(\"Failed to wrap group key for creator\");\n }\n\n memberEnvelopes.push({\n userId: input.signerUserId,\n memberKeyFingerprint: creatorFingerprint,\n kemCipherText: bytesToBase64(creatorEnvelope.kemCipherText),\n wrappedKey: bytesToBase64(creatorEnvelope.wrappedKey),\n });\n }\n const name = input.name.trim();\n // A name is compared by canonical key but displayed raw, so an invisible\n // code point would let one signed name render as another. Refuse them\n // where the name is signed.\n if (name.length === 0 || hasForbiddenGroupNameCharacter(name)) {\n throw new Error(\n \"Group names must be non-empty and contain no control, format, or surrogate characters\",\n );\n }\n const payloadCiphertext = input.builtinRole\n ? encodeBuiltinGroupMetadata(input.builtinRole)\n : input.metadataKey\n ? await encryptGroupMetadata({\n key: input.metadataKey,\n groupId: input.groupId,\n name,\n })\n : (() => {\n throw new Error(\"Group metadata encryption context is unavailable\");\n })();\n const policyRequest = await signedGroupPolicyRequest({\n encapsulationPublicKey: bytesToBase64(groupKem.publicKey),\n externalAuthority: input.externalAuthority ?? null,\n keyEpoch: 1,\n keyFingerprint: await toFingerprint(groupKem.publicKey),\n grants: input.grants ?? [],\n memberEnvelopes,\n payloadCiphertext,\n principalId: input.groupId,\n projection,\n signedAt: new Date().toISOString(),\n signerUserId: input.signerUserId,\n signingFingerprint: input.signingFingerprint,\n signingKeyPair: input.signingKeyPair,\n });\n\n return {\n groupId: input.groupId,\n initialGroupPolicy: policyRequest,\n };\n}\n\n/**\n * Members at bootstrap holds the registering user alone.\n *\n * It used to also contain the Admins group as a nested member, so that admins\n * were implicitly members. Principals contain only users now, so an admin is an\n * ordinary Members entry — and bootstrap has exactly one user, who is that\n * admin.\n */\nexport async function buildInitialMemberGroupPolicyRequest(input: {\n readonly identityTrustDomain: string;\n readonly creatorEncapsulationKeyPair: EncapsulationKeyPair;\n readonly groupId: string;\n readonly grants?: readonly PrincipalContainerGrant[] | undefined;\n readonly signerUserId: string;\n readonly signingFingerprint: string;\n readonly signingKeyPair: SigningKeyPair;\n}): Promise<CreateOrganizationGroupRequest> {\n return buildInitialGroupPolicyRequest({\n ...input,\n name: \"Members\",\n builtinRole: \"members\",\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"principalPolicyRequest.js","sourceRoot":"","sources":["principalPolicyRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAE/B,0BAA0B,EAC1B,oBAAoB,EAEpB,yBAAyB,EACzB,iCAAiC,EACjC,mCAAmC,EAGnC,iBAAiB,EAEjB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAmBrG,SAAS,wBAAwB,CAC/B,UAA2D;IAE3D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,8BAA8B,CAAC,IAAY;IAClD,OAAO,uDAAuD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,CACL,IAAI;SACD,SAAS,CAAC,MAAM,CAAC;SACjB,OAAO,CAAC,kDAAkD,EAA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incipalStateSigningInput,\n type EncapsulationKeyPair,\n encodeBuiltinGroupMetadata,\n encryptGroupMetadata,\n type GroupMetadataKey,\n generateKemSeedAndKeyPair,\n normalizePrincipalContainerGrants,\n normalizePrincipalProjectionMembers,\n type PrincipalContainerGrant,\n type PrincipalPolicyExternalAuthority,\n readGroupMetadata,\n type SigningKeyPair,\n signPrincipalState,\n toFingerprint,\n wrapDekForRecipients,\n} from \"@tearleads/crypto\";\nimport { bytesToBase64 } from \"@tearleads/encoding\";\nimport type {\n CreateOrganizationGroupRequest,\n PrincipalMemberEnvelopeRequest,\n PrincipalProjectionMemberRequest,\n PutPrincipalPolicyRequest,\n} from \"@tearleads/validators/request\";\nimport type { PrincipalPolicyBundleResponse } from \"@tearleads/validators/response\";\nimport { createPrincipalProjectionMember } from \"../principalContracts/principalIdentityCommitments\";\n\ninterface BuildInitialGroupPolicyInput {\n readonly identityTrustDomain: string;\n readonly creatorEncapsulationKeyPair: EncapsulationKeyPair;\n readonly externalAuthority?:\n | PrincipalPolicyExternalAuthority[\"currentHead\"]\n | null;\n readonly groupId: string;\n readonly grants?: readonly PrincipalContainerGrant[] | undefined;\n readonly includeSignerAsAdmin?: boolean;\n readonly name: string;\n readonly metadataKey?: GroupMetadataKey;\n readonly builtinRole?: \"admins\" | \"members\";\n readonly signerUserId: string;\n readonly signingFingerprint: string;\n readonly signingKeyPair: SigningKeyPair;\n}\n\nfunction projectionToStateMembers(\n projection: ReadonlyArray<PrincipalProjectionMemberRequest>,\n) {\n return projection.map((member) => ({ userId: member.userId }));\n}\n\n/**\n * Code points that must never appear in a group name: control and format\n * characters (bidi overrides, zero-width joiners, newlines), lone surrogates\n * (re-encoded as U+FFFD when signed, so the signed name would no longer match\n * the one sent to the server), and every other default-ignorable code point\n * (Hangul fillers, variation selectors), which render as nothing and would\n * let one name pass for another. A group name is an identifier here, so this\n * deliberately refuses ZWJ emoji sequences as well. One predicate serves the\n * signing-time and the share-time refusal so the two cannot drift.\n */\nfunction hasForbiddenGroupNameCharacter(name: string): boolean {\n return /[\\p{Cc}\\p{Cf}\\p{Cs}\\p{Default_Ignorable_Code_Point}]/u.test(name);\n}\n\n/**\n * The comparison key for a group display name: width- and compatibility-\n * normalized, stripped of control, format, and default-ignorable characters,\n * whitespace-collapsed, and case-folded. Two names that a user cannot tell\n * apart in a picker must compare equal, or a look-alike name would slip past\n * the share-time binding. Cross-script homoglyphs (Latin \"A\" against Greek\n * \"Α\") are not folded: that needs the UTS #39 confusables table, and both\n * names would still have to be signed groups the organization's own admins\n * created.\n */\nexport function canonicalGroupNameKey(name: string): string {\n return (\n name\n .normalize(\"NFKC\")\n .replace(/[\\p{Cc}\\p{Cf}\\p{Default_Ignorable_Code_Point}]/gu, \"\")\n .replace(/\\s+/gu, \" \")\n .trim()\n .toLocaleLowerCase(\"en-US\")\n // Case folding can leave the string un-normalized (U+0130 lowercases to\n // \"i\" plus a combining dot), so normalize once more after it.\n .normalize(\"NFKC\")\n );\n}\n\ntype GroupPolicyNameInput = Pick<\n PrincipalPolicyBundleResponse,\n \"currentState\" | \"currentPayload\"\n>;\n\nexport type GroupPolicyNameReader = (\n bundle: GroupPolicyNameInput,\n) => Promise<string>;\n\n/** Read only after the policy and its organization-directory binding verify. */\nexport async function readGroupPolicyPayloadName(\n bundle: GroupPolicyNameInput,\n readEncryptedName?: GroupPolicyNameReader,\n): Promise<string> {\n const metadata = readGroupMetadata(bundle.currentPayload.ciphertext);\n if (\"role\" in metadata)\n return metadata.role === \"admins\" ? \"Admins\" : \"Members\";\n if (!readEncryptedName)\n throw new Error(\"Group metadata decryption context is unavailable\");\n return readEncryptedName(bundle);\n}\n\n/** One binding predicate for every operation selected by a read-model label. */\nexport async function groupPolicyNameMismatch(\n bundle: GroupPolicyNameInput,\n expectedGroupName: string,\n readEncryptedName?: GroupPolicyNameReader,\n): Promise<\"forbidden_characters\" | \"name_mismatch\" | null> {\n if (hasForbiddenGroupNameCharacter(expectedGroupName)) {\n return \"forbidden_characters\";\n }\n const signedName = await readGroupPolicyPayloadName(\n bundle,\n readEncryptedName,\n );\n if (hasForbiddenGroupNameCharacter(signedName)) return \"forbidden_characters\";\n return canonicalGroupNameKey(signedName) ===\n canonicalGroupNameKey(expectedGroupName)\n ? null\n : \"name_mismatch\";\n}\n\nexport async function signedGroupPolicyRequest(input: {\n readonly currentPolicy?: Pick<PrincipalPolicyBundleResponse, \"currentState\">;\n readonly encapsulationPublicKey: string;\n readonly externalAuthority:\n | PrincipalPolicyExternalAuthority[\"currentHead\"]\n | null;\n readonly keyEpoch: number;\n readonly keyFingerprint: string;\n readonly grants: ReadonlyArray<PrincipalContainerGrant>;\n readonly memberEnvelopes: ReadonlyArray<PrincipalMemberEnvelopeRequest>;\n readonly payloadCiphertext: string;\n readonly principalId: string;\n readonly projection: ReadonlyArray<PrincipalProjectionMemberRequest>;\n readonly signedAt: string;\n readonly signerUserId: string;\n readonly signingFingerprint: string;\n readonly signingKeyPair: SigningKeyPair;\n}): Promise<PutPrincipalPolicyRequest> {\n const projection = normalizePrincipalProjectionMembers(input.projection);\n const grants = normalizePrincipalContainerGrants(input.grants);\n const payloadCiphertext = input.payloadCiphertext;\n const state = await signPrincipalState(\n await buildPrincipalStateSigningInput({\n principalType: \"group\",\n principalId: input.principalId,\n version: input.currentPolicy\n ? input.currentPolicy.currentState.version + 1\n : 1,\n prevStateHash: input.currentPolicy?.currentState.stateHash ?? null,\n keyEpoch: input.keyEpoch,\n encapsulationPublicKey: input.encapsulationPublicKey,\n keyFingerprint: input.keyFingerprint,\n members: projectionToStateMembers(projection),\n memberEnvelopes: [...input.memberEnvelopes],\n projection,\n grants,\n payloadCiphertext,\n externalAuthority: input.externalAuthority,\n signedAt: input.signedAt,\n signerUserId: input.signerUserId,\n signerUserKeyFingerprint: input.signingFingerprint,\n }),\n input.signingKeyPair.signingPrivateKey,\n );\n\n return {\n state,\n encryptedPayload: {\n ciphertext: payloadCiphertext,\n },\n projection,\n grants,\n memberEnvelopes: [...input.memberEnvelopes],\n };\n}\n\nexport async function buildInitialGroupPolicyRequest(\n input: BuildInitialGroupPolicyInput,\n): Promise<CreateOrganizationGroupRequest> {\n const groupKem = generateKemSeedAndKeyPair();\n const withSigner = input.includeSignerAsAdmin ?? true;\n const projection = withSigner\n ? [\n await createPrincipalProjectionMember(\n {\n userId: input.signerUserId,\n identityTrustDomain: input.identityTrustDomain,\n signingPublicKey: input.signingKeyPair.signingPublicKey,\n encapsulationPublicKey: input.creatorEncapsulationKeyPair.publicKey,\n },\n \"admin\",\n ),\n ]\n : [];\n const memberEnvelopes: PrincipalMemberEnvelopeRequest[] = [];\n\n if (withSigner) {\n const creatorFingerprint = await toFingerprint(\n input.creatorEncapsulationKeyPair.publicKey,\n );\n const [creatorEnvelope] = await wrapDekForRecipients(groupKem.secretKey, [\n input.creatorEncapsulationKeyPair.publicKey,\n ]);\n\n if (!creatorEnvelope) {\n throw new Error(\"Failed to wrap group key for creator\");\n }\n\n memberEnvelopes.push({\n userId: input.signerUserId,\n memberKeyFingerprint: creatorFingerprint,\n kemCipherText: bytesToBase64(creatorEnvelope.kemCipherText),\n wrappedKey: bytesToBase64(creatorEnvelope.wrappedKey),\n });\n }\n const name = input.name.trim();\n // A name is compared by canonical key but displayed raw, so an invisible\n // code point would let one signed name render as another. Refuse them\n // where the name is signed.\n if (name.length === 0 || hasForbiddenGroupNameCharacter(name)) {\n throw new Error(\n \"Group names must be non-empty and contain no control, format, or surrogate characters\",\n );\n }\n const payloadCiphertext = input.builtinRole\n ? encodeBuiltinGroupMetadata(input.builtinRole)\n : input.metadataKey\n ? await encryptGroupMetadata({\n key: input.metadataKey,\n groupId: input.groupId,\n name,\n })\n : (() => {\n throw new Error(\"Group metadata encryption context is unavailable\");\n })();\n const policyRequest = await signedGroupPolicyRequest({\n encapsulationPublicKey: bytesToBase64(groupKem.publicKey),\n externalAuthority: input.externalAuthority ?? null,\n keyEpoch: 1,\n keyFingerprint: await toFingerprint(groupKem.publicKey),\n grants: input.grants ?? [],\n memberEnvelopes,\n payloadCiphertext,\n principalId: input.groupId,\n projection,\n signedAt: new Date().toISOString(),\n signerUserId: input.signerUserId,\n signingFingerprint: input.signingFingerprint,\n signingKeyPair: input.signingKeyPair,\n });\n\n return {\n groupId: input.groupId,\n initialGroupPolicy: policyRequest,\n };\n}\n\n/**\n * Members at bootstrap holds the registering user alone.\n *\n * It used to also contain the Admins group as a nested member, so that admins\n * were implicitly members. Principals contain only users now, so an admin is an\n * ordinary Members entry — and bootstrap has exactly one user, who is that\n * admin.\n */\nexport async function buildInitialMemberGroupPolicyRequest(input: {\n readonly identityTrustDomain: string;\n readonly creatorEncapsulationKeyPair: EncapsulationKeyPair;\n readonly groupId: string;\n readonly grants?: readonly PrincipalContainerGrant[] | undefined;\n readonly signerUserId: string;\n readonly signingFingerprint: string;\n readonly signingKeyPair: SigningKeyPair;\n}): Promise<CreateOrganizationGroupRequest> {\n return buildInitialGroupPolicyRequest({\n ...input,\n name: \"Members\",\n builtinRole: \"members\",\n });\n}\n"]}
|
|
@@ -300,13 +300,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
300
300
|
stateHash: string;
|
|
301
301
|
};
|
|
302
302
|
currentPayload: {
|
|
303
|
-
cipherSuite: "aes-256-gcm";
|
|
304
303
|
ciphertext: string;
|
|
305
|
-
ciphertextHash: string;
|
|
306
|
-
createdAt: string;
|
|
307
|
-
principalId: string;
|
|
308
|
-
principalType: "group" | "organization";
|
|
309
|
-
stateHash: string;
|
|
310
304
|
};
|
|
311
305
|
currentProjection: {
|
|
312
306
|
identityBundleFingerprint: string;
|
|
@@ -409,13 +403,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
409
403
|
stateHash: string;
|
|
410
404
|
};
|
|
411
405
|
currentPayload: {
|
|
412
|
-
cipherSuite: "aes-256-gcm";
|
|
413
406
|
ciphertext: string;
|
|
414
|
-
ciphertextHash: string;
|
|
415
|
-
createdAt: string;
|
|
416
|
-
principalId: string;
|
|
417
|
-
principalType: "group" | "organization";
|
|
418
|
-
stateHash: string;
|
|
419
407
|
};
|
|
420
408
|
currentProjection: {
|
|
421
409
|
identityBundleFingerprint: string;
|
|
@@ -536,13 +524,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
536
524
|
stateHash: string;
|
|
537
525
|
};
|
|
538
526
|
currentPayload: {
|
|
539
|
-
cipherSuite: "aes-256-gcm";
|
|
540
527
|
ciphertext: string;
|
|
541
|
-
ciphertextHash: string;
|
|
542
|
-
createdAt: string;
|
|
543
|
-
principalId: string;
|
|
544
|
-
principalType: "group" | "organization";
|
|
545
|
-
stateHash: string;
|
|
546
528
|
};
|
|
547
529
|
currentProjection: {
|
|
548
530
|
identityBundleFingerprint: string;
|
|
@@ -583,9 +565,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
583
565
|
} | null>;
|
|
584
566
|
putPrincipalPolicy: (principalType: "organization", principalId: string, input: {
|
|
585
567
|
encryptedPayload: {
|
|
586
|
-
cipherSuite: "aes-256-gcm";
|
|
587
568
|
ciphertext: string;
|
|
588
|
-
ciphertextHash: string;
|
|
589
569
|
};
|
|
590
570
|
grants: {
|
|
591
571
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -707,9 +687,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
707
687
|
} | null>;
|
|
708
688
|
putPrincipalPolicyResult: (principalType: "organization", principalId: string, input: {
|
|
709
689
|
encryptedPayload: {
|
|
710
|
-
cipherSuite: "aes-256-gcm";
|
|
711
690
|
ciphertext: string;
|
|
712
|
-
ciphertextHash: string;
|
|
713
691
|
};
|
|
714
692
|
grants: {
|
|
715
693
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -929,15 +907,14 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
929
907
|
version: number;
|
|
930
908
|
};
|
|
931
909
|
} | undefined;
|
|
910
|
+
readModel?: unknown;
|
|
932
911
|
} | null>;
|
|
933
912
|
commitOrganizationGroupPolicyResult: (organizationId: string, groupId: string, input: import("../validators/request/index.js").CommitOrganizationGroupPolicyRequest, options?: import("./types.js").RequestResultOptions) => Promise<import("./types.js").RequestResult<import("../validators/response/index.js").CommitOrganizationGroupPolicyResponse>>;
|
|
934
913
|
getOrganizationPolicyHistoryResult: (organizationId: string, stateHash: string, options?: Parameters<typeof import("./organizationPolicyHistory.js").getOrganizationPolicyHistoryResult>[3]) => Promise<import("./types.js").RequestResult<import("../validators/response/index.js").OrganizationPolicyHistoryResponse>>;
|
|
935
914
|
createOrganizationGroup: (organizationId: string, input: {
|
|
936
915
|
organizationPolicy: {
|
|
937
916
|
encryptedPayload: {
|
|
938
|
-
cipherSuite: "aes-256-gcm";
|
|
939
917
|
ciphertext: string;
|
|
940
|
-
ciphertextHash: string;
|
|
941
918
|
};
|
|
942
919
|
grants: {
|
|
943
920
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1028,9 +1005,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
1028
1005
|
groupId: string;
|
|
1029
1006
|
initialGroupPolicy: {
|
|
1030
1007
|
encryptedPayload: {
|
|
1031
|
-
cipherSuite: "aes-256-gcm";
|
|
1032
1008
|
ciphertext: string;
|
|
1033
|
-
ciphertextHash: string;
|
|
1034
1009
|
};
|
|
1035
1010
|
grants: {
|
|
1036
1011
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1165,13 +1140,12 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
1165
1140
|
version: number;
|
|
1166
1141
|
};
|
|
1167
1142
|
};
|
|
1143
|
+
readModel?: unknown;
|
|
1168
1144
|
} | null>;
|
|
1169
1145
|
createOrganizationGroupResult: (organizationId: string, input: {
|
|
1170
1146
|
organizationPolicy: {
|
|
1171
1147
|
encryptedPayload: {
|
|
1172
|
-
cipherSuite: "aes-256-gcm";
|
|
1173
1148
|
ciphertext: string;
|
|
1174
|
-
ciphertextHash: string;
|
|
1175
1149
|
};
|
|
1176
1150
|
grants: {
|
|
1177
1151
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1262,9 +1236,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
1262
1236
|
groupId: string;
|
|
1263
1237
|
initialGroupPolicy: {
|
|
1264
1238
|
encryptedPayload: {
|
|
1265
|
-
cipherSuite: "aes-256-gcm";
|
|
1266
1239
|
ciphertext: string;
|
|
1267
|
-
ciphertextHash: string;
|
|
1268
1240
|
};
|
|
1269
1241
|
grants: {
|
|
1270
1242
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1399,13 +1371,12 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
1399
1371
|
version: number;
|
|
1400
1372
|
};
|
|
1401
1373
|
};
|
|
1374
|
+
readModel?: unknown;
|
|
1402
1375
|
}>>;
|
|
1403
1376
|
deleteOrganizationGroup: (organizationId: string, groupId: string, input: {
|
|
1404
1377
|
organizationPolicy: {
|
|
1405
1378
|
encryptedPayload: {
|
|
1406
|
-
cipherSuite: "aes-256-gcm";
|
|
1407
1379
|
ciphertext: string;
|
|
1408
|
-
ciphertextHash: string;
|
|
1409
1380
|
};
|
|
1410
1381
|
grants: {
|
|
1411
1382
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -1534,9 +1505,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
1534
1505
|
deleteOrganizationGroupResult: (organizationId: string, groupId: string, input: {
|
|
1535
1506
|
organizationPolicy: {
|
|
1536
1507
|
encryptedPayload: {
|
|
1537
|
-
cipherSuite: "aes-256-gcm";
|
|
1538
1508
|
ciphertext: string;
|
|
1539
|
-
ciphertextHash: string;
|
|
1540
1509
|
};
|
|
1541
1510
|
grants: {
|
|
1542
1511
|
accessLevel: "write" | "admin" | "read";
|
|
@@ -2304,7 +2273,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
2304
2273
|
updatedAt: string;
|
|
2305
2274
|
systemSlot?: string | null | undefined;
|
|
2306
2275
|
} | null>;
|
|
2307
|
-
shareContainerResult: (containerId: string, input: import("../validators/request/index.js").ContainerMutationRequest, options?: import("./types.js").RequestResultOptions) => Promise<import("./types.js").RequestResult<import("../validators/response/index.js").
|
|
2276
|
+
shareContainerResult: (containerId: string, input: import("../validators/request/index.js").ContainerMutationRequest, options?: import("./types.js").RequestResultOptions) => Promise<import("./types.js").RequestResult<import("../validators/response/index.js").ContainerShareResponse>>;
|
|
2308
2277
|
revokeContainer: (containerId: string, input: import("../validators/request/index.js").ContainerRotationRequest, options?: import("./types.js").RequestResultOptions) => Promise<{
|
|
2309
2278
|
containerKek: {
|
|
2310
2279
|
containerKeyEpoch: number;
|
|
@@ -2693,13 +2662,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
2693
2662
|
version: number;
|
|
2694
2663
|
};
|
|
2695
2664
|
payload: {
|
|
2696
|
-
cipherSuite: "aes-256-gcm";
|
|
2697
2665
|
ciphertext: string;
|
|
2698
|
-
ciphertextHash: string;
|
|
2699
|
-
createdAt: string;
|
|
2700
|
-
principalId: string;
|
|
2701
|
-
principalType: "group" | "organization";
|
|
2702
|
-
stateHash: string;
|
|
2703
2666
|
};
|
|
2704
2667
|
}[];
|
|
2705
2668
|
groups: {
|
|
@@ -2795,13 +2758,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
2795
2758
|
version: number;
|
|
2796
2759
|
};
|
|
2797
2760
|
payload: {
|
|
2798
|
-
cipherSuite: "aes-256-gcm";
|
|
2799
2761
|
ciphertext: string;
|
|
2800
|
-
ciphertextHash: string;
|
|
2801
|
-
createdAt: string;
|
|
2802
|
-
principalId: string;
|
|
2803
|
-
principalType: "group" | "organization";
|
|
2804
|
-
stateHash: string;
|
|
2805
2762
|
};
|
|
2806
2763
|
}[];
|
|
2807
2764
|
groups: {
|
|
@@ -3011,13 +2968,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
3011
2968
|
version: number;
|
|
3012
2969
|
};
|
|
3013
2970
|
payload: {
|
|
3014
|
-
cipherSuite: "aes-256-gcm";
|
|
3015
2971
|
ciphertext: string;
|
|
3016
|
-
ciphertextHash: string;
|
|
3017
|
-
createdAt: string;
|
|
3018
|
-
principalId: string;
|
|
3019
|
-
principalType: "group" | "organization";
|
|
3020
|
-
stateHash: string;
|
|
3021
2972
|
};
|
|
3022
2973
|
}[];
|
|
3023
2974
|
groups: {
|
|
@@ -3099,13 +3050,7 @@ export declare class ApiClient extends ApiClientAreas {
|
|
|
3099
3050
|
version: number;
|
|
3100
3051
|
};
|
|
3101
3052
|
payload: {
|
|
3102
|
-
cipherSuite: "aes-256-gcm";
|
|
3103
3053
|
ciphertext: string;
|
|
3104
|
-
ciphertextHash: string;
|
|
3105
|
-
createdAt: string;
|
|
3106
|
-
principalId: string;
|
|
3107
|
-
principalType: "group" | "organization";
|
|
3108
|
-
stateHash: string;
|
|
3109
3054
|
};
|
|
3110
3055
|
}[];
|
|
3111
3056
|
groups: {
|
|
@@ -135,13 +135,7 @@ export declare class ApiClientContext {
|
|
|
135
135
|
version: number;
|
|
136
136
|
};
|
|
137
137
|
payload: {
|
|
138
|
-
cipherSuite: "aes-256-gcm";
|
|
139
138
|
ciphertext: string;
|
|
140
|
-
ciphertextHash: string;
|
|
141
|
-
createdAt: string;
|
|
142
|
-
principalId: string;
|
|
143
|
-
principalType: "group" | "organization";
|
|
144
|
-
stateHash: string;
|
|
145
139
|
};
|
|
146
140
|
}[];
|
|
147
141
|
groups: {
|
|
@@ -222,13 +216,7 @@ export declare class ApiClientContext {
|
|
|
222
216
|
version: number;
|
|
223
217
|
};
|
|
224
218
|
payload: {
|
|
225
|
-
cipherSuite: "aes-256-gcm";
|
|
226
219
|
ciphertext: string;
|
|
227
|
-
ciphertextHash: string;
|
|
228
|
-
createdAt: string;
|
|
229
|
-
principalId: string;
|
|
230
|
-
principalType: "group" | "organization";
|
|
231
|
-
stateHash: string;
|
|
232
220
|
};
|
|
233
221
|
}[];
|
|
234
222
|
groups: {
|
|
@@ -375,13 +363,7 @@ export declare class ApiClientContext {
|
|
|
375
363
|
version: number;
|
|
376
364
|
};
|
|
377
365
|
payload: {
|
|
378
|
-
cipherSuite: "aes-256-gcm";
|
|
379
366
|
ciphertext: string;
|
|
380
|
-
ciphertextHash: string;
|
|
381
|
-
createdAt: string;
|
|
382
|
-
principalId: string;
|
|
383
|
-
principalType: "group" | "organization";
|
|
384
|
-
stateHash: string;
|
|
385
367
|
};
|
|
386
368
|
}[];
|
|
387
369
|
groups: {
|
|
@@ -462,13 +444,7 @@ export declare class ApiClientContext {
|
|
|
462
444
|
version: number;
|
|
463
445
|
};
|
|
464
446
|
payload: {
|
|
465
|
-
cipherSuite: "aes-256-gcm";
|
|
466
447
|
ciphertext: string;
|
|
467
|
-
ciphertextHash: string;
|
|
468
|
-
createdAt: string;
|
|
469
|
-
principalId: string;
|
|
470
|
-
principalType: "group" | "organization";
|
|
471
|
-
stateHash: string;
|
|
472
448
|
};
|
|
473
449
|
}[];
|
|
474
450
|
groups: {
|
|
@@ -710,13 +686,7 @@ export declare class ApiClientContext {
|
|
|
710
686
|
stateHash: string;
|
|
711
687
|
};
|
|
712
688
|
currentPayload: {
|
|
713
|
-
cipherSuite: "aes-256-gcm";
|
|
714
689
|
ciphertext: string;
|
|
715
|
-
ciphertextHash: string;
|
|
716
|
-
createdAt: string;
|
|
717
|
-
principalId: string;
|
|
718
|
-
principalType: "group" | "organization";
|
|
719
|
-
stateHash: string;
|
|
720
690
|
};
|
|
721
691
|
currentProjection: {
|
|
722
692
|
identityBundleFingerprint: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContainerCreateWithMetadataDocumentRequest, ContainerMutationRequest, ContainerReciteRequest, ContainerRotationRequest } from "../../validators/request/index.js";
|
|
2
|
-
import type { ContainerCreateWithMetadataDocumentResponse, ContainerDeleteResponse, ContainerMutationResponse, ContainerRotationResponse } from "../../validators/response/index.js";
|
|
2
|
+
import type { ContainerCreateWithMetadataDocumentResponse, ContainerDeleteResponse, ContainerMutationResponse, ContainerRotationResponse, ContainerShareResponse } from "../../validators/response/index.js";
|
|
3
3
|
import type { RequestResult, RequestResultOptions } from "../types.js";
|
|
4
4
|
import { type ApiClientContext } from "./apiClientContext.js";
|
|
5
5
|
import type { ApiClientSelf, DeleteContainerOptions } from "./apiClientSelf.js";
|
|
@@ -97,7 +97,7 @@ export declare class ContainerMutationArea {
|
|
|
97
97
|
systemSlot?: string | null | undefined;
|
|
98
98
|
} | null>;
|
|
99
99
|
/** Status-bearing share: a stale path is retryable, a refusal is not. */
|
|
100
|
-
shareContainerResult(containerId: string, input: ContainerMutationRequest, options?: RequestResultOptions): Promise<RequestResult<
|
|
100
|
+
shareContainerResult(containerId: string, input: ContainerMutationRequest, options?: RequestResultOptions): Promise<RequestResult<ContainerShareResponse>>;
|
|
101
101
|
revokeContainer(containerId: string, input: ContainerRotationRequest, options?: RequestResultOptions): Promise<{
|
|
102
102
|
containerKek: {
|
|
103
103
|
containerKeyEpoch: number;
|
|
@@ -48,8 +48,9 @@ export class ContainerMutationArea {
|
|
|
48
48
|
}
|
|
49
49
|
/** Status-bearing share: a stale path is retryable, a refusal is not. */
|
|
50
50
|
async shareContainerResult(containerId, input, options = {}) {
|
|
51
|
+
const { readModelCursor, ...requestOptions } = options;
|
|
51
52
|
try {
|
|
52
|
-
return await this.context.sendResult(containerShare, containerShare.path(containerId), shareContainerOperation, input,
|
|
53
|
+
return await this.context.sendResult(containerShare, containerShare.path(containerId, readModelCursor), shareContainerOperation, input, requestOptions);
|
|
53
54
|
}
|
|
54
55
|
finally {
|
|
55
56
|
this.self.clearWriterProjectionCaches();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerMutations.js","sourceRoot":"","sources":["containerMutations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,4CAA4C,EAC5C,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AAazC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,eA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,OAAO,CAAC,CAAC,IAAI,CAClE,UAAU,CACX,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,WAAmB,EACnB,UAAkC,EAAE;QAEpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAED,qBAAqB,CACnB,WAAmB,EACnB,UAAkC,EAAE;QAEpC,OAAO,IAAI,CAAC,OAAO;aAChB,UAAU,CACT,eAAe,EACf,eAAe,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAC7D,wBAAwB,EACxB,SAAS,EACT,OAAO,CACR;aACA,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;CACF","sourcesContent":["import {\n createContainerOperation,\n createContainerWithMetadataDocumentOperation,\n deleteContainerOperation,\n moveContainerOperation,\n reciteContainerOperation,\n rekeyContainerOperation,\n revokeContainerOperation,\n shareContainerOperation,\n} from \"@tearleads/validators/operation\";\nimport type {\n ContainerCreateWithMetadataDocumentRequest,\n ContainerMutationRequest,\n ContainerReciteRequest,\n ContainerRotationRequest,\n} from \"@tearleads/validators/request\";\nimport type {\n ContainerCreateWithMetadataDocumentResponse,\n ContainerDeleteResponse,\n ContainerMutationResponse,\n ContainerRotationResponse,\n} from \"@tearleads/validators/response\";\nimport { bindPrototypeMethods } from \"../requestInternals\";\nimport {\n containerCreate,\n containerCreateWithMetadataDocument,\n containerDelete,\n containerMove,\n containerRecite,\n containerRekey,\n containerRevoke,\n containerShare,\n} from \"../routes/containers/mutations\";\nimport type { RequestResult, RequestResultOptions } from \"../types\";\nimport { type ApiClientContext, dataOrNull } from \"./apiClientContext\";\nimport type { ApiClientSelf, DeleteContainerOptions } from \"./apiClientSelf\";\n\n/** The rotations that may carry descendant rekeys, each with its operation. */\nconst CONTAINER_ROTATIONS = {\n move: { operation: moveContainerOperation, route: containerMove },\n rekey: { operation: rekeyContainerOperation, route: containerRekey },\n revoke: { operation: revokeContainerOperation, route: containerRevoke },\n} as const;\n\n/**\n * Container creates, shares, rotations, recitals, and deletes. Every access\n * change clears the writer-projection caches, whatever its outcome.\n */\nexport class ContainerMutationArea {\n constructor(\n private readonly context: ApiClientContext,\n private readonly self: Pick<\n ApiClientSelf,\n | \"clearWriterProjectionCaches\"\n | \"deleteContainerResult\"\n | \"shareContainerResult\"\n >,\n ) {\n bindPrototypeMethods(this, ContainerMutationArea.prototype);\n }\n\n private async rotationResult(\n rotation: keyof typeof CONTAINER_ROTATIONS,\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions,\n ): Promise<RequestResult<ContainerRotationResponse>> {\n const { operation, route } = CONTAINER_ROTATIONS[rotation];\n try {\n return await this.context.sendResult(\n route,\n route.path(containerId),\n operation,\n input,\n options,\n );\n } finally {\n this.self.clearWriterProjectionCaches();\n }\n }\n\n createContainer(\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.context.send(\n containerCreate,\n containerCreate.path,\n createContainerOperation,\n input,\n options,\n );\n }\n\n async createContainerResult(\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerMutationResponse>> {\n return this.context.sendResult(\n containerCreate,\n containerCreate.path,\n createContainerOperation,\n input,\n options,\n );\n }\n\n createContainerWithMetadataDocument(\n input: ContainerCreateWithMetadataDocumentRequest,\n options: RequestResultOptions = {},\n ) {\n return this.context.send(\n containerCreateWithMetadataDocument,\n containerCreateWithMetadataDocument.path,\n createContainerWithMetadataDocumentOperation,\n input,\n options,\n );\n }\n\n createContainerWithMetadataDocumentResult(\n input: ContainerCreateWithMetadataDocumentRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerCreateWithMetadataDocumentResponse>> {\n return this.context.sendResult(\n containerCreateWithMetadataDocument,\n containerCreateWithMetadataDocument.path,\n createContainerWithMetadataDocumentOperation,\n input,\n options,\n );\n }\n\n shareContainer(\n containerId: string,\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.self\n .shareContainerResult(containerId, input, options)\n .then(dataOrNull);\n }\n\n /** Status-bearing share: a stale path is retryable, a refusal is not. */\n async shareContainerResult(\n containerId: string,\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerMutationResponse>> {\n try {\n return await this.context.sendResult(\n containerShare,\n containerShare.path(containerId),\n shareContainerOperation,\n input,\n options,\n );\n } finally {\n this.self.clearWriterProjectionCaches();\n }\n }\n\n revokeContainer(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.rotationResult(\"revoke\", containerId, input, options).then(\n dataOrNull,\n );\n }\n\n rekeyContainer(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.rotationResult(\"rekey\", containerId, input, options).then(\n dataOrNull,\n );\n }\n\n /**\n * Status-bearing rotations: a caller that must tell a permanent refusal (403\n * once ancestor write access is revoked, 402) from a transient 5xx or an\n * offline blip cannot do so through the plain methods, which collapse both to\n * null. They are also how a rotation learns which descendant rekeys it must\n * carry.\n */\n rekeyContainerResult(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerRotationResponse>> {\n return this.rotationResult(\"rekey\", containerId, input, options);\n }\n\n revokeContainerResult(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerRotationResponse>> {\n return this.rotationResult(\"revoke\", containerId, input, options);\n }\n\n moveContainerResult(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerRotationResponse>> {\n return this.rotationResult(\"move\", containerId, input, options);\n }\n\n reciteContainer(\n containerId: string,\n input: ContainerReciteRequest,\n options: RequestResultOptions = {},\n ) {\n return this.context\n .send(\n containerRecite,\n containerRecite.path(containerId),\n reciteContainerOperation,\n input,\n options,\n )\n .finally(() => this.self.clearWriterProjectionCaches());\n }\n\n moveContainer(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.rotationResult(\"move\", containerId, input, options).then(\n dataOrNull,\n );\n }\n\n async deleteContainer(\n containerId: string,\n options: DeleteContainerOptions = {},\n ) {\n const result = await this.self.deleteContainerResult(containerId, options);\n return result.ok ? result.data : null;\n }\n\n deleteContainerResult(\n containerId: string,\n options: DeleteContainerOptions = {},\n ): Promise<RequestResult<ContainerDeleteResponse>> {\n return this.context\n .sendResult(\n containerDelete,\n containerDelete.path(containerId, options.requiredAncestorId),\n deleteContainerOperation,\n undefined,\n options,\n )\n .finally(() => {\n this.self.clearWriterProjectionCaches();\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerMutations.js","sourceRoot":"","sources":["containerMutations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,4CAA4C,EAC5C,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AAczC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,mCAAmC,EACnC,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAyB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGvE,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE,EAAE,SAAS,EAAE,sBAAsB,EAAE,KAAK,EAAE,aAAa,EAAE;IACjE,KAAK,EAAE,EAAE,SAAS,EA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,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAED,qBAAqB,CACnB,WAAmB,EACnB,UAAkC,EAAE;QAEpC,OAAO,IAAI,CAAC,OAAO;aAChB,UAAU,CACT,eAAe,EACf,eAAe,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAC7D,wBAAwB,EACxB,SAAS,EACT,OAAO,CACR;aACA,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;CACF","sourcesContent":["import {\n createContainerOperation,\n createContainerWithMetadataDocumentOperation,\n deleteContainerOperation,\n moveContainerOperation,\n reciteContainerOperation,\n rekeyContainerOperation,\n revokeContainerOperation,\n shareContainerOperation,\n} from \"@tearleads/validators/operation\";\nimport type {\n ContainerCreateWithMetadataDocumentRequest,\n ContainerMutationRequest,\n ContainerReciteRequest,\n ContainerRotationRequest,\n} from \"@tearleads/validators/request\";\nimport type {\n ContainerCreateWithMetadataDocumentResponse,\n ContainerDeleteResponse,\n ContainerMutationResponse,\n ContainerRotationResponse,\n ContainerShareResponse,\n} from \"@tearleads/validators/response\";\nimport { bindPrototypeMethods } from \"../requestInternals\";\nimport {\n containerCreate,\n containerCreateWithMetadataDocument,\n containerDelete,\n containerMove,\n containerRecite,\n containerRekey,\n containerRevoke,\n containerShare,\n} from \"../routes/containers/mutations\";\nimport type { RequestResult, RequestResultOptions } from \"../types\";\nimport { type ApiClientContext, dataOrNull } from \"./apiClientContext\";\nimport type { ApiClientSelf, DeleteContainerOptions } from \"./apiClientSelf\";\n\n/** The rotations that may carry descendant rekeys, each with its operation. */\nconst CONTAINER_ROTATIONS = {\n move: { operation: moveContainerOperation, route: containerMove },\n rekey: { operation: rekeyContainerOperation, route: containerRekey },\n revoke: { operation: revokeContainerOperation, route: containerRevoke },\n} as const;\n\n/**\n * Container creates, shares, rotations, recitals, and deletes. Every access\n * change clears the writer-projection caches, whatever its outcome.\n */\nexport class ContainerMutationArea {\n constructor(\n private readonly context: ApiClientContext,\n private readonly self: Pick<\n ApiClientSelf,\n | \"clearWriterProjectionCaches\"\n | \"deleteContainerResult\"\n | \"shareContainerResult\"\n >,\n ) {\n bindPrototypeMethods(this, ContainerMutationArea.prototype);\n }\n\n private async rotationResult(\n rotation: keyof typeof CONTAINER_ROTATIONS,\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions,\n ): Promise<RequestResult<ContainerRotationResponse>> {\n const { operation, route } = CONTAINER_ROTATIONS[rotation];\n try {\n return await this.context.sendResult(\n route,\n route.path(containerId),\n operation,\n input,\n options,\n );\n } finally {\n this.self.clearWriterProjectionCaches();\n }\n }\n\n createContainer(\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.context.send(\n containerCreate,\n containerCreate.path,\n createContainerOperation,\n input,\n options,\n );\n }\n\n async createContainerResult(\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerMutationResponse>> {\n return this.context.sendResult(\n containerCreate,\n containerCreate.path,\n createContainerOperation,\n input,\n options,\n );\n }\n\n createContainerWithMetadataDocument(\n input: ContainerCreateWithMetadataDocumentRequest,\n options: RequestResultOptions = {},\n ) {\n return this.context.send(\n containerCreateWithMetadataDocument,\n containerCreateWithMetadataDocument.path,\n createContainerWithMetadataDocumentOperation,\n input,\n options,\n );\n }\n\n createContainerWithMetadataDocumentResult(\n input: ContainerCreateWithMetadataDocumentRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerCreateWithMetadataDocumentResponse>> {\n return this.context.sendResult(\n containerCreateWithMetadataDocument,\n containerCreateWithMetadataDocument.path,\n createContainerWithMetadataDocumentOperation,\n input,\n options,\n );\n }\n\n shareContainer(\n containerId: string,\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.self\n .shareContainerResult(containerId, input, options)\n .then(dataOrNull);\n }\n\n /** Status-bearing share: a stale path is retryable, a refusal is not. */\n async shareContainerResult(\n containerId: string,\n input: ContainerMutationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerShareResponse>> {\n const { readModelCursor, ...requestOptions } = options;\n try {\n return await this.context.sendResult(\n containerShare,\n containerShare.path(containerId, readModelCursor),\n shareContainerOperation,\n input,\n requestOptions,\n );\n } finally {\n this.self.clearWriterProjectionCaches();\n }\n }\n\n revokeContainer(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.rotationResult(\"revoke\", containerId, input, options).then(\n dataOrNull,\n );\n }\n\n rekeyContainer(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.rotationResult(\"rekey\", containerId, input, options).then(\n dataOrNull,\n );\n }\n\n /**\n * Status-bearing rotations: a caller that must tell a permanent refusal (403\n * once ancestor write access is revoked, 402) from a transient 5xx or an\n * offline blip cannot do so through the plain methods, which collapse both to\n * null. They are also how a rotation learns which descendant rekeys it must\n * carry.\n */\n rekeyContainerResult(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerRotationResponse>> {\n return this.rotationResult(\"rekey\", containerId, input, options);\n }\n\n revokeContainerResult(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerRotationResponse>> {\n return this.rotationResult(\"revoke\", containerId, input, options);\n }\n\n moveContainerResult(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ): Promise<RequestResult<ContainerRotationResponse>> {\n return this.rotationResult(\"move\", containerId, input, options);\n }\n\n reciteContainer(\n containerId: string,\n input: ContainerReciteRequest,\n options: RequestResultOptions = {},\n ) {\n return this.context\n .send(\n containerRecite,\n containerRecite.path(containerId),\n reciteContainerOperation,\n input,\n options,\n )\n .finally(() => this.self.clearWriterProjectionCaches());\n }\n\n moveContainer(\n containerId: string,\n input: ContainerRotationRequest,\n options: RequestResultOptions = {},\n ) {\n return this.rotationResult(\"move\", containerId, input, options).then(\n dataOrNull,\n );\n }\n\n async deleteContainer(\n containerId: string,\n options: DeleteContainerOptions = {},\n ) {\n const result = await this.self.deleteContainerResult(containerId, options);\n return result.ok ? result.data : null;\n }\n\n deleteContainerResult(\n containerId: string,\n options: DeleteContainerOptions = {},\n ): Promise<RequestResult<ContainerDeleteResponse>> {\n return this.context\n .sendResult(\n containerDelete,\n containerDelete.path(containerId, options.requiredAncestorId),\n deleteContainerOperation,\n undefined,\n options,\n )\n .finally(() => {\n this.self.clearWriterProjectionCaches();\n });\n }\n}\n"]}
|
|
@@ -174,13 +174,7 @@ export declare class DocumentArea {
|
|
|
174
174
|
version: number;
|
|
175
175
|
};
|
|
176
176
|
payload: {
|
|
177
|
-
cipherSuite: "aes-256-gcm";
|
|
178
177
|
ciphertext: string;
|
|
179
|
-
ciphertextHash: string;
|
|
180
|
-
createdAt: string;
|
|
181
|
-
principalId: string;
|
|
182
|
-
principalType: "group" | "organization";
|
|
183
|
-
stateHash: string;
|
|
184
178
|
};
|
|
185
179
|
}[];
|
|
186
180
|
groups: {
|
|
@@ -276,13 +270,7 @@ export declare class DocumentArea {
|
|
|
276
270
|
version: number;
|
|
277
271
|
};
|
|
278
272
|
payload: {
|
|
279
|
-
cipherSuite: "aes-256-gcm";
|
|
280
273
|
ciphertext: string;
|
|
281
|
-
ciphertextHash: string;
|
|
282
|
-
createdAt: string;
|
|
283
|
-
principalId: string;
|
|
284
|
-
principalType: "group" | "organization";
|
|
285
|
-
stateHash: string;
|
|
286
274
|
};
|
|
287
275
|
}[];
|
|
288
276
|
groups: {
|
|
@@ -76,13 +76,7 @@ export declare class PrincipalPolicyArea {
|
|
|
76
76
|
stateHash: string;
|
|
77
77
|
};
|
|
78
78
|
currentPayload: {
|
|
79
|
-
cipherSuite: "aes-256-gcm";
|
|
80
79
|
ciphertext: string;
|
|
81
|
-
ciphertextHash: string;
|
|
82
|
-
createdAt: string;
|
|
83
|
-
principalId: string;
|
|
84
|
-
principalType: "group" | "organization";
|
|
85
|
-
stateHash: string;
|
|
86
80
|
};
|
|
87
81
|
currentProjection: {
|
|
88
82
|
identityBundleFingerprint: string;
|
|
@@ -186,13 +180,7 @@ export declare class PrincipalPolicyArea {
|
|
|
186
180
|
stateHash: string;
|
|
187
181
|
};
|
|
188
182
|
currentPayload: {
|
|
189
|
-
cipherSuite: "aes-256-gcm";
|
|
190
183
|
ciphertext: string;
|
|
191
|
-
ciphertextHash: string;
|
|
192
|
-
createdAt: string;
|
|
193
|
-
principalId: string;
|
|
194
|
-
principalType: "group" | "organization";
|
|
195
|
-
stateHash: string;
|
|
196
184
|
};
|
|
197
185
|
currentProjection: {
|
|
198
186
|
identityBundleFingerprint: string;
|
|
@@ -304,13 +292,7 @@ export declare class PrincipalPolicyArea {
|
|
|
304
292
|
stateHash: string;
|
|
305
293
|
};
|
|
306
294
|
currentPayload: {
|
|
307
|
-
cipherSuite: "aes-256-gcm";
|
|
308
295
|
ciphertext: string;
|
|
309
|
-
ciphertextHash: string;
|
|
310
|
-
createdAt: string;
|
|
311
|
-
principalId: string;
|
|
312
|
-
principalType: "group" | "organization";
|
|
313
|
-
stateHash: string;
|
|
314
296
|
};
|
|
315
297
|
currentProjection: {
|
|
316
298
|
identityBundleFingerprint: string;
|
|
@@ -516,6 +498,7 @@ export declare class PrincipalPolicyArea {
|
|
|
516
498
|
version: number;
|
|
517
499
|
};
|
|
518
500
|
} | undefined;
|
|
501
|
+
readModel?: unknown;
|
|
519
502
|
} | null>;
|
|
520
503
|
/**
|
|
521
504
|
* Status-bearing group policy commit. A rematerialized rotation the server
|
|
@@ -571,6 +554,7 @@ export declare class PrincipalPolicyArea {
|
|
|
571
554
|
version: number;
|
|
572
555
|
};
|
|
573
556
|
};
|
|
557
|
+
readModel?: unknown;
|
|
574
558
|
} | null>;
|
|
575
559
|
createOrganizationGroupResult(...args: Parameters<PrincipalPolicyRequests["createResult"]>): Promise<RequestResult<{
|
|
576
560
|
group: {
|
|
@@ -619,6 +603,7 @@ export declare class PrincipalPolicyArea {
|
|
|
619
603
|
version: number;
|
|
620
604
|
};
|
|
621
605
|
};
|
|
606
|
+
readModel?: unknown;
|
|
622
607
|
}>>;
|
|
623
608
|
deleteOrganizationGroup(...args: Parameters<PrincipalPolicyRequests["deleteResult"]>): Promise<{
|
|
624
609
|
deleted: true;
|
|
@@ -37,13 +37,7 @@ export declare class WriterProjectionArea {
|
|
|
37
37
|
version: number;
|
|
38
38
|
};
|
|
39
39
|
payload: {
|
|
40
|
-
cipherSuite: "aes-256-gcm";
|
|
41
40
|
ciphertext: string;
|
|
42
|
-
ciphertextHash: string;
|
|
43
|
-
createdAt: string;
|
|
44
|
-
principalId: string;
|
|
45
|
-
principalType: "group" | "organization";
|
|
46
|
-
stateHash: string;
|
|
47
41
|
};
|
|
48
42
|
}[];
|
|
49
43
|
groups: {
|
|
@@ -125,13 +119,7 @@ export declare class WriterProjectionArea {
|
|
|
125
119
|
version: number;
|
|
126
120
|
};
|
|
127
121
|
payload: {
|
|
128
|
-
cipherSuite: "aes-256-gcm";
|
|
129
122
|
ciphertext: string;
|
|
130
|
-
ciphertextHash: string;
|
|
131
|
-
createdAt: string;
|
|
132
|
-
principalId: string;
|
|
133
|
-
principalType: "group" | "organization";
|
|
134
|
-
stateHash: string;
|
|
135
123
|
};
|
|
136
124
|
}[];
|
|
137
125
|
groups: {
|
|
@@ -10,10 +10,14 @@ export interface HeldDirectoryCitation {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function isHeldDirectoryCitation(value: unknown): value is HeldDirectoryCitation;
|
|
12
12
|
/**
|
|
13
|
-
* The payload
|
|
14
|
-
* bytes hash to the `payloadCiphertextHash` that
|
|
15
|
-
*
|
|
13
|
+
* The payload, under its state hash, when its organization state recomputes
|
|
14
|
+
* to its own hash and its bytes hash to the `payloadCiphertextHash` that
|
|
15
|
+
* state signs; null otherwise. A payload is only its ciphertext (#2903 P23),
|
|
16
|
+
* so the signed hash is its whole identity: a cited payload is exactly the
|
|
16
17
|
* bytes the server would serve for that state, and verification of the
|
|
17
18
|
* rebuilt evidence decides as if they had travelled.
|
|
18
19
|
*/
|
|
19
|
-
export declare function signedDirectoryPayload(citation: HeldDirectoryCitation): Promise<
|
|
20
|
+
export declare function signedDirectoryPayload(citation: HeldDirectoryCitation): Promise<{
|
|
21
|
+
readonly payload: PrincipalStatePayloadResponse;
|
|
22
|
+
readonly stateHash: string;
|
|
23
|
+
} | null>;
|
|
@@ -8,9 +8,10 @@ export function isHeldDirectoryCitation(value) {
|
|
|
8
8
|
isPrincipalStatePayloadResponse(Reflect.get(value, "directoryPayload")));
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* The payload
|
|
12
|
-
* bytes hash to the `payloadCiphertextHash` that
|
|
13
|
-
*
|
|
11
|
+
* The payload, under its state hash, when its organization state recomputes
|
|
12
|
+
* to its own hash and its bytes hash to the `payloadCiphertextHash` that
|
|
13
|
+
* state signs; null otherwise. A payload is only its ciphertext (#2903 P23),
|
|
14
|
+
* so the signed hash is its whole identity: a cited payload is exactly the
|
|
14
15
|
* bytes the server would serve for that state, and verification of the
|
|
15
16
|
* rebuilt evidence decides as if they had travelled.
|
|
16
17
|
*/
|
|
@@ -18,16 +19,11 @@ export async function signedDirectoryPayload(citation) {
|
|
|
18
19
|
const { directoryState: state, directoryPayload: payload } = citation;
|
|
19
20
|
try {
|
|
20
21
|
if (state.principalType !== "organization" ||
|
|
21
|
-
payload.principalType !== "organization" ||
|
|
22
|
-
payload.principalId !== state.principalId ||
|
|
23
|
-
payload.stateHash !== state.stateHash ||
|
|
24
22
|
!isSha256HexString(state.stateHash) ||
|
|
25
23
|
(await computePrincipalStateHash(state)) !== state.stateHash)
|
|
26
24
|
return null;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
hash === payload.ciphertextHash
|
|
30
|
-
? payload
|
|
25
|
+
return (await computePrincipalStatePayloadCiphertextHash(payload.ciphertext)) === state.payloadCiphertextHash
|
|
26
|
+
? { payload, stateHash: state.stateHash }
|
|
31
27
|
: null;
|
|
32
28
|
}
|
|
33
29
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heldDirectoryCitations.js","sourceRoot":"","sources":["heldDirectoryCitations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,0CAA0C,GAC3C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,GAGzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAY/D,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,wBAAwB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAC9D,+BAA+B,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CACxE,CAAC;AACJ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"heldDirectoryCitations.js","sourceRoot":"","sources":["heldDirectoryCitations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,0CAA0C,GAC3C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,GAGzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAY/D,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,wBAAwB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAC9D,+BAA+B,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CACxE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,QAA+B;IAK/B,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IACtE,IAAI,CAAC;QACH,IACE,KAAK,CAAC,aAAa,KAAK,cAAc;YACtC,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,CAAC;YACnC,CAAC,MAAM,yBAAyB,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS;YAE5D,OAAO,IAAI,CAAC;QACd,OAAO,CAAC,MAAM,0CAA0C,CACtD,OAAO,CAAC,UAAU,CACnB,CAAC,KAAK,KAAK,CAAC,qBAAqB;YAChC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;YACzC,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import {\n computePrincipalStateHash,\n computePrincipalStatePayloadCiphertextHash,\n} from \"@tearleads/crypto\";\nimport {\n isPrincipalStatePayloadResponse,\n isPrincipalStateResponse,\n type PrincipalStatePayloadResponse,\n type PrincipalStateResponse,\n} from \"@tearleads/validators/response\";\nimport { isSha256HexString } from \"@tearleads/validators/util\";\n\n/**\n * An organization directory payload a device holds, beside the signed state\n * that commits its hash. Writer projections serve directory payloads as\n * policy evidence; a request may cite a held one by state hash instead.\n */\nexport interface HeldDirectoryCitation {\n readonly directoryState: PrincipalStateResponse;\n readonly directoryPayload: PrincipalStatePayloadResponse;\n}\n\nexport function isHeldDirectoryCitation(\n value: unknown,\n): value is HeldDirectoryCitation {\n return (\n typeof value === \"object\" &&\n value !== null &&\n isPrincipalStateResponse(Reflect.get(value, \"directoryState\")) &&\n isPrincipalStatePayloadResponse(Reflect.get(value, \"directoryPayload\"))\n );\n}\n\n/**\n * The payload, under its state hash, when its organization state recomputes\n * to its own hash and its bytes hash to the `payloadCiphertextHash` that\n * state signs; null otherwise. A payload is only its ciphertext (#2903 P23),\n * so the signed hash is its whole identity: a cited payload is exactly the\n * bytes the server would serve for that state, and verification of the\n * rebuilt evidence decides as if they had travelled.\n */\nexport async function signedDirectoryPayload(\n citation: HeldDirectoryCitation,\n): Promise<{\n readonly payload: PrincipalStatePayloadResponse;\n readonly stateHash: string;\n} | null> {\n const { directoryState: state, directoryPayload: payload } = citation;\n try {\n if (\n state.principalType !== \"organization\" ||\n !isSha256HexString(state.stateHash) ||\n (await computePrincipalStateHash(state)) !== state.stateHash\n )\n return null;\n return (await computePrincipalStatePayloadCiphertextHash(\n payload.ciphertext,\n )) === state.payloadCiphertextHash\n ? { payload, stateHash: state.stateHash }\n : null;\n } catch {\n return null;\n }\n}\n"]}
|