@tearleads/client-sdk 0.1.249 → 0.1.251

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 (119) hide show
  1. package/data/documents/shared/events.js +2 -1
  2. package/data/documents/shared/events.js.map +1 -1
  3. package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js +1 -4
  4. package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -1
  5. package/data/persistence/principalPolicy/heldOrganizationDirectories.js +6 -1
  6. package/data/persistence/principalPolicy/heldOrganizationDirectories.js.map +1 -1
  7. package/data/persistence/principalPolicy/principalPolicyBundleIntegrity.js +1 -1
  8. package/data/persistence/principalPolicy/principalPolicyBundleIntegrity.js.map +1 -1
  9. package/data/persistence/principalPolicy/verifiedPrincipalPolicyCurrent.js +1 -5
  10. package/data/persistence/principalPolicy/verifiedPrincipalPolicyCurrent.js.map +1 -1
  11. package/data/principals/organizationGroupDirectoryRequest.js +0 -2
  12. package/data/principals/organizationGroupDirectoryRequest.js.map +1 -1
  13. package/data/principals/organizationPolicyRequest.js +0 -2
  14. package/data/principals/organizationPolicyRequest.js.map +1 -1
  15. package/data/principals/principalPolicyRequest.js +0 -2
  16. package/data/principals/principalPolicyRequest.js.map +1 -1
  17. package/internal/api-client/ApiClient.d.ts +0 -58
  18. package/internal/api-client/client/apiClientContext.d.ts +0 -30
  19. package/internal/api-client/client/documents.d.ts +0 -12
  20. package/internal/api-client/client/principalPolicies.d.ts +0 -18
  21. package/internal/api-client/client/writerProjections.d.ts +0 -12
  22. package/internal/api-client/heldDirectoryCitations.d.ts +8 -4
  23. package/internal/api-client/heldDirectoryCitations.js +6 -10
  24. package/internal/api-client/heldDirectoryCitations.js.map +1 -1
  25. package/internal/api-client/organizationPolicyHistory.d.ts +0 -6
  26. package/internal/api-client/principalPolicyRequests.d.ts +0 -18
  27. package/internal/api-client/verifiedManifestCitations.js +3 -3
  28. package/internal/api-client/verifiedManifestCitations.js.map +1 -1
  29. package/internal/crypto/index.d.ts +1 -1
  30. package/internal/crypto/index.js.map +1 -1
  31. package/internal/crypto/keying/principalPolicyPayload.js +2 -12
  32. package/internal/crypto/keying/principalPolicyPayload.js.map +1 -1
  33. package/internal/crypto/keying/principalPolicyTypes.d.ts +5 -6
  34. package/internal/crypto/keying/principalPolicyTypes.js.map +1 -1
  35. package/internal/crypto/principalState.d.ts +1 -1
  36. package/internal/crypto/principalState.js.map +1 -1
  37. package/internal/crypto/principalStateTypes.d.ts +0 -1
  38. package/internal/crypto/principalStateTypes.js.map +1 -1
  39. package/internal/validators/documentCreateSeedRefinements.js +2 -2
  40. package/internal/validators/documentCreateSeedRefinements.js.map +1 -1
  41. package/internal/validators/operation/auth.d.ts +50 -1727
  42. package/internal/validators/operation/auth.js +2 -2
  43. package/internal/validators/operation/auth.js.map +1 -1
  44. package/internal/validators/operation/containerMutations.d.ts +1 -294
  45. package/internal/validators/operation/containerMutations.js +2 -2
  46. package/internal/validators/operation/containerMutations.js.map +1 -1
  47. package/internal/validators/operation/documentMutations.d.ts +1 -342
  48. package/internal/validators/operation/documentMutations.js +2 -2
  49. package/internal/validators/operation/documentMutations.js.map +1 -1
  50. package/internal/validators/operation/organizationPolicyHistory.d.ts +0 -24
  51. package/internal/validators/operation/organizations.d.ts +50 -1751
  52. package/internal/validators/operation/organizations.js +2 -2
  53. package/internal/validators/operation/organizations.js.map +1 -1
  54. package/internal/validators/operation/principals.d.ts +0 -56
  55. package/internal/validators/operation/writerProjections.d.ts +0 -48
  56. package/internal/validators/organizationProvisioningRefinements.js +2 -2
  57. package/internal/validators/organizationProvisioningRefinements.js.map +1 -1
  58. package/internal/validators/request/containerMetadata.d.ts +0 -276
  59. package/internal/validators/request/containerMetadata.js +5 -4
  60. package/internal/validators/request/containerMetadata.js.map +1 -1
  61. package/internal/validators/request/document.d.ts +0 -277
  62. package/internal/validators/request/document.js +8 -4
  63. package/internal/validators/request/document.js.map +1 -1
  64. package/internal/validators/request/documentCreateSeed.d.ts +99 -0
  65. package/internal/validators/request/documentCreateSeed.js +132 -9
  66. package/internal/validators/request/documentCreateSeed.js.map +1 -1
  67. package/internal/validators/request/documentSyncSchema.d.ts +41 -0
  68. package/internal/validators/request/documentSyncSchema.js +1 -1
  69. package/internal/validators/request/documentSyncSchema.js.map +1 -1
  70. package/internal/validators/request/index.d.ts +1 -0
  71. package/internal/validators/request/index.js +1 -0
  72. package/internal/validators/request/index.js.map +1 -1
  73. package/internal/validators/request/organization.d.ts +0 -32
  74. package/internal/validators/request/organizationProvisioning.d.ts +263 -5639
  75. package/internal/validators/request/organizationProvisioning.js +10 -4
  76. package/internal/validators/request/organizationProvisioning.js.map +1 -1
  77. package/internal/validators/request/principal.d.ts +4 -48
  78. package/internal/validators/request/principal.js +4 -2
  79. package/internal/validators/request/principal.js.map +1 -1
  80. package/internal/validators/request/registration.d.ts +71 -1727
  81. package/internal/validators/response/container.d.ts +0 -48
  82. package/internal/validators/response/documentMutation.d.ts +0 -96
  83. package/internal/validators/response/organizationPolicyHistory.d.ts +0 -24
  84. package/internal/validators/response/policyEvidenceWire.d.ts +5 -3
  85. package/internal/validators/response/policyEvidenceWire.js +6 -4
  86. package/internal/validators/response/policyEvidenceWire.js.map +1 -1
  87. package/internal/validators/response/principal.d.ts +0 -48
  88. package/internal/validators/response/principalPolicyPage.d.ts +0 -48
  89. package/internal/validators/response/principalSnapshot.d.ts +4 -24
  90. package/internal/validators/response/principalSnapshot.js +4 -6
  91. package/internal/validators/response/principalSnapshot.js.map +1 -1
  92. package/internal/validators/response/projectionPolicyEvidence.d.ts +0 -48
  93. package/package.json +1 -1
  94. package/workflows/container-contents/container-state/create/createWithMetadata.js +6 -3
  95. package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -1
  96. package/workflows/documents/create/index.js +4 -4
  97. package/workflows/documents/create/index.js.map +1 -1
  98. package/workflows/documents/sync/initialSync.d.ts +26 -11
  99. package/workflows/documents/sync/initialSync.js +32 -12
  100. package/workflows/documents/sync/initialSync.js.map +1 -1
  101. package/workflows/organizations/groupPolicy/currentPolicyMutationAcknowledgement.js +1 -6
  102. package/workflows/organizations/groupPolicy/currentPolicyMutationAcknowledgement.js.map +1 -1
  103. package/workflows/organizations/groupPolicy/groupPolicyMutationAcknowledgement.js +1 -6
  104. package/workflows/organizations/groupPolicy/groupPolicyMutationAcknowledgement.js.map +1 -1
  105. package/workflows/organizations/policyHistory/organizationPolicyHistoryVerification.js +4 -6
  106. package/workflows/organizations/policyHistory/organizationPolicyHistoryVerification.js.map +1 -1
  107. package/workflows/organizations/principalPolicy/principalPolicyReceiptArtifacts.js +1 -7
  108. package/workflows/organizations/principalPolicy/principalPolicyReceiptArtifacts.js.map +1 -1
  109. package/workflows/principals/policyCache/principalPolicyCacheValidation.js +0 -13
  110. package/workflows/principals/policyCache/principalPolicyCacheValidation.js.map +1 -1
  111. package/workflows/principals/publicHistory/publicProjectionDirectory.js +4 -5
  112. package/workflows/principals/publicHistory/publicProjectionDirectory.js.map +1 -1
  113. package/workflows/registration/provisionedProfileDocument.js +2 -2
  114. package/workflows/registration/provisionedProfileDocument.js.map +1 -1
  115. package/workflows/registration/provisioningBootstrapBuilders.d.ts +0 -74
  116. package/workflows/registration/provisioningBootstrapBuilders.js +3 -3
  117. package/workflows/registration/provisioningBootstrapBuilders.js.map +1 -1
  118. package/workflows/registration/registrationPrincipalPolicyPersistence.js +1 -7
  119. package/workflows/registration/registrationPrincipalPolicyPersistence.js.map +1 -1
