@tearleads/client-sdk 0.1.74 → 0.1.76

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 (70) hide show
  1. package/client/organizations/principalContainerMutations.js +1 -1
  2. package/client/organizations/principalContainerMutations.js.map +1 -1
  3. package/data/containers/shared/mutationAcknowledgement.d.ts +38 -0
  4. package/data/principals/currentPolicyReferenceResolver.d.ts +3 -0
  5. package/index.d.ts +2 -2
  6. package/index.js +2 -2
  7. package/index.js.map +1 -1
  8. package/package.json +1 -1
  9. package/workflows/container-contents/container-state/remote.js +1 -1
  10. package/workflows/container-contents/container-state/remote.js.map +1 -1
  11. package/workflows/container-contents/container-state/share/groupGrantVerification.js +1 -1
  12. package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -1
  13. package/workflows/container-contents/container-state/share/groupShareEpoch.js +1 -1
  14. package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -1
  15. package/workflows/container-contents/container-state/types.js.map +1 -1
  16. package/workflows/containers/child/mutationSubmit.d.ts +76 -0
  17. package/workflows/containers/child/rekey/carriedDescendantRekeys.d.ts +70 -0
  18. package/workflows/containers/child/share/index.d.ts +1 -38
  19. package/workflows/containers/child/share/index.js +1 -205
  20. package/workflows/containers/child/share/index.js.map +1 -1
  21. package/workflows/containers/child/share/shareAncestorRepair.d.ts +37 -0
  22. package/workflows/containers/child/share/shareProjection.d.ts +7 -0
  23. package/workflows/containers/index.d.ts +3 -2
  24. package/workflows/containers/index.js +4 -2
  25. package/workflows/containers/index.js.map +1 -1
  26. package/workflows/containers/rematerialization/index.js +4 -0
  27. package/workflows/containers/rematerialization/index.js.map +1 -0
  28. package/workflows/{organizations → containers}/rematerialization/precedingPrincipalRematerialization.js +1 -1
  29. package/workflows/containers/rematerialization/precedingPrincipalRematerialization.js.map +1 -0
  30. package/workflows/{organizations → containers}/rematerialization/principalContainerRematerialization.js +7 -7
  31. package/workflows/containers/rematerialization/principalContainerRematerialization.js.map +1 -0
  32. package/workflows/{organizations → containers}/rematerialization/principalContainerRematerializationPlanning.js +1 -1
  33. package/workflows/containers/rematerialization/principalContainerRematerializationPlanning.js.map +1 -0
  34. package/workflows/containers/rematerialization/principalContainerRematerializationTargets.js.map +1 -0
  35. package/workflows/organizations/currentOrganizationAuthority.d.ts +21 -0
  36. package/workflows/organizations/groupMetadata/groupMetadataRuntime.d.ts +30 -0
  37. package/workflows/organizations/groupPolicy/commitCurrentGroupPolicyMutation.js.map +1 -1
  38. package/workflows/{containers/child/share → organizations/groupShare}/currentShareGrantMutation.js +6 -6
  39. package/workflows/organizations/groupShare/currentShareGrantMutation.js.map +1 -0
  40. package/workflows/organizations/groupShare/currentSharePrincipalPolicy.d.ts +30 -0
  41. package/workflows/{containers/child/share → organizations/groupShare}/currentSharePrincipalPolicy.js +10 -10
  42. package/workflows/organizations/groupShare/currentSharePrincipalPolicy.js.map +1 -0
  43. package/workflows/organizations/groupShare/index.d.ts +4 -0
  44. package/workflows/organizations/groupShare/index.js +7 -0
  45. package/workflows/organizations/groupShare/index.js.map +1 -0
  46. package/workflows/organizations/groupShare/runtimeCurrentGroupShare.d.ts +4 -0
  47. package/workflows/{containers/child/share → organizations/groupShare}/runtimeCurrentGroupShare.js +6 -8
  48. package/workflows/organizations/groupShare/runtimeCurrentGroupShare.js.map +1 -0
  49. package/workflows/{containers/child/share → organizations/groupShare}/sharePrincipalPolicy.d.ts +9 -9
  50. package/workflows/{containers/child/share → organizations/groupShare}/sharePrincipalPolicy.js +13 -13
  51. package/workflows/organizations/groupShare/sharePrincipalPolicy.js.map +1 -0
  52. package/workflows/organizations/groupShare/shareWithGroup.d.ts +44 -0
  53. package/workflows/organizations/groupShare/shareWithGroup.js +210 -0
  54. package/workflows/organizations/groupShare/shareWithGroup.js.map +1 -0
  55. package/workflows/organizations/index.d.ts +1 -0
  56. package/workflows/organizations/index.js +1 -0
  57. package/workflows/organizations/index.js.map +1 -1
  58. package/workflows/organizations/principalMutations/currentPrincipalMutationLease.d.ts +16 -0
  59. package/workflows/principals/runtimePolicyRecovery.d.ts +42 -0
  60. package/workflows/containers/child/share/currentShareGrantMutation.js.map +0 -1
  61. package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +0 -1
  62. package/workflows/containers/child/share/runtimeCurrentGroupShare.js.map +0 -1
  63. package/workflows/containers/child/share/sharePrincipalPolicy.js.map +0 -1
  64. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +0 -1
  65. package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +0 -1
  66. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +0 -1
  67. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +0 -1
  68. /package/workflows/{organizations → containers}/rematerialization/authoredPrincipalPolicyWarmer.js +0 -0
  69. /package/workflows/{organizations → containers}/rematerialization/authoredPrincipalPolicyWarmer.js.map +0 -0
  70. /package/workflows/{organizations → containers}/rematerialization/principalContainerRematerializationTargets.js +0 -0
