@tearleads/client-sdk 0.1.247 → 0.1.249
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/Tearleads.js +4 -2
- package/Tearleads.js.map +1 -1
- 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/persistence/organizations/organizationReadModelRepository.js +20 -2
- package/data/persistence/organizations/organizationReadModelRepository.js.map +1 -1
- package/data/persistence/principalPolicy/heldOrganizationDirectories.js +53 -0
- package/data/persistence/principalPolicy/heldOrganizationDirectories.js.map +1 -0
- package/data/persistence/verifiedManifestBundlePersistence.d.ts +8 -3
- package/data/persistence/verifiedManifestBundlePersistence.js +34 -15
- package/data/persistence/verifiedManifestBundlePersistence.js.map +1 -1
- package/internal/api-client/ApiClient.d.ts +4 -1
- 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/principalPolicies.d.ts +3 -0
- package/internal/api-client/heldDirectoryCitations.d.ts +19 -0
- package/internal/api-client/heldDirectoryCitations.js +37 -0
- package/internal/api-client/heldDirectoryCitations.js.map +1 -0
- package/internal/api-client/index.d.ts +1 -1
- package/internal/api-client/index.js.map +1 -1
- package/internal/api-client/principalPolicyRequests.d.ts +2 -0
- 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.d.ts +16 -6
- package/internal/api-client/verifiedManifestCitations.js +32 -13
- package/internal/api-client/verifiedManifestCitations.js.map +1 -1
- package/internal/api-client/writerProjectionRequests.js +5 -3
- package/internal/api-client/writerProjectionRequests.js.map +1 -1
- package/internal/validators/knownManifestsRefinements.js +1 -1
- package/internal/validators/knownManifestsRefinements.js.map +1 -1
- 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/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/organizations.d.ts +17 -1
- 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 -1
- package/internal/validators/operation/principals.js +5 -2
- package/internal/validators/operation/principals.js.map +1 -1
- package/internal/validators/operation/writerProjections.d.ts +11 -11
- package/internal/validators/operation/writerProjections.js +1 -1
- package/internal/validators/operation/writerProjections.js.map +1 -1
- 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 -0
- package/internal/validators/request/organization.js +8 -0
- package/internal/validators/request/organization.js.map +1 -1
- 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 +3 -2
- package/internal/validators/response/areas/principals.js +2 -2
- 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 +56 -4
- package/internal/validators/response/container.js +5 -5
- package/internal/validators/response/container.js.map +1 -1
- package/internal/validators/response/documentMutation.d.ts +4 -4
- package/internal/validators/response/documentMutation.js +2 -2
- package/internal/validators/response/documentMutation.js.map +1 -1
- 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/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 +17 -0
- package/internal/validators/response/policyEvidenceWire.js +36 -0
- package/internal/validators/response/policyEvidenceWire.js.map +1 -0
- package/internal/validators/response/principal.d.ts +0 -403
- package/internal/validators/response/principal.js +0 -8
- package/internal/validators/response/principal.js.map +1 -1
- package/internal/validators/response/projectionPolicyEvidence.d.ts +175 -0
- package/internal/validators/response/projectionPolicyEvidence.js +13 -0
- package/internal/validators/response/projectionPolicyEvidence.js.map +1 -1
- package/internal/validators/response/writerProjectionWire.d.ts +11 -7
- package/internal/validators/response/writerProjectionWire.js +19 -10
- package/internal/validators/response/writerProjectionWire.js.map +1 -1
- package/internal/validators/util/index.d.ts +1 -1
- package/internal/validators/util/index.js +1 -1
- package/internal/validators/util/index.js.map +1 -1
- package/internal/validators/util/knownManifestWire.d.ts +9 -3
- package/internal/validators/util/knownManifestWire.js +24 -8
- package/internal/validators/util/knownManifestWire.js.map +1 -1
- 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/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/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
|
@@ -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,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,EAAE,uBAAuB,EAAE,KAAK,EAAE,cAAc,EAAE;IACpE,MAAM,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE,KAAK,EAAE,eAAe,EAAE;CAC/D,CAAC;AAEX;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAEb;IACA;IAFnB,YACmB,OAAyB,EACzB,IAKhB;QANgB,YAAO,GAAP,OAAO,CAAkB;QACzB,SAAI,GAAJ,IAAI,CAKpB;QAED,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;IAEO,KAAK,CAAC,cAAc,CAC1B,QAA0C,EAC1C,WAAmB,EACnB,KAA+B,EAC/B,OAA6B;QAE7B,MAAM,EAAE,SAAS,EAAE,KAAK,EAA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,CAAC,CAAC;IAClE,CAAC;IAED,eAAe,CACb,WAAmB,EACnB,KAA6B,EAC7B,UAAgC,EAAE;QAElC,OAAO,IAAI,CAAC,OAAO;aAChB,IAAI,CACH,eAAe,EACf,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EACjC,wBAAwB,EACxB,KAAK,EACL,OAAO,CACR;aACA,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,aAAa,CACX,WAAmB,EACnB,KAA+B,EAC/B,UAAgC,EAAE;QAElC,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,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,uBAA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,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,aAAa,CACX,WAAmB,EACnB,KAA+B,EAC/B,UAAgC,EAAE;QAElC,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,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 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"]}
|
|
@@ -516,6 +516,7 @@ export declare class PrincipalPolicyArea {
|
|
|
516
516
|
version: number;
|
|
517
517
|
};
|
|
518
518
|
} | undefined;
|
|
519
|
+
readModel?: unknown;
|
|
519
520
|
} | null>;
|
|
520
521
|
/**
|
|
521
522
|
* Status-bearing group policy commit. A rematerialized rotation the server
|
|
@@ -571,6 +572,7 @@ export declare class PrincipalPolicyArea {
|
|
|
571
572
|
version: number;
|
|
572
573
|
};
|
|
573
574
|
};
|
|
575
|
+
readModel?: unknown;
|
|
574
576
|
} | null>;
|
|
575
577
|
createOrganizationGroupResult(...args: Parameters<PrincipalPolicyRequests["createResult"]>): Promise<RequestResult<{
|
|
576
578
|
group: {
|
|
@@ -619,6 +621,7 @@ export declare class PrincipalPolicyArea {
|
|
|
619
621
|
version: number;
|
|
620
622
|
};
|
|
621
623
|
};
|
|
624
|
+
readModel?: unknown;
|
|
622
625
|
}>>;
|
|
623
626
|
deleteOrganizationGroup(...args: Parameters<PrincipalPolicyRequests["deleteResult"]>): Promise<{
|
|
624
627
|
deleted: true;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PrincipalStatePayloadResponse, type PrincipalStateResponse } from "../validators/response/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* An organization directory payload a device holds, beside the signed state
|
|
4
|
+
* that commits its hash. Writer projections serve directory payloads as
|
|
5
|
+
* policy evidence; a request may cite a held one by state hash instead.
|
|
6
|
+
*/
|
|
7
|
+
export interface HeldDirectoryCitation {
|
|
8
|
+
readonly directoryState: PrincipalStateResponse;
|
|
9
|
+
readonly directoryPayload: PrincipalStatePayloadResponse;
|
|
10
|
+
}
|
|
11
|
+
export declare function isHeldDirectoryCitation(value: unknown): value is HeldDirectoryCitation;
|
|
12
|
+
/**
|
|
13
|
+
* The payload when its organization state recomputes to its own hash and its
|
|
14
|
+
* bytes hash to the `payloadCiphertextHash` that state signs; null otherwise.
|
|
15
|
+
* The state hash commits that payload hash, so a cited payload is exactly the
|
|
16
|
+
* bytes the server would serve for that state, and verification of the
|
|
17
|
+
* rebuilt evidence decides as if they had travelled.
|
|
18
|
+
*/
|
|
19
|
+
export declare function signedDirectoryPayload(citation: HeldDirectoryCitation): Promise<PrincipalStatePayloadResponse | null>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { computePrincipalStateHash, computePrincipalStatePayloadCiphertextHash, } from "../crypto/index.js";
|
|
2
|
+
import { isPrincipalStatePayloadResponse, isPrincipalStateResponse, } from "../validators/response/index.js";
|
|
3
|
+
import { isSha256HexString } from "../validators/util/index.js";
|
|
4
|
+
export function isHeldDirectoryCitation(value) {
|
|
5
|
+
return (typeof value === "object" &&
|
|
6
|
+
value !== null &&
|
|
7
|
+
isPrincipalStateResponse(Reflect.get(value, "directoryState")) &&
|
|
8
|
+
isPrincipalStatePayloadResponse(Reflect.get(value, "directoryPayload")));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The payload when its organization state recomputes to its own hash and its
|
|
12
|
+
* bytes hash to the `payloadCiphertextHash` that state signs; null otherwise.
|
|
13
|
+
* The state hash commits that payload hash, so a cited payload is exactly the
|
|
14
|
+
* bytes the server would serve for that state, and verification of the
|
|
15
|
+
* rebuilt evidence decides as if they had travelled.
|
|
16
|
+
*/
|
|
17
|
+
export async function signedDirectoryPayload(citation) {
|
|
18
|
+
const { directoryState: state, directoryPayload: payload } = citation;
|
|
19
|
+
try {
|
|
20
|
+
if (state.principalType !== "organization" ||
|
|
21
|
+
payload.principalType !== "organization" ||
|
|
22
|
+
payload.principalId !== state.principalId ||
|
|
23
|
+
payload.stateHash !== state.stateHash ||
|
|
24
|
+
!isSha256HexString(state.stateHash) ||
|
|
25
|
+
(await computePrincipalStateHash(state)) !== state.stateHash)
|
|
26
|
+
return null;
|
|
27
|
+
const hash = await computePrincipalStatePayloadCiphertextHash(payload.ciphertext);
|
|
28
|
+
return hash === state.payloadCiphertextHash &&
|
|
29
|
+
hash === payload.ciphertextHash
|
|
30
|
+
? payload
|
|
31
|
+
: null;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=heldDirectoryCitations.js.map
|
|
@@ -0,0 +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,wBA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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 when its organization state recomputes to its own hash and its\n * bytes hash to the `payloadCiphertextHash` that state signs; null otherwise.\n * The state hash commits that payload hash, so 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<PrincipalStatePayloadResponse | null> {\n const { directoryState: state, directoryPayload: payload } = citation;\n try {\n if (\n state.principalType !== \"organization\" ||\n payload.principalType !== \"organization\" ||\n payload.principalId !== state.principalId ||\n payload.stateHash !== state.stateHash ||\n !isSha256HexString(state.stateHash) ||\n (await computePrincipalStateHash(state)) !== state.stateHash\n )\n return null;\n const hash = await computePrincipalStatePayloadCiphertextHash(\n payload.ciphertext,\n );\n return hash === state.payloadCiphertextHash &&\n hash === payload.ciphertextHash\n ? payload\n : null;\n } catch {\n return null;\n }\n}\n"]}
|
|
@@ -8,5 +8,5 @@ export type { ProjectionPolicyHistoryReadOptions } from "./projectionPolicyHisto
|
|
|
8
8
|
export type { BlobBytesResponse, UploadMultipartBlobPartBytesRequest, } from "./routes/blobs/get.js";
|
|
9
9
|
export { describeMultipartBlobPart } from "./routes/blobs/multipartUpload.js";
|
|
10
10
|
export type { HttpMethod, ListDocumentEditAttributionRangesOptions, RequestFailure, RequestFailureKind, RequestResult, RequestResultOptions, RequestSuccess, } from "./types.js";
|
|
11
|
-
export type { HeldProjectionCitation, VerifiedManifestCitations, WriterProjectionListing, WriterProjectionTarget, } from "./verifiedManifestCitations.js";
|
|
11
|
+
export type { HeldDirectoryCitation, HeldProjectionCitation, VerifiedManifestCitations, WriterProjectionListing, WriterProjectionTarget, } from "./verifiedManifestCitations.js";
|
|
12
12
|
export { openServerEventsSocket } from "./webSocketTickets.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAGL,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,GAGhB,MAAM,kBAAkB,CAAC;AAa1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAGL,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,GAGhB,MAAM,kBAAkB,CAAC;AAa1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAiB3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { ApiClient } from \"./ApiClient\";\nexport { AccountSuspendedError } from \"./accountSuspension\";\nexport {\n type ApiReachability,\n type ApiReachabilityProbe,\n createApiReachabilityProbe,\n} from \"./apiReachabilityProbe\";\nexport {\n type ApiRequestCounts,\n type ApiRequestEndpointCounts,\n ApiRequestMetrics,\n type ApiRequestMetricsSnapshot,\n} from \"./apiRequestMetrics\";\nexport {\n ApiNetworkError,\n type ApiNetworkFailureClass,\n type ApiNetworkFailureDetails,\n} from \"./networkFailure\";\nexport type {\n PrincipalPolicyDiscoveryOptions,\n PrincipalPolicyHeldHead,\n PrincipalPolicyPageCurrent,\n PrincipalPolicyPageReadOptions,\n PrincipalPolicyPageResume,\n} from \"./principalPolicyPages\";\nexport type { ProjectionPolicyHistoryReadOptions } from \"./projectionPolicyHistoryPages\";\nexport type {\n BlobBytesResponse,\n UploadMultipartBlobPartBytesRequest,\n} from \"./routes/blobs/get\";\nexport { describeMultipartBlobPart } from \"./routes/blobs/multipartUpload\";\nexport type {\n HttpMethod,\n ListDocumentEditAttributionRangesOptions,\n RequestFailure,\n RequestFailureKind,\n RequestResult,\n RequestResultOptions,\n RequestSuccess,\n} from \"./types\";\nexport type {\n HeldDirectoryCitation,\n HeldProjectionCitation,\n VerifiedManifestCitations,\n WriterProjectionListing,\n WriterProjectionTarget,\n} from \"./verifiedManifestCitations\";\nexport { openServerEventsSocket } from \"./webSocketTickets\";\n"]}
|
|
@@ -463,6 +463,7 @@ export declare class PrincipalPolicyRequests {
|
|
|
463
463
|
version: number;
|
|
464
464
|
};
|
|
465
465
|
};
|
|
466
|
+
readModel?: unknown;
|
|
466
467
|
}>>;
|
|
467
468
|
deleteResult(organizationId: string, groupId: string, input: DeleteOrganizationGroupRequest, options?: RequestResultOptions): Promise<RequestResult<{
|
|
468
469
|
deleted: true;
|
|
@@ -603,5 +604,6 @@ export declare class PrincipalPolicyRequests {
|
|
|
603
604
|
version: number;
|
|
604
605
|
};
|
|
605
606
|
} | undefined;
|
|
607
|
+
readModel?: unknown;
|
|
606
608
|
}>>;
|
|
607
609
|
}
|
|
@@ -68,14 +68,15 @@ export class PrincipalPolicyRequests {
|
|
|
68
68
|
}).finally(() => this.cache.delete(key));
|
|
69
69
|
}
|
|
70
70
|
createResult(organizationId, input, options = {}) {
|
|
71
|
+
const { readModelCursor, ...requestOptions } = options;
|
|
71
72
|
return this.groupMutation(organizationId, input.groupId, () => principalHistoryRequest(this.runtime, {
|
|
72
|
-
path: createOrganizationGroup.path(organizationId),
|
|
73
|
+
path: createOrganizationGroup.path(organizationId, readModelCursor),
|
|
73
74
|
validator: createOrganizationGroup.isResponse,
|
|
74
75
|
method: createOrganizationGroup.method,
|
|
75
76
|
body: JSON.stringify(input),
|
|
76
77
|
options: {
|
|
77
78
|
expectedPaymentRequiredOrganizationId: organizationId,
|
|
78
|
-
...
|
|
79
|
+
...requestOptions,
|
|
79
80
|
},
|
|
80
81
|
operation: createOrganizationGroupOperation,
|
|
81
82
|
}));
|
|
@@ -110,17 +111,18 @@ export class PrincipalPolicyRequests {
|
|
|
110
111
|
async commitResult(organizationId, groupId, input, options = {}) {
|
|
111
112
|
const groupKey = JSON.stringify(["group", groupId]);
|
|
112
113
|
const organizationKey = JSON.stringify(["organization", organizationId]);
|
|
114
|
+
const { readModelCursor, ...requestOptions } = options;
|
|
113
115
|
this.cache.delete(groupKey);
|
|
114
116
|
this.cache.delete(organizationKey);
|
|
115
117
|
try {
|
|
116
118
|
return await principalHistoryRequest(this.runtime, {
|
|
117
|
-
path: commitOrganizationGroupPolicy.path(organizationId, groupId),
|
|
119
|
+
path: commitOrganizationGroupPolicy.path(organizationId, groupId, readModelCursor),
|
|
118
120
|
validator: commitOrganizationGroupPolicy.isResponse,
|
|
119
121
|
method: commitOrganizationGroupPolicy.method,
|
|
120
122
|
body: JSON.stringify(input),
|
|
121
123
|
options: {
|
|
122
124
|
expectedPaymentRequiredOrganizationId: organizationId,
|
|
123
|
-
...
|
|
125
|
+
...requestOptions,
|
|
124
126
|
},
|
|
125
127
|
operation: commitOrganizationGroupPolicyOperation,
|
|
126
128
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"principalPolicyRequests.js","sourceRoot":"","sources":["principalPolicyRequests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,gCAAgC,EAChC,gCAAgC,EAChC,oCAAoC,EACpC,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AAazC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,2BAA2B,EAG3B,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,OAAO,uBAAuB;IAEf;IACA;IAGA;IALnB,YACmB,OAA0B,EAC1B,KAEhB,EACgB,2BAAuC;QAJvC,YAAO,GAAP,OAAO,CAAmB;QAC1B,UAAK,GAAL,KAAK,CAErB;QACgB,gCAA2B,GAA3B,2BAA2B,CAAY;IACvD,CAAC;IAEJ,WAAW,CACT,MAA8D,EAC9D,UAAkE,EAAE;QAEpE,OAAO,gCAAgC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CACH,aAAuC,EACvC,WAAmB,EACnB,UAA0C,EAAE;QAE5C,OAAO,wBAAwB,CAC7B,IAAI,CAAC,OAAO,EACZ,aAAa,EACb,WAAW,EACX,OAAO,CACR,CAAC;IACJ,CAAC;IAED,QAAQ,CACN,aAAuC,EACvC,WAAmB,EACnB,UAA2C,EAAE;QAE7C,OAAO,4BAA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AAY,CAChB,cAAsB,EACtB,OAAe,EACf,KAA2C,EAC3C,UAAgC,EAAE;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACnC,IAAI,CAAC;YACH,OAAO,MAAM,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjD,IAAI,EAAE,6BAA6B,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC;gBACjE,SAAS,EAAE,6BAA6B,CAAC,UAAU;gBACnD,MAAM,EAAE,6BAA6B,CAAC,MAAM;gBAC5C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gBAC3B,OAAO,EAAE;oBACP,qCAAqC,EAAE,cAAc;oBACrD,GAAG,OAAO;iBACX;gBACD,SAAS,EAAE,sCAAsC;aAClD,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YACnC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACrC,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n commitOrganizationGroupPolicyOperation,\n createOrganizationGroupOperation,\n deleteOrganizationGroupOperation,\n getPrincipalMemberEnvelopesOperation,\n putPrincipalPolicyOperation,\n} from \"@tearleads/validators/operation\";\nimport type {\n CommitOrganizationGroupPolicyRequest,\n CreateOrganizationGroupWithPolicyRequest,\n DeleteOrganizationGroupRequest,\n OrganizationPrincipalPolicyRequest,\n} from \"@tearleads/validators/request\";\nimport type {\n CurrentPrincipalMemberEnvelopesResponse,\n PrincipalPolicyBundleResponse,\n} from \"@tearleads/validators/response\";\nimport type { BoundedCache } from \"./ApiCache\";\nimport type { ApiRequestRuntime } from \"./apiRequestRuntime\";\nimport { principalHistoryRequest } from \"./principalHistoryRequest\";\nimport {\n collectPrincipalPolicyPages,\n type PrincipalPolicyDiscoveryOptions,\n type PrincipalPolicyPageReadOptions,\n readPrincipalPolicyDiscovery,\n readPrincipalPolicyPages,\n} from \"./principalPolicyPages\";\nimport { readProjectionPolicyHistoryPages } from \"./projectionPolicyHistoryPages\";\nimport { dedupedRequest } from \"./requestInternals\";\nimport { createOrganizationGroup } from \"./routes/organizations/createGroup\";\nimport { deleteOrganizationGroup } from \"./routes/organizations/deleteGroup\";\nimport {\n commitOrganizationGroupPolicy,\n getPrincipalMemberEnvelopes,\n putPrincipalPolicy,\n} from \"./routes/principals/policy\";\nimport type { RequestResult, RequestResultOptions } from \"./types\";\n\nexport class PrincipalPolicyRequests {\n constructor(\n private readonly runtime: ApiRequestRuntime,\n private readonly cache: BoundedCache<\n Promise<PrincipalPolicyBundleResponse | null>\n >,\n private readonly clearWriterProjectionCaches: () => void,\n ) {}\n\n publicPages(\n source: Parameters<typeof readProjectionPolicyHistoryPages>[1],\n options: Parameters<typeof readProjectionPolicyHistoryPages>[2] = {},\n ) {\n return readProjectionPolicyHistoryPages(this.runtime, source, options);\n }\n\n pages(\n principalType: \"group\" | \"organization\",\n principalId: string,\n options: PrincipalPolicyPageReadOptions = {},\n ) {\n return readPrincipalPolicyPages(\n this.runtime,\n principalType,\n principalId,\n options,\n );\n }\n\n discover(\n principalType: \"group\" | \"organization\",\n principalId: string,\n options: PrincipalPolicyDiscoveryOptions = {},\n ) {\n return readPrincipalPolicyDiscovery(\n this.runtime,\n principalType,\n principalId,\n options,\n );\n }\n\n /**\n * Every member envelope of one named state. A response that fails its\n * schema, or names another state, is a `shape` failure the caller can treat\n * as tampering; an unknown state is an HTTP 404.\n */\n memberEnvelopes(\n principalType: \"group\" | \"organization\",\n principalId: string,\n stateHash: string,\n ): Promise<RequestResult<CurrentPrincipalMemberEnvelopesResponse>> {\n return principalHistoryRequest(this.runtime, {\n path: getPrincipalMemberEnvelopes.path(\n principalType,\n principalId,\n stateHash,\n ),\n validator: (value): value is CurrentPrincipalMemberEnvelopesResponse =>\n getPrincipalMemberEnvelopes.isResponse(value) &&\n value.principalType === principalType &&\n value.principalId === principalId &&\n value.stateHash === stateHash,\n method: getPrincipalMemberEnvelopes.method,\n options: { reportErrors: false },\n operation: getPrincipalMemberEnvelopesOperation,\n });\n }\n\n get(\n principalType: \"group\" | \"organization\",\n principalId: string,\n options: RequestResultOptions = {},\n ) {\n const request = () =>\n collectPrincipalPolicyPages(\n this.runtime,\n principalType,\n principalId,\n options,\n );\n const key = JSON.stringify([principalType, principalId]);\n // Cancellation, reporting and renewal preferences belong to their caller.\n return Object.keys(options).length > 0\n ? request()\n : dedupedRequest(this.cache, key, request);\n }\n\n put(...args: Parameters<PrincipalPolicyRequests[\"putResult\"]>) {\n return this.putResult(...args).then((result) =>\n result.ok ? result.data : null,\n );\n }\n\n putResult(\n principalType: \"organization\",\n principalId: string,\n input: OrganizationPrincipalPolicyRequest,\n options: RequestResultOptions = {},\n ) {\n const key = JSON.stringify([principalType, principalId]);\n this.cache.delete(key);\n return principalHistoryRequest(this.runtime, {\n path: putPrincipalPolicy.path(principalType, principalId),\n validator: putPrincipalPolicy.isResponse,\n method: putPrincipalPolicy.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: principalId,\n ...options,\n },\n operation: putPrincipalPolicyOperation,\n }).finally(() => this.cache.delete(key));\n }\n\n createResult(\n organizationId: string,\n input: CreateOrganizationGroupWithPolicyRequest,\n options: RequestResultOptions = {},\n ) {\n return this.groupMutation(organizationId, input.groupId, () =>\n principalHistoryRequest(this.runtime, {\n path: createOrganizationGroup.path(organizationId),\n validator: createOrganizationGroup.isResponse,\n method: createOrganizationGroup.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: organizationId,\n ...options,\n },\n operation: createOrganizationGroupOperation,\n }),\n );\n }\n\n deleteResult(\n organizationId: string,\n groupId: string,\n input: DeleteOrganizationGroupRequest,\n options: RequestResultOptions = {},\n ) {\n return this.groupMutation(organizationId, groupId, () =>\n principalHistoryRequest(this.runtime, {\n path: deleteOrganizationGroup.path(organizationId, groupId),\n validator: deleteOrganizationGroup.isResponse,\n method: deleteOrganizationGroup.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: organizationId,\n ...options,\n },\n operation: deleteOrganizationGroupOperation,\n }),\n );\n }\n\n private async groupMutation<T>(\n organizationId: string,\n groupId: string,\n request: () => Promise<T>,\n ): Promise<T> {\n const groupKey = JSON.stringify([\"group\", groupId]);\n const organizationKey = JSON.stringify([\"organization\", organizationId]);\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n try {\n return await request();\n } finally {\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n this.clearWriterProjectionCaches();\n }\n }\n\n async commitResult(\n organizationId: string,\n groupId: string,\n input: CommitOrganizationGroupPolicyRequest,\n options: RequestResultOptions = {},\n ) {\n const groupKey = JSON.stringify([\"group\", groupId]);\n const organizationKey = JSON.stringify([\"organization\", organizationId]);\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n try {\n return await principalHistoryRequest(this.runtime, {\n path: commitOrganizationGroupPolicy.path(organizationId, groupId),\n validator: commitOrganizationGroupPolicy.isResponse,\n method: commitOrganizationGroupPolicy.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: organizationId,\n ...options,\n },\n operation: commitOrganizationGroupPolicyOperation,\n });\n } finally {\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n this.clearWriterProjectionCaches();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"principalPolicyRequests.js","sourceRoot":"","sources":["principalPolicyRequests.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,EACtB,OAAe,EACf,KAA2C,EAC3C,UAAgC,EAAE;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;QACzE,MAAM,EAAE,eAAe,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;QACvD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACnC,IAAI,CAAC;YACH,OAAO,MAAM,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjD,IAAI,EAAE,6BAA6B,CAAC,IAAI,CACtC,cAAc,EACd,OAAO,EACP,eAAe,CAChB;gBACD,SAAS,EAAE,6BAA6B,CAAC,UAAU;gBACnD,MAAM,EAAE,6BAA6B,CAAC,MAAM;gBAC5C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gBAC3B,OAAO,EAAE;oBACP,qCAAqC,EAAE,cAAc;oBACrD,GAAG,cAAc;iBAClB;gBACD,SAAS,EAAE,sCAAsC;aAClD,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YACnC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACrC,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n commitOrganizationGroupPolicyOperation,\n createOrganizationGroupOperation,\n deleteOrganizationGroupOperation,\n getPrincipalMemberEnvelopesOperation,\n putPrincipalPolicyOperation,\n} from \"@tearleads/validators/operation\";\nimport type {\n CommitOrganizationGroupPolicyRequest,\n CreateOrganizationGroupWithPolicyRequest,\n DeleteOrganizationGroupRequest,\n OrganizationPrincipalPolicyRequest,\n} from \"@tearleads/validators/request\";\nimport type {\n CurrentPrincipalMemberEnvelopesResponse,\n PrincipalPolicyBundleResponse,\n} from \"@tearleads/validators/response\";\nimport type { BoundedCache } from \"./ApiCache\";\nimport type { ApiRequestRuntime } from \"./apiRequestRuntime\";\nimport { principalHistoryRequest } from \"./principalHistoryRequest\";\nimport {\n collectPrincipalPolicyPages,\n type PrincipalPolicyDiscoveryOptions,\n type PrincipalPolicyPageReadOptions,\n readPrincipalPolicyDiscovery,\n readPrincipalPolicyPages,\n} from \"./principalPolicyPages\";\nimport { readProjectionPolicyHistoryPages } from \"./projectionPolicyHistoryPages\";\nimport { dedupedRequest } from \"./requestInternals\";\nimport { createOrganizationGroup } from \"./routes/organizations/createGroup\";\nimport { deleteOrganizationGroup } from \"./routes/organizations/deleteGroup\";\nimport {\n commitOrganizationGroupPolicy,\n getPrincipalMemberEnvelopes,\n putPrincipalPolicy,\n} from \"./routes/principals/policy\";\nimport type { RequestResult, RequestResultOptions } from \"./types\";\n\nexport class PrincipalPolicyRequests {\n constructor(\n private readonly runtime: ApiRequestRuntime,\n private readonly cache: BoundedCache<\n Promise<PrincipalPolicyBundleResponse | null>\n >,\n private readonly clearWriterProjectionCaches: () => void,\n ) {}\n\n publicPages(\n source: Parameters<typeof readProjectionPolicyHistoryPages>[1],\n options: Parameters<typeof readProjectionPolicyHistoryPages>[2] = {},\n ) {\n return readProjectionPolicyHistoryPages(this.runtime, source, options);\n }\n\n pages(\n principalType: \"group\" | \"organization\",\n principalId: string,\n options: PrincipalPolicyPageReadOptions = {},\n ) {\n return readPrincipalPolicyPages(\n this.runtime,\n principalType,\n principalId,\n options,\n );\n }\n\n discover(\n principalType: \"group\" | \"organization\",\n principalId: string,\n options: PrincipalPolicyDiscoveryOptions = {},\n ) {\n return readPrincipalPolicyDiscovery(\n this.runtime,\n principalType,\n principalId,\n options,\n );\n }\n\n /**\n * Every member envelope of one named state. A response that fails its\n * schema, or names another state, is a `shape` failure the caller can treat\n * as tampering; an unknown state is an HTTP 404.\n */\n memberEnvelopes(\n principalType: \"group\" | \"organization\",\n principalId: string,\n stateHash: string,\n ): Promise<RequestResult<CurrentPrincipalMemberEnvelopesResponse>> {\n return principalHistoryRequest(this.runtime, {\n path: getPrincipalMemberEnvelopes.path(\n principalType,\n principalId,\n stateHash,\n ),\n validator: (value): value is CurrentPrincipalMemberEnvelopesResponse =>\n getPrincipalMemberEnvelopes.isResponse(value) &&\n value.principalType === principalType &&\n value.principalId === principalId &&\n value.stateHash === stateHash,\n method: getPrincipalMemberEnvelopes.method,\n options: { reportErrors: false },\n operation: getPrincipalMemberEnvelopesOperation,\n });\n }\n\n get(\n principalType: \"group\" | \"organization\",\n principalId: string,\n options: RequestResultOptions = {},\n ) {\n const request = () =>\n collectPrincipalPolicyPages(\n this.runtime,\n principalType,\n principalId,\n options,\n );\n const key = JSON.stringify([principalType, principalId]);\n // Cancellation, reporting and renewal preferences belong to their caller.\n return Object.keys(options).length > 0\n ? request()\n : dedupedRequest(this.cache, key, request);\n }\n\n put(...args: Parameters<PrincipalPolicyRequests[\"putResult\"]>) {\n return this.putResult(...args).then((result) =>\n result.ok ? result.data : null,\n );\n }\n\n putResult(\n principalType: \"organization\",\n principalId: string,\n input: OrganizationPrincipalPolicyRequest,\n options: RequestResultOptions = {},\n ) {\n const key = JSON.stringify([principalType, principalId]);\n this.cache.delete(key);\n return principalHistoryRequest(this.runtime, {\n path: putPrincipalPolicy.path(principalType, principalId),\n validator: putPrincipalPolicy.isResponse,\n method: putPrincipalPolicy.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: principalId,\n ...options,\n },\n operation: putPrincipalPolicyOperation,\n }).finally(() => this.cache.delete(key));\n }\n\n createResult(\n organizationId: string,\n input: CreateOrganizationGroupWithPolicyRequest,\n options: RequestResultOptions = {},\n ) {\n const { readModelCursor, ...requestOptions } = options;\n return this.groupMutation(organizationId, input.groupId, () =>\n principalHistoryRequest(this.runtime, {\n path: createOrganizationGroup.path(organizationId, readModelCursor),\n validator: createOrganizationGroup.isResponse,\n method: createOrganizationGroup.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: organizationId,\n ...requestOptions,\n },\n operation: createOrganizationGroupOperation,\n }),\n );\n }\n\n deleteResult(\n organizationId: string,\n groupId: string,\n input: DeleteOrganizationGroupRequest,\n options: RequestResultOptions = {},\n ) {\n return this.groupMutation(organizationId, groupId, () =>\n principalHistoryRequest(this.runtime, {\n path: deleteOrganizationGroup.path(organizationId, groupId),\n validator: deleteOrganizationGroup.isResponse,\n method: deleteOrganizationGroup.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: organizationId,\n ...options,\n },\n operation: deleteOrganizationGroupOperation,\n }),\n );\n }\n\n private async groupMutation<T>(\n organizationId: string,\n groupId: string,\n request: () => Promise<T>,\n ): Promise<T> {\n const groupKey = JSON.stringify([\"group\", groupId]);\n const organizationKey = JSON.stringify([\"organization\", organizationId]);\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n try {\n return await request();\n } finally {\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n this.clearWriterProjectionCaches();\n }\n }\n\n async commitResult(\n organizationId: string,\n groupId: string,\n input: CommitOrganizationGroupPolicyRequest,\n options: RequestResultOptions = {},\n ) {\n const groupKey = JSON.stringify([\"group\", groupId]);\n const organizationKey = JSON.stringify([\"organization\", organizationId]);\n const { readModelCursor, ...requestOptions } = options;\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n try {\n return await principalHistoryRequest(this.runtime, {\n path: commitOrganizationGroupPolicy.path(\n organizationId,\n groupId,\n readModelCursor,\n ),\n validator: commitOrganizationGroupPolicy.isResponse,\n method: commitOrganizationGroupPolicy.method,\n body: JSON.stringify(input),\n options: {\n expectedPaymentRequiredOrganizationId: organizationId,\n ...requestOptions,\n },\n operation: commitOrganizationGroupPolicyOperation,\n });\n } finally {\n this.cache.delete(groupKey);\n this.cache.delete(organizationKey);\n this.clearWriterProjectionCaches();\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContainerOperation, createContainerWithMetadataDocumentOperation, deleteContainerOperation, isContainerMutationOperationRequest, isContainerMutationOperationResponse, isContainerRotationOperationRequest, isContainerRotationOperationResponse, isCreateContainerWithMetadataDocumentOperationRequest, isCreateContainerWithMetadataDocumentOperationResponse, isDeleteContainerOperationResponse, moveContainerOperation, operationRequestPath, operationRequestPathWithQuery, reciteContainerOperation, rekeyContainerOperation, revokeContainerOperation, shareContainerOperation, } from "../../../validators/operation/index.js";
|
|
1
|
+
import { createContainerOperation, createContainerWithMetadataDocumentOperation, deleteContainerOperation, isContainerMutationOperationRequest, isContainerMutationOperationResponse, isContainerRotationOperationRequest, isContainerRotationOperationResponse, isCreateContainerWithMetadataDocumentOperationRequest, isCreateContainerWithMetadataDocumentOperationResponse, isDeleteContainerOperationResponse, isShareContainerOperationResponse, moveContainerOperation, operationRequestPath, operationRequestPathWithQuery, reciteContainerOperation, rekeyContainerOperation, revokeContainerOperation, shareContainerOperation, } from "../../../validators/operation/index.js";
|
|
2
2
|
import { isContainerReciteRequest } from "../../../validators/request/index.js";
|
|
3
3
|
import { isContainerReciteResponse } from "../../../validators/response/index.js";
|
|
4
4
|
export const containerRecite = {
|
|
@@ -24,9 +24,9 @@ function containerMutationPath(operation, containerId) {
|
|
|
24
24
|
}
|
|
25
25
|
export const containerShare = {
|
|
26
26
|
isRequest: isContainerMutationOperationRequest,
|
|
27
|
-
isResponse:
|
|
27
|
+
isResponse: isShareContainerOperationResponse,
|
|
28
28
|
method: shareContainerOperation.method,
|
|
29
|
-
path: (containerId) =>
|
|
29
|
+
path: (containerId, readModelCursor) => operationRequestPathWithQuery(shareContainerOperation, { containerId }, { readModelCursor }),
|
|
30
30
|
};
|
|
31
31
|
export const containerRevoke = {
|
|
32
32
|
isRequest: isContainerRotationOperationRequest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,4CAA4C,EAC5C,wBAAwB,EACxB,mCAAmC,EACnC,oCAAoC,EACpC,mCAAmC,EACnC,oCAAoC,EACpC,qDAAqD,EACrD,sDAAsD,EACtD,kCAAkC,EAClC,sBAAsB,EACtB,oBAAoB,EACpB,6BAA6B,EAC7B,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,wBAAwB;IACnC,UAAU,EAAE,yBAAyB;IACrC,MAAM,EAAE,wBAAwB,CAAC,MAAM;IACvC,IAAI,EAAE,CAAC,WAAmB,EAAE,EAAE,CAC5B,oBAAoB,CAAC,wBAAwB,EAAE,EAAE,WAAW,EAAE,CAAC;CACzD,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,mCAAmC;IAC9C,UAAU,EAAE,oCAAoC;IAChD,MAAM,EAAE,wBAAwB,CAAC,MAAM;IACvC,IAAI,EAAE,oBAAoB,CAAC,wBAAwB,EAAE,EAAE,CAAC;CAChD,CAAC;AAEX,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,SAAS,EAAE,qDAAqD;IAChE,UAAU,EAAE,sDAAsD;IAClE,MAAM,EAAE,4CAA4C,CAAC,MAAM;IAC3D,IAAI,EAAE,oBAAoB,CAAC,4CAA4C,EAAE,EAAE,CAAC;CACpE,CAAC;AAEX,SAAS,qBAAqB,CAC5B,
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["mutations.ts"],"names":[],"mappings":"AA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Operation,\n deleteContainerOperation,\n isContainerMutationOperationRequest,\n isContainerMutationOperationResponse,\n isContainerRotationOperationRequest,\n isContainerRotationOperationResponse,\n isCreateContainerWithMetadataDocumentOperationRequest,\n isCreateContainerWithMetadataDocumentOperationResponse,\n isDeleteContainerOperationResponse,\n isShareContainerOperationResponse,\n moveContainerOperation,\n operationRequestPath,\n operationRequestPathWithQuery,\n reciteContainerOperation,\n rekeyContainerOperation,\n revokeContainerOperation,\n shareContainerOperation,\n} from \"@tearleads/validators/operation\";\nimport { isContainerReciteRequest } from \"@tearleads/validators/request\";\nimport { isContainerReciteResponse } from \"@tearleads/validators/response\";\n\nexport const containerRecite = {\n isRequest: isContainerReciteRequest,\n isResponse: isContainerReciteResponse,\n method: reciteContainerOperation.method,\n path: (containerId: string) =>\n operationRequestPath(reciteContainerOperation, { containerId }),\n} as const;\n\nexport const containerCreate = {\n isRequest: isContainerMutationOperationRequest,\n isResponse: isContainerMutationOperationResponse,\n method: createContainerOperation.method,\n path: operationRequestPath(createContainerOperation, {}),\n} as const;\n\nexport const containerCreateWithMetadataDocument = {\n isRequest: isCreateContainerWithMetadataDocumentOperationRequest,\n isResponse: isCreateContainerWithMetadataDocumentOperationResponse,\n method: createContainerWithMetadataDocumentOperation.method,\n path: operationRequestPath(createContainerWithMetadataDocumentOperation, {}),\n} as const;\n\nfunction containerMutationPath(\n operation:\n | typeof moveContainerOperation\n | typeof rekeyContainerOperation\n | typeof revokeContainerOperation,\n containerId: string,\n) {\n return operationRequestPath(operation, { containerId });\n}\n\nexport const containerShare = {\n isRequest: isContainerMutationOperationRequest,\n isResponse: isShareContainerOperationResponse,\n method: shareContainerOperation.method,\n path: (containerId: string, readModelCursor?: string) =>\n operationRequestPathWithQuery(\n shareContainerOperation,\n { containerId },\n { readModelCursor },\n ),\n} as const;\n\nexport const containerRevoke = {\n isRequest: isContainerRotationOperationRequest,\n isResponse: isContainerRotationOperationResponse,\n method: revokeContainerOperation.method,\n path: (containerId: string) =>\n containerMutationPath(revokeContainerOperation, containerId),\n} as const;\n\nexport const containerRekey = {\n isRequest: isContainerRotationOperationRequest,\n isResponse: isContainerRotationOperationResponse,\n method: rekeyContainerOperation.method,\n path: (containerId: string) =>\n containerMutationPath(rekeyContainerOperation, containerId),\n} as const;\n\nexport const containerMove = {\n isRequest: isContainerRotationOperationRequest,\n isResponse: isContainerRotationOperationResponse,\n method: moveContainerOperation.method,\n path: (containerId: string) =>\n containerMutationPath(moveContainerOperation, containerId),\n} as const;\n\nexport const containerDelete = {\n isResponse: isDeleteContainerOperationResponse,\n method: deleteContainerOperation.method,\n path: (containerId: string, requiredAncestorId?: string) =>\n operationRequestPathWithQuery(\n deleteContainerOperation,\n { containerId },\n { requiredAncestorId },\n ),\n} as const;\n"]}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { createOrganizationGroupOperation, isCreateOrganizationGroupOperationRequest, isCreateOrganizationGroupOperationResponse,
|
|
1
|
+
import { createOrganizationGroupOperation, isCreateOrganizationGroupOperationRequest, isCreateOrganizationGroupOperationResponse, operationRequestPathWithQuery, } from "../../../validators/operation/index.js";
|
|
2
2
|
export const createOrganizationGroup = {
|
|
3
3
|
isRequest: isCreateOrganizationGroupOperationRequest,
|
|
4
4
|
isResponse: isCreateOrganizationGroupOperationResponse,
|
|
5
5
|
method: createOrganizationGroupOperation.method,
|
|
6
|
-
path(organizationId) {
|
|
7
|
-
return
|
|
8
|
-
organizationId,
|
|
9
|
-
});
|
|
6
|
+
path(organizationId, readModelCursor) {
|
|
7
|
+
return operationRequestPathWithQuery(createOrganizationGroupOperation, { organizationId }, { readModelCursor });
|
|
10
8
|
},
|
|
11
9
|
};
|
|
12
10
|
//# sourceMappingURL=createGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGroup.js","sourceRoot":"","sources":["createGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,yCAAyC,EACzC,0CAA0C,EAC1C,
|
|
1
|
+
{"version":3,"file":"createGroup.js","sourceRoot":"","sources":["createGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,yCAAyC,EACzC,0CAA0C,EAC1C,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,SAAS,EAAE,yCAAyC;IACpD,UAAU,EAAE,0CAA0C;IACtD,MAAM,EAAE,gCAAgC,CAAC,MAAM;IAC/C,IAAI,CAAC,cAAsB,EAAE,eAAwB;QACnD,OAAO,6BAA6B,CAClC,gCAAgC,EAChC,EAAE,cAAc,EAAE,EAClB,EAAE,eAAe,EAAE,CACpB,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import {\n createOrganizationGroupOperation,\n isCreateOrganizationGroupOperationRequest,\n isCreateOrganizationGroupOperationResponse,\n operationRequestPathWithQuery,\n} from \"@tearleads/validators/operation\";\n\nexport const createOrganizationGroup = {\n isRequest: isCreateOrganizationGroupOperationRequest,\n isResponse: isCreateOrganizationGroupOperationResponse,\n method: createOrganizationGroupOperation.method,\n path(organizationId: string, readModelCursor?: string) {\n return operationRequestPathWithQuery(\n createOrganizationGroupOperation,\n { organizationId },\n { readModelCursor },\n );\n },\n};\n"]}
|
|
@@ -3,11 +3,8 @@ export const commitOrganizationGroupPolicy = {
|
|
|
3
3
|
isRequest: isCommitOrganizationGroupPolicyOperationRequest,
|
|
4
4
|
isResponse: isCommitOrganizationGroupPolicyOperationResponse,
|
|
5
5
|
method: commitOrganizationGroupPolicyOperation.method,
|
|
6
|
-
path(organizationId, groupId) {
|
|
7
|
-
return
|
|
8
|
-
groupId,
|
|
9
|
-
organizationId,
|
|
10
|
-
});
|
|
6
|
+
path(organizationId, groupId, readModelCursor) {
|
|
7
|
+
return operationRequestPathWithQuery(commitOrganizationGroupPolicyOperation, { groupId, organizationId }, { readModelCursor });
|
|
11
8
|
},
|
|
12
9
|
};
|
|
13
10
|
export const getPrincipalPolicy = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,oCAAoC,EACpC,2BAA2B,EAC3B,+CAA+C,EAC/C,gDAAgD,EAChD,8CAA8C,EAC9C,qCAAqC,EACrC,oCAAoC,EACpC,qCAAqC,EACrC,oBAAoB,EACpB,6BAA6B,EAE7B,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,SAAS,EAAE,+CAA+C;IAC1D,UAAU,EAAE,gDAAgD;IAC5D,MAAM,EAAE,sCAAsC,CAAC,MAAM;IACrD,IAAI,CAAC,cAAsB,EAAE,OAAe;
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,oCAAoC,EACpC,2BAA2B,EAC3B,+CAA+C,EAC/C,gDAAgD,EAChD,8CAA8C,EAC9C,qCAAqC,EACrC,oCAAoC,EACpC,qCAAqC,EACrC,oBAAoB,EACpB,6BAA6B,EAE7B,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,SAAS,EAAE,+CAA+C;IAC1D,UAAU,EAAE,gDAAgD;IAC5D,MAAM,EAAE,sCAAsC,CAAC,MAAM;IACrD,IAAI,CAAC,cAAsB,EAAE,OAAe,EAAE,eAAwB;QACpE,OAAO,6BAA6B,CAClC,sCAAsC,EACtC,EAAE,OAAO,EAAE,cAAc,EAAE,EAC3B,EAAE,eAAe,EAAE,CACpB,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,UAAU,EAAE,qCAAqC;IACjD,MAAM,EAAE,2BAA2B,CAAC,MAAM;IAC1C,IAAI,CACF,aAAuC,EACvC,WAAmB,EACnB,QAAkC,EAAE;QAEpC,OAAO,6BAA6B,CAClC,2BAA2B,EAC3B;YACE,WAAW;YACX,aAAa;SACd,EACD,KAAK,CACN,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,UAAU,EAAE,8CAA8C;IAC1D,MAAM,EAAE,oCAAoC,CAAC,MAAM;IACnD,IAAI,CACF,aAAuC,EACvC,WAAmB,EACnB,SAAiB;QAEjB,OAAO,6BAA6B,CAClC,oCAAoC,EACpC,EAAE,WAAW,EAAE,aAAa,EAAE,EAC9B,EAAE,SAAS,EAAE,CACd,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,oCAAoC;IAC/C,UAAU,EAAE,qCAAqC;IACjD,MAAM,EAAE,2BAA2B,CAAC,MAAM;IAC1C,IAAI,CAAC,aAA6B,EAAE,WAAmB;QACrD,OAAO,oBAAoB,CAAC,2BAA2B,EAAE;YACvD,WAAW;YACX,aAAa;SACd,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import {\n commitOrganizationGroupPolicyOperation,\n getPrincipalMemberEnvelopesOperation,\n getPrincipalPolicyOperation,\n isCommitOrganizationGroupPolicyOperationRequest,\n isCommitOrganizationGroupPolicyOperationResponse,\n isGetPrincipalMemberEnvelopesOperationResponse,\n isGetPrincipalPolicyOperationResponse,\n isPutPrincipalPolicyOperationRequest,\n isPutPrincipalPolicyOperationResponse,\n operationRequestPath,\n operationRequestPathWithQuery,\n type PrincipalPolicyPageQuery,\n putPrincipalPolicyOperation,\n} from \"@tearleads/validators/operation\";\n\nexport const commitOrganizationGroupPolicy = {\n isRequest: isCommitOrganizationGroupPolicyOperationRequest,\n isResponse: isCommitOrganizationGroupPolicyOperationResponse,\n method: commitOrganizationGroupPolicyOperation.method,\n path(organizationId: string, groupId: string, readModelCursor?: string) {\n return operationRequestPathWithQuery(\n commitOrganizationGroupPolicyOperation,\n { groupId, organizationId },\n { readModelCursor },\n );\n },\n};\n\nexport const getPrincipalPolicy = {\n isResponse: isGetPrincipalPolicyOperationResponse,\n method: getPrincipalPolicyOperation.method,\n path(\n principalType: \"group\" | \"organization\",\n principalId: string,\n query: PrincipalPolicyPageQuery = {},\n ) {\n return operationRequestPathWithQuery(\n getPrincipalPolicyOperation,\n {\n principalId,\n principalType,\n },\n query,\n );\n },\n};\n\nexport const getPrincipalMemberEnvelopes = {\n isResponse: isGetPrincipalMemberEnvelopesOperationResponse,\n method: getPrincipalMemberEnvelopesOperation.method,\n path(\n principalType: \"group\" | \"organization\",\n principalId: string,\n stateHash: string,\n ) {\n return operationRequestPathWithQuery(\n getPrincipalMemberEnvelopesOperation,\n { principalId, principalType },\n { stateHash },\n );\n },\n};\n\nexport const putPrincipalPolicy = {\n isRequest: isPutPrincipalPolicyOperationRequest,\n isResponse: isPutPrincipalPolicyOperationResponse,\n method: putPrincipalPolicyOperation.method,\n path(principalType: \"organization\", principalId: string) {\n return operationRequestPath(putPrincipalPolicyOperation, {\n principalId,\n principalType,\n });\n },\n};\n"]}
|
|
@@ -22,6 +22,12 @@ export interface RequestResultOptions {
|
|
|
22
22
|
* changes which hashes the read cites, never what the read accepts.
|
|
23
23
|
*/
|
|
24
24
|
readonly projectionListing?: WriterProjectionListing | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Group creates, group policy commits and shares only: the organization
|
|
27
|
+
* read-model cursor the caller holds. The response then carries the
|
|
28
|
+
* read-model delta from it when the commit advanced from that cursor.
|
|
29
|
+
*/
|
|
30
|
+
readonly readModelCursor?: string | undefined;
|
|
25
31
|
}
|
|
26
32
|
export type OperationRequestFn = <T>(path: string, validator: (value: unknown) => value is T, method: HttpMethod, body: RequestBody | undefined, options: RequestResultOptions | undefined, failureOperation: HttpOperation) => Promise<T | null>;
|
|
27
33
|
export type OperationRequestResultFn = <T>(path: string, validator: (value: unknown) => value is T, method: HttpMethod, body: RequestBody | undefined, options: RequestResultOptions | undefined, failureOperation: HttpOperation) => Promise<RequestResult<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DocumentAttributionRangesQuery,\n HttpOperation,\n HttpOperationMethod,\n} from \"@tearleads/validators/operation\";\nimport type { ReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport type { ApiNetworkError } from \"./networkFailure\";\nimport type { WriterProjectionListing } from \"./verifiedManifestCitations\";\n\nexport type HttpMethod = HttpOperationMethod;\nexport type RequestBody = BodyInit;\n\nexport type ListDocumentEditAttributionRangesOptions = Omit<\n DocumentAttributionRangesQuery,\n \"cursor\"\n> & {\n cursor?: DocumentAttributionRangesQuery[\"cursor\"] | null;\n};\n\nexport interface RequestResultOptions {\n readonly signal?: AbortSignal | undefined;\n /** Expected target for a declared 402; mismatched response identities fail closed. */\n readonly expectedPaymentRequiredOrganizationId?: string | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly reportErrors?: boolean | undefined;\n /** Called after this request or a concurrent request renews the same session. */\n readonly onSessionRenewed?: (() => void) | undefined;\n readonly retryOnSessionExpired?: boolean | \"renew-only\" | undefined;\n /**\n * Writer-projection reads only: where a listing placed the container, so\n * an unplaced container can cite its listed parent's held bytes. It\n * changes which hashes the read cites, never what the read accepts.\n */\n readonly projectionListing?: WriterProjectionListing | undefined;\n}\n\nexport type OperationRequestFn = <T>(\n path: string,\n validator: (value: unknown) => value is T,\n method: HttpMethod,\n body: RequestBody | undefined,\n options: RequestResultOptions | undefined,\n failureOperation: HttpOperation,\n) => Promise<T | null>;\n\nexport type OperationRequestResultFn = <T>(\n path: string,\n validator: (value: unknown) => value is T,\n method: HttpMethod,\n body: RequestBody | undefined,\n options: RequestResultOptions | undefined,\n failureOperation: HttpOperation,\n) => Promise<RequestResult<T>>;\n\nexport type RequestFailureKind =\n | \"storage\"\n | \"http\"\n | \"network\"\n | \"json\"\n | \"shape\"\n | \"cancelled\"\n | \"outcome-unknown\";\n\nexport interface RequestFailure {\n readonly code?: string | undefined;\n readonly kind: RequestFailureKind;\n readonly message: string;\n readonly method: HttpMethod;\n /** Set when the fetch itself threw: what the client could observe, without secrets. */\n readonly networkError?: ApiNetworkError | undefined;\n readonly ok: false;\n readonly path: string;\n readonly report: () => void;\n readonly status: number | null;\n readonly statusText: string;\n readonly stalePrincipalHeads?: ReferencedPrincipalStateResponse[] | undefined;\n /**\n * With `container_descendant_rekeys_required`, the full owed set, parent-first;\n * with `container_descendant_rekeys_inaccessible`, its unwritable subset.\n * A hint, never authority; verify each container before signing for it.\n */\n readonly requiredContainerIds?: readonly string[] | undefined;\n}\n\nexport interface RequestSuccess<T> {\n readonly data: T;\n readonly ok: true;\n}\n\nexport type RequestResult<T> = RequestFailure | RequestSuccess<T>;\n\nexport interface ResponseRequestValidationFailureInput {\n readonly code?: string | undefined;\n readonly kind: RequestFailureKind;\n readonly message: string;\n readonly method: HttpMethod;\n readonly options?: RequestResultOptions | undefined;\n readonly path: string;\n readonly status: number | null;\n readonly statusText: string;\n}\n\nexport interface OperationResponseRequestFn {\n (\n path: string,\n method: HttpMethod,\n body: RequestBody | undefined,\n options: RequestResultOptions,\n additionalSuccessStatuses: readonly number[],\n failureOperation: HttpOperation,\n ): Promise<RequestResult<Response>>;\n readonly reportFailure: (\n input: ResponseRequestValidationFailureInput,\n ) => RequestFailure;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DocumentAttributionRangesQuery,\n HttpOperation,\n HttpOperationMethod,\n} from \"@tearleads/validators/operation\";\nimport type { ReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport type { ApiNetworkError } from \"./networkFailure\";\nimport type { WriterProjectionListing } from \"./verifiedManifestCitations\";\n\nexport type HttpMethod = HttpOperationMethod;\nexport type RequestBody = BodyInit;\n\nexport type ListDocumentEditAttributionRangesOptions = Omit<\n DocumentAttributionRangesQuery,\n \"cursor\"\n> & {\n cursor?: DocumentAttributionRangesQuery[\"cursor\"] | null;\n};\n\nexport interface RequestResultOptions {\n readonly signal?: AbortSignal | undefined;\n /** Expected target for a declared 402; mismatched response identities fail closed. */\n readonly expectedPaymentRequiredOrganizationId?: string | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly reportErrors?: boolean | undefined;\n /** Called after this request or a concurrent request renews the same session. */\n readonly onSessionRenewed?: (() => void) | undefined;\n readonly retryOnSessionExpired?: boolean | \"renew-only\" | undefined;\n /**\n * Writer-projection reads only: where a listing placed the container, so\n * an unplaced container can cite its listed parent's held bytes. It\n * changes which hashes the read cites, never what the read accepts.\n */\n readonly projectionListing?: WriterProjectionListing | undefined;\n /**\n * Group creates, group policy commits and shares only: the organization\n * read-model cursor the caller holds. The response then carries the\n * read-model delta from it when the commit advanced from that cursor.\n */\n readonly readModelCursor?: string | undefined;\n}\n\nexport type OperationRequestFn = <T>(\n path: string,\n validator: (value: unknown) => value is T,\n method: HttpMethod,\n body: RequestBody | undefined,\n options: RequestResultOptions | undefined,\n failureOperation: HttpOperation,\n) => Promise<T | null>;\n\nexport type OperationRequestResultFn = <T>(\n path: string,\n validator: (value: unknown) => value is T,\n method: HttpMethod,\n body: RequestBody | undefined,\n options: RequestResultOptions | undefined,\n failureOperation: HttpOperation,\n) => Promise<RequestResult<T>>;\n\nexport type RequestFailureKind =\n | \"storage\"\n | \"http\"\n | \"network\"\n | \"json\"\n | \"shape\"\n | \"cancelled\"\n | \"outcome-unknown\";\n\nexport interface RequestFailure {\n readonly code?: string | undefined;\n readonly kind: RequestFailureKind;\n readonly message: string;\n readonly method: HttpMethod;\n /** Set when the fetch itself threw: what the client could observe, without secrets. */\n readonly networkError?: ApiNetworkError | undefined;\n readonly ok: false;\n readonly path: string;\n readonly report: () => void;\n readonly status: number | null;\n readonly statusText: string;\n readonly stalePrincipalHeads?: ReferencedPrincipalStateResponse[] | undefined;\n /**\n * With `container_descendant_rekeys_required`, the full owed set, parent-first;\n * with `container_descendant_rekeys_inaccessible`, its unwritable subset.\n * A hint, never authority; verify each container before signing for it.\n */\n readonly requiredContainerIds?: readonly string[] | undefined;\n}\n\nexport interface RequestSuccess<T> {\n readonly data: T;\n readonly ok: true;\n}\n\nexport type RequestResult<T> = RequestFailure | RequestSuccess<T>;\n\nexport interface ResponseRequestValidationFailureInput {\n readonly code?: string | undefined;\n readonly kind: RequestFailureKind;\n readonly message: string;\n readonly method: HttpMethod;\n readonly options?: RequestResultOptions | undefined;\n readonly path: string;\n readonly status: number | null;\n readonly statusText: string;\n}\n\nexport interface OperationResponseRequestFn {\n (\n path: string,\n method: HttpMethod,\n body: RequestBody | undefined,\n options: RequestResultOptions,\n additionalSuccessStatuses: readonly number[],\n failureOperation: HttpOperation,\n ): Promise<RequestResult<Response>>;\n readonly reportFailure: (\n input: ResponseRequestValidationFailureInput,\n ) => RequestFailure;\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type ContainerKekWireLevel } from "../validators/response/index.js";
|
|
1
|
+
import { type ContainerKekWireLevel, type PrincipalStatePayloadResponse } from "../validators/response/index.js";
|
|
2
2
|
import { type ServedAccessManifestBundleWireResponse } from "../validators/util/index.js";
|
|
3
|
+
import { type HeldDirectoryCitation } from "./heldDirectoryCitations.js";
|
|
4
|
+
export type { HeldDirectoryCitation } from "./heldDirectoryCitations.js";
|
|
3
5
|
/** Citation only saves bytes: a source slower than this sends the read uncited. */
|
|
4
6
|
export declare const MANIFEST_CITATION_DEADLINE_MS = 250;
|
|
5
7
|
/**
|
|
@@ -15,11 +17,15 @@ export interface WriterProjectionTarget {
|
|
|
15
17
|
readonly id: string;
|
|
16
18
|
readonly listing?: WriterProjectionListing | undefined;
|
|
17
19
|
}
|
|
18
|
-
/** A held access-manifest bundle or a held container KEK level. */
|
|
19
|
-
export type HeldProjectionCitation = ServedAccessManifestBundleWireResponse | ContainerKekWireLevel;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* A held access-manifest bundle, a held container KEK level, or a held
|
|
22
|
+
* organization directory payload with its signed state.
|
|
23
|
+
*/
|
|
24
|
+
export type HeldProjectionCitation = ServedAccessManifestBundleWireResponse | ContainerKekWireLevel | HeldDirectoryCitation;
|
|
25
|
+
/**
|
|
26
|
+
* Verified access-manifest bundles, container KEK levels and organization
|
|
27
|
+
* directory payloads a device durably holds that a writer projection of
|
|
28
|
+
* `target` may cite, most useful first.
|
|
23
29
|
* This is never trust input: the exact cited bytes only fill the response's
|
|
24
30
|
* omitted positions, and the caller verifies the rebuilt projection exactly
|
|
25
31
|
* as a full one.
|
|
@@ -27,10 +33,14 @@ export type HeldProjectionCitation = ServedAccessManifestBundleWireResponse | Co
|
|
|
27
33
|
export interface VerifiedManifestCitations {
|
|
28
34
|
cite(target: WriterProjectionTarget): Promise<readonly HeldProjectionCitation[]>;
|
|
29
35
|
}
|
|
30
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The exact bytes one request cites: bundles by hash, levels by digest,
|
|
38
|
+
* directory payloads by their organization state's hash.
|
|
39
|
+
*/
|
|
31
40
|
export interface HeldProjectionCitations {
|
|
32
41
|
readonly bundles: Map<string, ServedAccessManifestBundleWireResponse>;
|
|
33
42
|
readonly kekLevels: Map<string, ContainerKekWireLevel>;
|
|
43
|
+
readonly directories: Map<string, PrincipalStatePayloadResponse>;
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
36
46
|
* The bytes one request cites, copied so a later eviction or mutation of the
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { computeContainerKekLevelDigest } from "../crypto/index.js";
|
|
2
2
|
import { isContainerKekWireLevel, } from "../validators/response/index.js";
|
|
3
|
-
import { isServedAccessManifestBundleWireResponse, isSha256HexString, KNOWN_MANIFEST_HINT_LIMIT, } from "../validators/util/index.js";
|
|
3
|
+
import { isServedAccessManifestBundleWireResponse, isSha256HexString, KNOWN_DIRECTORY_HINT_LIMIT, KNOWN_MANIFEST_HINT_LIMIT, } from "../validators/util/index.js";
|
|
4
|
+
import { isHeldDirectoryCitation, signedDirectoryPayload, } from "./heldDirectoryCitations.js";
|
|
4
5
|
/** Citation only saves bytes: a source slower than this sends the read uncited. */
|
|
5
6
|
export const MANIFEST_CITATION_DEADLINE_MS = 250;
|
|
6
7
|
function noCitations() {
|
|
7
|
-
return { bundles: new Map(), kekLevels: new Map() };
|
|
8
|
+
return { bundles: new Map(), kekLevels: new Map(), directories: new Map() };
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* The prepared citations, or none once the deadline passes, the caller
|
|
@@ -35,34 +36,52 @@ function boundedCitation(prepare, signal) {
|
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*/
|
|
42
|
-
async function prepareHeldCitations(entries) {
|
|
43
|
-
const held = noCitations();
|
|
39
|
+
/** Copies of the source's entries, each kind within its own hint quota. */
|
|
40
|
+
function copyHeldEntries(entries) {
|
|
41
|
+
const bundles = new Map();
|
|
44
42
|
const levels = [];
|
|
43
|
+
const directories = [];
|
|
44
|
+
const manifestQuotaLeft = () => bundles.size + levels.length < KNOWN_MANIFEST_HINT_LIMIT;
|
|
45
45
|
for (const entry of entries) {
|
|
46
|
-
if (held.bundles.size + levels.length >= KNOWN_MANIFEST_HINT_LIMIT)
|
|
47
|
-
break;
|
|
48
46
|
try {
|
|
49
|
-
if (
|
|
47
|
+
if (isHeldDirectoryCitation(entry)) {
|
|
48
|
+
if (directories.length < KNOWN_DIRECTORY_HINT_LIMIT)
|
|
49
|
+
directories.push(structuredClone(entry));
|
|
50
|
+
}
|
|
51
|
+
else if (!manifestQuotaLeft())
|
|
52
|
+
continue;
|
|
53
|
+
else if (isContainerKekWireLevel(entry))
|
|
50
54
|
levels.push(structuredClone(entry));
|
|
51
55
|
else if (isServedAccessManifestBundleWireResponse(entry) &&
|
|
52
56
|
isSha256HexString(entry.manifestHash) &&
|
|
53
|
-
!
|
|
54
|
-
|
|
57
|
+
!bundles.has(entry.manifestHash))
|
|
58
|
+
bundles.set(entry.manifestHash, structuredClone(entry));
|
|
55
59
|
}
|
|
56
60
|
catch {
|
|
57
61
|
// An uncloneable entry is skipped; its bytes simply travel.
|
|
58
62
|
}
|
|
59
63
|
}
|
|
64
|
+
return { bundles, levels, directories };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Copies the source's answer and keys each KEK level by the digest
|
|
68
|
+
* recomputed from its own bytes, never by a digest the source names. A
|
|
69
|
+
* directory payload is cited only when it hashes to the payload hash its own
|
|
70
|
+
* signed organization state commits.
|
|
71
|
+
*/
|
|
72
|
+
async function prepareHeldCitations(entries) {
|
|
73
|
+
const { bundles, levels, directories } = copyHeldEntries(entries);
|
|
74
|
+
const held = { ...noCitations(), bundles };
|
|
60
75
|
const digests = await Promise.all(levels.map(computeContainerKekLevelDigest));
|
|
61
76
|
levels.forEach((level, index) => {
|
|
62
77
|
const digest = digests[index];
|
|
63
78
|
if (digest && !held.kekLevels.has(digest))
|
|
64
79
|
held.kekLevels.set(digest, level);
|
|
65
80
|
});
|
|
81
|
+
const payloads = await Promise.all(directories.map(signedDirectoryPayload));
|
|
82
|
+
for (const payload of payloads)
|
|
83
|
+
if (payload && !held.directories.has(payload.stateHash))
|
|
84
|
+
held.directories.set(payload.stateHash, payload);
|
|
66
85
|
return held;
|
|
67
86
|
}
|
|
68
87
|
/**
|