@@ -5,8 +5,8 @@ import { arraySchema, loosePlainObject, uuidV4StringSchema } from "../schema.js"
5
5
  import { OrganizationReplacementAuthorizationSchema } from "../util/organizationReplacement.js";
6
6
  import { ContainerMutationRequestSchema } from "./container.js";
7
7
  import { containerCreateWithMetadataDocumentRequestShape } from "./containerMetadata.js";
8
- import { DocumentSyncRequestSchema, documentCreateRequestShape, } from "./document.js";
9
- import { refineSingleUpdateSeed } from "./documentCreateSeed.js";
8
+ import { documentCreateRequestShape } from "./document.js";
9
+ import { DocumentCreateSeedRequestSchema, refineCreateSeedSync, refineSingleUpdateSeed, } from "./documentCreateSeed.js";
10
10
  import { CreateOrganizationGroupRequestSchema } from "./organization.js";
11
11
  import { OrganizationPrincipalPolicyRequestSchema } from "./principal.js";
12
12
  /**
@@ -16,7 +16,7 @@ import { OrganizationPrincipalPolicyRequestSchema } from "./principal.js";
16
16
  */
17
17
  const provisionedSystemContainerRequestShape = {
18
18
  ...containerCreateWithMetadataDocumentRequestShape,
19
- initialMetadataSync: DocumentSyncRequestSchema,
19
+ initialMetadataSync: DocumentCreateSeedRequestSchema,
20
20
  };
21
21
  /**
22
22
  * A document whose encrypted initial body is committed with its manifest in the
@@ -24,19 +24,25 @@ const provisionedSystemContainerRequestShape = {
24
24
  */
25
25
  const provisionedDocumentRequestShape = {
26
26
  ...documentCreateRequestShape,
27
- initialSync: DocumentSyncRequestSchema,
27
+ initialSync: DocumentCreateSeedRequestSchema,
28
28
  };
29
29
  export const ProvisionedDocumentRequestSchema = registerJsonSchemaRuntimeRefinements(loosePlainObject(provisionedDocumentRequestShape).superRefine((value, context) => {
30
30
  refineSingleUpdateSeed(value.initialSync, context, {
31
31
  message: "provisioned document seed requires one update and no container rekeys",
32
32
  path: "initialSync",
33
33
  });
34
+ refineCreateSeedSync(value, value.initialSync, context, {
35
+ path: "initialSync",
36
+ withinSyncLimit: true,
37
+ });
34
38
  }), [organizationProvisioningDocumentSeedRefinement]);
35
39
  export const ProvisionedSystemContainerRequestSchema = registerJsonSchemaRuntimeRefinements(loosePlainObject(provisionedSystemContainerRequestShape).superRefine((value, context) => {
36
40
  refineSingleUpdateSeed(value.initialMetadataSync, context, {
37
41
  message: "provisioned system-container metadata seed requires one update and no container rekeys",
38
42
  path: "initialMetadataSync",
39
43
  });
44
+ if (typeof value.metadataDocument === "object")
45
+ refineCreateSeedSync(value.metadataDocument, value.initialMetadataSync, context, { path: "initialMetadataSync", withinSyncLimit: true });
40
46
  }), [organizationProvisioningContainerSeedRefinement]);