@@ -0,0 +1,70 @@
1
+ import type { ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
2
+ import type { ContainerMutationAuthor, ContainerRekeyApi, MaterializedContainerRekeyPlan } from "../../../../data/containers/shared/types.js";
3
+ import { type PrincipalPolicyCache, type ProjectionUserKeyResolver, type ReferencedPrincipalPolicyWarmer } from "../../../../data/keyingProjectionVerification/index.js";
4
+ import type { CurrentPolicyReferenceResolver } from "../../../../data/principals/currentPolicyReferenceResolver.js";
5
+ import type { PrincipalPolicyCurrentEvidence } from "../../../../data/principals/principalPolicyEvidence.js";
6
+ import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
7
+ /** What a rotation needs in hand to sign the descendant rekeys it must carry. */
8
+ export interface CarriedRekeyPlanningInput {
9
+ readonly apiClient: Pick<ContainerRekeyApi, "getContainerWriterProjection">;
10
+ readonly author: ContainerMutationAuthor;
11
+ readonly execSql: ExecSql;
12
+ /**
13
+ * Keys the batch minted and has yet to commit, by epoch id. A rotation's
14
+ * successor is wrapped to recipients at heads the batch itself commits, so
15
+ * no wrap on a re-rooted path opens it for the signer before then; the key
16
+ * the signer just minted does, and its keyring then opens what sits below.
17
+ */
18
+ readonly knownContainerKeks?: ReadonlyMap<string, Uint8Array> | undefined;
19
+ /**
20
+ * Verified policies the batch itself commits, which the rebased paths cite
21
+ * before any store holds them; and the one each carried rekey cites anew.
22
+ */
23
+ readonly principalPolicyCache?: PrincipalPolicyCache | undefined;
24
+ readonly replacementPrincipalPolicy?: PrincipalPolicyCurrentEvidence | undefined;
25
+ readonly resolveAuthoredPolicyReferences?: CurrentPolicyReferenceResolver | undefined;
26
+ readonly resolveProjectionUserKey: ProjectionUserKeyResolver;
27
+ readonly stillCurrent?: (() => boolean) | undefined;
28
+ readonly targetSecretKey: Uint8Array;
29
+ readonly warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;
30
+ }
31
+ /** A rotated container's own path once its batch is accepted. */
32
+ export type SpeculativePath = Pick<ContainerWriterProjectionResponse, "containerKeks" | "organizationId" | "path" | "policyEvidence">;
33
+ /**
34
+ * Re-root a served projection on the deepest not-yet-accepted proper ancestor
35
+ * among `speculativePaths`. Each carried plan's own path was built the same
36
+ * way, so the deepest one already holds every speculative level above it. The
37
+ * container's own path, when the batch rotates it too, is not an ancestor: the
38
+ * caller is re-planning that rotation, and it extends what sits above.
39
+ */
40
+ export declare function rebaseOnDeepestAncestor(served: ContainerWriterProjectionResponse, speculativePaths: readonly SpeculativePath[]): {
41
+ ancestor: SpeculativePath;
42
+ projection: ContainerWriterProjectionResponse;
43
+ } | null;
44
+ /**
45
+ * Sign one carried rekey against the path its batch will leave behind. The
46
+ * served projection is fetched by the caller; here it is verified, must sit
47
+ * below one of the rotated containers and in that container's organization,
48
+ * and is signed only if this signer holds its key and write access — which a
49
+ * member able to rotate the ancestor always does, since both inherit downward.
50
+ */
51
+ export declare function planCarriedDescendantRekey(input: CarriedRekeyPlanningInput & {
52
+ readonly rotated: readonly SpeculativePath[];
53
+ readonly served: ContainerWriterProjectionResponse;
54
+ }): Promise<MaterializedContainerRekeyPlan>;
55
+ /**
56
+ * Sign the descendant rekeys a rotation must commit with (#2340). The server
57
+ * refuses a rotation that would leave a level above a directly granted
58
+ * container pinned to a retired epoch, because the grantee could never re-key
59
+ * that level itself and its writes would wait on another device. It names the
60
+ * levels; this signs them, parent-first, each against the path the batch will
61
+ * leave behind rather than the one currently served.
62
+ *
63
+ * `requiredContainerIds` is a hint, never an authority: each container is
64
+ * fetched and verified here, and refused unless it sits below a rotation.
65
+ */
66
+ export declare function planCarriedDescendantRekeys(input: CarriedRekeyPlanningInput & {
67
+ readonly requiredContainerIds: readonly string[];
68
+ /** Each rotated container's own path once the batch is accepted. */
69
+ readonly rotated: readonly SpeculativePath[];
70
+ }): Promise<MaterializedContainerRekeyPlan[]>;
@@ -1,12 +1,10 @@
1
- import type { ContainerAccessLevel, SigningKeyPair } from "../../../../internal/crypto/index.js";
1
+ import type { ContainerAccessLevel } from "../../../../internal/crypto/index.js";
2
2
  import type { ContainerMutationResponse, ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
3
3
  import type { ContainerMutationAuthor, ContainerShareApi, ContainerSharePlan } from "../../../../data/containers/shared/types.js";
4
4
  import { type ProjectionUserKeyResolver, type ReferencedPrincipalPolicyWarmer } from "../../../../data/keyingProjectionVerification/index.js";
5
5
  import type { SecurityIncidentReporter } from "../../../../data/shared/securityIncidents.js";
6
6
  import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
7
7
  import { type TrustedUserIdentityResolver } from "../../../../data/trustedUserIdentity/index.js";
8
- import type { GroupPolicyNameReader } from "../../../organizations/principalPolicy/principalPolicyRequest.js";
9
- import { type ContainerManagedPrincipalShareApi } from "./sharePrincipalPolicy.js";
10
8
  export declare function shareRemoteContainer(input: {
11
9
  reportSecurityIncident: SecurityIncidentReporter;
12
10
  accessLevel: ContainerAccessLevel;
@@ -28,38 +26,3 @@ export declare function shareRemoteContainer(input: {
28
26
  plan: ContainerSharePlan;
29
27
  response: ContainerMutationResponse;
30
28
  } | null>;
31
- interface RemoteContainerGroupShareInput {
32
- reportSecurityIncident: SecurityIncidentReporter;
33
- accessLevel: ContainerAccessLevel;
34
- apiClient: ContainerManagedPrincipalShareApi;
35
- author: ContainerMutationAuthor;
36
- containerId: string;
37
- eventId?: string | undefined;
38
- execSql: ExecSql;
39
- /**
40
- * The display name the user chose the group by, checked against the name
41
- * committed in the verified group policy so a relabeled read-model row
42
- * cannot redirect the share onto another group. `null` is reserved for the
43
- * grant-preserving re-wrap: a share that would mint a new grant without a
44
- * name is refused.
45
- */
46
- expectedGroupName: string | null;
47
- readEncryptedName?: GroupPolicyNameReader | undefined;
48
- knownContainerKeks?: ReadonlyMap<string, Uint8Array> | undefined;
49
- previousProjection?: ContainerWriterProjectionResponse | undefined;
50
- recipientGroupId: string;
51
- resolveProjectionUserKey: ProjectionUserKeyResolver;
52
- resolveTrustedUserIdentity: TrustedUserIdentityResolver;
53
- signedAt?: string | undefined;
54
- signingKeyPair?: SigningKeyPair | null | undefined;
55
- stillCurrent?: (() => boolean) | undefined;
56
- targetSecretKey: Uint8Array;
57
- warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;
58
- }
59
- interface RemoteContainerGroupShareResult {
60
- containerKey: Uint8Array;
61
- plan: ContainerSharePlan;
62
- response: ContainerMutationResponse;
63
- }
64
- export declare function shareRemoteContainerWithGroup(input: RemoteContainerGroupShareInput): Promise<RemoteContainerGroupShareResult | null>;
65
- export {};
@@ -1,17 +1,8 @@
1
- import { isProjectionVerificationCancelledError, nullOnProjectionVerificationCancellation, requireProjectionUserKeyResolver, } from "../../../../data/keyingProjectionVerification/index.js";
2
- import { principalPolicyCacheForVerifiedPolicies } from "../../../../data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js";
3
- import { savePrincipalPolicyBundle } from "../../../../data/persistence/principalPolicy/principalPolicyPersistence.js";
1
+ import { nullOnProjectionVerificationCancellation, requireProjectionUserKeyResolver, } from "../../../../data/keyingProjectionVerification/index.js";
4
2
  import { requireTrustedUserIdentityResolver, } from "../../../../data/trustedUserIdentity/index.js";
5
- import { createGroupMetadataAccess } from "../../../organizations/groupMetadata/groupMetadataAccess.js";
6
- import { createGroupMetadataContainerVerifier } from "../../../organizations/groupMetadata/groupMetadataContainerAuthority.js";
7
- import { setOrganizationGroupContainerGrant } from "../../../organizations/principalPolicy/index.js";
8
- import { preparePrincipalContainerRematerializationBatch } from "../../../organizations/rematerialization/principalContainerRematerialization.js";
9
3
  import { submitAcknowledgedContainerMutation, submitPlainContainerMutation, } from "../mutationSubmit.js";
10
4
  import { buildMaterializedContainerSharePlan } from "./shareMaterialization.js";
11
- import { advanceVerifiedSharePolicies, loadVerifiedGroupSharePrincipalPolicy, } from "./sharePrincipalPolicy.js";
12
5
  import { resolveShareProjection } from "./shareProjection.js";
13
- class ContainerShareGenerationExpiredError extends Error {
14
- }
15
6
  async function buildCurrentContainerSharePlan(input) {
16
7
  return nullOnProjectionVerificationCancellation(() => buildMaterializedContainerSharePlan(input));
17
8
  }
@@ -58,199 +49,4 @@ export async function shareRemoteContainer(input) {
58
49
  })),
59
50
  });
60
51
  }
