@tearleads/client-sdk 0.1.247 → 0.1.248

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.
Files changed (47) hide show
  1. package/Tearleads.js +4 -2
  2. package/Tearleads.js.map +1 -1
  3. package/data/persistence/principalPolicy/heldOrganizationDirectories.js +53 -0
  4. package/data/persistence/principalPolicy/heldOrganizationDirectories.js.map +1 -0
  5. package/data/persistence/verifiedManifestBundlePersistence.d.ts +8 -3
  6. package/data/persistence/verifiedManifestBundlePersistence.js +34 -15
  7. package/data/persistence/verifiedManifestBundlePersistence.js.map +1 -1
  8. package/internal/api-client/heldDirectoryCitations.d.ts +19 -0
  9. package/internal/api-client/heldDirectoryCitations.js +37 -0
  10. package/internal/api-client/heldDirectoryCitations.js.map +1 -0
  11. package/internal/api-client/index.d.ts +1 -1
  12. package/internal/api-client/index.js.map +1 -1
  13. package/internal/api-client/verifiedManifestCitations.d.ts +16 -6
  14. package/internal/api-client/verifiedManifestCitations.js +32 -13
  15. package/internal/api-client/verifiedManifestCitations.js.map +1 -1
  16. package/internal/api-client/writerProjectionRequests.js +5 -3
  17. package/internal/api-client/writerProjectionRequests.js.map +1 -1
  18. package/internal/validators/knownManifestsRefinements.js +1 -1
  19. package/internal/validators/knownManifestsRefinements.js.map +1 -1
  20. package/internal/validators/operation/writerProjections.d.ts +11 -11
  21. package/internal/validators/operation/writerProjections.js +1 -1
  22. package/internal/validators/operation/writerProjections.js.map +1 -1
  23. package/internal/validators/response/areas/principals.d.ts +2 -1
  24. package/internal/validators/response/areas/principals.js +1 -1
  25. package/internal/validators/response/areas/principals.js.map +1 -1
  26. package/internal/validators/response/container.d.ts +4 -4
  27. package/internal/validators/response/container.js +2 -2
  28. package/internal/validators/response/container.js.map +1 -1
  29. package/internal/validators/response/documentMutation.d.ts +4 -4
  30. package/internal/validators/response/documentMutation.js +2 -2
  31. package/internal/validators/response/documentMutation.js.map +1 -1
  32. package/internal/validators/response/policyEvidenceWire.d.ts +17 -0
  33. package/internal/validators/response/policyEvidenceWire.js +36 -0
  34. package/internal/validators/response/policyEvidenceWire.js.map +1 -0
  35. package/internal/validators/response/projectionPolicyEvidence.d.ts +175 -0
  36. package/internal/validators/response/projectionPolicyEvidence.js +13 -0
  37. package/internal/validators/response/projectionPolicyEvidence.js.map +1 -1
  38. package/internal/validators/response/writerProjectionWire.d.ts +11 -7
  39. package/internal/validators/response/writerProjectionWire.js +19 -10
  40. package/internal/validators/response/writerProjectionWire.js.map +1 -1
  41. package/internal/validators/util/index.d.ts +1 -1
  42. package/internal/validators/util/index.js +1 -1
  43. package/internal/validators/util/index.js.map +1 -1
  44. package/internal/validators/util/knownManifestWire.d.ts +9 -3
  45. package/internal/validators/util/knownManifestWire.js +24 -8
  46. package/internal/validators/util/knownManifestWire.js.map +1 -1
  47. package/package.json +1 -1
@@ -1576,7 +1576,7 @@ export declare const DocumentWriterProjectionWireResponseSchema: z.ZodType<{
1576
1576
  principalId: string;
1577
1577
  principalType: "group" | "organization";
1578
1578
  stateHash: string;
1579
- };
1579
+ } | null;
1580
1580
  }[];
1581
1581
  groups: {
1582
1582
  head: {
@@ -1688,7 +1688,7 @@ export declare const DocumentWriterProjectionWireResponseSchema: z.ZodType<{
1688
1688
  principalId: string;
1689
1689
  principalType: "group" | "organization";
1690
1690
  stateHash: string;
1691
- };
1691
+ } | null;
1692
1692
  }[];
1693
1693
  groups: {
1694
1694
  head: {
@@ -1800,7 +1800,7 @@ export declare const DocumentWriterProjectionWireResponseSchema: z.ZodType<{
1800
1800
  principalId: string;
1801
1801
  principalType: "group" | "organization";
1802
1802
  stateHash: string;
1803
- };
1803
+ } | null;
1804
1804
  }[];
1805
1805
  groups: {
1806
1806
  head: {
@@ -1912,7 +1912,7 @@ export declare const DocumentWriterProjectionWireResponseSchema: z.ZodType<{
1912
1912
  principalId: string;
1913
1913
  principalType: "group" | "organization";
1914
1914
  stateHash: string;
1915
- };
1915
+ } | null;
1916
1916
  }[];