41
47
  export function isProvisionedDocumentRequest(value) {
42
48
  return ProvisionedDocumentRequestSchema.safeParse(value).success;
@@ -1 +1 @@
1
- {"version":3,"file":"organizationProvisioning.js","sourceRoot":"","sources":["organizationProvisioning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,+CAA+C,EAC/C,8CAA8C,GAC/C,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,0CAA0C,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,+CAA+C,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,wCAAwC,EAAE,MAAM,aAAa,CAAC;AAEvE;;;;GAIG;AACH,MAAM,sCAAsC,GAAG;IAC7C,GAAG,+CAA+C;IAClD,mBAAmB,EAAE,yBAAyB;CAC/C,CAAC;AAEF;;;GAGG;AACH,MAAM,+BAA+B,GAAG;IACtC,GAAG,0BAA0B;IAC7B,WAAW,EAAE,yBAAyB;CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAC3C,oCAAoC,CAClC,gBAAgB,CAAC,+BAA+B,CAAC,CAAC,WAAW,CAC3D,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACjB,sBAAsB,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE;QACjD,OAAO,EACL,uEAAuE;QACzE,I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AgB,CACnE,oCAAoC,CACrC,CAAC;AAMF,MAAM,UAAU,iCAAiC,CAC/C,KAAc;IAEd,OAAO,qCAAqC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,gBAAgB,CAAC;IAC9D,GAAG,oCAAoC;IACvC,wBAAwB,EACtB,0CAA0C,CAAC,QAAQ,EAAE;IACvD;;;;OAIG;IACH,yBAAyB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IACrD;;;;;OAKG;IACH,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC3C;;;;OAIG;IACH,sBAAsB,EAAE,kBAAkB,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAC;AAMH,MAAM,UAAU,2BAA2B,CACzC,KAAc;IAEd,OAAO,+BAA+B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAClE,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { registerJsonSchemaRuntimeRefinements } from \"../jsonSchema\";\nimport {\n organizationProvisioningContainerSeedRefinement,\n organizationProvisioningDocumentSeedRefinement,\n} from \"../organizationProvisioningRefinements\";\nimport { arraySchema, loosePlainObject, uuidV4StringSchema } from \"../schema\";\nimport { OrganizationReplacementAuthorizationSchema } from \"../util/organizationReplacement\";\nimport { ContainerMutationRequestSchema } from \"./container\";\nimport { containerCreateWithMetadataDocumentRequestShape } from \"./containerMetadata\";\nimport {\n DocumentSyncRequestSchema,\n documentCreateRequestShape,\n} from \"./document\";\nimport { refineSingleUpdateSeed } from \"./documentCreateSeed\";\nimport { CreateOrganizationGroupRequestSchema } from \"./organization\";\nimport { OrganizationPrincipalPolicyRequestSchema } from \"./principal\";\n\n/**\n * A built-in or app-owned system container whose encrypted initial metadata\n * body is committed in the same transaction as the organization and document\n * shell.\n */\nconst provisionedSystemContainerRequestShape = {\n ...containerCreateWithMetadataDocumentRequestShape,\n initialMetadataSync: DocumentSyncRequestSchema,\n};\n\n/**\n * A document whose encrypted initial body is committed with its manifest in the\n * organization-provisioning transaction.\n */\nconst provisionedDocumentRequestShape = {\n ...documentCreateRequestShape,\n initialSync: DocumentSyncRequestSchema,\n};\n\nexport const ProvisionedDocumentRequestSchema =\n registerJsonSchemaRuntimeRefinements(\n loosePlainObject(provisionedDocumentRequestShape).superRefine(\n (value, context) => {\n refineSingleUpdateSeed(value.initialSync, context, {\n message:\n \"provisioned document seed requires one update and no container rekeys\",\n path: \"initialSync\",\n });\n },\n ),\n [organizationProvisioningDocumentSeedRefinement],\n );\n\nexport type ProvisionedDocumentRequest = z.infer<\n typeof ProvisionedDocumentRequestSchema\n>;\n\nexport const ProvisionedSystemContainerRequestSchema =\n registerJsonSchemaRuntimeRefinements(\n loosePlainObject(provisionedSystemContainerRequestShape).superRefine(\n (value, context) => {\n refineSingleUpdateSeed(value.initialMetadataSync, context, {\n message:\n \"provisioned system-container metadata seed requires one update and no container rekeys\",\n path: \"initialMetadataSync\",\n });\n },\n ),\n [organizationProvisioningContainerSeedRefinement],\n );\n\nexport type ProvisionedSystemContainerRequest = z.infer<\n typeof ProvisionedSystemContainerRequestSchema\n>;\n\nexport function isProvisionedDocumentRequest(\n value: unknown,\n): value is ProvisionedDocumentRequest {\n return ProvisionedDocumentRequestSchema.safeParse(value).success;\n}\n\nexport function isProvisionedSystemContainerRequest(\n value: unknown,\n): value is ProvisionedSystemContainerRequest {\n return ProvisionedSystemContainerRequestSchema.safeParse(value).success;\n}\n\n/**\n * The client-signed artifacts required to bootstrap a fresh organization: the\n * organization + admin/member group policies, the signed root container and its\n * metadata document, the organization metadata root, and the optional\n * roster/organization profile documents.\n *\n * This is the shared shape between user registration (which bootstraps the\n * user's personal organization) and creating an additional organization for an\n * existing user. Registration additionally carries the new user's public key\n * material (see {@link RegistrationRequest}); creating an additional\n * organization reuses the caller's existing keys, so it needs only this base.\n */\nexport const organizationProvisioningRequestShape = {\n initialAdminGroup: CreateOrganizationGroupRequestSchema,\n initialMemberGroup: CreateOrganizationGroupRequestSchema,\n initialOrganizationMetadataContainer: ProvisionedSystemContainerRequestSchema,\n initialOrganizationPolicy: OrganizationPrincipalPolicyRequestSchema,\n initialOrganizationProfileDocument:\n ProvisionedDocumentRequestSchema.optional(),\n initialRootContainer: ContainerMutationRequestSchema,\n initialRootMetadataDocument: ProvisionedDocumentRequestSchema,\n initialRosterProfileContainer:\n ProvisionedSystemContainerRequestSchema.optional(),\n initialRosterProfileDocument: ProvisionedDocumentRequestSchema.optional(),\n initialSystemContainers: arraySchema(\n ProvisionedSystemContainerRequestSchema,\n ).optional(),\n organizationId: uuidV4StringSchema,\n rootContainerId: uuidV4StringSchema,\n userId: uuidV4StringSchema,\n} satisfies z.ZodRawShape;\n\nexport const OrganizationProvisioningRequestSchema = loosePlainObject(\n organizationProvisioningRequestShape,\n);\n\nexport type OrganizationProvisioningRequest = z.infer<\n typeof OrganizationProvisioningRequestSchema\n>;\n\nexport function isOrganizationProvisioningRequest(\n value: unknown,\n): value is OrganizationProvisioningRequest {\n return OrganizationProvisioningRequestSchema.safeParse(value).success;\n}\n\n/**\n * Request to create an additional organization for the authenticated user. The\n * caller re-signs the same provisioning artifacts as registration, but with\n * their existing identity keys, so the request is exactly an\n * {@link OrganizationProvisioningRequest} where `userId` is the caller.\n */\nexport const CreateOrganizationRequestSchema = loosePlainObject({\n ...organizationProvisioningRequestShape,\n replacementAuthorization:\n OrganizationReplacementAuthorizationSchema.optional(),\n /**\n * Marks this fresh organization as the durable destination for one native\n * subscription restore. The server records and later verifies this intent;\n * ordinary existing organizations cannot be used as restore destinations.\n */\n nativeSubscriptionRestore: z.literal(true).optional(),\n /**\n * Completes a previously provisioned personal-organization replacement\n * after the client has committed its local remote-state reset. The server\n * rechecks replacement ownership and sync eligibility before moving the\n * user's default-organization pointer.\n */\n finalizeReplacement: z.boolean().optional(),\n /**\n * Purged personal organization this fresh organization replaces. The server\n * accepts this only after the old organization's purge is complete. The\n * default pointer moves only on a later `finalizeReplacement` replay.\n */\n replacesOrganizationId: uuidV4StringSchema.optional(),\n});\n\nexport type CreateOrganizationRequest = z.infer<\n typeof CreateOrganizationRequestSchema\n>;\n\nexport function isCreateOrganizationRequest(\n value: unknown,\n): value is CreateOrganizationRequest {\n return CreateOrganizationRequestSchema.safeParse(value).success;\n}\n"]}
1
+ {"version":3,"file":"organizationProvisioning.js","sourceRoot":"","sources":["organizationProvisioning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,+CAA+C,EAC/C,8CAA8C,GAC/C,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,0CAA0C,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,+CAA+C,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,wCAAwC,EAAE,MAAM,aAAa,CAAC;AAEvE;;;;GAIG;AACH,MAAM,sCAAsC,GAAG;IAC7C,GAAG,+CAA+C;IAClD,mBAAmB,EAAE,+BAA+B;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,+BAA+B,GAAG;IACtC,GAAG,0BAA0B;IAC7B,WAAW,EAAE,+BAA+B;CAC7C,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAC3C,oC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ements } from \"../jsonSchema\";\nimport {\n organizationProvisioningContainerSeedRefinement,\n organizationProvisioningDocumentSeedRefinement,\n} from \"../organizationProvisioningRefinements\";\nimport { arraySchema, loosePlainObject, uuidV4StringSchema } from \"../schema\";\nimport { OrganizationReplacementAuthorizationSchema } from \"../util/organizationReplacement\";\nimport { ContainerMutationRequestSchema } from \"./container\";\nimport { containerCreateWithMetadataDocumentRequestShape } from \"./containerMetadata\";\nimport { documentCreateRequestShape } from \"./document\";\nimport {\n DocumentCreateSeedRequestSchema,\n refineCreateSeedSync,\n refineSingleUpdateSeed,\n} from \"./documentCreateSeed\";\nimport { CreateOrganizationGroupRequestSchema } from \"./organization\";\nimport { OrganizationPrincipalPolicyRequestSchema } from \"./principal\";\n\n/**\n * A built-in or app-owned system container whose encrypted initial metadata\n * body is committed in the same transaction as the organization and document\n * shell.\n */\nconst provisionedSystemContainerRequestShape = {\n ...containerCreateWithMetadataDocumentRequestShape,\n initialMetadataSync: DocumentCreateSeedRequestSchema,\n};\n\n/**\n * A document whose encrypted initial body is committed with its manifest in the\n * organization-provisioning transaction.\n */\nconst provisionedDocumentRequestShape = {\n ...documentCreateRequestShape,\n initialSync: DocumentCreateSeedRequestSchema,\n};\n\nexport const ProvisionedDocumentRequestSchema =\n registerJsonSchemaRuntimeRefinements(\n loosePlainObject(provisionedDocumentRequestShape).superRefine(\n (value, context) => {\n refineSingleUpdateSeed(value.initialSync, context, {\n message:\n \"provisioned document seed requires one update and no container rekeys\",\n path: \"initialSync\",\n });\n refineCreateSeedSync(value, value.initialSync, context, {\n path: \"initialSync\",\n withinSyncLimit: true,\n });\n },\n ),\n [organizationProvisioningDocumentSeedRefinement],\n );\n\nexport type ProvisionedDocumentRequest = z.infer<\n typeof ProvisionedDocumentRequestSchema\n>;\n\nexport const ProvisionedSystemContainerRequestSchema =\n registerJsonSchemaRuntimeRefinements(\n loosePlainObject(provisionedSystemContainerRequestShape).superRefine(\n (value, context) => {\n refineSingleUpdateSeed(value.initialMetadataSync, context, {\n message:\n \"provisioned system-container metadata seed requires one update and no container rekeys\",\n path: \"initialMetadataSync\",\n });\n if (typeof value.metadataDocument === \"object\")\n refineCreateSeedSync(\n value.metadataDocument,\n value.initialMetadataSync,\n context,\n { path: \"initialMetadataSync\", withinSyncLimit: true },\n );\n },\n ),\n [organizationProvisioningContainerSeedRefinement],\n );\n\nexport type ProvisionedSystemContainerRequest = z.infer<\n typeof ProvisionedSystemContainerRequestSchema\n>;\n\nexport function isProvisionedDocumentRequest(\n value: unknown,\n): value is ProvisionedDocumentRequest {\n return ProvisionedDocumentRequestSchema.safeParse(value).success;\n}\n\nexport function isProvisionedSystemContainerRequest(\n value: unknown,\n): value is ProvisionedSystemContainerRequest {\n return ProvisionedSystemContainerRequestSchema.safeParse(value).success;\n}\n\n/**\n * The client-signed artifacts required to bootstrap a fresh organization: the\n * organization + admin/member group policies, the signed root container and its\n * metadata document, the organization metadata root, and the optional\n * roster/organization profile documents.\n *\n * This is the shared shape between user registration (which bootstraps the\n * user's personal organization) and creating an additional organization for an\n * existing user. Registration additionally carries the new user's public key\n * material (see {@link RegistrationRequest}); creating an additional\n * organization reuses the caller's existing keys, so it needs only this base.\n */\nexport const organizationProvisioningRequestShape = {\n initialAdminGroup: CreateOrganizationGroupRequestSchema,\n initialMemberGroup: CreateOrganizationGroupRequestSchema,\n initialOrganizationMetadataContainer: ProvisionedSystemContainerRequestSchema,\n initialOrganizationPolicy: OrganizationPrincipalPolicyRequestSchema,\n initialOrganizationProfileDocument:\n ProvisionedDocumentRequestSchema.optional(),\n initialRootContainer: ContainerMutationRequestSchema,\n initialRootMetadataDocument: ProvisionedDocumentRequestSchema,\n initialRosterProfileContainer:\n ProvisionedSystemContainerRequestSchema.optional(),\n initialRosterProfileDocument: ProvisionedDocumentRequestSchema.optional(),\n initialSystemContainers: arraySchema(\n ProvisionedSystemContainerRequestSchema,\n ).optional(),\n organizationId: uuidV4StringSchema,\n rootContainerId: uuidV4StringSchema,\n userId: uuidV4StringSchema,\n} satisfies z.ZodRawShape;\n\nexport const OrganizationProvisioningRequestSchema = loosePlainObject(\n organizationProvisioningRequestShape,\n);\n\nexport type OrganizationProvisioningRequest = z.infer<\n typeof OrganizationProvisioningRequestSchema\n>;\n\nexport function isOrganizationProvisioningRequest(\n value: unknown,\n): value is OrganizationProvisioningRequest {\n return OrganizationProvisioningRequestSchema.safeParse(value).success;\n}\n\n/**\n * Request to create an additional organization for the authenticated user. The\n * caller re-signs the same provisioning artifacts as registration, but with\n * their existing identity keys, so the request is exactly an\n * {@link OrganizationProvisioningRequest} where `userId` is the caller.\n */\nexport const CreateOrganizationRequestSchema = loosePlainObject({\n ...organizationProvisioningRequestShape,\n replacementAuthorization:\n OrganizationReplacementAuthorizationSchema.optional(),\n /**\n * Marks this fresh organization as the durable destination for one native\n * subscription restore. The server records and later verifies this intent;\n * ordinary existing organizations cannot be used as restore destinations.\n */\n nativeSubscriptionRestore: z.literal(true).optional(),\n /**\n * Completes a previously provisioned personal-organization replacement\n * after the client has committed its local remote-state reset. The server\n * rechecks replacement ownership and sync eligibility before moving the\n * user's default-organization pointer.\n */\n finalizeReplacement: z.boolean().optional(),\n /**\n * Purged personal organization this fresh organization replaces. The server\n * accepts this only after the old organization's purge is complete. The\n * default pointer moves only on a later `finalizeReplacement` replay.\n */\n replacesOrganizationId: uuidV4StringSchema.optional(),\n});\n\nexport type CreateOrganizationRequest = z.infer<\n typeof CreateOrganizationRequestSchema\n>;\n\nexport function isCreateOrganizationRequest(\n value: unknown,\n): value is CreateOrganizationRequest {\n return CreateOrganizationRequestSchema.safeParse(value).success;\n}\n"]}
@@ -145,22 +145,18 @@ declare const PrincipalStateRequestSchema: z.ZodType<{
145
145
  version: number;
146
146
  }>>;
147
147
  export type PrincipalStateRequest = z.infer<typeof PrincipalStateRequestSchema>;
148
+ /**
149
+ * Only the ciphertext: the signed state's `payloadCiphertextHash` commits to
150
+ * it, and the cipher suite is fixed (#2903 P23).
151
+ */
148
152
  declare const PrincipalStateEncryptedPayloadRequestSchema: z.ZodType<{
149
- cipherSuite: "aes-256-gcm";
150
153
  ciphertext: string;
151
- ciphertextHash: string;
152
154
  }, {
153
- cipherSuite: "aes-256-gcm";
154
155
  ciphertext: string;
155
- ciphertextHash: string;
156
156
  }, z.core.$ZodTypeInternals<{
157
- cipherSuite: "aes-256-gcm";
158
157
  ciphertext: string;
159
- ciphertextHash: string;
160
158
  }, {
161
- cipherSuite: "aes-256-gcm";
162
159
  ciphertext: string;
163
- ciphertextHash: string;
164
160
  }>>;
165
161
  export type PrincipalStateEncryptedPayloadRequest = z.infer<typeof PrincipalStateEncryptedPayloadRequestSchema>;
166
162
  declare const PrincipalMemberEnvelopeRequestSchema: z.ZodType<{
@@ -187,9 +183,7 @@ declare const PrincipalMemberEnvelopeRequestSchema: z.ZodType<{
187
183
  export type PrincipalMemberEnvelopeRequest = z.infer<typeof PrincipalMemberEnvelopeRequestSchema>;
188
184
  export declare const PutPrincipalPolicyRequestSchema: z.ZodType<{
189
185
  encryptedPayload: {
190
- cipherSuite: "aes-256-gcm";
191
186
  ciphertext: string;
192
- ciphertextHash: string;
193
187
  };
194
188
  grants: {
195
189
  accessLevel: "write" | "admin" | "read";
@@ -278,9 +272,7 @@ export declare const PutPrincipalPolicyRequestSchema: z.ZodType<{
278
272
  }[] | undefined;
279
273
  }, {
280
274
  encryptedPayload: {
281
- cipherSuite: "aes-256-gcm";
282
275
  ciphertext: string;
283
- ciphertextHash: string;
284
276
  };
285
277
  grants: {
286
278
  accessLevel: "write" | "admin" | "read";
@@ -369,9 +361,7 @@ export declare const PutPrincipalPolicyRequestSchema: z.ZodType<{
369
361
  }[] | undefined;
370
362
  }, z.core.$ZodTypeInternals<{
371
363
  encryptedPayload: {
372
- cipherSuite: "aes-256-gcm";
373
364
  ciphertext: string;
374
- ciphertextHash: string;
375
365
  };
376
366
  grants: {
377
367
  accessLevel: "write" | "admin" | "read";
@@ -460,9 +450,7 @@ export declare const PutPrincipalPolicyRequestSchema: z.ZodType<{
460
450
  }[] | undefined;
461
451
  }, {
462
452
  encryptedPayload: {
463
- cipherSuite: "aes-256-gcm";
464
453
  ciphertext: string;
465
- ciphertextHash: string;
466
454
  };
467
455
  grants: {
468
456
  accessLevel: "write" | "admin" | "read";
@@ -553,9 +541,7 @@ export declare const PutPrincipalPolicyRequestSchema: z.ZodType<{
553
541
  export type PutPrincipalPolicyRequest = z.infer<typeof PutPrincipalPolicyRequestSchema>;
554
542
  export declare const OrganizationPrincipalPolicyRequestSchema: z.ZodType<{
555
543
  encryptedPayload: {
556
- cipherSuite: "aes-256-gcm";
557
544
  ciphertext: string;
558
- ciphertextHash: string;
559
545
  };
560
546
  grants: {
561
547
  accessLevel: "write" | "admin" | "read";
@@ -644,9 +630,7 @@ export declare const OrganizationPrincipalPolicyRequestSchema: z.ZodType<{
644
630
  }[] | undefined;
645
631
  }, {
646
632
  encryptedPayload: {
647
- cipherSuite: "aes-256-gcm";
648
633
  ciphertext: string;
649
- ciphertextHash: string;
650
634
  };
651
635
  grants: {
652
636
  accessLevel: "write" | "admin" | "read";
@@ -735,9 +719,7 @@ export declare const OrganizationPrincipalPolicyRequestSchema: z.ZodType<{
735
719
  }[] | undefined;
736
720
  }, z.core.$ZodTypeInternals<{
737
721
  encryptedPayload: {
738
- cipherSuite: "aes-256-gcm";
739
722
  ciphertext: string;
740
- ciphertextHash: string;
741
723
  };
742
724
  grants: {
743
725
  accessLevel: "write" | "admin" | "read";
@@ -826,9 +808,7 @@ export declare const OrganizationPrincipalPolicyRequestSchema: z.ZodType<{
826
808
  }[] | undefined;
827
809
  }, {
828
810
  encryptedPayload: {
829
- cipherSuite: "aes-256-gcm";
830
811
  ciphertext: string;
831
- ciphertextHash: string;
832
812
  };
833
813
  grants: {
834
814
  accessLevel: "write" | "admin" | "read";
@@ -920,9 +900,7 @@ export type OrganizationPrincipalPolicyRequest = z.infer<typeof OrganizationPrin
920
900
  export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
921
901
  groupPolicy: {
922
902
  encryptedPayload: {
923
- cipherSuite: "aes-256-gcm";
924
903
  ciphertext: string;
925
- ciphertextHash: string;
926
904
  };
927
905
  grants: {
928
906
  accessLevel: "write" | "admin" | "read";
@@ -1012,9 +990,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1012
990
  };
1013
991
  organizationPolicy: {
1014
992
  encryptedPayload: {
1015
- cipherSuite: "aes-256-gcm";
1016
993
  ciphertext: string;
1017
- ciphertextHash: string;
1018
994
  };
1019
995
  grants: {
1020
996
  accessLevel: "write" | "admin" | "read";
@@ -1104,9 +1080,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1104
1080
  };
1105
1081
  memberPolicy?: {
1106
1082
  encryptedPayload: {
1107
- cipherSuite: "aes-256-gcm";
1108
1083
  ciphertext: string;
1109
- ciphertextHash: string;
1110
1084
  };
1111
1085
  grants: {
1112
1086
  accessLevel: "write" | "admin" | "read";
@@ -1197,9 +1171,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1197
1171
  }, {
1198
1172
  groupPolicy: {
1199
1173
  encryptedPayload: {
1200
- cipherSuite: "aes-256-gcm";
1201
1174
  ciphertext: string;
1202
- ciphertextHash: string;
1203
1175
  };
1204
1176
  grants: {
1205
1177
  accessLevel: "write" | "admin" | "read";
@@ -1289,9 +1261,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1289
1261
  };
1290
1262
  organizationPolicy: {
1291
1263
  encryptedPayload: {
1292
- cipherSuite: "aes-256-gcm";
1293
1264
  ciphertext: string;
1294
- ciphertextHash: string;
1295
1265
  };
1296
1266
  grants: {
1297
1267
  accessLevel: "write" | "admin" | "read";
@@ -1381,9 +1351,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1381
1351
  };
1382
1352
  memberPolicy?: {
1383
1353
  encryptedPayload: {
1384
- cipherSuite: "aes-256-gcm";
1385
1354
  ciphertext: string;
1386
- ciphertextHash: string;
1387
1355
  };
1388
1356
  grants: {
1389
1357
  accessLevel: "write" | "admin" | "read";
@@ -1474,9 +1442,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1474
1442
  }, z.core.$ZodTypeInternals<{
1475
1443
  groupPolicy: {
1476
1444
  encryptedPayload: {
1477
- cipherSuite: "aes-256-gcm";
1478
1445
  ciphertext: string;
1479
- ciphertextHash: string;
1480
1446
  };
1481
1447
  grants: {
1482
1448
  accessLevel: "write" | "admin" | "read";
@@ -1566,9 +1532,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1566
1532
  };
1567
1533
  organizationPolicy: {
1568
1534
  encryptedPayload: {
1569
- cipherSuite: "aes-256-gcm";
1570
1535
  ciphertext: string;
1571
- ciphertextHash: string;
1572
1536
  };
1573
1537
  grants: {
1574
1538
  accessLevel: "write" | "admin" | "read";
@@ -1658,9 +1622,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1658
1622
  };
1659
1623
  memberPolicy?: {
1660
1624
  encryptedPayload: {
1661
- cipherSuite: "aes-256-gcm";
1662
1625
  ciphertext: string;
1663
- ciphertextHash: string;
1664
1626
  };
1665
1627
  grants: {
1666
1628
  accessLevel: "write" | "admin" | "read";
@@ -1751,9 +1713,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1751
1713
  }, {
1752
1714
  groupPolicy: {
1753
1715
  encryptedPayload: {
1754
- cipherSuite: "aes-256-gcm";
1755
1716
  ciphertext: string;
1756
- ciphertextHash: string;
1757
1717
  };
1758
1718
  grants: {
1759
1719
  accessLevel: "write" | "admin" | "read";
@@ -1843,9 +1803,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1843
1803
  };
1844
1804
  organizationPolicy: {
1845
1805
  encryptedPayload: {
1846
- cipherSuite: "aes-256-gcm";
1847
1806
  ciphertext: string;
1848
- ciphertextHash: string;
1849
1807
  };
1850
1808
  grants: {
1851
1809
  accessLevel: "write" | "admin" | "read";
@@ -1935,9 +1893,7 @@ export declare const CommitOrganizationGroupPolicyRequestSchema: z.ZodType<{
1935
1893
  };
1936
1894
  memberPolicy?: {
1937
1895
  encryptedPayload: {
1938
- cipherSuite: "aes-256-gcm";
1939
1896
  ciphertext: string;
1940
- ciphertextHash: string;
1941
1897
  };
1942
1898
  grants: {
1943
1899
  accessLevel: "write" | "admin" | "read";
@@ -44,10 +44,12 @@ const PrincipalStateRequestSchema = loosePlainObject({
44
44
  signerUserKeyFingerprint: z.string(),
45
45
  version: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),
46
46
  });
47
+ /**
48
+ * Only the ciphertext: the signed state's `payloadCiphertextHash` commits to
49
+ * it, and the cipher suite is fixed (#2903 P23).
50
+ */
47
51
  const PrincipalStateEncryptedPayloadRequestSchema = loosePlainObject({
48
- cipherSuite: z.literal("aes-256-gcm"),
49
52
  ciphertext: z.string(),
50
- ciphertextHash: z.string(),
51
53
  });
52
54
  const PrincipalMemberEnvelopeRequestSchema = loosePlainObject({
53
55
  kemCipherText: z.string(),
@@ -1 +1 @@
1
- {"version":3,"file":"principal.js","sourceRoot":"","sources":["principal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,4BAA4B,EAC5B,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,sCAAsC,GAAG,gBAAgB,CAAC;IAC9D,yBAAyB,EAAE,qBAAqB;IAChD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QA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KAAK,EAAE,2BAA2B;CACnC,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,wCAAwC,GAAG,gBAAgB,CAAC;IACvE,kBAAkB,EAAE,WAAW,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7E,gBAAgB,EAAE,2CAA2C;IAC7D,MAAM,EAAE,WAAW,CAAC,oCAAoC,CAAC;IACzD,eAAe,EAAE,WAAW,CAAC,oCAAoC,CAAC;IAClE,UAAU,EAAE,WAAW,CAAC,sCAAsC,CAAC;IAC/D,KAAK,EAAE,2BAA2B;CACnC,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,0CAA0C,GAAG,gBAAgB,CAAC;IACzE,WAAW,EAAE,+BAA+B;IAC5C,YAAY,EAAE,+BAA+B,CAAC,QAAQ,EAAE;IACxD,kBAAkB,EAAE,wCAAwC;CAC7D,CAAC,CAAC;AAMH,MAAM,UAAU,2BAA2B,CACzC,KAAc;IAEd,OAAO,+BAA+B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,oCAAoC,CAClD,KAAc;IAEd,OAAO,wCAAwC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC3E,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 { registerJsonSchemaFragment } from \"../jsonSchema\";\nimport {\n arraySchema,\n boundedPositiveIntegerSchema,\n loosePlainObject,\n nonNegativeIntegerSchema,\n sha256HexStringSchema,\n uuidV4StringSchema,\n} from \"../schema\";\nimport {\n CANONICAL_SIGNED_AT_PATTERN,\n isCanonicalSignedAt,\n SIGNED_AT_CONTRACT,\n} from \"../util\";\nimport { ContainerMutationRequestSchema } from \"./container\";\n\nconst PrincipalProjectionMemberRequestSchema = loosePlainObject({\n identityBundleFingerprint: sha256HexStringSchema,\n role: z.literal([\"member\", \"admin\"]),\n userId: uuidV4StringSchema,\n});\n\nexport type PrincipalProjectionMemberRequest = z.infer<\n typeof PrincipalProjectionMemberRequestSchema\n>;\n\nexport const PrincipalContainerGrantRequestSchema = loosePlainObject({\n accessLevel: z.literal([\"admin\", \"read\", \"write\"]),\n containerId: uuidV4StringSchema,\n});\n\nexport type PrincipalContainerGrantRequest = z.infer<\n typeof PrincipalContainerGrantRequestSchema\n>;\n\nconst PrincipalStateExternalAuthorityRequestSchema = loosePlainObject({\n keyEpoch: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n keyFingerprint: z.string(),\n principalId: uuidV4StringSchema,\n principalType: z.literal(\"group\"),\n stateHash: z.string(),\n version: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n});\n\nconst PrincipalStateRequestSchema = loosePlainObject({\n encapsulationPublicKey: z.string(),\n externalAuthority: PrincipalStateExternalAuthorityRequestSchema.nullable(),\n grantCount: nonNegativeIntegerSchema,\n grantRoot: z.string(),\n keyEpoch: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n keyFingerprint: z.string(),\n memberCount: nonNegativeIntegerSchema,\n memberEnvelopesRoot: z.string(),\n membershipMode: z.literal(\"projection\"),\n membershipRoot: z.string(),\n payloadCiphertextHash: z.string(),\n prevStateHash: z.string().nullable(),\n principalId: uuidV4StringSchema,\n principalType: z.literal([\"group\", \"organization\"]),\n projectionRoot: z.string(),\n signature: z.string(),\n signedAt: registerJsonSchemaFragment(\n z.string().refine(isCanonicalSignedAt, {\n message: `signedAt must be ${SIGNED_AT_CONTRACT}`,\n }),\n { pattern: CANONICAL_SIGNED_AT_PATTERN.source, type: \"string\" },\n ),\n signerUserId: uuidV4StringSchema,\n signerUserKeyFingerprint: z.string(),\n version: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n});\n\nexport type PrincipalStateRequest = z.infer<typeof PrincipalStateRequestSchema>;\n\nconst PrincipalStateEncryptedPayloadRequestSchema = loosePlainObject({\n cipherSuite: z.literal(\"aes-256-gcm\"),\n ciphertext: z.string(),\n ciphertextHash: z.string(),\n});\n\nexport type PrincipalStateEncryptedPayloadRequest = z.infer<\n typeof PrincipalStateEncryptedPayloadRequestSchema\n>;\n\nconst PrincipalMemberEnvelopeRequestSchema = loosePlainObject({\n kemCipherText: z.string(),\n memberKeyFingerprint: z.string(),\n userId: uuidV4StringSchema,\n wrappedKey: z.string(),\n});\n\nexport type PrincipalMemberEnvelopeRequest = z.infer<\n typeof PrincipalMemberEnvelopeRequestSchema\n>;\n\nexport const PutPrincipalPolicyRequestSchema = loosePlainObject({\n containerMutations: arraySchema(ContainerMutationRequestSchema).optional(),\n encryptedPayload: PrincipalStateEncryptedPayloadRequestSchema,\n grants: arraySchema(PrincipalContainerGrantRequestSchema),\n memberEnvelopes: arraySchema(PrincipalMemberEnvelopeRequestSchema),\n projection: arraySchema(PrincipalProjectionMemberRequestSchema),\n state: PrincipalStateRequestSchema,\n});\n\nexport type PutPrincipalPolicyRequest = z.infer<\n typeof PutPrincipalPolicyRequestSchema\n>;\n\nexport const OrganizationPrincipalPolicyRequestSchema = loosePlainObject({\n containerMutations: arraySchema(ContainerMutationRequestSchema, 0).optional(),\n encryptedPayload: PrincipalStateEncryptedPayloadRequestSchema,\n grants: arraySchema(PrincipalContainerGrantRequestSchema),\n memberEnvelopes: arraySchema(PrincipalMemberEnvelopeRequestSchema),\n projection: arraySchema(PrincipalProjectionMemberRequestSchema),\n state: PrincipalStateRequestSchema,\n});\n\nexport type OrganizationPrincipalPolicyRequest = z.infer<\n typeof OrganizationPrincipalPolicyRequestSchema\n>;\n\nexport const CommitOrganizationGroupPolicyRequestSchema = loosePlainObject({\n groupPolicy: PutPrincipalPolicyRequestSchema,\n memberPolicy: PutPrincipalPolicyRequestSchema.optional(),\n organizationPolicy: OrganizationPrincipalPolicyRequestSchema,\n});\n\nexport type CommitOrganizationGroupPolicyRequest = z.infer<\n typeof CommitOrganizationGroupPolicyRequestSchema\n>;\n\nexport function isPutPrincipalPolicyRequest(\n value: unknown,\n): value is PutPrincipalPolicyRequest {\n return PutPrincipalPolicyRequestSchema.safeParse(value).success;\n}\n\nexport function isOrganizationPrincipalPolicyRequest(\n value: unknown,\n): value is OrganizationPrincipalPolicyRequest {\n return OrganizationPrincipalPolicyRequestSchema.safeParse(value).success;\n}\n\nexport function isCommitOrganizationGroupPolicyRequest(\n value: unknown,\n): value is CommitOrganizationGroupPolicyRequest {\n return CommitOrganizationGroupPolicyRequestSchema.safeParse(value).success;\n}\n"]}
1
+ {"version":3,"file":"principal.js","sourceRoot":"","sources":["principal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,4BAA4B,EAC5B,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,sCAAsC,GAAG,gBAAgB,CAAC;IAC9D,yBAAyB,EAAE,qBAAqB;IAChD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,oCAAoC,GAAG,gBAAgB,CAAC;IACnE,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,WAAW,EAAE,kBAAkB;CAChC,CAAC,CAAC;AAMH,MAAM,4CAA4C,GAAG,gBAAgB,CAAC;IACpE,QAAQ,E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M,0CAA0C,GAAG,gBAAgB,CAAC;IACzE,WAAW,EAAE,+BAA+B;IAC5C,YAAY,EAAE,+BAA+B,CAAC,QAAQ,EAAE;IACxD,kBAAkB,EAAE,wCAAwC;CAC7D,CAAC,CAAC;AAMH,MAAM,UAAU,2BAA2B,CACzC,KAAc;IAEd,OAAO,+BAA+B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,oCAAoC,CAClD,KAAc;IAEd,OAAO,wCAAwC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC3E,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 { registerJsonSchemaFragment } from \"../jsonSchema\";\nimport {\n arraySchema,\n boundedPositiveIntegerSchema,\n loosePlainObject,\n nonNegativeIntegerSchema,\n sha256HexStringSchema,\n uuidV4StringSchema,\n} from \"../schema\";\nimport {\n CANONICAL_SIGNED_AT_PATTERN,\n isCanonicalSignedAt,\n SIGNED_AT_CONTRACT,\n} from \"../util\";\nimport { ContainerMutationRequestSchema } from \"./container\";\n\nconst PrincipalProjectionMemberRequestSchema = loosePlainObject({\n identityBundleFingerprint: sha256HexStringSchema,\n role: z.literal([\"member\", \"admin\"]),\n userId: uuidV4StringSchema,\n});\n\nexport type PrincipalProjectionMemberRequest = z.infer<\n typeof PrincipalProjectionMemberRequestSchema\n>;\n\nexport const PrincipalContainerGrantRequestSchema = loosePlainObject({\n accessLevel: z.literal([\"admin\", \"read\", \"write\"]),\n containerId: uuidV4StringSchema,\n});\n\nexport type PrincipalContainerGrantRequest = z.infer<\n typeof PrincipalContainerGrantRequestSchema\n>;\n\nconst PrincipalStateExternalAuthorityRequestSchema = loosePlainObject({\n keyEpoch: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n keyFingerprint: z.string(),\n principalId: uuidV4StringSchema,\n principalType: z.literal(\"group\"),\n stateHash: z.string(),\n version: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n});\n\nconst PrincipalStateRequestSchema = loosePlainObject({\n encapsulationPublicKey: z.string(),\n externalAuthority: PrincipalStateExternalAuthorityRequestSchema.nullable(),\n grantCount: nonNegativeIntegerSchema,\n grantRoot: z.string(),\n keyEpoch: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n keyFingerprint: z.string(),\n memberCount: nonNegativeIntegerSchema,\n memberEnvelopesRoot: z.string(),\n membershipMode: z.literal(\"projection\"),\n membershipRoot: z.string(),\n payloadCiphertextHash: z.string(),\n prevStateHash: z.string().nullable(),\n principalId: uuidV4StringSchema,\n principalType: z.literal([\"group\", \"organization\"]),\n projectionRoot: z.string(),\n signature: z.string(),\n signedAt: registerJsonSchemaFragment(\n z.string().refine(isCanonicalSignedAt, {\n message: `signedAt must be ${SIGNED_AT_CONTRACT}`,\n }),\n { pattern: CANONICAL_SIGNED_AT_PATTERN.source, type: \"string\" },\n ),\n signerUserId: uuidV4StringSchema,\n signerUserKeyFingerprint: z.string(),\n version: boundedPositiveIntegerSchema(Number.MAX_SAFE_INTEGER),\n});\n\nexport type PrincipalStateRequest = z.infer<typeof PrincipalStateRequestSchema>;\n\n/**\n * Only the ciphertext: the signed state's `payloadCiphertextHash` commits to\n * it, and the cipher suite is fixed (#2903 P23).\n */\nconst PrincipalStateEncryptedPayloadRequestSchema = loosePlainObject({\n ciphertext: z.string(),\n});\n\nexport type PrincipalStateEncryptedPayloadRequest = z.infer<\n typeof PrincipalStateEncryptedPayloadRequestSchema\n>;\n\nconst PrincipalMemberEnvelopeRequestSchema = loosePlainObject({\n kemCipherText: z.string(),\n memberKeyFingerprint: z.string(),\n userId: uuidV4StringSchema,\n wrappedKey: z.string(),\n});\n\nexport type PrincipalMemberEnvelopeRequest = z.infer<\n typeof PrincipalMemberEnvelopeRequestSchema\n>;\n\nexport const PutPrincipalPolicyRequestSchema = loosePlainObject({\n containerMutations: arraySchema(ContainerMutationRequestSchema).optional(),\n encryptedPayload: PrincipalStateEncryptedPayloadRequestSchema,\n grants: arraySchema(PrincipalContainerGrantRequestSchema),\n memberEnvelopes: arraySchema(PrincipalMemberEnvelopeRequestSchema),\n projection: arraySchema(PrincipalProjectionMemberRequestSchema),\n state: PrincipalStateRequestSchema,\n});\n\nexport type PutPrincipalPolicyRequest = z.infer<\n typeof PutPrincipalPolicyRequestSchema\n>;\n\nexport const OrganizationPrincipalPolicyRequestSchema = loosePlainObject({\n containerMutations: arraySchema(ContainerMutationRequestSchema, 0).optional(),\n encryptedPayload: PrincipalStateEncryptedPayloadRequestSchema,\n grants: arraySchema(PrincipalContainerGrantRequestSchema),\n memberEnvelopes: arraySchema(PrincipalMemberEnvelopeRequestSchema),\n projection: arraySchema(PrincipalProjectionMemberRequestSchema),\n state: PrincipalStateRequestSchema,\n});\n\nexport type OrganizationPrincipalPolicyRequest = z.infer<\n typeof OrganizationPrincipalPolicyRequestSchema\n>;\n\nexport const CommitOrganizationGroupPolicyRequestSchema = loosePlainObject({\n groupPolicy: PutPrincipalPolicyRequestSchema,\n memberPolicy: PutPrincipalPolicyRequestSchema.optional(),\n organizationPolicy: OrganizationPrincipalPolicyRequestSchema,\n});\n\nexport type CommitOrganizationGroupPolicyRequest = z.infer<\n typeof CommitOrganizationGroupPolicyRequestSchema\n>;\n\nexport function isPutPrincipalPolicyRequest(\n value: unknown,\n): value is PutPrincipalPolicyRequest {\n return PutPrincipalPolicyRequestSchema.safeParse(value).success;\n}\n\nexport function isOrganizationPrincipalPolicyRequest(\n value: unknown,\n): value is OrganizationPrincipalPolicyRequest {\n return OrganizationPrincipalPolicyRequestSchema.safeParse(value).success;\n}\n\nexport function isCommitOrganizationGroupPolicyRequest(\n value: unknown,\n): value is CommitOrganizationGroupPolicyRequest {\n return CommitOrganizationGroupPolicyRequestSchema.safeParse(value).success;\n}\n"]}