61
- function isMaterializedContainerSharePlan(value) {
62
- return value.plan.body.eventType === "container.grant";
63
- }
64
- async function prepareMissingGroupGrantMutations(input) {
65
- const { currentPolicy, nextPolicy, shareInput } = input;
66
- return preparePrincipalContainerRematerializationBatch({
67
- reportSecurityIncident: shareInput.reportSecurityIncident,
68
- apiClient: shareInput.apiClient,
69
- author: shareInput.author,
70
- execSql: shareInput.execSql,
71
- grants: [
72
- ...new Map([...currentPolicy.currentGrants, ...nextPolicy.grants].map((grant) => [grant.containerId, grant])).values(),
73
- ],
74
- groupId: shareInput.recipientGroupId,
75
- nextPolicy,
76
- resolveTrustedUserIdentity: shareInput.resolveTrustedUserIdentity,
77
- stillCurrent: shareInput.stillCurrent,
78
- targetSecretKey: shareInput.targetSecretKey,
79
- warmReferencedPrincipalPolicies: shareInput.warmReferencedPrincipalPolicies,
80
- });
81
- }
82
- async function commitMissingGroupGrantPolicy(input) {
83
- const signingKeyPair = input.signingKeyPair;
84
- if (!signingKeyPair) {
85
- throw new Error("Container group share requires principal policy signing context");
86
- }
87
- const policyApi = {
88
- recoverPendingPrincipalMutation: input.apiClient.recoverPendingPrincipalMutation?.bind(input.apiClient),
89
- commitOrganizationGroupPolicy: input.apiClient.commitOrganizationGroupPolicy.bind(input.apiClient),
90
- getCurrentPrincipalPolicy: input.apiClient.getCurrentPrincipalPolicy.bind(input.apiClient),
91
- };
92
- let preparedTarget;
93
- try {
94
- const storedPolicy = await setOrganizationGroupContainerGrant({
95
- accessLevel: input.accessLevel,
96
- apiClient: policyApi,
97
- assertCanCommit: () => {
98
- if (input.stillCurrent?.() === false) {
99
- throw new ContainerShareGenerationExpiredError();
100
- }
101
- },
102
- containerId: input.containerId,
103
- execSql: input.execSql,
104
- groupId: input.recipientGroupId,
105
- organizationId: input.author.organizationId,
106
- prepareContainerMutations: async ({ currentPolicy, nextPolicy }) => {
107
- preparedTarget = await prepareMissingGroupGrantMutations({
108
- currentPolicy,
109
- nextPolicy,
110
- shareInput: input,
111
- });
112
- return preparedTarget;
113
- },
114
- resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,
115
- signerUserId: input.author.signerUserId,
116
- signingFingerprint: input.author.signerKeyFingerprint,
117
- signingKeyPair,
118
- });
119
- if (!preparedTarget) {
120
- throw new Error("Container group share preparation is incomplete");
121
- }
122
- return { preparedTarget, storedPolicy };
123
- }
124
- catch (error) {
125
- if (error instanceof ContainerShareGenerationExpiredError ||
126
- isProjectionVerificationCancelledError(error)) {
127
- return null;
128
- }
129
- throw error;
130
- }
131
- }
132
- async function commitMissingGroupGrant(input) {
133
- if (!input.signingKeyPair) {
134
- throw new Error("Container group share requires principal policy signing context");
135
- }
136
- if (input.stillCurrent?.() === false)
137
- return null;
138
- const committed = await commitMissingGroupGrantPolicy(input);
139
- if (!committed)
140
- return null;
141
- const { preparedTarget, storedPolicy } = committed;
142
- const targetIndex = preparedTarget?.plans.findIndex((planned) => planned.plan.containerId === input.containerId);
143
- const response = targetIndex === undefined || targetIndex < 0
144
- ? undefined
145
- : storedPolicy.containerMutations[targetIndex];
146
- const targetPlan = targetIndex === undefined || targetIndex < 0
147
- ? undefined
148
- : preparedTarget?.plans[targetIndex];
149
- if (!targetPlan ||
150
- !response ||
151
- !isMaterializedContainerSharePlan(targetPlan)) {
152
- throw new Error("Container group share acknowledgement is incomplete");
153
- }
154
- return {
155
- containerKey: targetPlan.containerKey,
156
- plan: targetPlan.plan,
157
- response,
158
- };
159
- }
160
- // Only a re-wrap of an existing signed grant may run without the chosen name;
161
- // minting a grant is exactly the operation the name binding protects.
162
- function assertGrantMintNamed(expectedGroupName) {
163
- if (expectedGroupName === null) {
164
- throw new Error("Minting a group grant requires the chosen group name; only a re-wrap of an existing signed grant may omit it");
165
- }
166
- }
167
- function loadShareGroupPolicy(input) {
168
- return loadVerifiedGroupSharePrincipalPolicy({
169
- apiClient: input.apiClient,
170
- execSql: input.execSql,
171
- expectedGroupName: input.expectedGroupName ?? undefined,
172
- readEncryptedName: input.readEncryptedName ??
173
- createGroupMetadataAccess({
174
- ...input,
175
- organizationId: input.author.organizationId,
176
- verifyMetadataContainer: createGroupMetadataContainerVerifier({
177
- ...input,
178
- organizationId: input.author.organizationId,
179
- stillCurrent: input.stillCurrent ?? (() => true),
180
- }),
181
- }).readName,
182
- groupId: input.recipientGroupId,
183
- organizationId: input.author.organizationId,
184
- resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,
185
- stillCurrent: input.stillCurrent,
186
- });
187
- }
188
- export async function shareRemoteContainerWithGroup(input) {
189
- if (input.stillCurrent?.() === false)
190
- return null;
191
- await input.apiClient.recoverPendingPrincipalMutation?.(input.author.organizationId);
192
- if (input.stillCurrent?.() === false)
193
- return null;
194
- const resolveProjectionUserKey = requireProjectionUserKeyResolver(input.resolveProjectionUserKey, "Remote container share");
195
- const previousProjection = await resolveShareProjection(input, resolveProjectionUserKey);
196
- if (!previousProjection)
197
- return null;
198
- const verifiedPrincipalPolicy = await loadShareGroupPolicy(input);
199
- if (input.stillCurrent?.() === false)
200
- return null;
201
- await advanceVerifiedSharePolicies(input.execSql, verifiedPrincipalPolicy, input.stillCurrent);
202
- if (input.stillCurrent?.() === false)
203
- return null;
204
- const signedGrant = verifiedPrincipalPolicy.policy.grants.find((grant) => grant.containerId === input.containerId);
205
- if (!signedGrant || signedGrant.accessLevel !== input.accessLevel) {
206
- assertGrantMintNamed(input.expectedGroupName);
207
- return commitMissingGroupGrant(input);
208
- }
209
- const materializedPlan = await buildCurrentContainerSharePlan({
210
- accessLevel: input.accessLevel,
211
- author: input.author,
212
- eventId: input.eventId,
213
- execSql: input.execSql,
214
- knownContainerKeks: input.knownContainerKeks,
215
- principalPolicyCache: principalPolicyCacheForVerifiedPolicies(verifiedPrincipalPolicy.checkpointPolicies),
216
- previousProjection,
217
- recipient: {
218
- principalPolicy: verifiedPrincipalPolicy.policy,
219
- subjectId: input.recipientGroupId,
220
- subjectType: "group",
221
- },
222
- resolveProjectionUserKey,
223
- signedAt: input.signedAt,
224
- stillCurrent: input.stillCurrent,
225
- targetSecretKey: input.targetSecretKey,
226
- warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,
227
- });
228
- if (!materializedPlan)
229
- return null;
230
- const result = await submitAcknowledgedContainerMutation({
231
- reportSecurityIncident: input.reportSecurityIncident,
232
- recitationPolicies: verifiedPrincipalPolicy.checkpointPolicies,
233
- apiClient: input.apiClient,
234
- author: input.author,
235
- containerKey: materializedPlan.containerKey,
236
- execSql: input.execSql,
237
- plan: materializedPlan.plan,
238
- stillCurrent: input.stillCurrent,
239
- submit: () => submitPlainContainerMutation(() => input.apiClient.shareContainer(input.containerId, materializedPlan.plan.request, {
240
- expectedPaymentRequiredOrganizationId: input.author.organizationId,
241
- })),
242
- });
243
- if (!result)
244
- return null;
245
- // Keep the previously cached group epoch available until the old container
246
- // wrap has been unwrapped and the replacement has committed. Root has no
247
- // parent fallback, so caching the rotated policy any earlier destroys the
248
- // only local path to the KEK that must be re-wrapped.
249
- if (input.stillCurrent?.() !== false) {
250
- await savePrincipalPolicyBundle(input.execSql, verifiedPrincipalPolicy.bundle, new Date().toISOString(), input.author.organizationId, { stillCurrent: input.stillCurrent });
251
- }
252
- if (input.stillCurrent?.() === false)
253
- return null;
254
- return result;
255
- }
256
52
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,sCAAsC,EACtC,wCAAwC,EAGxC,gCAAgC,GACjC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,uCAAuC,EAAE,MAAM,oFAAoF,CAAC;AAC7I,OAAO,EAAE,yBAAyB,EAAE,MAAM,yEAAyE,CAAC;AAGpH,OAAO,EACL,kCAAkC,GAEnC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AACrG,OAAO,EAAE,oCAAoC,EAAE,MAAM,sEAAsE,CAAC;AAC5H,OAAO,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AAE5F,OAAO,EAAE,+CAA+C,EAAE,MAAM,8EAA8E,CAAC;AAC/I,OAAO,EACL,mCAAmC,EACnC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACL,4BAA4B,EAE5B,qCAAqC,GACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,oCAAqC,SAAQ,KAAK;CAAG;AAE3D,KAAK,UAAU,8BAA8B,CAC3C,KAAgE;IAEhE,OAAO,wCAAwC,CAAC,GAAG,EAAE,CACnD,mCAAmC,CAAC,KAA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,EAAE,CAChC,KAAK,CAAC,SAAS,CAAC,cAAc,CAC5B,KAAK,CAAC,WAAW,EACjB,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAC7B;YACE,qCAAqC,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc;SACnE,CACF,CACF;KACJ,CAAC,CAAC;IACH,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,2EAA2E;IAC3E,yEAAyE;IACzE,0EAA0E;IAC1E,sDAAsD;IACtD,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QACrC,MAAM,yBAAyB,CAC7B,KAAK,CAAC,OAAO,EACb,uBAAuB,CAAC,MAAM,EAC9B,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EACxB,KAAK,CAAC,MAAM,CAAC,cAAc,EAC3B,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CACrC,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAElD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n ContainerAccessLevel,\n SigningKeyPair,\n VerifiedPrincipalPolicy,\n} from \"@tearleads/crypto\";\nimport type {\n ContainerMutationResponse,\n ContainerWriterProjectionResponse,\n PrincipalPolicyBundleResponse,\n} from \"@tearleads/validators/response\";\nimport type {\n ContainerMutationAuthor,\n ContainerShareApi,\n ContainerSharePlan,\n MaterializedContainerSharePlan,\n} from \"../../../../data/containers/shared/types\";\nimport {\n isProjectionVerificationCancelledError,\n nullOnProjectionVerificationCancellation,\n type ProjectionUserKeyResolver,\n type ReferencedPrincipalPolicyWarmer,\n requireProjectionUserKeyResolver,\n} from \"../../../../data/keyingProjectionVerification\";\nimport { principalPolicyCacheForVerifiedPolicies } from \"../../../../data/keyingProjectionVerification/principalPolicy/principalPolicyCache\";\nimport { savePrincipalPolicyBundle } from \"../../../../data/persistence/principalPolicy/principalPolicyPersistence\";\nimport type { SecurityIncidentReporter } from \"../../../../data/shared/securityIncidents\";\nimport type { ExecSql } from \"../../../../data/sqlite/sqlSchema\";\nimport {\n requireTrustedUserIdentityResolver,\n type TrustedUserIdentityResolver,\n} from \"../../../../data/trustedUserIdentity\";\nimport { createGroupMetadataAccess } from \"../../../organizations/groupMetadata/groupMetadataAccess\";\nimport { createGroupMetadataContainerVerifier } from \"../../../organizations/groupMetadata/groupMetadataContainerAuthority\";\nimport { setOrganizationGroupContainerGrant } from \"../../../organizations/principalPolicy\";\nimport type { GroupPolicyNameReader } from \"../../../organizations/principalPolicy/principalPolicyRequest\";\nimport { preparePrincipalContainerRematerializationBatch } from \"../../../organizations/rematerialization/principalContainerRematerialization\";\nimport {\n submitAcknowledgedContainerMutation,\n submitPlainContainerMutation,\n} from \"../mutationSubmit\";\nimport { buildMaterializedContainerSharePlan } from \"./shareMaterialization\";\nimport {\n advanceVerifiedSharePolicies,\n type ContainerManagedPrincipalShareApi,\n loadVerifiedGroupSharePrincipalPolicy,\n} from \"./sharePrincipalPolicy\";\nimport { resolveShareProjection } from \"./shareProjection\";\n\nclass ContainerShareGenerationExpiredError extends Error {}\n\nasync function buildCurrentContainerSharePlan(\n input: Parameters<typeof buildMaterializedContainerSharePlan>[0],\n): Promise<MaterializedContainerSharePlan | null> {\n return nullOnProjectionVerificationCancellation(() =>\n buildMaterializedContainerSharePlan(input),\n );\n}\n\nexport async function shareRemoteContainer(input: {\n reportSecurityIncident: SecurityIncidentReporter;\n accessLevel: ContainerAccessLevel;\n apiClient: ContainerShareApi;\n author: ContainerMutationAuthor;\n containerId: string;\n eventId?: string | undefined;\n execSql: ExecSql;\n previousProjection?: ContainerWriterProjectionResponse | undefined;\n recipientUserId: string;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n signedAt?: string | undefined;\n stillCurrent?: (() => boolean) | undefined;\n targetSecretKey: Uint8Array;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}): Promise<{\n containerKey: Uint8Array;\n plan: ContainerSharePlan;\n response: ContainerMutationResponse;\n} | null> {\n const resolveProjectionUserKey = requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n \"Remote container share\",\n );\n const resolveTrustedUserIdentity = requireTrustedUserIdentityResolver(\n input.resolveTrustedUserIdentity,\n );\n const recipientIdentity = await resolveTrustedUserIdentity(\n input.recipientUserId,\n );\n if (!recipientIdentity || input.stillCurrent?.() === false) {\n return null;\n }\n const previousProjection = await resolveShareProjection(\n input,\n resolveProjectionUserKey,\n );\n if (!previousProjection) return null;\n\n const materializedPlan = await buildCurrentContainerSharePlan({\n accessLevel: input.accessLevel,\n author: input.author,\n eventId: input.eventId,\n execSql: input.execSql,\n previousProjection,\n recipient: {\n recipientEncapsulationPublicKey: recipientIdentity.encapsulationPublicKey,\n subjectId: input.recipientUserId,\n subjectType: \"user\",\n },\n resolveProjectionUserKey,\n signedAt: input.signedAt,\n stillCurrent: input.stillCurrent,\n targetSecretKey: input.targetSecretKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n if (!materializedPlan) return null;\n return submitAcknowledgedContainerMutation({\n reportSecurityIncident: input.reportSecurityIncident,\n recitationPolicies: [],\n apiClient: input.apiClient,\n author: input.author,\n containerKey: materializedPlan.containerKey,\n execSql: input.execSql,\n plan: materializedPlan.plan,\n stillCurrent: input.stillCurrent,\n submit: () =>\n submitPlainContainerMutation(() =>\n input.apiClient.shareContainer(\n input.containerId,\n materializedPlan.plan.request,\n {\n expectedPaymentRequiredOrganizationId: input.author.organizationId,\n },\n ),\n ),\n });\n}\n\ninterface RemoteContainerGroupShareInput {\n reportSecurityIncident: SecurityIncidentReporter;\n accessLevel: ContainerAccessLevel;\n apiClient: ContainerManagedPrincipalShareApi;\n author: ContainerMutationAuthor;\n containerId: string;\n eventId?: string | undefined;\n execSql: ExecSql;\n /**\n * The display name the user chose the group by, checked against the name\n * committed in the verified group policy so a relabeled read-model row\n * cannot redirect the share onto another group. `null` is reserved for the\n * grant-preserving re-wrap: a share that would mint a new grant without a\n * name is refused.\n */\n expectedGroupName: string | null;\n readEncryptedName?: GroupPolicyNameReader | undefined;\n knownContainerKeks?: ReadonlyMap<string, Uint8Array> | undefined;\n previousProjection?: ContainerWriterProjectionResponse | undefined;\n recipientGroupId: string;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n signedAt?: string | undefined;\n signingKeyPair?: SigningKeyPair | null | undefined;\n stillCurrent?: (() => boolean) | undefined;\n targetSecretKey: Uint8Array;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}\n\ninterface RemoteContainerGroupShareResult {\n containerKey: Uint8Array;\n plan: ContainerSharePlan;\n response: ContainerMutationResponse;\n}\n\nfunction isMaterializedContainerSharePlan(\n value: Awaited<\n ReturnType<typeof preparePrincipalContainerRematerializationBatch>\n >[\"plans\"][number],\n): value is MaterializedContainerSharePlan {\n return value.plan.body.eventType === \"container.grant\";\n}\n\nasync function prepareMissingGroupGrantMutations(input: {\n currentPolicy: PrincipalPolicyBundleResponse;\n nextPolicy: VerifiedPrincipalPolicy;\n shareInput: RemoteContainerGroupShareInput;\n}) {\n const { currentPolicy, nextPolicy, shareInput } = input;\n return preparePrincipalContainerRematerializationBatch({\n reportSecurityIncident: shareInput.reportSecurityIncident,\n apiClient: shareInput.apiClient,\n author: shareInput.author,\n execSql: shareInput.execSql,\n grants: [\n ...new Map(\n [...currentPolicy.currentGrants, ...nextPolicy.grants].map(\n (grant) => [grant.containerId, grant] as const,\n ),\n ).values(),\n ],\n groupId: shareInput.recipientGroupId,\n nextPolicy,\n resolveTrustedUserIdentity: shareInput.resolveTrustedUserIdentity,\n stillCurrent: shareInput.stillCurrent,\n targetSecretKey: shareInput.targetSecretKey,\n warmReferencedPrincipalPolicies: shareInput.warmReferencedPrincipalPolicies,\n });\n}\n\nasync function commitMissingGroupGrantPolicy(\n input: RemoteContainerGroupShareInput,\n): Promise<{\n preparedTarget: Awaited<\n ReturnType<typeof preparePrincipalContainerRematerializationBatch>\n >;\n storedPolicy: Awaited<ReturnType<typeof setOrganizationGroupContainerGrant>>;\n} | null> {\n const signingKeyPair = input.signingKeyPair;\n if (!signingKeyPair) {\n throw new Error(\n \"Container group share requires principal policy signing context\",\n );\n }\n const policyApi = {\n recoverPendingPrincipalMutation:\n input.apiClient.recoverPendingPrincipalMutation?.bind(input.apiClient),\n commitOrganizationGroupPolicy:\n input.apiClient.commitOrganizationGroupPolicy.bind(input.apiClient),\n getCurrentPrincipalPolicy: input.apiClient.getCurrentPrincipalPolicy.bind(\n input.apiClient,\n ),\n };\n let preparedTarget:\n | Awaited<\n ReturnType<typeof preparePrincipalContainerRematerializationBatch>\n >\n | undefined;\n try {\n const storedPolicy = await setOrganizationGroupContainerGrant({\n accessLevel: input.accessLevel,\n apiClient: policyApi,\n assertCanCommit: () => {\n if (input.stillCurrent?.() === false) {\n throw new ContainerShareGenerationExpiredError();\n }\n },\n containerId: input.containerId,\n execSql: input.execSql,\n groupId: input.recipientGroupId,\n organizationId: input.author.organizationId,\n prepareContainerMutations: async ({ currentPolicy, nextPolicy }) => {\n preparedTarget = await prepareMissingGroupGrantMutations({\n currentPolicy,\n nextPolicy,\n shareInput: input,\n });\n return preparedTarget;\n },\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n signerUserId: input.author.signerUserId,\n signingFingerprint: input.author.signerKeyFingerprint,\n signingKeyPair,\n });\n if (!preparedTarget) {\n throw new Error(\"Container group share preparation is incomplete\");\n }\n return { preparedTarget, storedPolicy };\n } catch (error) {\n if (\n error instanceof ContainerShareGenerationExpiredError ||\n isProjectionVerificationCancelledError(error)\n ) {\n return null;\n }\n throw error;\n }\n}\n\nasync function commitMissingGroupGrant(\n input: RemoteContainerGroupShareInput,\n): Promise<RemoteContainerGroupShareResult | null> {\n if (!input.signingKeyPair) {\n throw new Error(\n \"Container group share requires principal policy signing context\",\n );\n }\n if (input.stillCurrent?.() === false) return null;\n const committed = await commitMissingGroupGrantPolicy(input);\n if (!committed) return null;\n const { preparedTarget, storedPolicy } = committed;\n const targetIndex = preparedTarget?.plans.findIndex(\n (planned) => planned.plan.containerId === input.containerId,\n );\n const response =\n targetIndex === undefined || targetIndex < 0\n ? undefined\n : storedPolicy.containerMutations[targetIndex];\n const targetPlan =\n targetIndex === undefined || targetIndex < 0\n ? undefined\n : preparedTarget?.plans[targetIndex];\n if (\n !targetPlan ||\n !response ||\n !isMaterializedContainerSharePlan(targetPlan)\n ) {\n throw new Error(\"Container group share acknowledgement is incomplete\");\n }\n return {\n containerKey: targetPlan.containerKey,\n plan: targetPlan.plan,\n response,\n };\n}\n\n// Only a re-wrap of an existing signed grant may run without the chosen name;\n// minting a grant is exactly the operation the name binding protects.\nfunction assertGrantMintNamed(expectedGroupName: string | null): void {\n if (expectedGroupName === null) {\n throw new Error(\n \"Minting a group grant requires the chosen group name; only a re-wrap of an existing signed grant may omit it\",\n );\n }\n}\n\nfunction loadShareGroupPolicy(input: RemoteContainerGroupShareInput) {\n return loadVerifiedGroupSharePrincipalPolicy({\n apiClient: input.apiClient,\n execSql: input.execSql,\n expectedGroupName: input.expectedGroupName ?? undefined,\n readEncryptedName:\n input.readEncryptedName ??\n createGroupMetadataAccess({\n ...input,\n organizationId: input.author.organizationId,\n verifyMetadataContainer: createGroupMetadataContainerVerifier({\n ...input,\n organizationId: input.author.organizationId,\n stillCurrent: input.stillCurrent ?? (() => true),\n }),\n }).readName,\n groupId: input.recipientGroupId,\n organizationId: input.author.organizationId,\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n stillCurrent: input.stillCurrent,\n });\n}\n\nexport async function shareRemoteContainerWithGroup(\n input: RemoteContainerGroupShareInput,\n): Promise<RemoteContainerGroupShareResult | null> {\n if (input.stillCurrent?.() === false) return null;\n await input.apiClient.recoverPendingPrincipalMutation?.(\n input.author.organizationId,\n );\n if (input.stillCurrent?.() === false) return null;\n const resolveProjectionUserKey = requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n \"Remote container share\",\n );\n const previousProjection = await resolveShareProjection(\n input,\n resolveProjectionUserKey,\n );\n if (!previousProjection) return null;\n const verifiedPrincipalPolicy = await loadShareGroupPolicy(input);\n if (input.stillCurrent?.() === false) return null;\n await advanceVerifiedSharePolicies(\n input.execSql,\n verifiedPrincipalPolicy,\n input.stillCurrent,\n );\n if (input.stillCurrent?.() === false) return null;\n\n const signedGrant = verifiedPrincipalPolicy.policy.grants.find(\n (grant) => grant.containerId === input.containerId,\n );\n if (!signedGrant || signedGrant.accessLevel !== input.accessLevel) {\n assertGrantMintNamed(input.expectedGroupName);\n return commitMissingGroupGrant(input);\n }\n\n const materializedPlan = await buildCurrentContainerSharePlan({\n accessLevel: input.accessLevel,\n author: input.author,\n eventId: input.eventId,\n execSql: input.execSql,\n knownContainerKeks: input.knownContainerKeks,\n principalPolicyCache: principalPolicyCacheForVerifiedPolicies(\n verifiedPrincipalPolicy.checkpointPolicies,\n ),\n previousProjection,\n recipient: {\n principalPolicy: verifiedPrincipalPolicy.policy,\n subjectId: input.recipientGroupId,\n subjectType: \"group\",\n },\n resolveProjectionUserKey,\n signedAt: input.signedAt,\n stillCurrent: input.stillCurrent,\n targetSecretKey: input.targetSecretKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n if (!materializedPlan) return null;\n const result = await submitAcknowledgedContainerMutation({\n reportSecurityIncident: input.reportSecurityIncident,\n recitationPolicies: verifiedPrincipalPolicy.checkpointPolicies,\n apiClient: input.apiClient,\n author: input.author,\n containerKey: materializedPlan.containerKey,\n execSql: input.execSql,\n plan: materializedPlan.plan,\n stillCurrent: input.stillCurrent,\n submit: () =>\n submitPlainContainerMutation(() =>\n input.apiClient.shareContainer(\n input.containerId,\n materializedPlan.plan.request,\n {\n expectedPaymentRequiredOrganizationId: input.author.organizationId,\n },\n ),\n ),\n });\n if (!result) return null;\n\n // Keep the previously cached group epoch available until the old container\n // wrap has been unwrapped and the replacement has committed. Root has no\n // parent fallback, so caching the rotated policy any earlier destroys the\n // only local path to the KEK that must be re-wrapped.\n if (input.stillCurrent?.() !== false) {\n await savePrincipalPolicyBundle(\n input.execSql,\n verifiedPrincipalPolicy.bundle,\n new Date().toISOString(),\n input.author.organizationId,\n { stillCurrent: input.stillCurrent },\n );\n }\n if (input.stillCurrent?.() === false) return null;\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,wCAAwC,EAGxC,gCAAgC,GACjC,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EACL,kCAAkC,GAEnC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,mCAAmC,EACnC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,KAAK,UAAU,8BAA8B,CAC3C,KAAgE;IAEhE,OAAO,wCAAwC,CAAC,GAAG,EAAE,CACnD,mCAAmC,CAAC,KAAK,CAAC,CAC3C,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAgB1C;IAKC,MAAM,wBAAwB,GAAG,gCAAgC,CAC/D,KAAK,CAAC,wBAAwB,EAC9B,wBAAwB,CACzB,CAAC;IACF,MAAM,0BAA0B,GAAG,kCAAkC,CACnE,KAAK,CAAC,0BAA0B,CACjC,CAAC;IACF,MAAM,iBAAiB,GAAG,MAAM,0BAA0B,CACxD,KAAK,CAAC,eAAe,CACtB,CAAC;IACF,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,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ACF,CACF;KACJ,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ContainerAccessLevel } from \"@tearleads/crypto\";\nimport type {\n ContainerMutationResponse,\n ContainerWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport type {\n ContainerMutationAuthor,\n ContainerShareApi,\n ContainerSharePlan,\n MaterializedContainerSharePlan,\n} from \"../../../../data/containers/shared/types\";\nimport {\n nullOnProjectionVerificationCancellation,\n type ProjectionUserKeyResolver,\n type ReferencedPrincipalPolicyWarmer,\n requireProjectionUserKeyResolver,\n} from \"../../../../data/keyingProjectionVerification\";\nimport type { SecurityIncidentReporter } from \"../../../../data/shared/securityIncidents\";\nimport type { ExecSql } from \"../../../../data/sqlite/sqlSchema\";\nimport {\n requireTrustedUserIdentityResolver,\n type TrustedUserIdentityResolver,\n} from \"../../../../data/trustedUserIdentity\";\nimport {\n submitAcknowledgedContainerMutation,\n submitPlainContainerMutation,\n} from \"../mutationSubmit\";\nimport { buildMaterializedContainerSharePlan } from \"./shareMaterialization\";\nimport { resolveShareProjection } from \"./shareProjection\";\n\nasync function buildCurrentContainerSharePlan(\n input: Parameters<typeof buildMaterializedContainerSharePlan>[0],\n): Promise<MaterializedContainerSharePlan | null> {\n return nullOnProjectionVerificationCancellation(() =>\n buildMaterializedContainerSharePlan(input),\n );\n}\n\nexport async function shareRemoteContainer(input: {\n reportSecurityIncident: SecurityIncidentReporter;\n accessLevel: ContainerAccessLevel;\n apiClient: ContainerShareApi;\n author: ContainerMutationAuthor;\n containerId: string;\n eventId?: string | undefined;\n execSql: ExecSql;\n previousProjection?: ContainerWriterProjectionResponse | undefined;\n recipientUserId: string;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n signedAt?: string | undefined;\n stillCurrent?: (() => boolean) | undefined;\n targetSecretKey: Uint8Array;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}): Promise<{\n containerKey: Uint8Array;\n plan: ContainerSharePlan;\n response: ContainerMutationResponse;\n} | null> {\n const resolveProjectionUserKey = requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n \"Remote container share\",\n );\n const resolveTrustedUserIdentity = requireTrustedUserIdentityResolver(\n input.resolveTrustedUserIdentity,\n );\n const recipientIdentity = await resolveTrustedUserIdentity(\n input.recipientUserId,\n );\n if (!recipientIdentity || input.stillCurrent?.() === false) {\n return null;\n }\n const previousProjection = await resolveShareProjection(\n input,\n resolveProjectionUserKey,\n );\n if (!previousProjection) return null;\n\n const materializedPlan = await buildCurrentContainerSharePlan({\n accessLevel: input.accessLevel,\n author: input.author,\n eventId: input.eventId,\n execSql: input.execSql,\n previousProjection,\n recipient: {\n recipientEncapsulationPublicKey: recipientIdentity.encapsulationPublicKey,\n subjectId: input.recipientUserId,\n subjectType: \"user\",\n },\n resolveProjectionUserKey,\n signedAt: input.signedAt,\n stillCurrent: input.stillCurrent,\n targetSecretKey: input.targetSecretKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n if (!materializedPlan) return null;\n return submitAcknowledgedContainerMutation({\n reportSecurityIncident: input.reportSecurityIncident,\n recitationPolicies: [],\n apiClient: input.apiClient,\n author: input.author,\n containerKey: materializedPlan.containerKey,\n execSql: input.execSql,\n plan: materializedPlan.plan,\n stillCurrent: input.stillCurrent,\n submit: () =>\n submitPlainContainerMutation(() =>\n input.apiClient.shareContainer(\n input.containerId,\n materializedPlan.plan.request,\n {\n expectedPaymentRequiredOrganizationId: input.author.organizationId,\n },\n ),\n ),\n });\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
2
+ import type { ContainerMutationAuthor, ContainerRekeyApi, ContainerShareApi } from "../../../../data/containers/shared/types.js";
3
+ import type { ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "../../../../data/keyingProjectionVerification/index.js";
4
+ import type { SecurityIncidentReporter } from "../../../../data/shared/securityIncidents.js";
5
+ import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
6
+ /**
7
+ * Repair a stale path down to and including a container before granting on it
8
+ * (#2340).
9
+ *
10
+ * A chain with no grant beneath it may sit lazily stale after an ancestor
11
+ * rotation, since nobody's writes depend on it. The first grant changes that:
12
+ * its grantee could never re-key the levels above its container, so the server
13
+ * refuses a first grant below a stale chain. The container's own edge must be
14
+ * current too, because a grant cites the parent's current epoch and the
15
+ * container's key epoch has to pin it. The sharer administers the container
16
+ * through a grant at or above it, and the levels above that grant are already
17
+ * current, so every stale level here is one the sharer can re-key. These
18
+ * repairs are standalone and need not be atomic with the grant: a repair never
19
+ * strands anyone.
20
+ *
21
+ * Every share does this, not only a first grant, which is all the server
22
+ * insists on. A container that already carries a grant is stale only past the
23
+ * carried-rekey cap, and its grantees are then parked behind exactly these
24
+ * levels; the sharer is already here and able.
25
+ */
26
+ export declare function projectionWithCurrentAncestors(input: {
27
+ apiClient: ContainerShareApi & Partial<Pick<ContainerRekeyApi, "rekeyContainer" | "rekeyContainerResult">>;
28
+ author: ContainerMutationAuthor;
29
+ containerId: string;
30
+ execSql: ExecSql;
31
+ previousProjection: ContainerWriterProjectionResponse;
32
+ reportSecurityIncident: SecurityIncidentReporter;
33
+ resolveProjectionUserKey: ProjectionUserKeyResolver;
34
+ stillCurrent?: (() => boolean) | undefined;
35
+ targetSecretKey: Uint8Array;
36
+ warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;
37
+ }): Promise<ContainerWriterProjectionResponse | null>;
@@ -0,0 +1,7 @@
1
+ import type { ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
2
+ import type { ProjectionUserKeyResolver } from "../../../../data/keyingProjectionVerification/index.js";
3
+ import { projectionWithCurrentAncestors } from "./shareAncestorRepair.js";
4
+ /** The container's projection, with any lazily stale chain above it repaired. */
5
+ export declare function resolveShareProjection(input: Omit<Parameters<typeof projectionWithCurrentAncestors>[0], "previousProjection" | "resolveProjectionUserKey"> & {
6
+ previousProjection?: ContainerWriterProjectionResponse | undefined;
7
+ }, resolveProjectionUserKey: ProjectionUserKeyResolver): Promise<ContainerWriterProjectionResponse | null>;
@@ -8,15 +8,16 @@ export { fetchContainerKekLog, HistoricalWrapUnavailableError, type HistoricalWr
8
8
  export { isProjectionVerificationCancelledError } from "../../data/keyingProjectionVerification/types.js";
9
9
  export { buildContainerCreatePlan, buildMaterializedContainerCreatePlan, childContainerWriterProjectionFromCreatePlan, createRemoteContainer, } from "./child/create/index.js";
10
10
  export { type AppliedContainerMove, moveRemoteContainer, replayRemoteContainerMove, } from "./child/move/index.js";
11
+ export { submitAcknowledgedContainerMutation, submitPlainContainerMutation, } from "./child/mutationSubmit.js";
11
12
  export { buildMaterializedContainerRekeyPlan } from "./child/rekey/index.js";
12
13
  export { ContainerKeyringOverrideStaleError } from "./child/rekey/keyringOverrideLineage.js";
13
14
  export { containerWriterProjectionFromRekeyPlan } from "./child/rekey/rekeyProjection.js";
14
15
  export { rekeyRemoteContainer } from "./child/rekey/rekeyRemote.js";
15
16
  export { buildMaterializedContainerRevokePlan, revokeRemoteContainer, } from "./child/revoke.js";
16
- export { shareRemoteContainer, shareRemoteContainerWithGroup, } from "./child/share/index.js";
17
+ export { shareRemoteContainer } from "./child/share/index.js";
17
18
  export { buildMaterializedContainerSharePlan } from "./child/share/shareMaterialization.js";
18
19
  export { referencedPrincipalHeadFromPolicy } from "./child/share/sharePlanCore.js";
19
- export { advanceVerifiedSharePolicies, GroupShareNameMismatchError, loadVerifiedGroupSharePrincipalPolicy, type VerifiedSharePrincipalPolicy, } from "./child/share/sharePrincipalPolicy.js";
20
+ export { resolveShareProjection } from "./child/share/shareProjection.js";
20
21
  export { readContainerMutationMetadataDocumentId, referencedPrincipalHeadsFromContainerMutationResponse, } from "./mutationResponse.js";
21
22
  export { buildRootContainerCreatePlan, rootContainerWriterProjectionFromCreatePlan, } from "./root/create.js";
22
23
  export { type ContainerWriteRefusal, classifyContainerWriteRefusal, } from "./writeRefusal.js";
@@ -11,16 +11,18 @@ export { fetchContainerKekLog, HistoricalWrapUnavailableError, rebuildKeyringEnt
11
11
  export { isProjectionVerificationCancelledError } from "../../data/keyingProjectionVerification/types.js";
12
12
  export { buildContainerCreatePlan, buildMaterializedContainerCreatePlan, childContainerWriterProjectionFromCreatePlan, createRemoteContainer, } from "./child/create/index.js";
13
13
  export { moveRemoteContainer, replayRemoteContainerMove, } from "./child/move/index.js";
14
+ // Organizations' group shares submit and acknowledge their container mutation.
15
+ export { submitAcknowledgedContainerMutation, submitPlainContainerMutation, } from "./child/mutationSubmit.js";
14
16
  export { buildMaterializedContainerRekeyPlan } from "./child/rekey/index.js";
15
17
  // A rebuilt keyring override that a concurrent rotation outdated: rebuild it.
16
18
  export { ContainerKeyringOverrideStaleError } from "./child/rekey/keyringOverrideLineage.js";
17
19
  export { containerWriterProjectionFromRekeyPlan } from "./child/rekey/rekeyProjection.js";
18
20
  export { rekeyRemoteContainer } from "./child/rekey/rekeyRemote.js";
19
21
  export { buildMaterializedContainerRevokePlan, revokeRemoteContainer, } from "./child/revoke.js";
20
- export { shareRemoteContainer, shareRemoteContainerWithGroup, } from "./child/share/index.js";
22
+ export { shareRemoteContainer } from "./child/share/index.js";
21
23
  export { buildMaterializedContainerSharePlan } from "./child/share/shareMaterialization.js";
22
24
  export { referencedPrincipalHeadFromPolicy } from "./child/share/sharePlanCore.js";
23
- export { advanceVerifiedSharePolicies, GroupShareNameMismatchError, loadVerifiedGroupSharePrincipalPolicy, } from "./child/share/sharePrincipalPolicy.js";
25
+ export { resolveShareProjection } from "./child/share/shareProjection.js";
24
26
  export { readContainerMutationMetadataDocumentId, referencedPrincipalHeadsFromContainerMutationResponse, } from "./mutationResponse.js";
25
27
  export { buildRootContainerCreatePlan, rootContainerWriterProjectionFromCreatePlan, } from "./root/create.js";
26
28
  export { classifyContainerWriteRefusal, } from "./writeRefusal.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","s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EACL,4BAA4B,EAC5B,2CAA2C,GAC5C,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC","sourcesContent":["// Refusals the SDK raises before it encrypts or sends a container-scoped\n// write; hosts classify them with classifyContainerWriteRefusal.\nexport { ContainerAuthorAccessError } from \"../../data/containers/shared/authorAccess\";\n// A create or move past the readable path length; `code` is\n// `container_path_too_deep`. Queued moves are abandoned, queued creates wait.\nexport { ContainerPathTooDeepError } from \"../../data/containers/shared/containerPathLimits\";\nexport type { ContainerReciteApi } from \"../../data/containers/shared/reciteApi\";\nexport type {\n ContainerMutationAuthor,\n MaterializedContainerRekeyPlan,\n} from \"../../data/containers/shared/types\";\nexport {\n ContainerKekRepairInaccessibleError,\n ContainerKekRepairRequiredError,\n} from \"../../data/documents/shared/containerKek/containerKekCurrency\";\nexport type {\n AggregatedContainerKekLog,\n KeyringRebuildResult,\n} from \"../../data/documents/shared/containerKek/keyringRebuild\";\nexport {\n fetchContainerKekLog,\n HistoricalWrapUnavailableError,\n type HistoricalWrapUnavailableReason,\n rebuildKeyringEntriesFromLog,\n recoverKeyringEntryFromWraps,\n} from \"../../data/documents/shared/containerKek/keyringRebuild\";\n// A share's projection verification can be cancelled by a newer generation\n// underneath the caller; hosts filter that outcome from their own reporting.\nexport { isProjectionVerificationCancelledError } from \"../../data/keyingProjectionVerification/types\";\nexport {\n buildContainerCreatePlan,\n buildMaterializedContainerCreatePlan,\n childContainerWriterProjectionFromCreatePlan,\n createRemoteContainer,\n} from \"./child/create\";\nexport {\n type AppliedContainerMove,\n moveRemoteContainer,\n replayRemoteContainerMove,\n} from \"./child/move\";\nexport { buildMaterializedContainerRekeyPlan } from \"./child/rekey\";\n// A rebuilt keyring override that a concurrent rotation outdated: rebuild it.\nexport { ContainerKeyringOverrideStaleError } from \"./child/rekey/keyringOverrideLineage\";\nexport { containerWriterProjectionFromRekeyPlan } from \"./child/rekey/rekeyProjection\";\nexport { rekeyRemoteContainer } from \"./child/rekey/rekeyRemote\";\nexport {\n buildMaterializedContainerRevokePlan,\n revokeRemoteContainer,\n} from \"./child/revoke\";\nexport {\n shareRemoteContainer,\n shareRemoteContainerWithGroup,\n} from \"./child/share\";\nexport { buildMaterializedContainerSharePlan } from \"./child/share/shareMaterialization\";\nexport { referencedPrincipalHeadFromPolicy } from \"./child/share/sharePlanCore\";\nexport {\n advanceVerifiedSharePolicies,\n GroupShareNameMismatchError,\n loadVerifiedGroupSharePrincipalPolicy,\n type VerifiedSharePrincipalPolicy,\n} from \"./child/share/sharePrincipalPolicy\";\nexport {\n readContainerMutationMetadataDocumentId,\n referencedPrincipalHeadsFromContainerMutationResponse,\n} from \"./mutationResponse\";\nexport {\n buildRootContainerCreatePlan,\n rootContainerWriterProjectionFromCreatePlan,\n} from \"./root/create\";\nexport {\n type ContainerWriteRefusal,\n classifyContainerWriteRefusal,\n} from \"./writeRefusal\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,iEAAiE;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,4DAA4D;AAC5D,8EAA8E;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAM7F,OAAO,EACL,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,+DAA+D,CAAC;AAKvE,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAE9B,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,yDAAyD,CAAC;AACjE,2EAA2E;AAC3E,6EAA6E;AAC7E,OAAO,EAAE,sCAAsC,EAAE,MAAM,+CAA+C,CAAC;AACvG,OAAO,EACL,wBAAwB,EACxB,oCAAoC,EACpC,4CAA4C,EAC5C,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,+EAA+E;AAC/E,OAAO,EACL,mCAAmC,EACnC,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mCAAmC,EAAE,MAAM,eAAe,CAAC;AACpE,8EAA8E;AAC9E,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,sCAAsC,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EACL,uCAAuC,EACvC,qDAAqD,GACtD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,4BAA4B,EAC5B,2CAA2C,GAC5C,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC","sourcesContent":["// Refusals the SDK raises before it encrypts or sends a container-scoped\n// write; hosts classify them with classifyContainerWriteRefusal.\nexport { ContainerAuthorAccessError } from \"../../data/containers/shared/authorAccess\";\n// A create or move past the readable path length; `code` is\n// `container_path_too_deep`. Queued moves are abandoned, queued creates wait.\nexport { ContainerPathTooDeepError } from \"../../data/containers/shared/containerPathLimits\";\nexport type { ContainerReciteApi } from \"../../data/containers/shared/reciteApi\";\nexport type {\n ContainerMutationAuthor,\n MaterializedContainerRekeyPlan,\n} from \"../../data/containers/shared/types\";\nexport {\n ContainerKekRepairInaccessibleError,\n ContainerKekRepairRequiredError,\n} from \"../../data/documents/shared/containerKek/containerKekCurrency\";\nexport type {\n AggregatedContainerKekLog,\n KeyringRebuildResult,\n} from \"../../data/documents/shared/containerKek/keyringRebuild\";\nexport {\n fetchContainerKekLog,\n HistoricalWrapUnavailableError,\n type HistoricalWrapUnavailableReason,\n rebuildKeyringEntriesFromLog,\n recoverKeyringEntryFromWraps,\n} from \"../../data/documents/shared/containerKek/keyringRebuild\";\n// A share's projection verification can be cancelled by a newer generation\n// underneath the caller; hosts filter that outcome from their own reporting.\nexport { isProjectionVerificationCancelledError } from \"../../data/keyingProjectionVerification/types\";\nexport {\n buildContainerCreatePlan,\n buildMaterializedContainerCreatePlan,\n childContainerWriterProjectionFromCreatePlan,\n createRemoteContainer,\n} from \"./child/create\";\nexport {\n type AppliedContainerMove,\n moveRemoteContainer,\n replayRemoteContainerMove,\n} from \"./child/move\";\n// Organizations' group shares submit and acknowledge their container mutation.\nexport {\n submitAcknowledgedContainerMutation,\n submitPlainContainerMutation,\n} from \"./child/mutationSubmit\";\nexport { buildMaterializedContainerRekeyPlan } from \"./child/rekey\";\n// A rebuilt keyring override that a concurrent rotation outdated: rebuild it.\nexport { ContainerKeyringOverrideStaleError } from \"./child/rekey/keyringOverrideLineage\";\nexport { containerWriterProjectionFromRekeyPlan } from \"./child/rekey/rekeyProjection\";\nexport { rekeyRemoteContainer } from \"./child/rekey/rekeyRemote\";\nexport {\n buildMaterializedContainerRevokePlan,\n revokeRemoteContainer,\n} from \"./child/revoke\";\nexport { shareRemoteContainer } from \"./child/share\";\nexport { buildMaterializedContainerSharePlan } from \"./child/share/shareMaterialization\";\nexport { referencedPrincipalHeadFromPolicy } from \"./child/share/sharePlanCore\";\nexport { resolveShareProjection } from \"./child/share/shareProjection\";\nexport {\n readContainerMutationMetadataDocumentId,\n referencedPrincipalHeadsFromContainerMutationResponse,\n} from \"./mutationResponse\";\nexport {\n buildRootContainerCreatePlan,\n rootContainerWriterProjectionFromCreatePlan,\n} from \"./root/create\";\nexport {\n type ContainerWriteRefusal,\n classifyContainerWriteRefusal,\n} from \"./writeRefusal\";\n"]}
@@ -0,0 +1,4 @@
1
+ // A principal policy change re-wraps every container it grants or revokes.
2
+ // Group-policy commits and group shares prepare that batch through this surface.
3
+ export { preparePrincipalContainerRematerializationBatch, } from "./principalContainerRematerialization.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iFAAiF;AACjF,OAAO,EAEL,+CAA+C,GAChD,MAAM,uCAAuC,CAAC","sourcesContent":["// A principal policy change re-wraps every container it grants or revokes.\n// Group-policy commits and group shares prepare that batch through this surface.\nexport {\n type PreparedPrincipalContainerRematerializationBatch,\n preparePrincipalContainerRematerializationBatch,\n} from \"./principalContainerRematerialization\";\nexport type { PrincipalRematerializationPredecessor } from \"./principalContainerRematerializationPlanning\";\n"]}
@@ -1,4 +1,4 @@
1
- import { rebaseOnDeepestAncestor } from "../../containers/child/rekey/carriedDescendantRekeys.js";
1
+ import { rebaseOnDeepestAncestor } from "../child/rekey/carriedDescendantRekeys.js";
2
2
  import { withAuthoredPrincipalPolicies } from "./authoredPrincipalPolicyWarmer.js";
3
3
  /** Plan the next group against container heads authored earlier in the same transaction. */
4
4
  export function withPrecedingRematerialization(input) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"precedingPrincipalRematerialization.js","sourceRoot":"","sources":["precedingPrincipalRematerialization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAGhF,4FAA4F;AAC5F,MAAM,UAAU,8BAA8B,CAC5C,KAA+C;IAE/C,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,MAAM,MAAM,GAAG,CAAC,MAAyC,EAAE,EAAE;QAC3D,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,QAAQ,CACxC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,CAC9D,CAAC;QACF,MAAM,UAAU,GAAG,GAAG,IAAI,MAAM,CAAC;QACjC,OAAO,CACL,uBAAuB,CAAC,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,UAAU;YACtE,UAAU,CACX,CAAC;IACJ,CAAC,CAAC;IACF,OAAO;QACL,GAAG,KAAK;QACR,+BAA+B,EAAE,6BAA6B,CAC5D,KAAK,CAAC,+BAA+B,EACrC,SAAS,CAAC,QAAQ,IAAI,EAAE,CACzB;QACD,SAAS,EAAE;YACT,GAAG,KAAK,CAAC,SAAS;YAClB,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YACtE,4BAA4B,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;gBAClD,MAAM,UAAU,GACd,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,CAAC,WAAW,CAAC,CAAC;gBAClE,OAAO,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAChD,CAAC;YACD,kCAAkC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;gBACjE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,kCAAkC,CACrE,WAAW,EACX,OAAO,CACR,CAAC;gBACF,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YACvE,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport { rebaseOnDeepestAncestor } from \"../child/rekey/carriedDescendantRekeys\";\nimport { withAuthoredPrincipalPolicies } from \"./authoredPrincipalPolicyWarmer\";\nimport type { PrincipalContainerRematerializationInput } from \"./principalContainerRematerializationPlanning\";\n\n/** Plan the next group against container heads authored earlier in the same transaction. */\nexport function withPrecedingRematerialization(\n input: PrincipalContainerRematerializationInput,\n): PrincipalContainerRematerializationInput {\n const preceding = input.preceding;\n if (!preceding) return input;\n const rebase = (served: ContainerWriterProjectionResponse) => {\n const own = preceding.projections.findLast(\n (projection) => projection.containerId === served.containerId,\n );\n const projection = own ?? served;\n return (\n rebaseOnDeepestAncestor(projection, preceding.projections)?.projection ??\n projection\n );\n };\n return {\n ...input,\n warmReferencedPrincipalPolicies: withAuthoredPrincipalPolicies(\n input.warmReferencedPrincipalPolicies,\n preceding.authored ?? [],\n ),\n apiClient: {\n ...input.apiClient,\n reciteContainer: input.apiClient.reciteContainer.bind(input.apiClient),\n getContainerWriterProjection: async (containerId) => {\n const projection =\n await input.apiClient.getContainerWriterProjection(containerId);\n return projection ? rebase(projection) : null;\n },\n getContainerWriterProjectionResult: async (containerId, options) => {\n const result = await input.apiClient.getContainerWriterProjectionResult(\n containerId,\n options,\n );\n return result.ok ? { ...result, data: rebase(result.data) } : result;\n },\n },\n };\n}\n"]}
@@ -4,13 +4,13 @@ import { acknowledgeContainerMutationBatch } from "../../../data/containers/shar
4
4
  import { getTargetContainerContext, readContainerState, } from "../../../data/containers/shared/projection.js";
5
5
  import { verifyContainerWriterProjection, } from "../../../data/keyingProjectionVerification/index.js";
6
6
  import { createProjectionUserKeyResolver } from "../../../data/keyingProjectionVerification/userKeyResolver.js";
7
- import { scheduleHeldDescendantRecitations } from "../../containers/child/recite.js";
8
- import { buildMaterializedContainerRekeyPlan } from "../../containers/child/rekey/index.js";
9
- import { rebaseOnDeepestAncestor } from "../../containers/child/rekey/carriedDescendantRekeys.js";
10
- import { containerWriterProjectionFromRotationPlan, containerWriterProjectionFromSharePlan, isSpeculativeContainerWriterProjection, } from "../../containers/child/rekey/rekeyProjection.js";
11
- import { buildMaterializedContainerRevokePlan } from "../../containers/child/revoke.js";
12
- import { selectReplacementPrincipalPolicyReferences } from "../../containers/child/rotation/replacementPrincipalPolicyReferences.js";
13
- import { buildMaterializedContainerSharePlan } from "../../containers/child/share/shareMaterialization.js";
7
+ import { scheduleHeldDescendantRecitations } from "../child/recite.js";
8
+ import { buildMaterializedContainerRekeyPlan } from "../child/rekey/index.js";
9
+ import { rebaseOnDeepestAncestor } from "../child/rekey/carriedDescendantRekeys.js";
10
+ import { containerWriterProjectionFromRotationPlan, containerWriterProjectionFromSharePlan, isSpeculativeContainerWriterProjection, } from "../child/rekey/rekeyProjection.js";
11
+ import { buildMaterializedContainerRevokePlan } from "../child/revoke.js";
12
+ import { selectReplacementPrincipalPolicyReferences } from "../child/rotation/replacementPrincipalPolicyReferences.js";
13
+ import { buildMaterializedContainerSharePlan } from "../child/share/shareMaterialization.js";
14
14
  import { withPrecedingRematerialization } from "./precedingPrincipalRematerialization.js";
15
15
  import { addPlan, carryLevel, staleLevelsAbove, } from "./principalContainerRematerializationPlanning.js";
16
16
  import { loadRematerializationTargets, loadServedProjection, seededPrincipalPolicyCache, } from "./principalContainerRematerializationTargets.js";