1917
1917
  groups: {
1918
1918
  head: {
@@ -6,7 +6,7 @@ import { writerProjectionManifestBundlesRefinement } from "../writerProjectionRe
6
6
  import { ContainerKeyingPathResponseSchema, ContainerKeyingPathWireResponseSchema, } from "./container.js";
7
7
  import { commitLsnResponseShape, DocumentContentKeyBundleResponseSchema, DocumentKekTargetsResponseSchema, DocumentSyncResponseSchema, } from "./documentSyncSchema.js";
8
8
  import { containerKeyingPathReferences, ManifestBundlesSchema, ManifestHashReferenceSchema, OmittedManifestBundlesSchema, refineManifestBundleReferences, } from "./manifestBundleReferences.js";
9
- import { ProjectionPolicyEvidenceResponseSchema } from "./projectionPolicyEvidence.js";
9
+ import { ProjectionPolicyEvidenceResponseSchema, ProjectionPolicyEvidenceWireResponseSchema, } from "./projectionPolicyEvidence.js";
10
10
  export { DocumentContentKeyBundleResponseSchema, DocumentContentKeyTargetEnvelopeResponseSchema, DocumentKekTargetsResponseSchema, DocumentSyncPullPageResponseSchema, DocumentSyncResponseSchema, DocumentSyncUpdateResponseSchema, } from "./documentSyncSchema.js";
11
11
  /**
12
12
  * What the create transaction committed of a seed: the accepted update id and
@@ -83,7 +83,7 @@ function documentWriterProjectionReferences(projection) {
83
83
  export const DocumentWriterProjectionWireResponseSchema = registerJsonSchemaRuntimeRefinements(loosePlainObject({
84
84
  bundles: ManifestBundlesSchema,
85
85
  omittedBundles: OmittedManifestBundlesSchema,
86
- policyEvidence: ProjectionPolicyEvidenceResponseSchema,
86
+ policyEvidence: ProjectionPolicyEvidenceWireResponseSchema,
87
87
  authorizingContainerPaths: nonEmptyArraySchema(ContainerKeyingPathWireResponseSchema),
88
88
  contentKeyBundle: DocumentContentKeyBundleResponseSchema,
89
89
  /** Present only when the stored content-key bundle targets stale KEKs. */
@@ -1 +1 @@
1
- {"version":3,"file":"documentMutation.js","sourceRoot":"","sources":["documentMutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oCAAoC,EA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,qCAAqC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,OAAO,gCAAgC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,0BAA0B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,KAAc;IAEd,OAAO,sCAAsC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,sCAAsC,CACpD,KAAc;IAEd,OAAO,0CAA0C,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC7E,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { registerJsonSchemaRuntimeRefinements } from \"../jsonSchema\";\nimport {\n arraySchema,\n loosePlainObject,\n nonEmptyArraySchema,\n nonEmptyStringSchema,\n positiveIntegerSchema,\n sha256HexStringSchema,\n} from \"../schema\";\nimport {\n AccessEventBundleWireResponseSchema,\n AccessManifestBundleWireResponseSchema,\n} from \"../util\";\nimport { writerProjectionManifestBundlesRefinement } from \"../writerProjectionRefinements\";\nimport {\n ContainerKeyingPathResponseSchema,\n ContainerKeyingPathWireResponseSchema,\n} from \"./container\";\nimport {\n commitLsnResponseShape,\n type DocumentContentKeyBundleResponse,\n DocumentContentKeyBundleResponseSchema,\n type DocumentKekTargetsResponse,\n DocumentKekTargetsResponseSchema,\n type DocumentSyncResponse,\n DocumentSyncResponseSchema,\n} from \"./documentSyncSchema\";\nimport {\n containerKeyingPathReferences,\n ManifestBundlesSchema,\n ManifestHashReferenceSchema,\n OmittedManifestBundlesSchema,\n refineManifestBundleReferences,\n} from \"./manifestBundleReferences\";\nimport { ProjectionPolicyEvidenceResponseSchema } from \"./projectionPolicyEvidence\";\n\nexport {\n type DocumentContentKeyBundleResponse,\n DocumentContentKeyBundleResponseSchema,\n type DocumentContentKeyTargetEnvelopeResponse,\n DocumentContentKeyTargetEnvelopeResponseSchema,\n type DocumentKekTargetsResponse,\n DocumentKekTargetsResponseSchema,\n type DocumentSyncPullPageResponse,\n DocumentSyncPullPageResponseSchema,\n type DocumentSyncResponse,\n DocumentSyncResponseSchema,\n type DocumentSyncUpdateResponse,\n DocumentSyncUpdateResponseSchema,\n} from \"./documentSyncSchema\";\n\n/**\n * What the create transaction committed of a seed: the accepted update id and\n * the commit position a following sync reads from, as a sync response reports\n * them.\n */\nexport const DocumentCreateSeedResponseSchema = loosePlainObject({\n acceptedOutgoingUpdateIds: arraySchema(nonEmptyStringSchema, 1),\n ...commitLsnResponseShape,\n});\n\nexport type DocumentCreateSeedResponse = z.infer<\n typeof DocumentCreateSeedResponseSchema\n>;\n\n/**\n * A document create or link-set mutation acknowledges by hash: the signed\n * event's hash, the committed link-set manifest hash, the content-key epoch\n * the server stored, and the KEK target hash it resolved. It never echoes the\n * signed event, manifest, state, content-key wraps, or KEK targets; the client\n * compares each hash with the plan it signed and records state built from\n * that plan.\n */\nconst documentMutationAcknowledgementShape = {\n bundleDigest: sha256HexStringSchema,\n contentKeyEpoch: positiveIntegerSchema,\n eventHash: nonEmptyStringSchema,\n id: z.string(),\n manifestHash: nonEmptyStringSchema,\n targetHash: nonEmptyStringSchema,\n} satisfies z.ZodRawShape;\n\nexport const DocumentCreateResponseSchema = loosePlainObject({\n ...documentMutationAcknowledgementShape,\n createdAt: z.string(),\n /** Present exactly when the request carried a seed. */\n initialSync: DocumentCreateSeedResponseSchema.optional(),\n});\n\nexport type DocumentCreateResponse = z.infer<\n typeof DocumentCreateResponseSchema\n>;\n\nexport const DocumentLinkSetMutationResponseSchema = loosePlainObject(\n documentMutationAcknowledgementShape,\n);\n\nexport type DocumentLinkSetMutationResponse = z.infer<\n typeof DocumentLinkSetMutationResponseSchema\n>;\n\nconst documentPurgeProofShape = {\n authorizingContainerPath: nonEmptyArraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n documentContainerManifestHistory: arraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n documentId: nonEmptyStringSchema,\n documentManifest: AccessManifestBundleWireResponseSchema,\n documentManifestContainerPaths: arraySchema(\n arraySchema(AccessManifestBundleWireResponseSchema),\n ),\n documentManifestPredecessors: arraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n purgeEvent: AccessEventBundleWireResponseSchema,\n purgedAt: nonEmptyStringSchema,\n policyEvidence: ProjectionPolicyEvidenceResponseSchema,\n} as const;\n\nexport const DocumentPurgeProofResponseSchema = loosePlainObject(\n documentPurgeProofShape,\n);\n\nexport type DocumentPurgeProofResponse = z.infer<\n typeof DocumentPurgeProofResponseSchema\n>;\n\nexport const DocumentPurgeResponseSchema = loosePlainObject({\n ...documentPurgeProofShape,\n reclaimedBlobStorageKeys: arraySchema(z.string()),\n});\n\nexport type DocumentPurgeResponse = z.infer<typeof DocumentPurgeResponseSchema>;\n\nexport const DocumentWriterProjectionResponseSchema = loosePlainObject({\n policyEvidence: ProjectionPolicyEvidenceResponseSchema,\n authorizingContainerPaths: nonEmptyArraySchema(\n ContainerKeyingPathResponseSchema,\n ),\n contentKeyBundle: DocumentContentKeyBundleResponseSchema,\n /** Present only when the stored content-key bundle targets stale KEKs. */\n contentKeyBundleStale: z.literal(true).optional(),\n documentContainerManifestHistory: arraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n documentId: z.string(),\n documentKekTargets: DocumentKekTargetsResponseSchema,\n documentManifest: AccessManifestBundleWireResponseSchema,\n documentManifestContainerPaths: arraySchema(\n arraySchema(AccessManifestBundleWireResponseSchema),\n ),\n documentManifestHistory: arraySchema(AccessManifestBundleWireResponseSchema),\n});\n\nexport type DocumentWriterProjectionResponse = z.infer<\n typeof DocumentWriterProjectionResponseSchema\n>;\n\nfunction documentWriterProjectionReferences(projection: {\n readonly authorizingContainerPaths: unknown;\n readonly documentContainerManifestHistory: unknown;\n readonly documentManifest: unknown;\n readonly documentManifestContainerPaths: unknown;\n readonly documentManifestHistory: unknown;\n}): unknown[] {\n const listed = (value: unknown): unknown[] =>\n Array.isArray(value) ? value : [];\n return [\n projection.documentManifest,\n ...listed(projection.documentManifestHistory),\n ...listed(projection.documentContainerManifestHistory),\n ...listed(projection.documentManifestContainerPaths).flatMap(listed),\n ...listed(projection.authorizingContainerPaths).flatMap(\n containerKeyingPathReferences,\n ),\n ];\n}\n\n/** The served shape; see ContainerWriterProjectionWireResponseSchema. */\nexport const DocumentWriterProjectionWireResponseSchema =\n registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n bundles: ManifestBundlesSchema,\n omittedBundles: OmittedManifestBundlesSchema,\n policyEvidence: ProjectionPolicyEvidenceResponseSchema,\n authorizingContainerPaths: nonEmptyArraySchema(\n ContainerKeyingPathWireResponseSchema,\n ),\n contentKeyBundle: DocumentContentKeyBundleResponseSchema,\n /** Present only when the stored content-key bundle targets stale KEKs. */\n contentKeyBundleStale: z.literal(true).optional(),\n documentContainerManifestHistory: arraySchema(\n ManifestHashReferenceSchema,\n ),\n documentId: z.string(),\n documentKekTargets: DocumentKekTargetsResponseSchema,\n documentManifest: ManifestHashReferenceSchema,\n documentManifestContainerPaths: arraySchema(\n arraySchema(ManifestHashReferenceSchema),\n ),\n documentManifestHistory: arraySchema(ManifestHashReferenceSchema),\n }).superRefine((projection, context) =>\n refineManifestBundleReferences(\n projection,\n documentWriterProjectionReferences(projection),\n context,\n ),\n ),\n [writerProjectionManifestBundlesRefinement],\n );\n\nexport type DocumentWriterProjectionWireResponse = z.infer<\n typeof DocumentWriterProjectionWireResponseSchema\n>;\n\n/**\n * Derives the KEK-target summary that corresponds to a content-key bundle,\n * preserving the bundle's served target order. Both the API (for stale-bundle\n * read-only sync responses) and clients (for plans built against a stale\n * bundle) must derive this identically so response/plan state comparisons\n * hold byte-for-byte.\n */\nexport function documentKekTargetsFromContentKeyBundle(\n bundle: DocumentContentKeyBundleResponse,\n): DocumentKekTargetsResponse {\n const targets = bundle.targets.map((target) => ({\n containerId: target.containerId,\n containerManifestHash: target.containerManifestHash,\n containerKeyEpochId: target.containerKeyEpochId,\n containerKeyEpoch: target.containerKeyEpoch,\n }));\n\n return {\n documentId: bundle.documentId,\n documentKeyTargetHash: bundle.targetHash,\n linkSetManifestHash: bundle.linkSetManifestHash,\n linkedContainerKeyEpochIds: targets.map(\n (target) => target.containerKeyEpochId,\n ),\n linkedContainerManifestHashes: targets.map(\n (target) => target.containerManifestHash,\n ),\n targets,\n };\n}\n\nexport function isDocumentKekTargetsResponse(\n value: unknown,\n): value is DocumentKekTargetsResponse {\n return DocumentKekTargetsResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentContentKeyBundleResponse(\n value: unknown,\n): value is DocumentContentKeyBundleResponse {\n return DocumentContentKeyBundleResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentCreateResponse(\n value: unknown,\n): value is DocumentCreateResponse {\n return DocumentCreateResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentLinkSetMutationResponse(\n value: unknown,\n): value is DocumentLinkSetMutationResponse {\n return DocumentLinkSetMutationResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentPurgeResponse(\n value: unknown,\n): value is DocumentPurgeResponse {\n return DocumentPurgeResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentPurgeProofResponse(\n value: unknown,\n): value is DocumentPurgeProofResponse {\n return DocumentPurgeProofResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentSyncResponse(\n value: unknown,\n): value is DocumentSyncResponse {\n return DocumentSyncResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentWriterProjectionResponse(\n value: unknown,\n): value is DocumentWriterProjectionResponse {\n return DocumentWriterProjectionResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentWriterProjectionWireResponse(\n value: unknown,\n): value is DocumentWriterProjectionWireResponse {\n return DocumentWriterProjectionWireResponseSchema.safeParse(value).success;\n}\n"]}
1
+ {"version":3,"file":"documentMutation.js","sourceRoot":"","sources":["documentMutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,mCAAmC,EACnC,sCAAsC,GACvC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,yCAAyC,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EACL,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EAEtB,sCAAsC,EAEtC,gCAAgC,EAEhC,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sCAAsC,EACtC,0CAA0C,GAC3C,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEL,sCAAsC,EAEtC,8CAA8C,EAE9C,gCAAgC,EAEhC,kCAAkC,EAElC,0BAA0B,EAE1B,gCAAgC,GACjC,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,gBAAgB,CAAC;IAC/D,yBAAyB,EAAE,WAAW,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC/D,GAAG,sBAAsB;CAC1B,CAAC,CAAC;AAMH;;;;;;;GAOG;AACH,MAAM,oCAAoC,GAAG;IAC3C,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AAC;AAED,MAAM,UAAU,kCAAkC,CAChD,KAAc;IAEd,OAAO,sCAAsC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAc;IAEd,OAAO,4BAA4B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,KAAc;IAEd,OAAO,qCAAqC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,OAAO,gCAAgC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,0BAA0B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,KAAc;IAEd,OAAO,sCAAsC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,sCAAsC,CACpD,KAAc;IAEd,OAAO,0CAA0C,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC7E,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { registerJsonSchemaRuntimeRefinements } from \"../jsonSchema\";\nimport {\n arraySchema,\n loosePlainObject,\n nonEmptyArraySchema,\n nonEmptyStringSchema,\n positiveIntegerSchema,\n sha256HexStringSchema,\n} from \"../schema\";\nimport {\n AccessEventBundleWireResponseSchema,\n AccessManifestBundleWireResponseSchema,\n} from \"../util\";\nimport { writerProjectionManifestBundlesRefinement } from \"../writerProjectionRefinements\";\nimport {\n ContainerKeyingPathResponseSchema,\n ContainerKeyingPathWireResponseSchema,\n} from \"./container\";\nimport {\n commitLsnResponseShape,\n type DocumentContentKeyBundleResponse,\n DocumentContentKeyBundleResponseSchema,\n type DocumentKekTargetsResponse,\n DocumentKekTargetsResponseSchema,\n type DocumentSyncResponse,\n DocumentSyncResponseSchema,\n} from \"./documentSyncSchema\";\nimport {\n containerKeyingPathReferences,\n ManifestBundlesSchema,\n ManifestHashReferenceSchema,\n OmittedManifestBundlesSchema,\n refineManifestBundleReferences,\n} from \"./manifestBundleReferences\";\nimport {\n ProjectionPolicyEvidenceResponseSchema,\n ProjectionPolicyEvidenceWireResponseSchema,\n} from \"./projectionPolicyEvidence\";\n\nexport {\n type DocumentContentKeyBundleResponse,\n DocumentContentKeyBundleResponseSchema,\n type DocumentContentKeyTargetEnvelopeResponse,\n DocumentContentKeyTargetEnvelopeResponseSchema,\n type DocumentKekTargetsResponse,\n DocumentKekTargetsResponseSchema,\n type DocumentSyncPullPageResponse,\n DocumentSyncPullPageResponseSchema,\n type DocumentSyncResponse,\n DocumentSyncResponseSchema,\n type DocumentSyncUpdateResponse,\n DocumentSyncUpdateResponseSchema,\n} from \"./documentSyncSchema\";\n\n/**\n * What the create transaction committed of a seed: the accepted update id and\n * the commit position a following sync reads from, as a sync response reports\n * them.\n */\nexport const DocumentCreateSeedResponseSchema = loosePlainObject({\n acceptedOutgoingUpdateIds: arraySchema(nonEmptyStringSchema, 1),\n ...commitLsnResponseShape,\n});\n\nexport type DocumentCreateSeedResponse = z.infer<\n typeof DocumentCreateSeedResponseSchema\n>;\n\n/**\n * A document create or link-set mutation acknowledges by hash: the signed\n * event's hash, the committed link-set manifest hash, the content-key epoch\n * the server stored, and the KEK target hash it resolved. It never echoes the\n * signed event, manifest, state, content-key wraps, or KEK targets; the client\n * compares each hash with the plan it signed and records state built from\n * that plan.\n */\nconst documentMutationAcknowledgementShape = {\n bundleDigest: sha256HexStringSchema,\n contentKeyEpoch: positiveIntegerSchema,\n eventHash: nonEmptyStringSchema,\n id: z.string(),\n manifestHash: nonEmptyStringSchema,\n targetHash: nonEmptyStringSchema,\n} satisfies z.ZodRawShape;\n\nexport const DocumentCreateResponseSchema = loosePlainObject({\n ...documentMutationAcknowledgementShape,\n createdAt: z.string(),\n /** Present exactly when the request carried a seed. */\n initialSync: DocumentCreateSeedResponseSchema.optional(),\n});\n\nexport type DocumentCreateResponse = z.infer<\n typeof DocumentCreateResponseSchema\n>;\n\nexport const DocumentLinkSetMutationResponseSchema = loosePlainObject(\n documentMutationAcknowledgementShape,\n);\n\nexport type DocumentLinkSetMutationResponse = z.infer<\n typeof DocumentLinkSetMutationResponseSchema\n>;\n\nconst documentPurgeProofShape = {\n authorizingContainerPath: nonEmptyArraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n documentContainerManifestHistory: arraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n documentId: nonEmptyStringSchema,\n documentManifest: AccessManifestBundleWireResponseSchema,\n documentManifestContainerPaths: arraySchema(\n arraySchema(AccessManifestBundleWireResponseSchema),\n ),\n documentManifestPredecessors: arraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n purgeEvent: AccessEventBundleWireResponseSchema,\n purgedAt: nonEmptyStringSchema,\n policyEvidence: ProjectionPolicyEvidenceResponseSchema,\n} as const;\n\nexport const DocumentPurgeProofResponseSchema = loosePlainObject(\n documentPurgeProofShape,\n);\n\nexport type DocumentPurgeProofResponse = z.infer<\n typeof DocumentPurgeProofResponseSchema\n>;\n\nexport const DocumentPurgeResponseSchema = loosePlainObject({\n ...documentPurgeProofShape,\n reclaimedBlobStorageKeys: arraySchema(z.string()),\n});\n\nexport type DocumentPurgeResponse = z.infer<typeof DocumentPurgeResponseSchema>;\n\nexport const DocumentWriterProjectionResponseSchema = loosePlainObject({\n policyEvidence: ProjectionPolicyEvidenceResponseSchema,\n authorizingContainerPaths: nonEmptyArraySchema(\n ContainerKeyingPathResponseSchema,\n ),\n contentKeyBundle: DocumentContentKeyBundleResponseSchema,\n /** Present only when the stored content-key bundle targets stale KEKs. */\n contentKeyBundleStale: z.literal(true).optional(),\n documentContainerManifestHistory: arraySchema(\n AccessManifestBundleWireResponseSchema,\n ),\n documentId: z.string(),\n documentKekTargets: DocumentKekTargetsResponseSchema,\n documentManifest: AccessManifestBundleWireResponseSchema,\n documentManifestContainerPaths: arraySchema(\n arraySchema(AccessManifestBundleWireResponseSchema),\n ),\n documentManifestHistory: arraySchema(AccessManifestBundleWireResponseSchema),\n});\n\nexport type DocumentWriterProjectionResponse = z.infer<\n typeof DocumentWriterProjectionResponseSchema\n>;\n\nfunction documentWriterProjectionReferences(projection: {\n readonly authorizingContainerPaths: unknown;\n readonly documentContainerManifestHistory: unknown;\n readonly documentManifest: unknown;\n readonly documentManifestContainerPaths: unknown;\n readonly documentManifestHistory: unknown;\n}): unknown[] {\n const listed = (value: unknown): unknown[] =>\n Array.isArray(value) ? value : [];\n return [\n projection.documentManifest,\n ...listed(projection.documentManifestHistory),\n ...listed(projection.documentContainerManifestHistory),\n ...listed(projection.documentManifestContainerPaths).flatMap(listed),\n ...listed(projection.authorizingContainerPaths).flatMap(\n containerKeyingPathReferences,\n ),\n ];\n}\n\n/** The served shape; see ContainerWriterProjectionWireResponseSchema. */\nexport const DocumentWriterProjectionWireResponseSchema =\n registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n bundles: ManifestBundlesSchema,\n omittedBundles: OmittedManifestBundlesSchema,\n policyEvidence: ProjectionPolicyEvidenceWireResponseSchema,\n authorizingContainerPaths: nonEmptyArraySchema(\n ContainerKeyingPathWireResponseSchema,\n ),\n contentKeyBundle: DocumentContentKeyBundleResponseSchema,\n /** Present only when the stored content-key bundle targets stale KEKs. */\n contentKeyBundleStale: z.literal(true).optional(),\n documentContainerManifestHistory: arraySchema(\n ManifestHashReferenceSchema,\n ),\n documentId: z.string(),\n documentKekTargets: DocumentKekTargetsResponseSchema,\n documentManifest: ManifestHashReferenceSchema,\n documentManifestContainerPaths: arraySchema(\n arraySchema(ManifestHashReferenceSchema),\n ),\n documentManifestHistory: arraySchema(ManifestHashReferenceSchema),\n }).superRefine((projection, context) =>\n refineManifestBundleReferences(\n projection,\n documentWriterProjectionReferences(projection),\n context,\n ),\n ),\n [writerProjectionManifestBundlesRefinement],\n );\n\nexport type DocumentWriterProjectionWireResponse = z.infer<\n typeof DocumentWriterProjectionWireResponseSchema\n>;\n\n/**\n * Derives the KEK-target summary that corresponds to a content-key bundle,\n * preserving the bundle's served target order. Both the API (for stale-bundle\n * read-only sync responses) and clients (for plans built against a stale\n * bundle) must derive this identically so response/plan state comparisons\n * hold byte-for-byte.\n */\nexport function documentKekTargetsFromContentKeyBundle(\n bundle: DocumentContentKeyBundleResponse,\n): DocumentKekTargetsResponse {\n const targets = bundle.targets.map((target) => ({\n containerId: target.containerId,\n containerManifestHash: target.containerManifestHash,\n containerKeyEpochId: target.containerKeyEpochId,\n containerKeyEpoch: target.containerKeyEpoch,\n }));\n\n return {\n documentId: bundle.documentId,\n documentKeyTargetHash: bundle.targetHash,\n linkSetManifestHash: bundle.linkSetManifestHash,\n linkedContainerKeyEpochIds: targets.map(\n (target) => target.containerKeyEpochId,\n ),\n linkedContainerManifestHashes: targets.map(\n (target) => target.containerManifestHash,\n ),\n targets,\n };\n}\n\nexport function isDocumentKekTargetsResponse(\n value: unknown,\n): value is DocumentKekTargetsResponse {\n return DocumentKekTargetsResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentContentKeyBundleResponse(\n value: unknown,\n): value is DocumentContentKeyBundleResponse {\n return DocumentContentKeyBundleResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentCreateResponse(\n value: unknown,\n): value is DocumentCreateResponse {\n return DocumentCreateResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentLinkSetMutationResponse(\n value: unknown,\n): value is DocumentLinkSetMutationResponse {\n return DocumentLinkSetMutationResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentPurgeResponse(\n value: unknown,\n): value is DocumentPurgeResponse {\n return DocumentPurgeResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentPurgeProofResponse(\n value: unknown,\n): value is DocumentPurgeProofResponse {\n return DocumentPurgeProofResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentSyncResponse(\n value: unknown,\n): value is DocumentSyncResponse {\n return DocumentSyncResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentWriterProjectionResponse(\n value: unknown,\n): value is DocumentWriterProjectionResponse {\n return DocumentWriterProjectionResponseSchema.safeParse(value).success;\n}\n\nexport function isDocumentWriterProjectionWireResponse(\n value: unknown,\n): value is DocumentWriterProjectionWireResponse {\n return DocumentWriterProjectionWireResponseSchema.safeParse(value).success;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { PrincipalStatePayloadResponse } from "./principalSnapshot.js";
2
+ import type { ProjectionPolicyEvidenceResponse, ProjectionPolicyEvidenceWireResponse } from "./projectionPolicyEvidence.js";
3
+ /** Directory payloads a request declared held, by organization state hash. */
4
+ export type HeldDirectoryPayloads = ReadonlyMap<string, PrincipalStatePayloadResponse>;
5
+ /**
6
+ * The served evidence: each directory payload whose organization state the
7
+ * request declared held is `null`; everything else travels. Call after the
8
+ * evidence is loaded and checked as for any reader. Unknown hashes are
9
+ * ignored.
10
+ */
11
+ export declare function encodeProjectionPolicyEvidence(evidence: ProjectionPolicyEvidenceResponse, heldDirectories: ReadonlySet<string>): ProjectionPolicyEvidenceWireResponse;
12
+ /**
13
+ * Fills each omitted directory payload with its own copy of the exact payload
14
+ * the request cited under that state hash. An omission the request did not
15
+ * cite makes the evidence unusable, so the caller refetches in full.
16
+ */
17
+ export declare function decodeProjectionPolicyEvidence(evidence: ProjectionPolicyEvidenceWireResponse, heldDirectories: HeldDirectoryPayloads): ProjectionPolicyEvidenceResponse | null;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The served evidence: each directory payload whose organization state the
3
+ * request declared held is `null`; everything else travels. Call after the
4
+ * evidence is loaded and checked as for any reader. Unknown hashes are
5
+ * ignored.
6
+ */
7
+ export function encodeProjectionPolicyEvidence(evidence, heldDirectories) {
8
+ if (heldDirectories.size === 0)
9
+ return evidence;
10
+ return {
11
+ ...evidence,
12
+ organizationPayloads: evidence.organizationPayloads.map((entry) => heldDirectories.has(entry.reference.stateHash)
13
+ ? { ...entry, payload: null }
14
+ : entry),
15
+ };
16
+ }
17
+ /**
18
+ * Fills each omitted directory payload with its own copy of the exact payload
19
+ * the request cited under that state hash. An omission the request did not
20
+ * cite makes the evidence unusable, so the caller refetches in full.
21
+ */
22
+ export function decodeProjectionPolicyEvidence(evidence, heldDirectories) {
23
+ const organizationPayloads = [];
24
+ for (const entry of evidence.organizationPayloads) {
25
+ if (entry.payload !== null) {
26
+ organizationPayloads.push({ ...entry, payload: entry.payload });
27
+ continue;
28
+ }
29
+ const payload = heldDirectories.get(entry.reference.stateHash);
30
+ if (payload?.stateHash !== entry.reference.stateHash)
31
+ return null;
32
+ organizationPayloads.push({ ...entry, payload: structuredClone(payload) });
33
+ }
34
+ return { ...evidence, organizationPayloads };
35
+ }
36
+ //# sourceMappingURL=policyEvidenceWire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policyEvidenceWire.js","sourceRoot":"","sources":["policyEvidenceWire.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA0C,EAC1C,eAAoC;IAEpC,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAChD,OAAO;QACL,GAAG,QAAQ;QACX,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAChE,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;YAC5C,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE;YAC7B,CAAC,CAAC,KAAK,CACV;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA8C,EAC9C,eAAsC;IAEtC,MAAM,oBAAoB,GACxB,EAAE,CAAC;IACL,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QAClD,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC3B,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAChE,SAAS;QACX,CAAC;QACD,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC/D,IAAI,OAAO,EAAE,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAClE,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,EAAE,GAAG,QAAQ,EAAE,oBAAoB,EAAE,CAAC;AAC/C,CAAC","sourcesContent":["import type { PrincipalStatePayloadResponse } from \"./principalSnapshot\";\nimport type {\n ProjectionPolicyEvidenceResponse,\n ProjectionPolicyEvidenceWireResponse,\n} from \"./projectionPolicyEvidence\";\n\n/** Directory payloads a request declared held, by organization state hash. */\nexport type HeldDirectoryPayloads = ReadonlyMap<\n string,\n PrincipalStatePayloadResponse\n>;\n\n/**\n * The served evidence: each directory payload whose organization state the\n * request declared held is `null`; everything else travels. Call after the\n * evidence is loaded and checked as for any reader. Unknown hashes are\n * ignored.\n */\nexport function encodeProjectionPolicyEvidence(\n evidence: ProjectionPolicyEvidenceResponse,\n heldDirectories: ReadonlySet<string>,\n): ProjectionPolicyEvidenceWireResponse {\n if (heldDirectories.size === 0) return evidence;\n return {\n ...evidence,\n organizationPayloads: evidence.organizationPayloads.map((entry) =>\n heldDirectories.has(entry.reference.stateHash)\n ? { ...entry, payload: null }\n : entry,\n ),\n };\n}\n\n/**\n * Fills each omitted directory payload with its own copy of the exact payload\n * the request cited under that state hash. An omission the request did not\n * cite makes the evidence unusable, so the caller refetches in full.\n */\nexport function decodeProjectionPolicyEvidence(\n evidence: ProjectionPolicyEvidenceWireResponse,\n heldDirectories: HeldDirectoryPayloads,\n): ProjectionPolicyEvidenceResponse | null {\n const organizationPayloads: ProjectionPolicyEvidenceResponse[\"organizationPayloads\"] =\n [];\n for (const entry of evidence.organizationPayloads) {\n if (entry.payload !== null) {\n organizationPayloads.push({ ...entry, payload: entry.payload });\n continue;\n }\n const payload = heldDirectories.get(entry.reference.stateHash);\n if (payload?.stateHash !== entry.reference.stateHash) return null;\n organizationPayloads.push({ ...entry, payload: structuredClone(payload) });\n }\n return { ...evidence, organizationPayloads };\n}\n"]}
@@ -170,3 +170,178 @@ export declare const ProjectionPolicyEvidenceResponseSchema: z.ZodType<{
170
170
  }[];
171
171
  }>>;
172
172
  export type ProjectionPolicyEvidenceResponse = z.infer<typeof ProjectionPolicyEvidenceResponseSchema>;
173
+ /**
174
+ * The served evidence: a directory payload is `null` exactly when the
175
+ * request cited its organization state as held (`d:` in
176
+ * `x-known-manifests`); decoding fills it from the cited bytes.
177
+ */
178
+ export declare const ProjectionPolicyEvidenceWireResponseSchema: z.ZodType<{
179
+ organization: {
180
+ head: {
181
+ keyEpoch: number;
182
+ keyFingerprint: string;
183
+ principalId: string;
184
+ principalType: "group" | "organization";
185
+ stateHash: string;
186
+ version: number;
187
+ };
188
+ grant: string;
189
+ } | null;
190
+ organizationPayloads: {
191
+ reference: {
192
+ keyEpoch: number;
193
+ keyFingerprint: string;
194
+ principalId: string;
195
+ principalType: "group" | "organization";
196
+ stateHash: string;
197
+ version: number;
198
+ };
199
+ payload: {
200
+ cipherSuite: "aes-256-gcm";
201
+ ciphertext: string;
202
+ ciphertextHash: string;
203
+ createdAt: string;
204
+ principalId: string;
205
+ principalType: "group" | "organization";
206
+ stateHash: string;
207
+ } | null;
208
+ }[];
209
+ groups: {
210
+ head: {
211
+ keyEpoch: number;
212
+ keyFingerprint: string;
213
+ principalId: string;
214
+ principalType: "group" | "organization";
215
+ stateHash: string;
216
+ version: number;
217
+ };
218
+ grant: string;
219
+ }[];
220
+ }, {
221
+ organization: {
222
+ head: {
223
+ keyEpoch: number;
224
+ keyFingerprint: string;
225
+ principalId: string;
226
+ principalType: "group" | "organization";
227
+ stateHash: string;
228
+ version: number;
229
+ };
230
+ grant: string;
231
+ } | null;
232
+ organizationPayloads: {
233
+ reference: {
234
+ keyEpoch: number;
235
+ keyFingerprint: string;
236
+ principalId: string;
237
+ principalType: "group" | "organization";
238
+ stateHash: string;
239
+ version: number;
240
+ };
241
+ payload: {
242
+ cipherSuite: "aes-256-gcm";
243
+ ciphertext: string;
244
+ ciphertextHash: string;
245
+ createdAt: string;
246
+ principalId: string;
247
+ principalType: "group" | "organization";
248
+ stateHash: string;
249
+ } | null;
250
+ }[];
251
+ groups: {
252
+ head: {
253
+ keyEpoch: number;
254
+ keyFingerprint: string;
255
+ principalId: string;
256
+ principalType: "group" | "organization";
257
+ stateHash: string;
258
+ version: number;
259
+ };
260
+ grant: string;
261
+ }[];
262
+ }, z.core.$ZodTypeInternals<{
263
+ organization: {
264
+ head: {
265
+ keyEpoch: number;
266
+ keyFingerprint: string;
267
+ principalId: string;
268
+ principalType: "group" | "organization";
269
+ stateHash: string;
270
+ version: number;
271
+ };
272
+ grant: string;
273
+ } | null;
274
+ organizationPayloads: {
275
+ reference: {
276
+ keyEpoch: number;
277
+ keyFingerprint: string;
278
+ principalId: string;
279
+ principalType: "group" | "organization";
280
+ stateHash: string;
281
+ version: number;
282
+ };
283
+ payload: {
284
+ cipherSuite: "aes-256-gcm";
285
+ ciphertext: string;
286
+ ciphertextHash: string;
287
+ createdAt: string;
288
+ principalId: string;
289
+ principalType: "group" | "organization";
290
+ stateHash: string;
291
+ } | null;
292
+ }[];
293
+ groups: {
294
+ head: {
295
+ keyEpoch: number;
296
+ keyFingerprint: string;
297
+ principalId: string;
298
+ principalType: "group" | "organization";
299
+ stateHash: string;
300
+ version: number;
301
+ };
302
+ grant: string;
303
+ }[];
304
+ }, {
305
+ organization: {
306
+ head: {
307
+ keyEpoch: number;
308
+ keyFingerprint: string;
309
+ principalId: string;
310
+ principalType: "group" | "organization";
311
+ stateHash: string;
312
+ version: number;
313
+ };
314
+ grant: string;
315
+ } | null;
316
+ organizationPayloads: {
317
+ reference: {
318
+ keyEpoch: number;
319
+ keyFingerprint: string;
320
+ principalId: string;
321
+ principalType: "group" | "organization";
322
+ stateHash: string;
323
+ version: number;
324
+ };
325
+ payload: {
326
+ cipherSuite: "aes-256-gcm";
327
+ ciphertext: string;
328
+ ciphertextHash: string;
329
+ createdAt: string;
330
+ principalId: string;
331
+ principalType: "group" | "organization";
332
+ stateHash: string;
333
+ } | null;
334
+ }[];
335
+ groups: {
336
+ head: {
337
+ keyEpoch: number;
338
+ keyFingerprint: string;
339
+ principalId: string;
340
+ principalType: "group" | "organization";
341
+ stateHash: string;
342
+ version: number;
343
+ };
344
+ grant: string;
345
+ }[];
346
+ }>>;
347
+ export type ProjectionPolicyEvidenceWireResponse = z.infer<typeof ProjectionPolicyEvidenceWireResponseSchema>;
@@ -11,4 +11,17 @@ export const ProjectionPolicyEvidenceResponseSchema = loosePlainObject({
11
11
  })),
12
12
  groups: arraySchema(PrincipalPolicyHistorySourceResponseSchema),
13
13
  });
