@tearleads/client-sdk 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/organizations/organizationGroupHistory.js +4 -7
- package/client/organizations/organizationGroupHistory.js.map +1 -1
- package/client/organizations/organizationReadModels.js +2 -86
- package/client/organizations/organizationReadModels.js.map +1 -1
- package/client/organizations/principalMutations.js +53 -133
- package/client/organizations/principalMutations.js.map +1 -1
- package/client/principalMutationDispatch.js +2 -2
- package/client/principalMutationDispatch.js.map +1 -1
- package/data/keyingProjectionVerification/principalPolicyVerification.js +5 -5
- package/data/keyingProjectionVerification/principalPolicyVerification.js.map +1 -1
- package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js +21 -7
- package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js.map +1 -1
- package/data/keyingProjectionVerification/types.d.ts +1 -8
- package/data/keyingProjectionVerification/types.js +0 -9
- package/data/keyingProjectionVerification/types.js.map +1 -1
- package/data/keyingProjectionVerification.d.ts +1 -1
- package/data/keyingProjectionVerification.js.map +1 -1
- package/data/persistence/documents/documentsPersistence.js +7 -0
- package/data/persistence/documents/documentsPersistence.js.map +1 -1
- package/data/persistence/documents/orphanBlobPersistence.d.ts +13 -0
- package/data/persistence/documents/orphanBlobPersistence.js +2 -0
- package/data/persistence/documents/orphanBlobPersistence.js.map +1 -0
- package/data/persistence/documents/types.d.ts +2 -0
- package/data/persistence/documents/types.js.map +1 -1
- package/data/persistence/principalHistoryPrefixPersistence.d.ts +5 -1
- package/data/persistence/principalHistoryPrefixPersistence.js +22 -5
- package/data/persistence/principalHistoryPrefixPersistence.js.map +1 -1
- package/data/principals/principalMutationJournalShape.d.ts +1 -1
- package/data/principals/principalMutationJournalShape.js +2 -2
- package/data/principals/principalMutationJournalShape.js.map +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/stores/documents/documentStore/attachmentHydration.js +2 -2
- package/stores/documents/documentStore/attachmentHydration.js.map +1 -1
- package/stores/documents/documentStore/attachments.js +7 -5
- package/stores/documents/documentStore/attachments.js.map +1 -1
- package/stores/documents/documentStore/discard.js +3 -2
- package/stores/documents/documentStore/discard.js.map +1 -1
- package/stores/documents/documentStore/orphanMaintenance.js +3 -5
- package/stores/documents/documentStore/orphanMaintenance.js.map +1 -1
- package/stores/documents/documentStore/persistence.js +3 -4
- package/stores/documents/documentStore/persistence.js.map +1 -1
- package/stores/documents/documentStore/syncDetachedAttachments.js +3 -2
- package/stores/documents/documentStore/syncDetachedAttachments.js.map +1 -1
- package/stores/documents/documentStore/syncRequest.js +3 -4
- package/stores/documents/documentStore/syncRequest.js.map +1 -1
- package/workflows/container-contents/container-state/groupGrantVerification.js +23 -74
- package/workflows/container-contents/container-state/groupGrantVerification.js.map +1 -1
- package/workflows/container-contents/container-state/groupShareEpoch.js +6 -23
- package/workflows/container-contents/container-state/groupShareEpoch.js.map +1 -1
- package/workflows/container-contents/container-state/remote.js +5 -3
- package/workflows/container-contents/container-state/remote.js.map +1 -1
- package/workflows/container-contents/container-state/types.js.map +1 -1
- package/workflows/container-contents/documentLinks.d.ts +1 -1
- package/workflows/container-contents/documentLinks.js.map +1 -1
- package/workflows/container-contents/documentPurge.d.ts +1 -1
- package/workflows/container-contents/documentPurge.js +4 -4
- package/workflows/container-contents/documentPurge.js.map +1 -1
- package/workflows/container-contents/metadataRemoteSync.d.ts +1 -1
- package/workflows/container-contents/metadataRemoteSync.js.map +1 -1
- package/workflows/container-contents/remoteHydration/types.d.ts +2 -2
- package/workflows/container-contents/remoteHydration/types.js.map +1 -1
- package/workflows/container-contents/remoteHydration/verifiedDestination.js +6 -7
- package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +1 -1
- package/workflows/containers/child/runtimeCurrentGroupShare.js +1 -1
- package/workflows/containers/child/runtimeCurrentGroupShare.js.map +1 -1
- package/workflows/documents/orphanBlobReclaimState.js +20 -0
- package/workflows/documents/orphanBlobReclaimState.js.map +1 -0
- package/workflows/documents/orphanBlobReclaims.d.ts +3 -2
- package/workflows/documents/orphanBlobReclaims.js +49 -47
- package/workflows/documents/orphanBlobReclaims.js.map +1 -1
- package/workflows/organizations/groupMetadataRuntime.js +11 -8
- package/workflows/organizations/groupMetadataRuntime.js.map +1 -1
- package/workflows/organizations/organizationGroupNames.js +8 -55
- package/workflows/organizations/organizationGroupNames.js.map +1 -1
- package/workflows/organizations/principalOperationReceipt.js +1 -1
- package/workflows/organizations/principalOperationReceipt.js.map +1 -1
- package/workflows/organizations/runtimeGroupMetadataAuthority.js +16 -0
- package/workflows/organizations/runtimeGroupMetadataAuthority.js.map +1 -0
- package/workflows/principals/runtimePolicyWarmer.js +29 -27
- package/workflows/principals/runtimePolicyWarmer.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"principalOperationReceipt.js","sourceRoot":"","sources":["principalOperationReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAIL,uCAAuC,EACvC,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,GAElC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EACL,sCAAsC,EACtC,oCAAoC,GACrC,MAAM,4BAA4B,CAAC;AAQpC,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAC3D,QAAmC,EACnC,QAAmC;IAEnC,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,
|
|
1
|
+
{"version":3,"file":"principalOperationReceipt.js","sourceRoot":"","sources":["principalOperationReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAIL,uCAAuC,EACvC,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,GAElC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,6BA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CACzC,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EACnC,QAAQ,CAAC,kBAAkB,CAC5B,CAAC;IACN,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { computePrincipalStateHash } from \"@tearleads/crypto\";\nimport {\n type CommitOrganizationGroupPolicyResponse,\n type CreateOrganizationGroupResponse,\n type DeleteOrganizationGroupResponse,\n isCommitOrganizationGroupPolicyResponse,\n isCreateOrganizationGroupResponse,\n isDeleteOrganizationGroupResponse,\n isPrincipalPolicyMutationResponse,\n type PrincipalPolicyMutationResponse,\n} from \"@tearleads/validators/response\";\nimport type { AuthoredPrincipalMutation } from \"../../data/principals/principalMutationJournal\";\nimport { acknowledgeInitialGroupPolicy } from \"./groupPolicyMutationAcknowledgement\";\nimport {\n assertAuthoredPrincipalMutationReceipt,\n assertAuthoredPrincipalPolicyReceipt,\n} from \"./principalMutationReceipt\";\n\nexport type PrincipalMutationResponse =\n | CommitOrganizationGroupPolicyResponse\n | CreateOrganizationGroupResponse\n | DeleteOrganizationGroupResponse\n | PrincipalPolicyMutationResponse;\n\n/** Match both the operation's route and its exact authored policy artifacts. */\nexport async function assertAuthoredPrincipalOperationReceipt(\n mutation: AuthoredPrincipalMutation,\n response: PrincipalMutationResponse,\n): Promise<void> {\n switch (mutation.kind) {\n case \"compound\":\n if (!isCommitOrganizationGroupPolicyResponse(response)) break;\n return assertAuthoredPrincipalMutationReceipt(mutation.request, response);\n case \"organization\":\n if (!isPrincipalPolicyMutationResponse(response)) break;\n return assertAuthoredPrincipalPolicyReceipt(mutation.request, response);\n case \"group-create\":\n if (!isCreateOrganizationGroupResponse(response)) break;\n await acknowledgeInitialGroupPolicy({\n organizationId: mutation.request.organizationPolicy.state.principalId,\n request: mutation.request,\n response: response.group,\n stateHash: await computePrincipalStateHash(\n mutation.request.initialGroupPolicy.state,\n ),\n });\n return assertAuthoredPrincipalPolicyReceipt(\n mutation.request.organizationPolicy,\n response.organizationPolicy,\n );\n case \"group-delete\":\n if (\n !isDeleteOrganizationGroupResponse(response) ||\n response.groupId !== mutation.groupId ||\n response.organizationId !==\n mutation.request.organizationPolicy.state.principalId\n )\n break;\n return assertAuthoredPrincipalPolicyReceipt(\n mutation.request.organizationPolicy,\n response.organizationPolicy,\n );\n }\n throw new Error(\"Principal mutation receipt operation or target differs\");\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProjectionDependencyUnavailableError } from "../../data/keyingProjectionVerification/dependencyUnavailable.js";
|
|
2
|
+
import { createRuntimePrincipalPolicyCurrentResolver, } from "../principals/runtimePolicyRecovery.js";
|
|
3
|
+
import { createCurrentGroupMetadataContainerVerifier } from "./currentGroupMetadataAuthority.js";
|
|
4
|
+
/** Remote metadata destinations require the same private authority as name reads. */
|
|
5
|
+
export async function verifyRuntimeGroupMetadataAuthority(input) {
|
|
6
|
+
const resolveCurrentPolicy = createRuntimePrincipalPolicyCurrentResolver(input.runtime);
|
|
7
|
+
if (!resolveCurrentPolicy)
|
|
8
|
+
throw new ProjectionDependencyUnavailableError("Group metadata requires private paged recovery");
|
|
9
|
+
await createCurrentGroupMetadataContainerVerifier({
|
|
10
|
+
execSql: input.runtime.infra.execSql,
|
|
11
|
+
organizationId: input.organizationId,
|
|
12
|
+
resolveCurrentPolicy,
|
|
13
|
+
stillCurrent: input.stillCurrent,
|
|
14
|
+
})(input.state, input.organizationReference);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=runtimeGroupMetadataAuthority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeGroupMetadataAuthority.js","sourceRoot":"","sources":["runtimeGroupMetadataAuthority.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oCAAoC,EAAE,MAAM,+DAA+D,CAAC;AACrH,OAAO,EACL,2CAA2C,GAE5C,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,2CAA2C,EAAE,MAAM,iCAAiC,CAAC;AAE9F,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,KAMzD;IACC,MAAM,oBAAoB,GAAG,2CAA2C,CACtE,KAAK,CAAC,OAAO,CACd,CAAC;IACF,IAAI,CAAC,oBAAoB;QACvB,MAAM,IAAI,oCAAoC,CAC5C,gDAAgD,CACjD,CAAC;IACJ,MAAM,2CAA2C,CAAC;QAChD,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO;QACpC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,oBAAoB;QACpB,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type {\n ContainerAccessManifestState,\n ReferencedPrincipalHead,\n} from \"@tearleads/crypto\";\nimport { ProjectionDependencyUnavailableError } from \"../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport {\n createRuntimePrincipalPolicyCurrentResolver,\n type PrincipalPolicyRecoveryRuntime,\n} from \"../principals/runtimePolicyRecovery\";\nimport { createCurrentGroupMetadataContainerVerifier } from \"./currentGroupMetadataAuthority\";\n\n/** Remote metadata destinations require the same private authority as name reads. */\nexport async function verifyRuntimeGroupMetadataAuthority(input: {\n readonly runtime: PrincipalPolicyRecoveryRuntime;\n readonly organizationId: string;\n readonly state: ContainerAccessManifestState;\n readonly organizationReference?: ReferencedPrincipalHead | undefined;\n readonly stillCurrent: () => boolean;\n}): Promise<void> {\n const resolveCurrentPolicy = createRuntimePrincipalPolicyCurrentResolver(\n input.runtime,\n );\n if (!resolveCurrentPolicy)\n throw new ProjectionDependencyUnavailableError(\n \"Group metadata requires private paged recovery\",\n );\n await createCurrentGroupMetadataContainerVerifier({\n execSql: input.runtime.infra.execSql,\n organizationId: input.organizationId,\n resolveCurrentPolicy,\n stillCurrent: input.stillCurrent,\n })(input.state, input.organizationReference);\n}\n"]}
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { errorMessage } from "../../data/errorMessage.js";
|
|
2
|
+
import { ProjectionDependencyUnavailableError } from "../../data/keyingProjectionVerification/dependencyUnavailable.js";
|
|
3
|
+
import { rethrowKeyingVerificationError } from "../../data/keyingProjectionVerification/error.js";
|
|
4
|
+
import { assertProjectionVerificationCurrent, isProjectionVerificationCancelledError, } from "../../data/keyingProjectionVerification/types.js";
|
|
2
5
|
import { createRuntimePrincipalPolicyResolver, } from "./runtimePolicyRecovery.js";
|
|
3
6
|
import { createRuntimeProjectionPolicyResolver } from "./runtimeProjectionPolicyRecovery.js";
|
|
7
|
+
/** Prefetch is best-effort; exact resolution still rejects unavailable evidence. */
|
|
4
8
|
export function createRuntimePrincipalPolicyWarmer(runtime, options = {}) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
organizationId,
|
|
11
|
-
reportSecurityIncident: runtime.util.reportSecurityIncident,
|
|
12
|
-
references,
|
|
13
|
-
resolveTrustedUserIdentity: runtime.resolveTrustedUserIdentity,
|
|
14
|
-
stillCurrent,
|
|
15
|
-
};
|
|
16
|
-
return input;
|
|
9
|
+
const resolve = createRuntimePrincipalPolicyResolver(runtime, options);
|
|
10
|
+
const resolveReference = async (input) => {
|
|
11
|
+
if (!resolve)
|
|
12
|
+
throw new ProjectionDependencyUnavailableError("Principal policies require private paged recovery");
|
|
13
|
+
return resolve(input);
|
|
17
14
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
bundles: input.bundles,
|
|
21
|
-
execSql: runtime.infra.execSql,
|
|
22
|
-
getCurrentPrincipalPolicy: (principalType, principalId) => runtime.apiClient.getCurrentPrincipalPolicy(principalType, principalId),
|
|
23
|
-
log: runtime.util.log,
|
|
24
|
-
organizationId: input.organizationId,
|
|
25
|
-
reportSecurityIncident: runtime.util.reportSecurityIncident,
|
|
26
|
-
resolveTrustedUserIdentity: runtime.resolveTrustedUserIdentity,
|
|
27
|
-
stillCurrent: input.stillCurrent,
|
|
28
|
-
});
|
|
29
|
-
return Object.assign(warmer, {
|
|
30
|
-
cacheBundles,
|
|
31
|
-
resolveReference: createRuntimePrincipalPolicyResolver(runtime, options),
|
|
15
|
+
return Object.assign((input) => prefetchReferences(runtime, resolveReference, input), {
|
|
16
|
+
resolveReference,
|
|
32
17
|
resolveProjectionHistory: createRuntimeProjectionPolicyResolver(runtime),
|
|
33
18
|
});
|
|
34
19
|
}
|
|
20
|
+
async function prefetchReferences(runtime, resolve, input) {
|
|
21
|
+
const recoveryBatch = {};
|
|
22
|
+
for (const reference of input.references) {
|
|
23
|
+
try {
|
|
24
|
+
assertProjectionVerificationCurrent(input.stillCurrent);
|
|
25
|
+
const resolved = await resolve({ ...input, reference, recoveryBatch });
|
|
26
|
+
assertProjectionVerificationCurrent(resolved.stillCurrent);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (isProjectionVerificationCancelledError(error))
|
|
30
|
+
return;
|
|
31
|
+
// Recovery already reports signature/authority failures. Keep them fatal.
|
|
32
|
+
rethrowKeyingVerificationError(error);
|
|
33
|
+
runtime.util.log?.(`Principal policy prefetch: ${reference.principalId}: ${errorMessage(error)}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
35
37
|
//# sourceMappingURL=runtimePolicyWarmer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimePolicyWarmer.js","sourceRoot":"","sources":["runtimePolicyWarmer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtimePolicyWarmer.js","sourceRoot":"","sources":["runtimePolicyWarmer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oCAAoC,EAAE,MAAM,+DAA+D,CAAC;AACrH,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC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AA8B,CAAC,KAAK,CAAC,CAAC;YACtC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAChB,8BAA8B,SAAS,CAAC,WAAW,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAC9E,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { errorMessage } from \"../../data/errorMessage\";\nimport { ProjectionDependencyUnavailableError } from \"../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport { rethrowKeyingVerificationError } from \"../../data/keyingProjectionVerification/error\";\nimport {\n assertProjectionVerificationCurrent,\n isProjectionVerificationCancelledError,\n type ReferencedPrincipalPolicyWarmer,\n} from \"../../data/keyingProjectionVerification/types\";\nimport {\n createRuntimePrincipalPolicyResolver,\n type PrincipalPolicyRecoveryRuntime,\n} from \"./runtimePolicyRecovery\";\nimport { createRuntimeProjectionPolicyResolver } from \"./runtimeProjectionPolicyRecovery\";\n\ntype PolicyResolver = NonNullable<\n ReferencedPrincipalPolicyWarmer[\"resolveReference\"]\n>;\ninterface PrincipalPolicyWarmRuntime extends PrincipalPolicyRecoveryRuntime {\n readonly util: PrincipalPolicyRecoveryRuntime[\"util\"] & {\n readonly log?: ((message: string) => void) | undefined;\n };\n}\n\n/** Prefetch is best-effort; exact resolution still rejects unavailable evidence. */\nexport function createRuntimePrincipalPolicyWarmer(\n runtime: PrincipalPolicyWarmRuntime,\n options: { readonly preferLocalCurrent?: boolean } = {},\n): ReferencedPrincipalPolicyWarmer {\n const resolve = createRuntimePrincipalPolicyResolver(runtime, options);\n const resolveReference: PolicyResolver = async (input) => {\n if (!resolve)\n throw new ProjectionDependencyUnavailableError(\n \"Principal policies require private paged recovery\",\n );\n return resolve(input);\n };\n return Object.assign(\n (input: Parameters<ReferencedPrincipalPolicyWarmer>[0]) =>\n prefetchReferences(runtime, resolveReference, input),\n {\n resolveReference,\n resolveProjectionHistory: createRuntimeProjectionPolicyResolver(runtime),\n },\n );\n}\n\nasync function prefetchReferences(\n runtime: PrincipalPolicyWarmRuntime,\n resolve: PolicyResolver,\n input: Parameters<ReferencedPrincipalPolicyWarmer>[0],\n): Promise<void> {\n const recoveryBatch = {};\n for (const reference of input.references) {\n try {\n assertProjectionVerificationCurrent(input.stillCurrent);\n const resolved = await resolve({ ...input, reference, recoveryBatch });\n assertProjectionVerificationCurrent(resolved.stillCurrent);\n } catch (error) {\n if (isProjectionVerificationCancelledError(error)) return;\n // Recovery already reports signature/authority failures. Keep them fatal.\n rethrowKeyingVerificationError(error);\n runtime.util.log?.(\n `Principal policy prefetch: ${reference.principalId}: ${errorMessage(error)}`,\n );\n }\n }\n}\n"]}
|