@voltro/protocol 0.86.0 → 0.87.0
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/CHANGELOG.md +5321 -0
- package/THIRD-PARTY-NOTICES.md +1130 -11
- package/dist/apiRoleEndpoints.js +108 -0
- package/dist/apiRoleObservation.js +68 -0
- package/dist/apikey.d.ts +10 -0
- package/dist/auth.js +39 -19
- package/dist/canonicalJson.js +14 -0
- package/dist/errorSchema.js +24 -0
- package/dist/event.js +51 -45
- package/dist/formCapture.js +12 -0
- package/dist/httpStreamMaxDuration.js +9 -0
- package/dist/idempotency.js +88 -33
- package/dist/idempotencyInput.js +123 -0
- package/dist/index.d.ts +876 -124
- package/dist/index.js +50 -38
- package/dist/inspect.d.ts +1 -1
- package/dist/jwt.d.ts +10 -0
- package/dist/jwt.js +1 -1
- package/dist/plugin.js +43 -17
- package/dist/pluginAccountMerge.js +88 -0
- package/dist/pluginPrivacy.js +166 -0
- package/dist/procedure.js +114 -96
- package/dist/publicApi.js +190 -209
- package/dist/queryOptionalSources.js +14 -0
- package/dist/rest.d.ts +227 -64
- package/dist/rest.js +295 -192
- package/dist/restReceipt.js +43 -0
- package/dist/revalidate.js +13 -0
- package/dist/scopes.js +71 -38
- package/dist/secretWindows.js +71 -0
- package/dist/session.d.ts +89 -6
- package/dist/session.js +55 -54
- package/dist/ssrfPolicy.js +30 -0
- package/dist/webSocketGateway.js +7 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,43 +1,55 @@
|
|
|
1
1
|
import { applyRowPatch as e, createRowPatchApplier as t, diffRows as n, idToPath as r, isIdKeyed as i, patchCellSchema as a, pathToId as o, rowPatchOpSchema as s, rowPatchSchema as c } from "./rowPatch.js";
|
|
2
2
|
import { firstEventValue as l, subscriptionEvent as u } from "./subscriptionEvent.js";
|
|
3
3
|
import { RequestedTenantRefused as d, TenantSelectionRefused as f, isTenantSelectable as p, selectSubjectTenant as m } from "./tenantSelection.js";
|
|
4
|
-
import { AuthMiddleware as h, ConnectionInfo as g, ConnectionInfoMiddleware as _, DEFAULT_SCOPE_CACHE_MAX_ENTRIES as v, DEFAULT_SCOPE_CACHE_TTL_MS as y, IMPERSONATION_METADATA_KEY as b, Subject as x, SubjectIdentity as S, SubjectService as C, Unauthenticated as w, anonymousSubject as T, applyScopeDecision as E, assertAuthenticated as D, bindSubjectAuthority as O, composeAuthStrategies as k, currentSubjectAuthority as A, hasCallbackRoutes as j, isMachineSubject as M, isServiceSubject as N, isSystemSubject as P, makeScopeCache as F, orderByBearerPrefix as I, rawImpersonationMark as L, reauthorizeSubject as R,
|
|
5
|
-
import { ADMIN_SCOPE as
|
|
6
|
-
import { inputLabel as
|
|
7
|
-
import { BusinessRuleViolation as
|
|
8
|
-
import { DEFAULT_IN_FLIGHT_LEASE_MS as
|
|
9
|
-
import { ValidationError as
|
|
10
|
-
import { ApprovalDecisionErrors as
|
|
11
|
-
import { REACTIVITY_CHANNEL_PREFIX as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
4
|
+
import { AuthMiddleware as h, ConnectionInfo as g, ConnectionInfoMiddleware as _, DEFAULT_SCOPE_CACHE_MAX_ENTRIES as v, DEFAULT_SCOPE_CACHE_TTL_MS as y, IMPERSONATION_METADATA_KEY as b, Subject as x, SubjectIdentity as S, SubjectService as C, Unauthenticated as w, anonymousSubject as T, applyScopeDecision as E, assertAuthenticated as D, bindSubjectAuthority as O, composeAuthStrategies as k, currentSubjectAuthority as A, hasCallbackRoutes as j, isMachineSubject as M, isServiceSubject as N, isSystemSubject as P, makeScopeCache as F, orderByBearerPrefix as I, rawImpersonationMark as L, reauthorizeSubject as R, resolveIdentityAuthority as z, scopeCacheKey as B, serviceSubject as V, subjectAuditActorId as H, subjectIdentity as U, systemSubject as W, tenantScopedSubject as G } from "./auth.js";
|
|
5
|
+
import { ADMIN_SCOPE as K, APIKEY_ISSUE_ORG_SCOPE as q, APIKEY_ISSUE_OTHER_SCOPE as J, APIKEY_ISSUE_SELF_SCOPE as Y, DEVICES_MANAGE_SCOPE as X, NoSuchResource as Z, ScopeError as Q, advisoryResourceGuardWarning as $, checkGuards as ee, checkGuardsEffect as te, declaresResourceGuard as ne, effectiveScopes as re, findAdvisoryResourceGuards as ie, getPolicyGuardResolver as ae, getResourceScopeResolver as oe, hasEffectiveScope as se, hasScope as ce, isAuthenticatedCheck as le, isOpenAccess as ue, isPolicyCheck as de, isServiceAccess as fe, isUpgradedCheck as pe, missingAccessDecision as me, openAccessSpec as he, recheckGuardsEffect as ge, refreshEffectiveScopes as _e, requireScope as ve, resolvePolicyAction as ye, serviceAccessSpec as be, serviceCallersOf as xe, setEffectiveScopes as Se, setEffectiveScopesRefresher as Ce, setPolicyGuardResolver as we, setResourceScopeResolver as Te, subjectScopes as Ee, upgradedGuardShapeError as De } from "./scopes.js";
|
|
6
|
+
import { inputLabel as Oe, strictInput as ke } from "./strictInput.js";
|
|
7
|
+
import { BusinessRuleViolation as Ae } from "./businessRule.js";
|
|
8
|
+
import { DEFAULT_IN_FLIGHT_LEASE_MS as je, MUTATION_IN_FLIGHT_RETRY_AFTER_MS as Me, MutationConnectionRequired as Ne, MutationIdempotencyRefused as Pe, MutationInFlight as Fe, beginIdempotent as Ie, failIdempotent as Le, finishIdempotent as Re, freshFor as ze, holdIdempotentClaim as Be, idempotencyScope as Ve, memoryIdempotencyStore as He, wsMutationIdempotencyScope as Ue } from "./idempotency.js";
|
|
9
|
+
import { ValidationError as We, ValidationErrors as Ge, ValidationIssue as Ke, fieldIssuesOf as qe } from "./validation.js";
|
|
10
|
+
import { ApprovalDecisionErrors as Je, ApprovalErrors as Ye, ApprovalExpired as Xe, ApprovalForbidden as Ze, ApprovalNotFound as Qe, ApprovalNotPending as $e, ApprovalRejected as et, ApprovalRequired as tt, ApprovalSelfApproval as nt, ApprovalUnavailable as rt, PendingApproval as it } from "./approval.js";
|
|
11
|
+
import { REACTIVITY_CHANNEL_PREFIX as at, declaredReactivityChannelKeys as ot, isReactivityChannel as st, isReactivityChannelKey as ct, normalizeSource as lt, publishReactivity as ut, reactivityChannel as dt, sourceKeys as ft, undeclaredChannelKeys as pt } from "./reactivityChannel.js";
|
|
12
|
+
import { captureOptionalQuerySources as mt } from "./queryOptionalSources.js";
|
|
13
|
+
import { FRAMEWORK_WIRE_ERRORS as ht, SERVICE_NAME_PATTERN as gt, actionToRpc as _t, defineAction as vt, defineMutation as yt, defineQuery as bt, defineStream as xt, hasAccessDecision as St, hasEnforcedGuard as Ct, isAuthenticatedGuard as wt, isClientReachable as Tt, isPolicyGuard as Et, isServiceReachable as Dt, isUpgradedGuard as Ot, isWireReachable as kt, mutationToRpc as At, normalizeDescriptor as jt, queryToRpc as Mt, requireUpgraded as Nt, streamToRpc as Pt, toRpc as Ft, wireAudienceOf as It, wireErrorUnion as Lt, withRpcTag as Rt, workflowWireErrorUnion as zt } from "./procedure.js";
|
|
14
|
+
import { errorMessage as Bt, errorTag as Vt, reportableError as Ht } from "./errorValue.js";
|
|
15
|
+
import { declaredErrorTags as Ut, errorMemberSchema as Wt } from "./errorSchema.js";
|
|
16
|
+
import { canonicalJson as Gt } from "./canonicalJson.js";
|
|
17
|
+
import { prepareIdempotentInput as Kt } from "./idempotencyInput.js";
|
|
18
|
+
import { EVENT_ROUTE_SEP as qt, EventKeyInvalid as Jt, EventPayloadInvalid as Yt, EventPayloadTooLarge as Xt, EventRpcWorkload as Zt, MAX_EVENT_ENVELOPE_BYTES as Qt, defineEvent as $t, encodeEventKey as en, eventAttached as tn, eventEnvelope as nn, eventGap as rn, eventResumePoint as an, eventRoute as on, eventStreamEvent as sn, eventSubscribeInput as cn, eventToRpc as ln, formatEventRoute as un, isEventDescriptor as dn, parseEventRoute as fn } from "./event.js";
|
|
19
|
+
import { DEV_ACTIVITY_EVENT as pn } from "./devActivity.js";
|
|
20
|
+
import { WorkflowAccessProperty as mn, attachWorkflowAccess as hn, getWorkflowAccess as gn, resolveWorkflowAccess as _n, workflowAccessDescriptor as vn } from "./workflowAccess.js";
|
|
21
|
+
import { compareSurfaces as yn, groupShapeDigests as bn, procedureShapeDigest as xn, schemaShape as Sn, shapeDigest as Cn } from "./schemaShape.js";
|
|
22
|
+
import { parseRevalidateMs as wn } from "./revalidate.js";
|
|
23
|
+
import { ApiUnavailable as Tn, isApiUnavailable as En } from "./serviceCall.js";
|
|
24
|
+
import { API_WORKLOADS as Dn, checkFrameworkCompat as On, composeReplayAuthorityBindings as kn, composeRpcInterceptors as An, definePlugin as jn, definePluginRoute as Mn, definePluginService as Nn, pluginInstanceName as Pn } from "./plugin.js";
|
|
25
|
+
import { PluginPrivacyErasePhaseSchema as Fn, PluginPrivacyFailure as In, createPluginPrivacyRegistry as Ln } from "./pluginPrivacy.js";
|
|
26
|
+
import { PluginAccountMergeFailure as Rn, createPluginAccountMergeRegistry as zn } from "./pluginAccountMerge.js";
|
|
27
|
+
import { validateHttpStreamMaxDuration as Bn } from "./httpStreamMaxDuration.js";
|
|
28
|
+
import { validateOutboxHandlerDefinition as Vn } from "./outbox.js";
|
|
29
|
+
import { pluginAlias as Hn, pluginSlug as Un, pluginTag as Wn, registerPluginAliases as Gn, resetPluginAliases as Kn } from "./pluginNaming.js";
|
|
30
|
+
import { publishServerError as qn, subscribeServerErrors as Jn, withheldServerError as Yn } from "./serverErrorBus.js";
|
|
31
|
+
import { WorkflowStartTerminalOutcomeSchema as Xn } from "./workflowStartOutcome.js";
|
|
32
|
+
import { WorkflowControlInputSchema as Zn, WorkflowControlIntentSchema as Qn, WorkflowControlReadInputSchema as $n, WorkflowControlResultSchema as er, WorkflowDomainEventRowSchema as tr, WorkflowDomainEventsInputSchema as nr, WorkflowEventDeliveriesInputSchema as rr, WorkflowEventDeliveryRowSchema as ir, WorkflowParentClosePolicySchema as ar, WorkflowQueuedCancelInputSchema as or, WorkflowQueuedCancellationResultSchema as sr, WorkflowQueuedControlTargetSchema as cr, WorkflowRunEventRowSchema as lr, WorkflowRunHandleSchema as ur, WorkflowRunRefSchema as dr, WorkflowRunRowSchema as fr, WorkflowRunSnapshotSchema as pr, WorkflowRunStatusSchema as mr, WorkflowRunStepRowSchema as hr, WorkflowRunTableRefSchema as gr, WorkflowRunsInputSchema as _r, WorkflowSignalInputSchema as vr, WorkflowStartDeferralSchema as yr, WorkflowUpdateInputSchema as br, WorkflowUpdateResultSchema as xr, workflowCancelDescriptor as Sr, workflowControlQueryDescriptor as Cr, workflowDomainEventsQueryDescriptor as wr, workflowEventDeliveriesQueryDescriptor as Tr, workflowQueuedCancelDescriptor as Er, workflowQueuedControlQueryDescriptor as Dr, workflowResumeDescriptor as Or, workflowRunEventsQueryDescriptor as kr, workflowRunQueryDescriptor as Ar, workflowRunStepsQueryDescriptor as jr, workflowRunsQueryDescriptor as Mr, workflowSignalDescriptor as Nr, workflowToRpc as Pr, workflowUpdateDescriptor as Fr } from "./workflow.js";
|
|
33
|
+
import { WorkflowRetryCommandSchema as Ir, WorkflowRetryObservationSchema as Lr, WorkflowRetryTargetSchema as Rr } from "./workflowRetry.js";
|
|
34
|
+
import { WorkflowRestartCommandSchema as zr, WorkflowRestartObservationSchema as Br, WorkflowRestartResultSchema as Vr, WorkflowRestartSelectionSchema as Hr, WorkflowRestartTargetSchema as Ur } from "./workflowRestart.js";
|
|
35
|
+
import { UNDO_APPLY_TAG as Wr, UNDO_LOG_TAG as Gr, UNDO_REDO_TAG as Kr, UndoConflict as qr, UndoForbidden as Jr, UndoLogEntry as Yr, UndoNotFound as Xr, undoApplyDescriptor as Zr, undoLogQueryDescriptor as Qr, undoRedoDescriptor as $r } from "./undo.js";
|
|
36
|
+
import { ssrfReason as ei } from "./ssrfPolicy.js";
|
|
37
|
+
import { ConstraintViolation as ti, NoRowFound as ni, ServerOnlyColumnWrite as ri, StoreOperationFailed as ii, TableValidationFailed as ai, TenantRowNotFound as oi, TenantScopeViolation as si } from "./storeErrors.js";
|
|
38
|
+
import { APPROVALS_DECIDE_TAG as ci, APPROVALS_PENDING_TAG as li, approvalsDecideDescriptor as ui, approvalsPendingQueryDescriptor as di } from "./approvalDescriptors.js";
|
|
39
|
+
import { CONNECTIONS_LIST_TAG as fi, CONNECTION_DISCONNECT_TAG as pi, CONNECTION_START_TAG as mi, CONNECTION_SUBMIT_TOKEN_TAG as hi, ConnectionHandshakeFailed as gi, ConnectionKind as _i, ConnectionKindMismatch as vi, ConnectionNotDeclared as yi, ConnectionState as bi, ConnectionStatus as xi, ConnectionSubjectRequired as Si, connectionDisconnectDescriptor as Ci, connectionStartDescriptor as wi, connectionSubmitTokenDescriptor as Ti, connectionsListQueryDescriptor as Ei } from "./connection.js";
|
|
40
|
+
import { tsMs as Di } from "./time.js";
|
|
41
|
+
import { STORE_SCREENSHOT_PRESETS as Oi, STORE_SCREENSHOT_PRESET_NAMES as ki, STORE_SCREENSHOT_STORES as Ai, storeScreenshotPixels as ji, storeScreenshotPreset as Mi, storeScreenshotPresetsFor as Ni } from "./storeScreenshots.js";
|
|
42
|
+
import { GATEWAY_CREDENTIAL_EXPIRED_CLOSE_CODE as Pi, defineWebSocket as Fi } from "./webSocketGateway.js";
|
|
43
|
+
import { SESSION_HEADER_NAME as Ii, sessionValueFromHeaders as Li } from "./sessionHeader.js";
|
|
44
|
+
import { JSONAPI_MEDIA_TYPE as Ri, PROBLEM_JSON as zi, REST_PROFILE_NAMES as Bi, encodeRestError as Vi, encodeRestSuccess as Hi, nextLink as Ui, problemDetails as Wi, problemTypeOf as Gi, resolveRestFormat as Ki, restViewSchema as qi, toSnakeCase as Ji } from "./restFormat.js";
|
|
45
|
+
import { finiteNumberView as Yi, jsonSchemaDocumentOf as Xi, jsonSchemaOf as Zi, plainJsonSchema as Qi } from "./jsonSchema.js";
|
|
46
|
+
import { PAIRING_HOST as $i, PAIRING_SCHEME as ea, PAIRING_STORAGE_KEY as ta, applyPairing as na, clearPairing as ra, pairingLink as ia, parsePairingLink as aa, readPairing as oa } from "./pairing.js";
|
|
47
|
+
import { apiRoleEndpointUrl as sa, apiRoleProxyBasePath as ca, captureApiRoleEndpoints as la, selectApiRoleEndpoint as ua } from "./apiRoleEndpoints.js";
|
|
48
|
+
import { ApiRoleObservationSchema as da } from "./apiRoleObservation.js";
|
|
49
|
+
import { StorageAccessPolicySchema as fa, StorageAccessRuleSchema as pa } from "./storageAccess.js";
|
|
50
|
+
import { BoundedRing as ma } from "./boundedRing.js";
|
|
51
|
+
import { FORM_CAPTURE_FIELD as ha, FORM_CAPTURE_META_NAME as ga, encodeNativeFormCapture as _a, formCaptureSource as va, readFormCaptureSource as ya } from "./formCapture.js";
|
|
40
52
|
//#region src/index.ts
|
|
41
|
-
var
|
|
53
|
+
var ba = 2;
|
|
42
54
|
//#endregion
|
|
43
|
-
export {
|
|
55
|
+
export { K as ADMIN_SCOPE, q as APIKEY_ISSUE_ORG_SCOPE, J as APIKEY_ISSUE_OTHER_SCOPE, Y as APIKEY_ISSUE_SELF_SCOPE, Dn as API_WORKLOADS, ci as APPROVALS_DECIDE_TAG, li as APPROVALS_PENDING_TAG, da as ApiRoleObservationSchema, Tn as ApiUnavailable, Je as ApprovalDecisionErrors, Ye as ApprovalErrors, Xe as ApprovalExpired, Ze as ApprovalForbidden, Qe as ApprovalNotFound, $e as ApprovalNotPending, et as ApprovalRejected, tt as ApprovalRequired, nt as ApprovalSelfApproval, rt as ApprovalUnavailable, h as AuthMiddleware, ma as BoundedRing, Ae as BusinessRuleViolation, fi as CONNECTIONS_LIST_TAG, pi as CONNECTION_DISCONNECT_TAG, mi as CONNECTION_START_TAG, hi as CONNECTION_SUBMIT_TOKEN_TAG, gi as ConnectionHandshakeFailed, g as ConnectionInfo, _ as ConnectionInfoMiddleware, _i as ConnectionKind, vi as ConnectionKindMismatch, yi as ConnectionNotDeclared, bi as ConnectionState, xi as ConnectionStatus, Si as ConnectionSubjectRequired, ti as ConstraintViolation, je as DEFAULT_IN_FLIGHT_LEASE_MS, v as DEFAULT_SCOPE_CACHE_MAX_ENTRIES, y as DEFAULT_SCOPE_CACHE_TTL_MS, X as DEVICES_MANAGE_SCOPE, pn as DEV_ACTIVITY_EVENT, qt as EVENT_ROUTE_SEP, Jt as EventKeyInvalid, Yt as EventPayloadInvalid, Xt as EventPayloadTooLarge, Zt as EventRpcWorkload, ha as FORM_CAPTURE_FIELD, ga as FORM_CAPTURE_META_NAME, ht as FRAMEWORK_WIRE_ERRORS, Pi as GATEWAY_CREDENTIAL_EXPIRED_CLOSE_CODE, b as IMPERSONATION_METADATA_KEY, Ri as JSONAPI_MEDIA_TYPE, Qt as MAX_EVENT_ENVELOPE_BYTES, Me as MUTATION_IN_FLIGHT_RETRY_AFTER_MS, Ne as MutationConnectionRequired, Pe as MutationIdempotencyRefused, Fe as MutationInFlight, ni as NoRowFound, Z as NoSuchResource, $i as PAIRING_HOST, ea as PAIRING_SCHEME, ta as PAIRING_STORAGE_KEY, zi as PROBLEM_JSON, ba as PROTOCOL_VERSION, it as PendingApproval, Rn as PluginAccountMergeFailure, Fn as PluginPrivacyErasePhaseSchema, In as PluginPrivacyFailure, at as REACTIVITY_CHANNEL_PREFIX, Bi as REST_PROFILE_NAMES, d as RequestedTenantRefused, gt as SERVICE_NAME_PATTERN, Ii as SESSION_HEADER_NAME, Oi as STORE_SCREENSHOT_PRESETS, ki as STORE_SCREENSHOT_PRESET_NAMES, Ai as STORE_SCREENSHOT_STORES, Q as ScopeError, ri as ServerOnlyColumnWrite, fa as StorageAccessPolicySchema, pa as StorageAccessRuleSchema, ii as StoreOperationFailed, x as Subject, S as SubjectIdentity, C as SubjectService, ai as TableValidationFailed, oi as TenantRowNotFound, si as TenantScopeViolation, f as TenantSelectionRefused, Wr as UNDO_APPLY_TAG, Gr as UNDO_LOG_TAG, Kr as UNDO_REDO_TAG, w as Unauthenticated, qr as UndoConflict, Jr as UndoForbidden, Yr as UndoLogEntry, Xr as UndoNotFound, We as ValidationError, Ge as ValidationErrors, Ke as ValidationIssue, mn as WorkflowAccessProperty, Zn as WorkflowControlInputSchema, Qn as WorkflowControlIntentSchema, $n as WorkflowControlReadInputSchema, er as WorkflowControlResultSchema, tr as WorkflowDomainEventRowSchema, nr as WorkflowDomainEventsInputSchema, rr as WorkflowEventDeliveriesInputSchema, ir as WorkflowEventDeliveryRowSchema, ar as WorkflowParentClosePolicySchema, or as WorkflowQueuedCancelInputSchema, sr as WorkflowQueuedCancellationResultSchema, cr as WorkflowQueuedControlTargetSchema, zr as WorkflowRestartCommandSchema, Br as WorkflowRestartObservationSchema, Vr as WorkflowRestartResultSchema, Hr as WorkflowRestartSelectionSchema, Ur as WorkflowRestartTargetSchema, Ir as WorkflowRetryCommandSchema, Lr as WorkflowRetryObservationSchema, Rr as WorkflowRetryTargetSchema, lr as WorkflowRunEventRowSchema, ur as WorkflowRunHandleSchema, dr as WorkflowRunRefSchema, fr as WorkflowRunRowSchema, pr as WorkflowRunSnapshotSchema, mr as WorkflowRunStatusSchema, hr as WorkflowRunStepRowSchema, gr as WorkflowRunTableRefSchema, _r as WorkflowRunsInputSchema, vr as WorkflowSignalInputSchema, yr as WorkflowStartDeferralSchema, Xn as WorkflowStartTerminalOutcomeSchema, br as WorkflowUpdateInputSchema, xr as WorkflowUpdateResultSchema, _t as actionToRpc, $ as advisoryResourceGuardWarning, T as anonymousSubject, sa as apiRoleEndpointUrl, ca as apiRoleProxyBasePath, na as applyPairing, e as applyRowPatch, E as applyScopeDecision, ui as approvalsDecideDescriptor, di as approvalsPendingQueryDescriptor, D as assertAuthenticated, hn as attachWorkflowAccess, Ie as beginIdempotent, O as bindSubjectAuthority, Gt as canonicalJson, la as captureApiRoleEndpoints, mt as captureOptionalQuerySources, On as checkFrameworkCompat, ee as checkGuards, te as checkGuardsEffect, ra as clearPairing, yn as compareSurfaces, k as composeAuthStrategies, kn as composeReplayAuthorityBindings, An as composeRpcInterceptors, Ci as connectionDisconnectDescriptor, wi as connectionStartDescriptor, Ti as connectionSubmitTokenDescriptor, Ei as connectionsListQueryDescriptor, zn as createPluginAccountMergeRegistry, Ln as createPluginPrivacyRegistry, t as createRowPatchApplier, A as currentSubjectAuthority, Ut as declaredErrorTags, ot as declaredReactivityChannelKeys, ne as declaresResourceGuard, vt as defineAction, $t as defineEvent, yt as defineMutation, jn as definePlugin, Mn as definePluginRoute, Nn as definePluginService, bt as defineQuery, xt as defineStream, Fi as defineWebSocket, n as diffRows, re as effectiveScopes, en as encodeEventKey, _a as encodeNativeFormCapture, Vi as encodeRestError, Hi as encodeRestSuccess, Wt as errorMemberSchema, Bt as errorMessage, Vt as errorTag, tn as eventAttached, nn as eventEnvelope, rn as eventGap, an as eventResumePoint, on as eventRoute, sn as eventStreamEvent, cn as eventSubscribeInput, ln as eventToRpc, Le as failIdempotent, qe as fieldIssuesOf, ie as findAdvisoryResourceGuards, Re as finishIdempotent, Yi as finiteNumberView, l as firstEventValue, va as formCaptureSource, un as formatEventRoute, ze as freshFor, ae as getPolicyGuardResolver, oe as getResourceScopeResolver, gn as getWorkflowAccess, bn as groupShapeDigests, St as hasAccessDecision, j as hasCallbackRoutes, se as hasEffectiveScope, Ct as hasEnforcedGuard, ce as hasScope, Be as holdIdempotentClaim, r as idToPath, Ve as idempotencyScope, Oe as inputLabel, En as isApiUnavailable, le as isAuthenticatedCheck, wt as isAuthenticatedGuard, Tt as isClientReachable, dn as isEventDescriptor, i as isIdKeyed, M as isMachineSubject, ue as isOpenAccess, de as isPolicyCheck, Et as isPolicyGuard, st as isReactivityChannel, ct as isReactivityChannelKey, fe as isServiceAccess, Dt as isServiceReachable, N as isServiceSubject, P as isSystemSubject, p as isTenantSelectable, pe as isUpgradedCheck, Ot as isUpgradedGuard, kt as isWireReachable, Xi as jsonSchemaDocumentOf, Zi as jsonSchemaOf, F as makeScopeCache, He as memoryIdempotencyStore, me as missingAccessDecision, At as mutationToRpc, Ui as nextLink, jt as normalizeDescriptor, lt as normalizeSource, he as openAccessSpec, I as orderByBearerPrefix, ia as pairingLink, fn as parseEventRoute, aa as parsePairingLink, wn as parseRevalidateMs, a as patchCellSchema, o as pathToId, Qi as plainJsonSchema, Hn as pluginAlias, Pn as pluginInstanceName, Un as pluginSlug, Wn as pluginTag, Kt as prepareIdempotentInput, Wi as problemDetails, Gi as problemTypeOf, xn as procedureShapeDigest, ut as publishReactivity, qn as publishServerError, Mt as queryToRpc, L as rawImpersonationMark, dt as reactivityChannel, ya as readFormCaptureSource, oa as readPairing, R as reauthorizeSubject, ge as recheckGuardsEffect, _e as refreshEffectiveScopes, Gn as registerPluginAliases, Ht as reportableError, ve as requireScope, Nt as requireUpgraded, Kn as resetPluginAliases, z as resolveIdentityAuthority, ye as resolvePolicyAction, Ki as resolveRestFormat, _n as resolveWorkflowAccess, qi as restViewSchema, s as rowPatchOpSchema, c as rowPatchSchema, Sn as schemaShape, B as scopeCacheKey, ua as selectApiRoleEndpoint, m as selectSubjectTenant, be as serviceAccessSpec, xe as serviceCallersOf, V as serviceSubject, Li as sessionValueFromHeaders, Se as setEffectiveScopes, Ce as setEffectiveScopesRefresher, we as setPolicyGuardResolver, Te as setResourceScopeResolver, Cn as shapeDigest, ft as sourceKeys, ei as ssrfReason, ji as storeScreenshotPixels, Mi as storeScreenshotPreset, Ni as storeScreenshotPresetsFor, Pt as streamToRpc, ke as strictInput, H as subjectAuditActorId, U as subjectIdentity, Ee as subjectScopes, Jn as subscribeServerErrors, u as subscriptionEvent, W as systemSubject, G as tenantScopedSubject, Ft as toRpc, Ji as toSnakeCase, Di as tsMs, pt as undeclaredChannelKeys, Zr as undoApplyDescriptor, Qr as undoLogQueryDescriptor, $r as undoRedoDescriptor, De as upgradedGuardShapeError, Bn as validateHttpStreamMaxDuration, Vn as validateOutboxHandlerDefinition, It as wireAudienceOf, Lt as wireErrorUnion, Rt as withRpcTag, Yn as withheldServerError, vn as workflowAccessDescriptor, Sr as workflowCancelDescriptor, Cr as workflowControlQueryDescriptor, wr as workflowDomainEventsQueryDescriptor, Tr as workflowEventDeliveriesQueryDescriptor, Er as workflowQueuedCancelDescriptor, Dr as workflowQueuedControlQueryDescriptor, Or as workflowResumeDescriptor, kr as workflowRunEventsQueryDescriptor, Ar as workflowRunQueryDescriptor, jr as workflowRunStepsQueryDescriptor, Mr as workflowRunsQueryDescriptor, Nr as workflowSignalDescriptor, Pr as workflowToRpc, Fr as workflowUpdateDescriptor, zt as workflowWireErrorUnion, Ue as wsMutationIdempotencyScope };
|
package/dist/inspect.d.ts
CHANGED
|
@@ -162,7 +162,7 @@ export declare class InvalidReplicaSelection extends Error {
|
|
|
162
162
|
|
|
163
163
|
export declare const isInspectCommandRejection: <I>(input: I) => input is I & {
|
|
164
164
|
readonly kind: "rejected";
|
|
165
|
-
readonly status: 400 |
|
|
165
|
+
readonly status: 400 | 404 | 401 | 403;
|
|
166
166
|
readonly message: string;
|
|
167
167
|
};
|
|
168
168
|
|
package/dist/jwt.d.ts
CHANGED
|
@@ -48,6 +48,13 @@ declare interface AuthStrategy {
|
|
|
48
48
|
declare interface AuthStrategyInput {
|
|
49
49
|
readonly headers: Readonly<Record<string, string | undefined>>;
|
|
50
50
|
readonly clientId: number;
|
|
51
|
+
/** HTTP request target, supplied by REST transports. Request selectors may
|
|
52
|
+
* read an explicit tenant hint here; it is never authentication or authority.
|
|
53
|
+
* Absent for connection transports and non-HTTP callers. */
|
|
54
|
+
readonly http?: {
|
|
55
|
+
readonly path: string;
|
|
56
|
+
readonly query: string;
|
|
57
|
+
};
|
|
51
58
|
/**
|
|
52
59
|
* The app's DataStore, for a strategy that must READ to identify the caller.
|
|
53
60
|
*
|
|
@@ -291,6 +298,9 @@ declare type StrategyResolution = {
|
|
|
291
298
|
|
|
292
299
|
declare const Subject: Schema.Union<readonly [Schema.Struct<{
|
|
293
300
|
readonly type: Schema.Literal<"user">;
|
|
301
|
+
/** A guest has a stable identity but has not linked a registered account.
|
|
302
|
+
* This identity mark survives session signing; it never grants authority. */
|
|
303
|
+
readonly kind: Schema.optional<Schema.Literal<"guest">>;
|
|
294
304
|
readonly id: Schema.String;
|
|
295
305
|
readonly tenantId: Schema.String;
|
|
296
306
|
readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
|
package/dist/jwt.js
CHANGED
|
@@ -77,7 +77,7 @@ var i = 36e5, a = /* @__PURE__ */ new Map(), o = (e, n) => {
|
|
|
77
77
|
if (e instanceof n.JWSInvalid || e instanceof n.JWTInvalid) return new c("malformed jwt", "malformed");
|
|
78
78
|
if (e instanceof n.JOSEAlgNotAllowed) return new c("jwt algorithm not allowed", "unsupported_algorithm");
|
|
79
79
|
let t = e?.message ?? String(e);
|
|
80
|
-
return /fetch|network|enotfound|econnrefused/i.test(t) ? new c(`jwks unreachable: ${t}`, "jwks_unreachable") : new c(`jwt verify failed: ${t}`, "other");
|
|
80
|
+
return e instanceof n.JWKSTimeout || /fetch|network|enotfound|econnrefused|JSON Web Key Set/i.test(t) ? new c(`jwks unreachable: ${t}`, "jwks_unreachable") : new c(`jwt verify failed: ${t}`, "other");
|
|
81
81
|
}, v = (t, n, r) => {
|
|
82
82
|
let i = t.authorization ?? t.Authorization;
|
|
83
83
|
if (i?.startsWith("Bearer ")) {
|
package/dist/plugin.js
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { Context as e, Layer as t } from "effect";
|
|
2
2
|
//#region src/plugin.ts
|
|
3
|
-
var n = (
|
|
3
|
+
var n = Object.freeze([
|
|
4
|
+
"rpc",
|
|
5
|
+
"subscriptions",
|
|
6
|
+
"events",
|
|
7
|
+
"presence",
|
|
8
|
+
"workflows",
|
|
9
|
+
"schedules",
|
|
10
|
+
"directors",
|
|
11
|
+
"drainers",
|
|
12
|
+
"reapers",
|
|
13
|
+
"retention",
|
|
14
|
+
"rest",
|
|
15
|
+
"webhooks",
|
|
16
|
+
"inspect",
|
|
17
|
+
"cdc"
|
|
18
|
+
]), r = (e) => e, i = (e) => e, a = (e) => {
|
|
4
19
|
let t = e.alias?.trim(), n = e.instance?.trim(), r = t !== void 0 && t !== "" ? t : e.base;
|
|
5
20
|
return n !== void 0 && n !== "" ? `${r}#${n}` : r;
|
|
6
|
-
},
|
|
21
|
+
}, o = (e) => {
|
|
7
22
|
if (e.length !== 0) return (t, n) => e.reduceRight((e, t) => t(e, n), t);
|
|
8
|
-
},
|
|
23
|
+
}, s = (n, r) => {
|
|
9
24
|
let i = e.Service(n);
|
|
10
25
|
return {
|
|
11
26
|
Tag: i,
|
|
12
27
|
Live: t.succeed(i, r)
|
|
13
28
|
};
|
|
14
|
-
},
|
|
29
|
+
}, c = (e, t, n) => {
|
|
15
30
|
if (!t) return { ok: !0 };
|
|
16
|
-
let r = n === void 0 ? null :
|
|
31
|
+
let r = n === void 0 ? null : l(n);
|
|
17
32
|
if (!r) return {
|
|
18
33
|
ok: !0,
|
|
19
34
|
unverified: `plugin "${e}" requires framework ${t}, but the running framework version is ${n === void 0 ? "unknown" : `unreadable ("${n}")`} — not checked.`
|
|
@@ -21,12 +36,12 @@ var n = (e) => e, r = (e) => e, i = (e) => {
|
|
|
21
36
|
let i = t.trim();
|
|
22
37
|
if (i === "*" || i === "") return { ok: !0 };
|
|
23
38
|
let a = i.split(/\s+/);
|
|
24
|
-
for (let i of a) if (!
|
|
39
|
+
for (let i of a) if (!d(i, r)) return {
|
|
25
40
|
ok: !1,
|
|
26
41
|
reason: `plugin "${e}" requires framework ${t}, running ${n}`
|
|
27
42
|
};
|
|
28
43
|
return { ok: !0 };
|
|
29
|
-
},
|
|
44
|
+
}, l = (e) => {
|
|
30
45
|
let t = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9a-zA-Z.-]+))?$/.exec(e.trim());
|
|
31
46
|
return t ? {
|
|
32
47
|
major: Number(t[1]),
|
|
@@ -34,28 +49,39 @@ var n = (e) => e, r = (e) => e, i = (e) => {
|
|
|
34
49
|
patch: Number(t[3]),
|
|
35
50
|
pre: t[4] ?? ""
|
|
36
51
|
} : null;
|
|
37
|
-
},
|
|
52
|
+
}, u = (e, t) => e.major === t.major ? e.minor === t.minor ? e.patch === t.patch ? e.pre && !t.pre ? -1 : !e.pre && t.pre ? 1 : e.pre && t.pre ? e.pre < t.pre ? -1 : +(e.pre > t.pre) : 0 : e.patch - t.patch : e.minor - t.minor : e.major - t.major, d = (e, t) => {
|
|
38
53
|
if (e === "*") return !0;
|
|
39
54
|
if (e.startsWith("^")) {
|
|
40
|
-
let n =
|
|
41
|
-
return !n || t.major !== n.major ? !1 :
|
|
55
|
+
let n = l(e.slice(1));
|
|
56
|
+
return !n || t.major !== n.major ? !1 : u(t, n) >= 0;
|
|
42
57
|
}
|
|
43
58
|
if (e.startsWith("~")) {
|
|
44
|
-
let n =
|
|
45
|
-
return !n || t.major !== n.major || t.minor !== n.minor ? !1 :
|
|
59
|
+
let n = l(e.slice(1));
|
|
60
|
+
return !n || t.major !== n.major || t.minor !== n.minor ? !1 : u(t, n) >= 0;
|
|
46
61
|
}
|
|
47
62
|
let n = /^(>=|<=|>|<)(.+)$/.exec(e);
|
|
48
63
|
if (n) {
|
|
49
|
-
let e = n[1], r =
|
|
64
|
+
let e = n[1], r = l(n[2]);
|
|
50
65
|
if (!r) return !1;
|
|
51
|
-
let i =
|
|
66
|
+
let i = u(t, r);
|
|
52
67
|
if (e === ">=") return i >= 0;
|
|
53
68
|
if (e === "<=") return i <= 0;
|
|
54
69
|
if (e === ">") return i > 0;
|
|
55
70
|
if (e === "<") return i < 0;
|
|
56
71
|
}
|
|
57
|
-
let r =
|
|
58
|
-
return r ?
|
|
72
|
+
let r = l(e);
|
|
73
|
+
return r ? u(t, r) === 0 : !1;
|
|
74
|
+
}, f = (e) => {
|
|
75
|
+
let t = e.flatMap((e) => e.bindReplayAuthority === void 0 ? [] : [e.bindReplayAuthority]);
|
|
76
|
+
if (t.length !== 0) {
|
|
77
|
+
if (t.some((e) => typeof e != "function")) throw Error("Invalid replay authority binding");
|
|
78
|
+
return (e) => {
|
|
79
|
+
for (let n of t) {
|
|
80
|
+
let t = n(e);
|
|
81
|
+
if (t !== void 0) throw t instanceof Promise && t.catch(() => void 0), Error("Replay authority bindings must complete synchronously");
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
59
85
|
};
|
|
60
86
|
//#endregion
|
|
61
|
-
export {
|
|
87
|
+
export { n as API_WORKLOADS, c as checkFrameworkCompat, f as composeReplayAuthorityBindings, o as composeRpcInterceptors, r as definePlugin, i as definePluginRoute, s as definePluginService, a as pluginInstanceName };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Effect as e, Schema as t } from "effect";
|
|
2
|
+
//#region src/pluginAccountMerge.ts
|
|
3
|
+
var n = class extends t.TaggedError()("PluginAccountMergeFailure", {
|
|
4
|
+
code: t.Literals([
|
|
5
|
+
"invalid_request",
|
|
6
|
+
"coverage_missing",
|
|
7
|
+
"hook_failed"
|
|
8
|
+
]),
|
|
9
|
+
requestId: t.String,
|
|
10
|
+
plugin: t.NullOr(t.String),
|
|
11
|
+
returned: t.Array(t.String),
|
|
12
|
+
missing: t.Array(t.String)
|
|
13
|
+
}) {}, r = (e) => typeof e == "object" && e && "tableName" in e && typeof e.tableName == "string" ? e.tableName : void 0, i = (t) => {
|
|
14
|
+
let i = /* @__PURE__ */ new Set(), a = t.map((e) => {
|
|
15
|
+
if (i.has(e.name)) throw Error("Duplicate account merge plugin instance: " + e.name);
|
|
16
|
+
i.add(e.name);
|
|
17
|
+
let t = e.subjectMerge;
|
|
18
|
+
if ((t !== void 0 || e.onMergeAccounts !== void 0) && (t === void 0 || e.onMergeAccounts === void 0 || t.kinds.length === 0 || t.kinds.some((e) => e !== "user" && e !== "guest") || new Set(t.kinds).size !== t.kinds.length || t.tables.some((e) => typeof e != "string" || !e.trim()) || new Set(t.tables).size !== t.tables.length)) throw Error("Account merge requires a valid declaration and hook: " + e.name);
|
|
19
|
+
return {
|
|
20
|
+
name: e.name,
|
|
21
|
+
tables: (e.extendSchema?.tables ?? []).map(r),
|
|
22
|
+
declaration: t === void 0 ? void 0 : {
|
|
23
|
+
tables: [...t.tables],
|
|
24
|
+
kinds: [...t.kinds]
|
|
25
|
+
},
|
|
26
|
+
hook: e.onMergeAccounts
|
|
27
|
+
};
|
|
28
|
+
}), o = (e) => {
|
|
29
|
+
let t = [], n = [];
|
|
30
|
+
for (let r of a) if (r.declaration?.kinds.includes(e) && r.hook) {
|
|
31
|
+
t.push({
|
|
32
|
+
name: r.name,
|
|
33
|
+
tables: Object.freeze([...r.declaration.tables])
|
|
34
|
+
});
|
|
35
|
+
for (let e of r.tables) (e === void 0 || !r.declaration.tables.includes(e)) && n.push(r.name);
|
|
36
|
+
} else (r.tables.length > 0 || r.declaration !== void 0) && n.push(r.name);
|
|
37
|
+
return {
|
|
38
|
+
participants: Object.freeze(t),
|
|
39
|
+
missing: Object.freeze([...new Set(n)])
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
coverage: o,
|
|
44
|
+
mergeInTransaction: (t) => e.gen(function* () {
|
|
45
|
+
if (![
|
|
46
|
+
t.requestId,
|
|
47
|
+
t.tenantId,
|
|
48
|
+
t.sourceId,
|
|
49
|
+
t.targetId
|
|
50
|
+
].every((e) => typeof e == "string" && e.trim().length > 0 && e.length <= 256) || t.sourceKind !== "user" && t.sourceKind !== "guest" || t.sourceId === t.targetId || t.store === void 0) return yield* e.fail(new n({
|
|
51
|
+
code: "invalid_request",
|
|
52
|
+
requestId: typeof t.requestId == "string" ? t.requestId.slice(0, 256) : "",
|
|
53
|
+
plugin: null,
|
|
54
|
+
returned: [],
|
|
55
|
+
missing: []
|
|
56
|
+
}));
|
|
57
|
+
let r = o(t.sourceKind);
|
|
58
|
+
if (r.missing.length > 0) return yield* e.fail(new n({
|
|
59
|
+
code: "coverage_missing",
|
|
60
|
+
requestId: t.requestId,
|
|
61
|
+
plugin: null,
|
|
62
|
+
returned: [],
|
|
63
|
+
missing: [...r.missing]
|
|
64
|
+
}));
|
|
65
|
+
let i = [], s = Object.freeze({
|
|
66
|
+
requestId: t.requestId,
|
|
67
|
+
tenantId: t.tenantId,
|
|
68
|
+
sourceId: t.sourceId,
|
|
69
|
+
sourceKind: t.sourceKind,
|
|
70
|
+
targetId: t.targetId,
|
|
71
|
+
store: t.store
|
|
72
|
+
});
|
|
73
|
+
for (let t of r.participants) {
|
|
74
|
+
let r = a.find((e) => e.name === t.name);
|
|
75
|
+
yield* e.suspend(() => r.hook(s)).pipe(e.catchCause(() => e.fail(new n({
|
|
76
|
+
code: "hook_failed",
|
|
77
|
+
requestId: s.requestId,
|
|
78
|
+
plugin: t.name,
|
|
79
|
+
returned: [...i],
|
|
80
|
+
missing: []
|
|
81
|
+
})))), i.push(t.name);
|
|
82
|
+
}
|
|
83
|
+
return Object.freeze(i);
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { n as PluginAccountMergeFailure, i as createPluginAccountMergeRegistry };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Effect as e, Schema as t } from "effect";
|
|
2
|
+
//#region src/pluginPrivacy.ts
|
|
3
|
+
var n = t.Literals([
|
|
4
|
+
"prepare",
|
|
5
|
+
"data",
|
|
6
|
+
"identity",
|
|
7
|
+
"finalize"
|
|
8
|
+
]), r = class extends t.TaggedError()("PluginPrivacyFailure", {
|
|
9
|
+
code: t.Literals([
|
|
10
|
+
"invalid_request",
|
|
11
|
+
"coverage_missing",
|
|
12
|
+
"hook_failed",
|
|
13
|
+
"unavailable"
|
|
14
|
+
]),
|
|
15
|
+
operation: t.Literals(["export", "erase"]),
|
|
16
|
+
requestId: t.String,
|
|
17
|
+
plugin: t.NullOr(t.String),
|
|
18
|
+
completed: t.Array(t.String),
|
|
19
|
+
missing: t.Array(t.String)
|
|
20
|
+
}) {}, i = (e) => typeof e == "object" && e && "tableName" in e && typeof e.tableName == "string" ? e.tableName : void 0, a = (e) => {
|
|
21
|
+
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
22
|
+
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return;
|
|
23
|
+
if (typeof e != "object" || !e || t.has(e)) throw Error("Invalid privacy JSON");
|
|
24
|
+
let r = Array.isArray(e), i = Object.getPrototypeOf(e);
|
|
25
|
+
if (r && i !== Array.prototype || !r && i !== Object.prototype && i !== null || Object.getOwnPropertySymbols(e).length !== 0) throw Error("Invalid privacy JSON");
|
|
26
|
+
t.add(e);
|
|
27
|
+
let a = Object.getOwnPropertyDescriptors(e);
|
|
28
|
+
if (r) {
|
|
29
|
+
let e = a.length?.value;
|
|
30
|
+
if (typeof e != "number" || Object.keys(a).length !== e + 1) throw Error("Invalid privacy JSON");
|
|
31
|
+
for (let t = 0; t < e; t++) {
|
|
32
|
+
let e = a[t];
|
|
33
|
+
if (!e || !e.enumerable || !("value" in e)) throw Error("Invalid privacy JSON");
|
|
34
|
+
n(e.value);
|
|
35
|
+
}
|
|
36
|
+
} else for (let e of Object.values(a)) {
|
|
37
|
+
if (!e.enumerable || !("value" in e)) throw Error("Invalid privacy JSON");
|
|
38
|
+
n(e.value);
|
|
39
|
+
}
|
|
40
|
+
t.delete(e);
|
|
41
|
+
};
|
|
42
|
+
return n(e), JSON.parse(JSON.stringify(e));
|
|
43
|
+
}, o = (o) => {
|
|
44
|
+
let s = /* @__PURE__ */ new Set(), c = o.map((e) => {
|
|
45
|
+
if (s.has(e.name)) throw Error(`Duplicate privacy plugin instance: ${e.name}`);
|
|
46
|
+
s.add(e.name);
|
|
47
|
+
let r = e.subjectPrivacy, a = [...e.extendSchema?.tables ?? []].map(i);
|
|
48
|
+
if (r !== void 0 || e.onErase !== void 0 || e.onExport !== void 0) {
|
|
49
|
+
if (r === void 0 || e.onErase === void 0 || e.onExport === void 0) throw Error(`Subject privacy requires a declaration and both hooks: ${e.name}`);
|
|
50
|
+
if (r.kinds.length === 0 || r.kinds.some((e) => e !== "user" && e !== "guest") || new Set(r.kinds).size !== r.kinds.length || r.tables.some((e) => typeof e != "string" || !e.trim()) || new Set(r.tables).size !== r.tables.length || r.erasePhase !== void 0 && !t.is(n)(r.erasePhase)) throw Error(`Invalid subject privacy declaration: ${e.name}`);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
name: e.name,
|
|
54
|
+
tables: a,
|
|
55
|
+
declaration: r === void 0 ? void 0 : {
|
|
56
|
+
tables: [...r.tables],
|
|
57
|
+
kinds: [...r.kinds],
|
|
58
|
+
erasePhase: r.erasePhase ?? "data"
|
|
59
|
+
},
|
|
60
|
+
onErase: e.onErase,
|
|
61
|
+
onExport: e.onExport
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
for (let e of ["user", "guest"]) if (c.filter((t) => t.declaration?.erasePhase === "finalize" && t.declaration.kinds.includes(e)).length > 1) throw Error(`Subject privacy allows one completion owner per kind: ${e}`);
|
|
65
|
+
let l = (e) => {
|
|
66
|
+
let t = [], n = [];
|
|
67
|
+
for (let r of c) {
|
|
68
|
+
let i = r.declaration;
|
|
69
|
+
(i === void 0 || i.kinds.includes(e)) && (i !== void 0 && t.push({
|
|
70
|
+
name: r.name,
|
|
71
|
+
tables: [...i.tables],
|
|
72
|
+
erasePhase: i.erasePhase
|
|
73
|
+
}), r.tables.some((e) => e === void 0 || !i?.tables.includes(e)) && n.push(r.name));
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
participants: t,
|
|
77
|
+
missing: n
|
|
78
|
+
};
|
|
79
|
+
}, u = (t, n) => e.gen(function* () {
|
|
80
|
+
let i = typeof t?.requestId == "string" ? t.requestId : "", a = t?.target;
|
|
81
|
+
if (!i.trim() || typeof a?.subjectId != "string" || !a.subjectId.trim() || !(a.tenantId === null || typeof a.tenantId == "string" && a.tenantId.trim()) || a.kind !== "user" && a.kind !== "guest") return yield* e.fail(new r({
|
|
82
|
+
code: "invalid_request",
|
|
83
|
+
operation: n,
|
|
84
|
+
requestId: i,
|
|
85
|
+
plugin: null,
|
|
86
|
+
completed: [],
|
|
87
|
+
missing: []
|
|
88
|
+
}));
|
|
89
|
+
let o = l(a.kind);
|
|
90
|
+
return o.missing.length > 0 || o.participants.length === 0 ? yield* e.fail(new r({
|
|
91
|
+
code: "coverage_missing",
|
|
92
|
+
operation: n,
|
|
93
|
+
requestId: i,
|
|
94
|
+
plugin: null,
|
|
95
|
+
completed: [],
|
|
96
|
+
missing: o.missing
|
|
97
|
+
})) : {
|
|
98
|
+
requestId: i,
|
|
99
|
+
target: Object.freeze({
|
|
100
|
+
subjectId: a.subjectId,
|
|
101
|
+
tenantId: a.tenantId,
|
|
102
|
+
kind: a.kind
|
|
103
|
+
}),
|
|
104
|
+
context: Object.freeze({
|
|
105
|
+
requestId: i,
|
|
106
|
+
tenantId: a.tenantId,
|
|
107
|
+
kind: a.kind
|
|
108
|
+
}),
|
|
109
|
+
participants: o.participants
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
coverage: l,
|
|
114
|
+
exportSubject: (t) => e.gen(function* () {
|
|
115
|
+
let n = yield* u(t, "export"), i = [];
|
|
116
|
+
for (let t of n.participants) {
|
|
117
|
+
let o = c.find((e) => e.name === t.name).onExport, s = yield* e.suspend(() => o(n.target.subjectId, n.context)).pipe(e.map(a), e.catchCause(() => e.fail(new r({
|
|
118
|
+
code: "hook_failed",
|
|
119
|
+
operation: "export",
|
|
120
|
+
requestId: n.requestId,
|
|
121
|
+
plugin: t.name,
|
|
122
|
+
completed: i.map((e) => e.name),
|
|
123
|
+
missing: []
|
|
124
|
+
}))));
|
|
125
|
+
i.push({
|
|
126
|
+
name: t.name,
|
|
127
|
+
data: s
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
requestId: n.requestId,
|
|
132
|
+
target: n.target,
|
|
133
|
+
plugins: i
|
|
134
|
+
};
|
|
135
|
+
}),
|
|
136
|
+
eraseSubject: (t) => e.gen(function* () {
|
|
137
|
+
let n = yield* u(t, "erase"), i = [], a = [
|
|
138
|
+
...n.participants.filter((e) => e.erasePhase === "prepare"),
|
|
139
|
+
...n.participants.filter((e) => e.erasePhase === "data"),
|
|
140
|
+
...n.participants.filter((e) => e.erasePhase === "identity"),
|
|
141
|
+
...n.participants.filter((e) => e.erasePhase === "finalize")
|
|
142
|
+
];
|
|
143
|
+
for (let t of a) {
|
|
144
|
+
let a = c.find((e) => e.name === t.name).onErase, o = t.erasePhase === "finalize" ? Object.freeze({
|
|
145
|
+
...n.context,
|
|
146
|
+
completed: Object.freeze([...i])
|
|
147
|
+
}) : n.context;
|
|
148
|
+
yield* e.suspend(() => a(n.target.subjectId, o)).pipe(e.catchCause(() => e.fail(new r({
|
|
149
|
+
code: "hook_failed",
|
|
150
|
+
operation: "erase",
|
|
151
|
+
requestId: n.requestId,
|
|
152
|
+
plugin: t.name,
|
|
153
|
+
completed: [...i],
|
|
154
|
+
missing: []
|
|
155
|
+
})))), i.push(t.name);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
requestId: n.requestId,
|
|
159
|
+
target: n.target,
|
|
160
|
+
completed: i
|
|
161
|
+
};
|
|
162
|
+
})
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
//#endregion
|
|
166
|
+
export { n as PluginPrivacyErasePhaseSchema, r as PluginPrivacyFailure, o as createPluginPrivacyRegistry };
|