14
+ /**
15
+ * The served evidence: a directory payload is `null` exactly when the
16
+ * request cited its organization state as held (`d:` in
17
+ * `x-known-manifests`); decoding fills it from the cited bytes.
18
+ */
19
+ export const ProjectionPolicyEvidenceWireResponseSchema = loosePlainObject({
20
+ organization: PrincipalPolicyHistorySourceResponseSchema.nullable(),
21
+ organizationPayloads: arraySchema(loosePlainObject({
22
+ reference: ReferencedPrincipalStateResponseSchema,
23
+ payload: PrincipalStatePayloadResponseSchema.nullable(),
24
+ })),
25
+ groups: arraySchema(PrincipalPolicyHistorySourceResponseSchema),
26
+ });
14
27
  //# sourceMappingURL=projectionPolicyEvidence.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"projectionPolicyEvidence.js","sourceRoot":"","sources":["projectionPolicyEvidence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,0CAA0C,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,sCAAsC,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAE1E,kFAAkF;AAClF,MAAM,CAAC,MAAM,sCAAsC,GAAG,gBAAgB,CAAC;IACrE,YAAY,EAAE,0CAA0C,CAAC,QAAQ,EAAE;IACnE,oBAAoB,EAAE,WAAW,CAC/B,gBAAgB,CAAC;QACf,SAAS,EAAE,sCAAsC;QACjD,OAAO,EAAE,mCAAmC;KAC7C,CAAC,CACH;IACD,MAAM,EAAE,WAAW,CAAC,0CAA0C,CAAC;CAChE,CAAC,CAAC","sourcesContent":["import type { z } from \"zod\";\nimport { arraySchema, loosePlainObject } from \"../schema\";\nimport { PrincipalPolicyHistorySourceResponseSchema } from \"./principalPolicySnapshotPage\";\nimport { ReferencedPrincipalStateResponseSchema } from \"./principalReference\";\nimport { PrincipalStatePayloadResponseSchema } from \"./principalSnapshot\";\n\n/** Pinned public history sources plus the signed directory payloads they need. */\nexport const ProjectionPolicyEvidenceResponseSchema = loosePlainObject({\n organization: PrincipalPolicyHistorySourceResponseSchema.nullable(),\n organizationPayloads: arraySchema(\n loosePlainObject({\n reference: ReferencedPrincipalStateResponseSchema,\n payload: PrincipalStatePayloadResponseSchema,\n }),\n ),\n groups: arraySchema(PrincipalPolicyHistorySourceResponseSchema),\n});\n\nexport type ProjectionPolicyEvidenceResponse = z.infer<\n typeof ProjectionPolicyEvidenceResponseSchema\n>;\n"]}
1
+ {"version":3,"file":"projectionPolicyEvidence.js","sourceRoot":"","sources":["projectionPolicyEvidence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,0CAA0C,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,sCAAsC,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAE1E,kFAAkF;AAClF,MAAM,CAAC,MAAM,sCAAsC,GAAG,gBAAgB,CAAC;IACrE,YAAY,EAAE,0CAA0C,CAAC,QAAQ,EAAE;IACnE,oBAAoB,EAAE,WAAW,CAC/B,gBAAgB,CAAC;QACf,SAAS,EAAE,sCAAsC;QACjD,OAAO,EAAE,mCAAmC;KAC7C,CAAC,CACH;IACD,MAAM,EAAE,WAAW,CAAC,0CAA0C,CAAC;CAChE,CAAC,CAAC;AAMH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,gBAAgB,CAAC;IACzE,YAAY,EAAE,0CAA0C,CAAC,QAAQ,EAAE;IACnE,oBAAoB,EAAE,WAAW,CAC/B,gBAAgB,CAAC;QACf,SAAS,EAAE,sCAAsC;QACjD,OAAO,EAAE,mCAAmC,CAAC,QAAQ,EAAE;KACxD,CAAC,CACH;IACD,MAAM,EAAE,WAAW,CAAC,0CAA0C,CAAC;CAChE,CAAC,CAAC","sourcesContent":["import type { z } from \"zod\";\nimport { arraySchema, loosePlainObject } from \"../schema\";\nimport { PrincipalPolicyHistorySourceResponseSchema } from \"./principalPolicySnapshotPage\";\nimport { ReferencedPrincipalStateResponseSchema } from \"./principalReference\";\nimport { PrincipalStatePayloadResponseSchema } from \"./principalSnapshot\";\n\n/** Pinned public history sources plus the signed directory payloads they need. */\nexport const ProjectionPolicyEvidenceResponseSchema = loosePlainObject({\n organization: PrincipalPolicyHistorySourceResponseSchema.nullable(),\n organizationPayloads: arraySchema(\n loosePlainObject({\n reference: ReferencedPrincipalStateResponseSchema,\n payload: PrincipalStatePayloadResponseSchema,\n }),\n ),\n groups: arraySchema(PrincipalPolicyHistorySourceResponseSchema),\n});\n\nexport type ProjectionPolicyEvidenceResponse = z.infer<\n typeof ProjectionPolicyEvidenceResponseSchema\n>;\n\n/**\n * The served evidence: a directory payload is `null` exactly when the\n * request cited its organization state as held (`d:` in\n * `x-known-manifests`); decoding fills it from the cited bytes.\n */\nexport const ProjectionPolicyEvidenceWireResponseSchema = loosePlainObject({\n organization: PrincipalPolicyHistorySourceResponseSchema.nullable(),\n organizationPayloads: arraySchema(\n loosePlainObject({\n reference: ReferencedPrincipalStateResponseSchema,\n payload: PrincipalStatePayloadResponseSchema.nullable(),\n }),\n ),\n groups: arraySchema(PrincipalPolicyHistorySourceResponseSchema),\n});\n\nexport type ProjectionPolicyEvidenceWireResponse = z.infer<\n typeof ProjectionPolicyEvidenceWireResponseSchema\n>;\n"]}
@@ -1,6 +1,7 @@
1
1
  import { type ServedAccessManifestBundleWireResponse } from "../util/index.js";
2
2
  import { type ContainerKekResponse, type ContainerKekWireLevel, type ContainerWriterProjectionResponse, type ContainerWriterProjectionWireResponse } from "./container.js";
3
3
  import { type DocumentWriterProjectionResponse, type DocumentWriterProjectionWireResponse } from "./documentMutation.js";
4
+ import { type HeldDirectoryPayloads } from "./policyEvidenceWire.js";
4
5
  type ServedBundle = ServedAccessManifestBundleWireResponse;
5
6
  type HeldLevels = ReadonlyMap<string, ContainerKekWireLevel>;
6
7
  /** A KEK level's wire form: its manifest history cited by hash. */
@@ -14,11 +15,13 @@ export type HeldKekLevelDigest = (kek: ContainerKekResponse) => string | null;
14
15
  /**
15
16
  * Call only after authorization and stored-evidence verification. `known`
16
17
  * holds the request's manifest hints; only hashes this projection cites are
17
- * omitted. `heldLevel` names each KEK level the request holds exactly.
18
+ * omitted. `heldLevel` names each KEK level the request holds exactly, and
19
+ * `heldDirectories` the organization states whose directory payloads it
20
+ * holds.
18
21
  */
19
- export declare function encodeContainerWriterProjection(projection: ContainerWriterProjectionResponse, known?: ReadonlySet<string>, heldLevel?: HeldKekLevelDigest): ContainerWriterProjectionWireResponse;
22
+ export declare function encodeContainerWriterProjection(projection: ContainerWriterProjectionResponse, known?: ReadonlySet<string>, heldLevel?: HeldKekLevelDigest, heldDirectories?: ReadonlySet<string>): ContainerWriterProjectionWireResponse;
20
23
  /** See {@link encodeContainerWriterProjection}. */
21
- export declare function encodeDocumentWriterProjection(projection: DocumentWriterProjectionResponse, known?: ReadonlySet<string>, heldLevel?: HeldKekLevelDigest): DocumentWriterProjectionWireResponse;
24
+ export declare function encodeDocumentWriterProjection(projection: DocumentWriterProjectionResponse, known?: ReadonlySet<string>, heldLevel?: HeldKekLevelDigest, heldDirectories?: ReadonlySet<string>): DocumentWriterProjectionWireResponse;
22
25
  /**
23
26
  * The held bundles a decoded projection filled omissions from. A verifier
24
27
  * that refuses such a projection drops exactly those held rows, so the next
@@ -45,11 +48,12 @@ export declare function rejectDecodedProjection(projection: object): void;
45
48
  export declare function acceptDecodedProjection(projection: object): void;
46
49
  export declare function isRejectedDecodedProjection(projection: unknown): boolean;
47
50
  /**
48
- * Null for any wire inconsistency or an omission `held` (bundles) or
49
- * `heldLevels` (KEK levels by digest) cannot fill; the caller treats either
51
+ * Null for any wire inconsistency or an omission `held` (bundles),
52
+ * `heldLevels` (KEK levels by digest) or `heldDirectories` (directory
53
+ * payloads by organization state hash) cannot fill; the caller treats either
50
54
  * as a shape failure.
51
55
  */
52
- export declare function decodeContainerWriterProjection(value: unknown, held?: ReadonlyMap<string, ServedBundle>, heldLevels?: HeldLevels): ContainerWriterProjectionResponse | null;
56
+ export declare function decodeContainerWriterProjection(value: unknown, held?: ReadonlyMap<string, ServedBundle>, heldLevels?: HeldLevels, heldDirectories?: HeldDirectoryPayloads): ContainerWriterProjectionResponse | null;
53
57
  /** See {@link decodeContainerWriterProjection}. */
54
- export declare function decodeDocumentWriterProjection(value: unknown, held?: ReadonlyMap<string, ServedBundle>, heldLevels?: HeldLevels): DocumentWriterProjectionResponse | null;
58
+ export declare function decodeDocumentWriterProjection(value: unknown, held?: ReadonlyMap<string, ServedBundle>, heldLevels?: HeldLevels, heldDirectories?: HeldDirectoryPayloads): DocumentWriterProjectionResponse | null;
55
59
  export {};
@@ -1,6 +1,7 @@
1
1
  import { completeServedAccessManifestBundle, toServedAccessManifestBundle, } from "../util/index.js";
2
2
  import { ContainerWriterProjectionWireResponseSchema, isCitedContainerKekLevel, } from "./container.js";
3
3
  import { DocumentWriterProjectionWireResponseSchema, } from "./documentMutation.js";
4
+ import { decodeProjectionPolicyEvidence, encodeProjectionPolicyEvidence, } from "./policyEvidenceWire.js";
4
5
  /**
5
6
  * Collects each distinct manifest once. Every slot a server fills for one
6
7
  * hash comes from the same stored row, and the client verifies the bundle it
@@ -55,24 +56,28 @@ const noHeldLevels = () => null;
55
56
  /**
56
57
  * Call only after authorization and stored-evidence verification. `known`
57
58
  * holds the request's manifest hints; only hashes this projection cites are
58
- * omitted. `heldLevel` names each KEK level the request holds exactly.
59
+ * omitted. `heldLevel` names each KEK level the request holds exactly, and
60
+ * `heldDirectories` the organization states whose directory payloads it
61
+ * holds.
59
62
  */
60
- export function encodeContainerWriterProjection(projection, known = new Set(), heldLevel = noHeldLevels) {
63
+ export function encodeContainerWriterProjection(projection, known = new Set(), heldLevel = noHeldLevels, heldDirectories = new Set()) {
61
64
  const citations = bundleCitations(known);
62
65
  const encoded = encodeKeyingPath(projection, citations.cite, heldLevel);
63
66
  return {
64
67
  ...projection,
65
68
  ...encoded,
69
+ policyEvidence: encodeProjectionPolicyEvidence(projection.policyEvidence, heldDirectories),
66
70
  bundles: citations.bundles(),
67
71
  omittedBundles: citations.omitted(),
68
72
  };
69
73
  }
70
74
  /** See {@link encodeContainerWriterProjection}. */
71
- export function encodeDocumentWriterProjection(projection, known = new Set(), heldLevel = noHeldLevels) {
75
+ export function encodeDocumentWriterProjection(projection, known = new Set(), heldLevel = noHeldLevels, heldDirectories = new Set()) {
72
76
  const { cite, bundles, omitted } = bundleCitations(known);
73
77
  const authorizingContainerPaths = projection.authorizingContainerPaths.map((path) => encodeKeyingPath(path, cite, heldLevel));
74
78
  return {
75
79
  ...projection,
80
+ policyEvidence: encodeProjectionPolicyEvidence(projection.policyEvidence, heldDirectories),
76
81
  authorizingContainerPaths,
77
82
  documentContainerManifestHistory: projection.documentContainerManifestHistory.map(cite),
78
83
  documentManifest: cite(projection.documentManifest),
@@ -248,33 +253,36 @@ function withHeldBundles(projection, omittedBundles, held) {
248
253
  return projection;
249
254
  }
250
255
  /**
251
- * Null for any wire inconsistency or an omission `held` (bundles) or
252
- * `heldLevels` (KEK levels by digest) cannot fill; the caller treats either
256
+ * Null for any wire inconsistency or an omission `held` (bundles),
257
+ * `heldLevels` (KEK levels by digest) or `heldDirectories` (directory
258
+ * payloads by organization state hash) cannot fill; the caller treats either
253
259
  * as a shape failure.
254
260
  */
255
- export function decodeContainerWriterProjection(value, held = new Map(), heldLevels = new Map()) {
261
+ export function decodeContainerWriterProjection(value, held = new Map(), heldLevels = new Map(), heldDirectories = new Map()) {
256
262
  const parsed = ContainerWriterProjectionWireResponseSchema.safeParse(value);
257
263
  if (!parsed.success) {
258
264
  return null;
259
265
  }
260
266
  const { bundles, omittedBundles, ...projection } = parsed.data;
267
+ const policyEvidence = decodeProjectionPolicyEvidence(projection.policyEvidence, heldDirectories);
261
268
  const resolve = bundleResolver(bundles, omittedBundles, held);
262
269
  const path = resolve
263
270
  ? decodeKeyingPath(projection, resolve, heldLevels)
264
271
  : null;
265
- return path
266
- ? withHeldBundles({ ...projection, ...path }, omittedBundles, held)
272
+ return path && policyEvidence
273
+ ? withHeldBundles({ ...projection, ...path, policyEvidence }, omittedBundles, held)
267
274
  : null;
268
275
  }
269
276
  /** See {@link decodeContainerWriterProjection}. */
270
- export function decodeDocumentWriterProjection(value, held = new Map(), heldLevels = new Map()) {
277
+ export function decodeDocumentWriterProjection(value, held = new Map(), heldLevels = new Map(), heldDirectories = new Map()) {
271
278
  const parsed = DocumentWriterProjectionWireResponseSchema.safeParse(value);
272
279
  if (!parsed.success) {
273
280
  return null;
274
281
  }
275
282
  const { bundles, omittedBundles, ...projection } = parsed.data;
283
+ const policyEvidence = decodeProjectionPolicyEvidence(projection.policyEvidence, heldDirectories);
276
284
  const resolve = bundleResolver(bundles, omittedBundles, held);
277
- if (!resolve) {
285
+ if (!resolve || !policyEvidence) {
278
286
  return null;
279
287
  }
280
288
  const authorizingContainerPaths = [];
@@ -289,6 +297,7 @@ export function decodeDocumentWriterProjection(value, held = new Map(), heldLeve
289
297
  return null;
290
298
  return withHeldBundles({
291
299
  ...projection,
300
+ policyEvidence,
292
301
  authorizingContainerPaths: [firstPath, ...otherPaths],
293
302
  documentContainerManifestHistory: projection.documentContainerManifestHistory.map(resolve),
294
303
  documentManifest: resolve(projection.documentManifest),