@sixb/core 0.0.1
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/LICENSE +21 -0
- package/README.md +470 -0
- package/dist/actions/builders/define-action.d.ts +7 -0
- package/dist/actions/builders/define-action.d.ts.map +1 -0
- package/dist/actions/builders/params.d.ts +23 -0
- package/dist/actions/builders/params.d.ts.map +1 -0
- package/dist/actions/builders.d.ts +3 -0
- package/dist/actions/builders.d.ts.map +1 -0
- package/dist/actions/commit-edits.d.ts +54 -0
- package/dist/actions/commit-edits.d.ts.map +1 -0
- package/dist/actions/errors.d.ts +9 -0
- package/dist/actions/errors.d.ts.map +1 -0
- package/dist/actions/index.d.ts +14 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +73 -0
- package/dist/actions/index.js.map +9 -0
- package/dist/actions/read-facade.d.ts +56 -0
- package/dist/actions/read-facade.d.ts.map +1 -0
- package/dist/actions/registry.d.ts +17 -0
- package/dist/actions/registry.d.ts.map +1 -0
- package/dist/actions/request.d.ts +37 -0
- package/dist/actions/request.d.ts.map +1 -0
- package/dist/actions/run-id.d.ts +3 -0
- package/dist/actions/run-id.d.ts.map +1 -0
- package/dist/actions/runtime.d.ts +11 -0
- package/dist/actions/runtime.d.ts.map +1 -0
- package/dist/actions/types/context.d.ts +147 -0
- package/dist/actions/types/context.d.ts.map +1 -0
- package/dist/actions/types/definitions.d.ts +67 -0
- package/dist/actions/types/definitions.d.ts.map +1 -0
- package/dist/actions/types/handlers.d.ts +19 -0
- package/dist/actions/types/handlers.d.ts.map +1 -0
- package/dist/actions/types/params.d.ts +45 -0
- package/dist/actions/types/params.d.ts.map +1 -0
- package/dist/actions/types.d.ts +5 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/validation.d.ts +33 -0
- package/dist/actions/validation.d.ts.map +1 -0
- package/dist/actions/validators.d.ts +8 -0
- package/dist/actions/validators.d.ts.map +1 -0
- package/dist/actions/worker.d.ts +3 -0
- package/dist/actions/worker.d.ts.map +1 -0
- package/dist/actions/worker.js +324 -0
- package/dist/actions/worker.js.map +11 -0
- package/dist/agents/adapters.d.ts +185 -0
- package/dist/agents/adapters.d.ts.map +1 -0
- package/dist/agents/api-gateway.d.ts +21 -0
- package/dist/agents/api-gateway.d.ts.map +1 -0
- package/dist/agents/builders.d.ts +10 -0
- package/dist/agents/builders.d.ts.map +1 -0
- package/dist/agents/context-model.d.ts +4 -0
- package/dist/agents/context-model.d.ts.map +1 -0
- package/dist/agents/context-resolution.d.ts +5 -0
- package/dist/agents/context-resolution.d.ts.map +1 -0
- package/dist/agents/context.d.ts +57 -0
- package/dist/agents/context.d.ts.map +1 -0
- package/dist/agents/context.js +23 -0
- package/dist/agents/context.js.map +9 -0
- package/dist/agents/dispatch.d.ts +36 -0
- package/dist/agents/dispatch.d.ts.map +1 -0
- package/dist/agents/errors.d.ts +27 -0
- package/dist/agents/errors.d.ts.map +1 -0
- package/dist/agents/ids.d.ts +11 -0
- package/dist/agents/ids.d.ts.map +1 -0
- package/dist/agents/index.d.ts +24 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +121 -0
- package/dist/agents/index.js.map +9 -0
- package/dist/agents/message.d.ts +78 -0
- package/dist/agents/message.d.ts.map +1 -0
- package/dist/agents/prompt.d.ts +15 -0
- package/dist/agents/prompt.d.ts.map +1 -0
- package/dist/agents/request.d.ts +42 -0
- package/dist/agents/request.d.ts.map +1 -0
- package/dist/agents/runtime.d.ts +41 -0
- package/dist/agents/runtime.d.ts.map +1 -0
- package/dist/agents/streams.d.ts +72 -0
- package/dist/agents/streams.d.ts.map +1 -0
- package/dist/agents/streams.js +32 -0
- package/dist/agents/streams.js.map +9 -0
- package/dist/agents/types.d.ts +52 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/validation.d.ts +10 -0
- package/dist/agents/validation.d.ts.map +1 -0
- package/dist/auth/access-tokens.d.ts +19 -0
- package/dist/auth/access-tokens.d.ts.map +1 -0
- package/dist/auth/audience.d.ts +8 -0
- package/dist/auth/audience.d.ts.map +1 -0
- package/dist/auth/cookies.d.ts +50 -0
- package/dist/auth/cookies.d.ts.map +1 -0
- package/dist/auth/csrf.d.ts +8 -0
- package/dist/auth/csrf.d.ts.map +1 -0
- package/dist/auth/errors.d.ts +7 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +101 -0
- package/dist/auth/index.js.map +9 -0
- package/dist/auth/runtime.d.ts +129 -0
- package/dist/auth/runtime.d.ts.map +1 -0
- package/dist/auth/session-cache.d.ts +44 -0
- package/dist/auth/session-cache.d.ts.map +1 -0
- package/dist/auth/sessions.d.ts +16 -0
- package/dist/auth/sessions.d.ts.map +1 -0
- package/dist/auth/strategy.d.ts +11 -0
- package/dist/auth/strategy.d.ts.map +1 -0
- package/dist/auth/strategy.js +14 -0
- package/dist/auth/strategy.js.map +9 -0
- package/dist/auth/types.d.ts +460 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/validation.d.ts +26 -0
- package/dist/auth/validation.d.ts.map +1 -0
- package/dist/authorization/application-access.d.ts +18 -0
- package/dist/authorization/application-access.d.ts.map +1 -0
- package/dist/authorization/decision.d.ts +104 -0
- package/dist/authorization/decision.d.ts.map +1 -0
- package/dist/authorization/errors.d.ts +10 -0
- package/dist/authorization/errors.d.ts.map +1 -0
- package/dist/authorization/event-visibility.d.ts +16 -0
- package/dist/authorization/event-visibility.d.ts.map +1 -0
- package/dist/authorization/grant-kinds.d.ts +48 -0
- package/dist/authorization/grant-kinds.d.ts.map +1 -0
- package/dist/authorization/index.d.ts +11 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +48 -0
- package/dist/authorization/index.js.map +9 -0
- package/dist/authorization/resolve.d.ts +28 -0
- package/dist/authorization/resolve.d.ts.map +1 -0
- package/dist/authorization/run-visibility.d.ts +15 -0
- package/dist/authorization/run-visibility.d.ts.map +1 -0
- package/dist/authorization/types.d.ts +46 -0
- package/dist/authorization/types.d.ts.map +1 -0
- package/dist/blob-storage/browser.d.ts +14 -0
- package/dist/blob-storage/browser.d.ts.map +1 -0
- package/dist/blob-storage/browser.js +22 -0
- package/dist/blob-storage/browser.js.map +9 -0
- package/dist/blob-storage/constants.d.ts +10 -0
- package/dist/blob-storage/constants.d.ts.map +1 -0
- package/dist/blob-storage/derive.d.ts +4 -0
- package/dist/blob-storage/derive.d.ts.map +1 -0
- package/dist/blob-storage/errors.d.ts +7 -0
- package/dist/blob-storage/errors.d.ts.map +1 -0
- package/dist/blob-storage/in-memory.d.ts +10 -0
- package/dist/blob-storage/in-memory.d.ts.map +1 -0
- package/dist/blob-storage/index.d.ts +8 -0
- package/dist/blob-storage/index.d.ts.map +1 -0
- package/dist/blob-storage/index.js +44 -0
- package/dist/blob-storage/index.js.map +9 -0
- package/dist/blob-storage/types.d.ts +126 -0
- package/dist/blob-storage/types.d.ts.map +1 -0
- package/dist/blob-storage/utils.d.ts +9 -0
- package/dist/blob-storage/utils.d.ts.map +1 -0
- package/dist/blob-storage/validation.d.ts +6 -0
- package/dist/blob-storage/validation.d.ts.map +1 -0
- package/dist/bootstrap/discovery.d.ts +34 -0
- package/dist/bootstrap/discovery.d.ts.map +1 -0
- package/dist/bootstrap/index.d.ts +4 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +80 -0
- package/dist/bootstrap/index.js.map +9 -0
- package/dist/bootstrap/ontology-type-manifest.d.ts +22 -0
- package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -0
- package/dist/broker/errors.d.ts +12 -0
- package/dist/broker/errors.d.ts.map +1 -0
- package/dist/broker/in-memory.d.ts +53 -0
- package/dist/broker/in-memory.d.ts.map +1 -0
- package/dist/broker/index.d.ts +5 -0
- package/dist/broker/index.d.ts.map +1 -0
- package/dist/broker/index.js +15 -0
- package/dist/broker/index.js.map +9 -0
- package/dist/broker/types.d.ts +119 -0
- package/dist/broker/types.d.ts.map +1 -0
- package/dist/chunk-04b07a9q.js +89 -0
- package/dist/chunk-04b07a9q.js.map +10 -0
- package/dist/chunk-0fygrz37.js +354 -0
- package/dist/chunk-0fygrz37.js.map +17 -0
- package/dist/chunk-0psb6kdw.js +989 -0
- package/dist/chunk-0psb6kdw.js.map +15 -0
- package/dist/chunk-1evzqhks.js +76 -0
- package/dist/chunk-1evzqhks.js.map +10 -0
- package/dist/chunk-1vffvydj.js +109 -0
- package/dist/chunk-1vffvydj.js.map +10 -0
- package/dist/chunk-2ab72m2h.js +59 -0
- package/dist/chunk-2ab72m2h.js.map +10 -0
- package/dist/chunk-2gpr6jsz.js +1968 -0
- package/dist/chunk-2gpr6jsz.js.map +13 -0
- package/dist/chunk-2s6sydsh.js +368 -0
- package/dist/chunk-2s6sydsh.js.map +12 -0
- package/dist/chunk-45tw90k7.js +72 -0
- package/dist/chunk-45tw90k7.js.map +11 -0
- package/dist/chunk-4pycxcj3.js +35 -0
- package/dist/chunk-4pycxcj3.js.map +11 -0
- package/dist/chunk-50kv63vj.js +523 -0
- package/dist/chunk-50kv63vj.js.map +12 -0
- package/dist/chunk-51fjndv0.js +17 -0
- package/dist/chunk-51fjndv0.js.map +11 -0
- package/dist/chunk-590dejbp.js +49 -0
- package/dist/chunk-590dejbp.js.map +10 -0
- package/dist/chunk-5yny9z0e.js +60 -0
- package/dist/chunk-5yny9z0e.js.map +10 -0
- package/dist/chunk-6wetht33.js +89 -0
- package/dist/chunk-6wetht33.js.map +10 -0
- package/dist/chunk-74drx9gd.js +362 -0
- package/dist/chunk-74drx9gd.js.map +11 -0
- package/dist/chunk-867jxh7c.js +1156 -0
- package/dist/chunk-867jxh7c.js.map +19 -0
- package/dist/chunk-88ppkr54.js +257 -0
- package/dist/chunk-88ppkr54.js.map +12 -0
- package/dist/chunk-8r8cw2xw.js +373 -0
- package/dist/chunk-8r8cw2xw.js.map +11 -0
- package/dist/chunk-8ydjhh27.js +95 -0
- package/dist/chunk-8ydjhh27.js.map +11 -0
- package/dist/chunk-9dzba0f2.js +43 -0
- package/dist/chunk-9dzba0f2.js.map +10 -0
- package/dist/chunk-aebzcsxr.js +5272 -0
- package/dist/chunk-aebzcsxr.js.map +48 -0
- package/dist/chunk-b49dgvsj.js +49 -0
- package/dist/chunk-b49dgvsj.js.map +10 -0
- package/dist/chunk-btpe64e4.js +554 -0
- package/dist/chunk-btpe64e4.js.map +13 -0
- package/dist/chunk-c3zd880g.js +629 -0
- package/dist/chunk-c3zd880g.js.map +14 -0
- package/dist/chunk-dcgrzj1t.js +2954 -0
- package/dist/chunk-dcgrzj1t.js.map +36 -0
- package/dist/chunk-dhmj53mx.js +501 -0
- package/dist/chunk-dhmj53mx.js.map +16 -0
- package/dist/chunk-dktq02ne.js +16 -0
- package/dist/chunk-dktq02ne.js.map +10 -0
- package/dist/chunk-f2b5e2gf.js +141 -0
- package/dist/chunk-f2b5e2gf.js.map +11 -0
- package/dist/chunk-gqdd7508.js +273 -0
- package/dist/chunk-gqdd7508.js.map +11 -0
- package/dist/chunk-hsv43v58.js +1390 -0
- package/dist/chunk-hsv43v58.js.map +21 -0
- package/dist/chunk-jdwx7vzs.js +454 -0
- package/dist/chunk-jdwx7vzs.js.map +14 -0
- package/dist/chunk-k25jm1x5.js +102 -0
- package/dist/chunk-k25jm1x5.js.map +10 -0
- package/dist/chunk-k41ajtz7.js +352 -0
- package/dist/chunk-k41ajtz7.js.map +13 -0
- package/dist/chunk-k6j72mtt.js +9 -0
- package/dist/chunk-k6j72mtt.js.map +10 -0
- package/dist/chunk-mx84y05q.js +426 -0
- package/dist/chunk-mx84y05q.js.map +11 -0
- package/dist/chunk-nvamz5dv.js +819 -0
- package/dist/chunk-nvamz5dv.js.map +21 -0
- package/dist/chunk-p6r5g77m.js +113 -0
- package/dist/chunk-p6r5g77m.js.map +10 -0
- package/dist/chunk-pv1yad91.js +1165 -0
- package/dist/chunk-pv1yad91.js.map +27 -0
- package/dist/chunk-q4qzq0ea.js +832 -0
- package/dist/chunk-q4qzq0ea.js.map +14 -0
- package/dist/chunk-r65yscvk.js +187 -0
- package/dist/chunk-r65yscvk.js.map +11 -0
- package/dist/chunk-ry24jbr1.js +50 -0
- package/dist/chunk-ry24jbr1.js.map +10 -0
- package/dist/chunk-t358gywy.js +991 -0
- package/dist/chunk-t358gywy.js.map +34 -0
- package/dist/chunk-t72dvahb.js +167 -0
- package/dist/chunk-t72dvahb.js.map +12 -0
- package/dist/chunk-tsk2bxs3.js +1254 -0
- package/dist/chunk-tsk2bxs3.js.map +17 -0
- package/dist/chunk-v5c085yp.js +49 -0
- package/dist/chunk-v5c085yp.js.map +10 -0
- package/dist/chunk-vj723r3p.js +146 -0
- package/dist/chunk-vj723r3p.js.map +12 -0
- package/dist/chunk-wj01s5hr.js +363 -0
- package/dist/chunk-wj01s5hr.js.map +11 -0
- package/dist/chunk-wxhdnwh4.js +37 -0
- package/dist/chunk-wxhdnwh4.js.map +10 -0
- package/dist/chunk-xqbtf4wn.js +170 -0
- package/dist/chunk-xqbtf4wn.js.map +10 -0
- package/dist/chunk-xwnf87e1.js +324 -0
- package/dist/chunk-xwnf87e1.js.map +13 -0
- package/dist/chunk-xz5g49bp.js +239 -0
- package/dist/chunk-xz5g49bp.js.map +11 -0
- package/dist/chunk-y64skrwp.js +19 -0
- package/dist/chunk-y64skrwp.js.map +9 -0
- package/dist/chunk-ya6brh8a.js +136 -0
- package/dist/chunk-ya6brh8a.js.map +11 -0
- package/dist/chunk-yt8wphsx.js +12 -0
- package/dist/chunk-yt8wphsx.js.map +10 -0
- package/dist/chunk-yvef9xwc.js +3842 -0
- package/dist/chunk-yvef9xwc.js.map +44 -0
- package/dist/chunk-yxss87qa.js +821 -0
- package/dist/chunk-yxss87qa.js.map +14 -0
- package/dist/connectors/builders.d.ts +10 -0
- package/dist/connectors/builders.d.ts.map +1 -0
- package/dist/connectors/errors.d.ts +14 -0
- package/dist/connectors/errors.d.ts.map +1 -0
- package/dist/connectors/index.d.ts +5 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/runtime.d.ts +13 -0
- package/dist/connectors/runtime.d.ts.map +1 -0
- package/dist/connectors/types.d.ts +39 -0
- package/dist/connectors/types.d.ts.map +1 -0
- package/dist/datasets/builders.d.ts +54 -0
- package/dist/datasets/builders.d.ts.map +1 -0
- package/dist/datasets/errors.d.ts +4 -0
- package/dist/datasets/errors.d.ts.map +1 -0
- package/dist/datasets/index.d.ts +5 -0
- package/dist/datasets/index.d.ts.map +1 -0
- package/dist/datasets/types.d.ts +23 -0
- package/dist/datasets/types.d.ts.map +1 -0
- package/dist/datasets/validation.d.ts +8 -0
- package/dist/datasets/validation.d.ts.map +1 -0
- package/dist/edits/errors.d.ts +4 -0
- package/dist/edits/errors.d.ts.map +1 -0
- package/dist/edits/index.d.ts +4 -0
- package/dist/edits/index.d.ts.map +1 -0
- package/dist/edits/index.js +14 -0
- package/dist/edits/index.js.map +9 -0
- package/dist/edits/normalize.d.ts +14 -0
- package/dist/edits/normalize.d.ts.map +1 -0
- package/dist/edits/properties.d.ts +25 -0
- package/dist/edits/properties.d.ts.map +1 -0
- package/dist/edits/recorder.d.ts +4 -0
- package/dist/edits/recorder.d.ts.map +1 -0
- package/dist/edits/types.d.ts +159 -0
- package/dist/edits/types.d.ts.map +1 -0
- package/dist/error-reporting/capability.d.ts +57 -0
- package/dist/error-reporting/capability.d.ts.map +1 -0
- package/dist/error-reporting/internal.d.ts +4 -0
- package/dist/error-reporting/internal.d.ts.map +1 -0
- package/dist/error-reporting/internal.js +24 -0
- package/dist/error-reporting/internal.js.map +9 -0
- package/dist/error-reporting/normalize.d.ts +3 -0
- package/dist/error-reporting/normalize.d.ts.map +1 -0
- package/dist/error-reporting/reporter.d.ts +10 -0
- package/dist/error-reporting/reporter.d.ts.map +1 -0
- package/dist/error-reporting/types.d.ts +112 -0
- package/dist/error-reporting/types.d.ts.map +1 -0
- package/dist/events/definitions.d.ts +76 -0
- package/dist/events/definitions.d.ts.map +1 -0
- package/dist/events/envelope.d.ts +56 -0
- package/dist/events/envelope.d.ts.map +1 -0
- package/dist/events/errors.d.ts +8 -0
- package/dist/events/errors.d.ts.map +1 -0
- package/dist/events/index.d.ts +11 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +68 -0
- package/dist/events/index.js.map +9 -0
- package/dist/events/outbox-dispatcher.d.ts +82 -0
- package/dist/events/outbox-dispatcher.d.ts.map +1 -0
- package/dist/events/property-changes.d.ts +16 -0
- package/dist/events/property-changes.d.ts.map +1 -0
- package/dist/events/runtime.d.ts +87 -0
- package/dist/events/runtime.d.ts.map +1 -0
- package/dist/events/scope.d.ts +25 -0
- package/dist/events/scope.d.ts.map +1 -0
- package/dist/events/scope.js +10 -0
- package/dist/events/scope.js.map +9 -0
- package/dist/events/selectors/builder.d.ts +64 -0
- package/dist/events/selectors/builder.d.ts.map +1 -0
- package/dist/events/selectors/index.d.ts +5 -0
- package/dist/events/selectors/index.d.ts.map +1 -0
- package/dist/events/selectors/index.js +15 -0
- package/dist/events/selectors/index.js.map +9 -0
- package/dist/events/selectors/predicate.d.ts +5 -0
- package/dist/events/selectors/predicate.d.ts.map +1 -0
- package/dist/events/selectors/types.d.ts +141 -0
- package/dist/events/selectors/types.d.ts.map +1 -0
- package/dist/events/toStoredEvent.d.ts +10 -0
- package/dist/events/toStoredEvent.d.ts.map +1 -0
- package/dist/events/types/actions.d.ts +39 -0
- package/dist/events/types/actions.d.ts.map +1 -0
- package/dist/events/types/datasets.d.ts +20 -0
- package/dist/events/types/datasets.d.ts.map +1 -0
- package/dist/events/types/index.d.ts +137 -0
- package/dist/events/types/index.d.ts.map +1 -0
- package/dist/events/types/links.d.ts +37 -0
- package/dist/events/types/links.d.ts.map +1 -0
- package/dist/events/types/objects.d.ts +33 -0
- package/dist/events/types/objects.d.ts.map +1 -0
- package/dist/events/types/pipelines.d.ts +59 -0
- package/dist/events/types/pipelines.d.ts.map +1 -0
- package/dist/events/types/rules.d.ts +28 -0
- package/dist/events/types/rules.d.ts.map +1 -0
- package/dist/events/types/schedules.d.ts +14 -0
- package/dist/events/types/schedules.d.ts.map +1 -0
- package/dist/events/types/syncs.d.ts +25 -0
- package/dist/events/types/syncs.d.ts.map +1 -0
- package/dist/events/types/telemetry.d.ts +17 -0
- package/dist/events/types/telemetry.d.ts.map +1 -0
- package/dist/events/types/workflows.d.ts +150 -0
- package/dist/events/types/workflows.d.ts.map +1 -0
- package/dist/http/api-routes.d.ts +24 -0
- package/dist/http/api-routes.d.ts.map +1 -0
- package/dist/http/index.d.ts +4 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +16 -0
- package/dist/http/index.js.map +9 -0
- package/dist/http/route-pattern.d.ts +14 -0
- package/dist/http/route-pattern.d.ts.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +430 -0
- package/dist/index.js.map +9 -0
- package/dist/json.d.ts +14 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/lake-storage/definition-updates.d.ts +40 -0
- package/dist/lake-storage/definition-updates.d.ts.map +1 -0
- package/dist/lake-storage/errors.d.ts +7 -0
- package/dist/lake-storage/errors.d.ts.map +1 -0
- package/dist/lake-storage/in-memory.d.ts +25 -0
- package/dist/lake-storage/in-memory.d.ts.map +1 -0
- package/dist/lake-storage/index.d.ts +9 -0
- package/dist/lake-storage/index.d.ts.map +1 -0
- package/dist/lake-storage/index.js +24 -0
- package/dist/lake-storage/index.js.map +9 -0
- package/dist/lake-storage/sql-transforms.d.ts +45 -0
- package/dist/lake-storage/sql-transforms.d.ts.map +1 -0
- package/dist/lake-storage/types.d.ts +114 -0
- package/dist/lake-storage/types.d.ts.map +1 -0
- package/dist/logging/console-logger.d.ts +17 -0
- package/dist/logging/console-logger.d.ts.map +1 -0
- package/dist/logging/index.d.ts +5 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +45 -0
- package/dist/logging/index.js.map +9 -0
- package/dist/logging/record.d.ts +10 -0
- package/dist/logging/record.d.ts.map +1 -0
- package/dist/logging/run-logger.d.ts +61 -0
- package/dist/logging/run-logger.d.ts.map +1 -0
- package/dist/logging/runtime.d.ts +87 -0
- package/dist/logging/runtime.d.ts.map +1 -0
- package/dist/logging/stream.d.ts +24 -0
- package/dist/logging/stream.d.ts.map +1 -0
- package/dist/logging/types.d.ts +82 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +27 -0
- package/dist/logging/types.js.map +9 -0
- package/dist/maintenance/index.d.ts +3 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/ontology-maintenance.d.ts +48 -0
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -0
- package/dist/maintenance/types.d.ts +53 -0
- package/dist/maintenance/types.d.ts.map +1 -0
- package/dist/materialization/dataset-watermark.d.ts +5 -0
- package/dist/materialization/dataset-watermark.d.ts.map +1 -0
- package/dist/materialization/errors.d.ts +37 -0
- package/dist/materialization/errors.d.ts.map +1 -0
- package/dist/materialization/events.d.ts +57 -0
- package/dist/materialization/events.d.ts.map +1 -0
- package/dist/materialization/identity.d.ts +8 -0
- package/dist/materialization/identity.d.ts.map +1 -0
- package/dist/materialization/index.d.ts +13 -0
- package/dist/materialization/index.d.ts.map +1 -0
- package/dist/materialization/index.js +56 -0
- package/dist/materialization/index.js.map +9 -0
- package/dist/materialization/model.d.ts +342 -0
- package/dist/materialization/model.d.ts.map +1 -0
- package/dist/materialization/refs.d.ts +24 -0
- package/dist/materialization/refs.d.ts.map +1 -0
- package/dist/materializer/context.d.ts +34 -0
- package/dist/materializer/context.d.ts.map +1 -0
- package/dist/materializer/edits/apply.d.ts +35 -0
- package/dist/materializer/edits/apply.d.ts.map +1 -0
- package/dist/materializer/edits/commit.d.ts +4 -0
- package/dist/materializer/edits/commit.d.ts.map +1 -0
- package/dist/materializer/edits/execution-units.d.ts +14 -0
- package/dist/materializer/edits/execution-units.d.ts.map +1 -0
- package/dist/materializer/edits/load-state.d.ts +6 -0
- package/dist/materializer/edits/load-state.d.ts.map +1 -0
- package/dist/materializer/edits/operations.d.ts +32 -0
- package/dist/materializer/edits/operations.d.ts.map +1 -0
- package/dist/materializer/edits/plan.d.ts +18 -0
- package/dist/materializer/edits/plan.d.ts.map +1 -0
- package/dist/materializer/edits/read-set.d.ts +8 -0
- package/dist/materializer/edits/read-set.d.ts.map +1 -0
- package/dist/materializer/edits/working-state.d.ts +30 -0
- package/dist/materializer/edits/working-state.d.ts.map +1 -0
- package/dist/materializer/effective/build-events.d.ts +26 -0
- package/dist/materializer/effective/build-events.d.ts.map +1 -0
- package/dist/materializer/effective/diff.d.ts +15 -0
- package/dist/materializer/effective/diff.d.ts.map +1 -0
- package/dist/materializer/effective/load-state.d.ts +7 -0
- package/dist/materializer/effective/load-state.d.ts.map +1 -0
- package/dist/materializer/effective/resolve.d.ts +26 -0
- package/dist/materializer/effective/resolve.d.ts.map +1 -0
- package/dist/materializer/effective/validate.d.ts +11 -0
- package/dist/materializer/effective/validate.d.ts.map +1 -0
- package/dist/materializer/execution/commit-lifecycle.d.ts +8 -0
- package/dist/materializer/execution/commit-lifecycle.d.ts.map +1 -0
- package/dist/materializer/execution/plan-stream.d.ts +8 -0
- package/dist/materializer/execution/plan-stream.d.ts.map +1 -0
- package/dist/materializer/execution/run-correlation.d.ts +19 -0
- package/dist/materializer/execution/run-correlation.d.ts.map +1 -0
- package/dist/materializer/execution/work-executor.d.ts +13 -0
- package/dist/materializer/execution/work-executor.d.ts.map +1 -0
- package/dist/materializer/execution/work-records.d.ts +15 -0
- package/dist/materializer/execution/work-records.d.ts.map +1 -0
- package/dist/materializer/index.d.ts +15 -0
- package/dist/materializer/index.d.ts.map +1 -0
- package/dist/materializer/index.js +134 -0
- package/dist/materializer/index.js.map +9 -0
- package/dist/materializer/materializer.d.ts +27 -0
- package/dist/materializer/materializer.d.ts.map +1 -0
- package/dist/materializer/projections/entry-validator.d.ts +8 -0
- package/dist/materializer/projections/entry-validator.d.ts.map +1 -0
- package/dist/materializer/projections/finish-run.d.ts +4 -0
- package/dist/materializer/projections/finish-run.d.ts.map +1 -0
- package/dist/materializer/projections/replace.d.ts +4 -0
- package/dist/materializer/projections/replace.d.ts.map +1 -0
- package/dist/materializer/projections/replacement-plan.d.ts +14 -0
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -0
- package/dist/materializer/projections/source-materialization.d.ts +27 -0
- package/dist/materializer/projections/source-materialization.d.ts.map +1 -0
- package/dist/materializer/shared/abort.d.ts +2 -0
- package/dist/materializer/shared/abort.d.ts.map +1 -0
- package/dist/materializer/shared/batching.d.ts +11 -0
- package/dist/materializer/shared/batching.d.ts.map +1 -0
- package/dist/materializer/shared/chunking.d.ts +6 -0
- package/dist/materializer/shared/chunking.d.ts.map +1 -0
- package/dist/materializer/shared/identity.d.ts +38 -0
- package/dist/materializer/shared/identity.d.ts.map +1 -0
- package/dist/materializer/shared/normalize.d.ts +10 -0
- package/dist/materializer/shared/normalize.d.ts.map +1 -0
- package/dist/materializer/shared/projection-run.d.ts +19 -0
- package/dist/materializer/shared/projection-run.d.ts.map +1 -0
- package/dist/materializer/telemetry/append.d.ts +4 -0
- package/dist/materializer/telemetry/append.d.ts.map +1 -0
- package/dist/materializer/telemetry/plan.d.ts +12 -0
- package/dist/materializer/telemetry/plan.d.ts.map +1 -0
- package/dist/objects/action/errors.d.ts +39 -0
- package/dist/objects/action/errors.d.ts.map +1 -0
- package/dist/objects/action/index.d.ts +4 -0
- package/dist/objects/action/index.d.ts.map +1 -0
- package/dist/objects/action/request.d.ts +23 -0
- package/dist/objects/action/request.d.ts.map +1 -0
- package/dist/objects/context/index.d.ts +3 -0
- package/dist/objects/context/index.d.ts.map +1 -0
- package/dist/objects/context/resolve.d.ts +27 -0
- package/dist/objects/context/resolve.d.ts.map +1 -0
- package/dist/objects/context/types.d.ts +28 -0
- package/dist/objects/context/types.d.ts.map +1 -0
- package/dist/objects/contexts.d.ts +45 -0
- package/dist/objects/contexts.d.ts.map +1 -0
- package/dist/objects/errors.d.ts +8 -0
- package/dist/objects/errors.d.ts.map +1 -0
- package/dist/objects/helpers.d.ts +7 -0
- package/dist/objects/helpers.d.ts.map +1 -0
- package/dist/objects/index.d.ts +18 -0
- package/dist/objects/index.d.ts.map +1 -0
- package/dist/objects/index.js +71 -0
- package/dist/objects/index.js.map +9 -0
- package/dist/objects/link/authorization.d.ts +25 -0
- package/dist/objects/link/authorization.d.ts.map +1 -0
- package/dist/objects/link/endpoints.d.ts +28 -0
- package/dist/objects/link/endpoints.d.ts.map +1 -0
- package/dist/objects/link/index.d.ts +4 -0
- package/dist/objects/link/index.d.ts.map +1 -0
- package/dist/objects/link/remove.d.ts +8 -0
- package/dist/objects/link/remove.d.ts.map +1 -0
- package/dist/objects/link/upsert-batch.d.ts +11 -0
- package/dist/objects/link/upsert-batch.d.ts.map +1 -0
- package/dist/objects/link/upsert.d.ts +12 -0
- package/dist/objects/link/upsert.d.ts.map +1 -0
- package/dist/objects/materializer-adapter.d.ts +114 -0
- package/dist/objects/materializer-adapter.d.ts.map +1 -0
- package/dist/objects/object/delete.d.ts +17 -0
- package/dist/objects/object/delete.d.ts.map +1 -0
- package/dist/objects/object/index.d.ts +4 -0
- package/dist/objects/object/index.d.ts.map +1 -0
- package/dist/objects/object/upsert-batch.d.ts +7 -0
- package/dist/objects/object/upsert-batch.d.ts.map +1 -0
- package/dist/objects/object/upsert.d.ts +7 -0
- package/dist/objects/object/upsert.d.ts.map +1 -0
- package/dist/objects/query/errors.d.ts +23 -0
- package/dist/objects/query/errors.d.ts.map +1 -0
- package/dist/objects/query/executor.d.ts +63 -0
- package/dist/objects/query/executor.d.ts.map +1 -0
- package/dist/objects/query/explain-format.d.ts +10 -0
- package/dist/objects/query/explain-format.d.ts.map +1 -0
- package/dist/objects/query/explain.d.ts +26 -0
- package/dist/objects/query/explain.d.ts.map +1 -0
- package/dist/objects/query/index.d.ts +14 -0
- package/dist/objects/query/index.d.ts.map +1 -0
- package/dist/objects/query/index.js +54 -0
- package/dist/objects/query/index.js.map +9 -0
- package/dist/objects/query/ir.d.ts +166 -0
- package/dist/objects/query/ir.d.ts.map +1 -0
- package/dist/objects/query/normalize.d.ts +12 -0
- package/dist/objects/query/normalize.d.ts.map +1 -0
- package/dist/objects/query/planner.d.ts +32 -0
- package/dist/objects/query/planner.d.ts.map +1 -0
- package/dist/objects/query/scalar-values.d.ts +6 -0
- package/dist/objects/query/scalar-values.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts +23 -0
- package/dist/objects/query/validate.d.ts.map +1 -0
- package/dist/objects/runtime-batch.d.ts +29 -0
- package/dist/objects/runtime-batch.d.ts.map +1 -0
- package/dist/objects/sdk/index.d.ts +3 -0
- package/dist/objects/sdk/index.d.ts.map +1 -0
- package/dist/objects/sdk/object-handle.d.ts +6 -0
- package/dist/objects/sdk/object-handle.d.ts.map +1 -0
- package/dist/objects/sdk/object-set.d.ts +14 -0
- package/dist/objects/sdk/object-set.d.ts.map +1 -0
- package/dist/objects/sdk/query-builder.d.ts +20 -0
- package/dist/objects/sdk/query-builder.d.ts.map +1 -0
- package/dist/objects/sdk/query-executor.d.ts +51 -0
- package/dist/objects/sdk/query-executor.d.ts.map +1 -0
- package/dist/objects/sdk/runtime-query-executor.d.ts +16 -0
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -0
- package/dist/objects/sdk/telemetry-channel.d.ts +6 -0
- package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -0
- package/dist/objects/sdk/where.d.ts +15 -0
- package/dist/objects/sdk/where.d.ts.map +1 -0
- package/dist/objects/service/action-service.d.ts +12 -0
- package/dist/objects/service/action-service.d.ts.map +1 -0
- package/dist/objects/service/index.d.ts +7 -0
- package/dist/objects/service/index.d.ts.map +1 -0
- package/dist/objects/service/link-service.d.ts +26 -0
- package/dist/objects/service/link-service.d.ts.map +1 -0
- package/dist/objects/service/list-service.d.ts +24 -0
- package/dist/objects/service/list-service.d.ts.map +1 -0
- package/dist/objects/service/object-service.d.ts +12 -0
- package/dist/objects/service/object-service.d.ts.map +1 -0
- package/dist/objects/service/telemetry-service.d.ts +12 -0
- package/dist/objects/service/telemetry-service.d.ts.map +1 -0
- package/dist/objects/telemetry/append-batch.d.ts +10 -0
- package/dist/objects/telemetry/append-batch.d.ts.map +1 -0
- package/dist/objects/telemetry/history.d.ts +8 -0
- package/dist/objects/telemetry/history.d.ts.map +1 -0
- package/dist/objects/telemetry/index.d.ts +5 -0
- package/dist/objects/telemetry/index.d.ts.map +1 -0
- package/dist/objects/telemetry/write-batch.d.ts +8 -0
- package/dist/objects/telemetry/write-batch.d.ts.map +1 -0
- package/dist/ontology/builders.d.ts +323 -0
- package/dist/ontology/builders.d.ts.map +1 -0
- package/dist/ontology/decimal.d.ts +28 -0
- package/dist/ontology/decimal.d.ts.map +1 -0
- package/dist/ontology/errors.d.ts +20 -0
- package/dist/ontology/errors.d.ts.map +1 -0
- package/dist/ontology/index.d.ts +23 -0
- package/dist/ontology/index.d.ts.map +1 -0
- package/dist/ontology/index.js +120 -0
- package/dist/ontology/index.js.map +9 -0
- package/dist/ontology/inference/index.d.ts +112 -0
- package/dist/ontology/inference/index.d.ts.map +1 -0
- package/dist/ontology/internal.d.ts +4 -0
- package/dist/ontology/internal.d.ts.map +1 -0
- package/dist/ontology/internal.js +118 -0
- package/dist/ontology/internal.js.map +10 -0
- package/dist/ontology/json-schema.d.ts +9 -0
- package/dist/ontology/json-schema.d.ts.map +1 -0
- package/dist/ontology/refs.d.ts +16 -0
- package/dist/ontology/refs.d.ts.map +1 -0
- package/dist/ontology/registry.d.ts +82 -0
- package/dist/ontology/registry.d.ts.map +1 -0
- package/dist/ontology/tokens.d.ts +54 -0
- package/dist/ontology/tokens.d.ts.map +1 -0
- package/dist/ontology/types.d.ts +402 -0
- package/dist/ontology/types.d.ts.map +1 -0
- package/dist/ontology/units/index.d.ts +74 -0
- package/dist/ontology/units/index.d.ts.map +1 -0
- package/dist/ontology/units/quantitative-types.d.ts +1605 -0
- package/dist/ontology/units/quantitative-types.d.ts.map +1 -0
- package/dist/ontology/units/types.d.ts +26 -0
- package/dist/ontology/units/types.d.ts.map +1 -0
- package/dist/ontology/validation/index.d.ts +7 -0
- package/dist/ontology/validation/index.d.ts.map +1 -0
- package/dist/ontology/validation/links.d.ts +18 -0
- package/dist/ontology/validation/links.d.ts.map +1 -0
- package/dist/ontology/validation/normalize.d.ts +21 -0
- package/dist/ontology/validation/normalize.d.ts.map +1 -0
- package/dist/ontology/validation/properties.d.ts +19 -0
- package/dist/ontology/validation/properties.d.ts.map +1 -0
- package/dist/ontology/validation/query.d.ts +3 -0
- package/dist/ontology/validation/query.d.ts.map +1 -0
- package/dist/ontology/validation/schema.d.ts +7 -0
- package/dist/ontology/validation/schema.d.ts.map +1 -0
- package/dist/ontology/validation/telemetry.d.ts +7 -0
- package/dist/ontology/validation/telemetry.d.ts.map +1 -0
- package/dist/pipelines/builders.d.ts +14 -0
- package/dist/pipelines/builders.d.ts.map +1 -0
- package/dist/pipelines/errors.d.ts +4 -0
- package/dist/pipelines/errors.d.ts.map +1 -0
- package/dist/pipelines/index.d.ts +7 -0
- package/dist/pipelines/index.d.ts.map +1 -0
- package/dist/pipelines/request.d.ts +31 -0
- package/dist/pipelines/request.d.ts.map +1 -0
- package/dist/pipelines/types.d.ts +84 -0
- package/dist/pipelines/types.d.ts.map +1 -0
- package/dist/predicates/builders.d.ts +24 -0
- package/dist/predicates/builders.d.ts.map +1 -0
- package/dist/predicates/evaluate.d.ts +8 -0
- package/dist/predicates/evaluate.d.ts.map +1 -0
- package/dist/predicates/index.d.ts +5 -0
- package/dist/predicates/index.d.ts.map +1 -0
- package/dist/predicates/types.d.ts +69 -0
- package/dist/predicates/types.d.ts.map +1 -0
- package/dist/predicates/validation.d.ts +15 -0
- package/dist/predicates/validation.d.ts.map +1 -0
- package/dist/projections/builders.d.ts +212 -0
- package/dist/projections/builders.d.ts.map +1 -0
- package/dist/projections/errors.d.ts +4 -0
- package/dist/projections/errors.d.ts.map +1 -0
- package/dist/projections/index.d.ts +5 -0
- package/dist/projections/index.d.ts.map +1 -0
- package/dist/projections/internal.d.ts +24 -0
- package/dist/projections/internal.d.ts.map +1 -0
- package/dist/projections/internal.js +26 -0
- package/dist/projections/internal.js.map +9 -0
- package/dist/projections/ownership.d.ts +9 -0
- package/dist/projections/ownership.d.ts.map +1 -0
- package/dist/projections/registry.d.ts +30 -0
- package/dist/projections/registry.d.ts.map +1 -0
- package/dist/projections/revision.d.ts +7 -0
- package/dist/projections/revision.d.ts.map +1 -0
- package/dist/projections/types.d.ts +153 -0
- package/dist/projections/types.d.ts.map +1 -0
- package/dist/projections/validation.d.ts +97 -0
- package/dist/projections/validation.d.ts.map +1 -0
- package/dist/provider-scope.d.ts +12 -0
- package/dist/provider-scope.d.ts.map +1 -0
- package/dist/query.d.ts +17 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +21 -0
- package/dist/query.js.map +9 -0
- package/dist/queues/errors.d.ts +7 -0
- package/dist/queues/errors.d.ts.map +1 -0
- package/dist/queues/in-memory.d.ts +73 -0
- package/dist/queues/in-memory.d.ts.map +1 -0
- package/dist/queues/index.d.ts +5 -0
- package/dist/queues/index.d.ts.map +1 -0
- package/dist/queues/index.js +12 -0
- package/dist/queues/index.js.map +9 -0
- package/dist/queues/types.d.ts +182 -0
- package/dist/queues/types.d.ts.map +1 -0
- package/dist/rules/builders.d.ts +10 -0
- package/dist/rules/builders.d.ts.map +1 -0
- package/dist/rules/dependencies.d.ts +9 -0
- package/dist/rules/dependencies.d.ts.map +1 -0
- package/dist/rules/errors.d.ts +11 -0
- package/dist/rules/errors.d.ts.map +1 -0
- package/dist/rules/index.d.ts +6 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/internal.d.ts +9 -0
- package/dist/rules/internal.d.ts.map +1 -0
- package/dist/rules/internal.js +10 -0
- package/dist/rules/internal.js.map +9 -0
- package/dist/rules/types.d.ts +72 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/validation.d.ts +23 -0
- package/dist/rules/validation.d.ts.map +1 -0
- package/dist/runtime/create.d.ts +68 -0
- package/dist/runtime/create.d.ts.map +1 -0
- package/dist/runtime/errors.d.ts +9 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +26 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/internal.d.ts +3 -0
- package/dist/runtime/internal.d.ts.map +1 -0
- package/dist/runtime/internal.js +16 -0
- package/dist/runtime/internal.js.map +9 -0
- package/dist/runtime/ontology-mutations.d.ts +16 -0
- package/dist/runtime/ontology-mutations.d.ts.map +1 -0
- package/dist/runtime/scoped.d.ts +158 -0
- package/dist/runtime/scoped.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +226 -0
- package/dist/runtime/sixb.d.ts.map +1 -0
- package/dist/runtime/storage-readiness.d.ts +20 -0
- package/dist/runtime/storage-readiness.d.ts.map +1 -0
- package/dist/runtime/types.d.ts +840 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/sandboxes/errors.d.ts +20 -0
- package/dist/sandboxes/errors.d.ts.map +1 -0
- package/dist/sandboxes/exec.d.ts +17 -0
- package/dist/sandboxes/exec.d.ts.map +1 -0
- package/dist/sandboxes/index.d.ts +5 -0
- package/dist/sandboxes/index.d.ts.map +1 -0
- package/dist/sandboxes/index.js +18 -0
- package/dist/sandboxes/index.js.map +9 -0
- package/dist/sandboxes/sandbox.d.ts +110 -0
- package/dist/sandboxes/sandbox.d.ts.map +1 -0
- package/dist/scheduler/errors.d.ts +7 -0
- package/dist/scheduler/errors.d.ts.map +1 -0
- package/dist/scheduler/index.d.ts +4 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +18 -0
- package/dist/scheduler/index.js.map +9 -0
- package/dist/scheduler/runtime.d.ts +32 -0
- package/dist/scheduler/runtime.d.ts.map +1 -0
- package/dist/schedules/builders.d.ts +4 -0
- package/dist/schedules/builders.d.ts.map +1 -0
- package/dist/schedules/cron.d.ts +14 -0
- package/dist/schedules/cron.d.ts.map +1 -0
- package/dist/schedules/errors.d.ts +7 -0
- package/dist/schedules/errors.d.ts.map +1 -0
- package/dist/schedules/index.d.ts +12 -0
- package/dist/schedules/index.d.ts.map +1 -0
- package/dist/schedules/index.js +37 -0
- package/dist/schedules/index.js.map +9 -0
- package/dist/schedules/next-occurrence.d.ts +11 -0
- package/dist/schedules/next-occurrence.d.ts.map +1 -0
- package/dist/schedules/runtime.d.ts +17 -0
- package/dist/schedules/runtime.d.ts.map +1 -0
- package/dist/schedules/types.d.ts +99 -0
- package/dist/schedules/types.d.ts.map +1 -0
- package/dist/schedules/validation.d.ts +13 -0
- package/dist/schedules/validation.d.ts.map +1 -0
- package/dist/security/applications.d.ts +15 -0
- package/dist/security/applications.d.ts.map +1 -0
- package/dist/security/builders.d.ts +20 -0
- package/dist/security/builders.d.ts.map +1 -0
- package/dist/security/errors.d.ts +4 -0
- package/dist/security/errors.d.ts.map +1 -0
- package/dist/security/every.d.ts +68 -0
- package/dist/security/every.d.ts.map +1 -0
- package/dist/security/grants.d.ts +40 -0
- package/dist/security/grants.d.ts.map +1 -0
- package/dist/security/index.d.ts +12 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/membership-policies.d.ts +17 -0
- package/dist/security/membership-policies.d.ts.map +1 -0
- package/dist/security/runtime.d.ts +16 -0
- package/dist/security/runtime.d.ts.map +1 -0
- package/dist/security/types.d.ts +133 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/validation.d.ts +36 -0
- package/dist/security/validation.d.ts.map +1 -0
- package/dist/storage/action-runs/errors.d.ts +10 -0
- package/dist/storage/action-runs/errors.d.ts.map +1 -0
- package/dist/storage/action-runs/idempotency.d.ts +10 -0
- package/dist/storage/action-runs/idempotency.d.ts.map +1 -0
- package/dist/storage/action-runs/in-memory.d.ts +28 -0
- package/dist/storage/action-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/action-runs/index.d.ts +6 -0
- package/dist/storage/action-runs/index.d.ts.map +1 -0
- package/dist/storage/action-runs/types.d.ts +138 -0
- package/dist/storage/action-runs/types.d.ts.map +1 -0
- package/dist/storage/agents/errors.d.ts +11 -0
- package/dist/storage/agents/errors.d.ts.map +1 -0
- package/dist/storage/agents/in-memory.d.ts +70 -0
- package/dist/storage/agents/in-memory.d.ts.map +1 -0
- package/dist/storage/agents/index.d.ts +7 -0
- package/dist/storage/agents/index.d.ts.map +1 -0
- package/dist/storage/agents/types.d.ts +295 -0
- package/dist/storage/agents/types.d.ts.map +1 -0
- package/dist/storage/auth/errors.d.ts +10 -0
- package/dist/storage/auth/errors.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/access-tokens.d.ts +32 -0
- package/dist/storage/auth/in-memory/access-tokens.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/auth-storage.d.ts +36 -0
- package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/group-memberships.d.ts +21 -0
- package/dist/storage/auth/in-memory/group-memberships.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/identities.d.ts +17 -0
- package/dist/storage/auth/in-memory/identities.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/index.d.ts +2 -0
- package/dist/storage/auth/in-memory/index.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/invitations.d.ts +28 -0
- package/dist/storage/auth/in-memory/invitations.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/magic-links.d.ts +28 -0
- package/dist/storage/auth/in-memory/magic-links.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/oidc-attempts.d.ts +18 -0
- package/dist/storage/auth/in-memory/oidc-attempts.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/service-account-group-memberships.d.ts +17 -0
- package/dist/storage/auth/in-memory/service-account-group-memberships.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/service-accounts.d.ts +14 -0
- package/dist/storage/auth/in-memory/service-accounts.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/sessions.d.ts +55 -0
- package/dist/storage/auth/in-memory/sessions.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/shared.d.ts +71 -0
- package/dist/storage/auth/in-memory/shared.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/users.d.ts +19 -0
- package/dist/storage/auth/in-memory/users.d.ts.map +1 -0
- package/dist/storage/auth/in-memory.d.ts +2 -0
- package/dist/storage/auth/in-memory.d.ts.map +1 -0
- package/dist/storage/auth/index.d.ts +5 -0
- package/dist/storage/auth/index.d.ts.map +1 -0
- package/dist/storage/auth/types.d.ts +584 -0
- package/dist/storage/auth/types.d.ts.map +1 -0
- package/dist/storage/errors.d.ts +27 -0
- package/dist/storage/errors.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/errors.d.ts +15 -0
- package/dist/storage/file-upload-sessions/errors.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/in-memory.d.ts +27 -0
- package/dist/storage/file-upload-sessions/in-memory.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/index.d.ts +6 -0
- package/dist/storage/file-upload-sessions/index.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/types.d.ts +53 -0
- package/dist/storage/file-upload-sessions/types.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/utils.d.ts +11 -0
- package/dist/storage/file-upload-sessions/utils.d.ts.map +1 -0
- package/dist/storage/in-memory/index.d.ts +105 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -0
- package/dist/storage/in-memory/testing.d.ts +8 -0
- package/dist/storage/in-memory/testing.d.ts.map +1 -0
- package/dist/storage/index.d.ts +44 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +144 -0
- package/dist/storage/index.js.map +9 -0
- package/dist/storage/migrations/check-schema.d.ts +19 -0
- package/dist/storage/migrations/check-schema.d.ts.map +1 -0
- package/dist/storage/migrations/index.d.ts +5 -0
- package/dist/storage/migrations/index.d.ts.map +1 -0
- package/dist/storage/migrations/migrate-storage.d.ts +6 -0
- package/dist/storage/migrations/migrate-storage.d.ts.map +1 -0
- package/dist/storage/migrations/migration-set.d.ts +27 -0
- package/dist/storage/migrations/migration-set.d.ts.map +1 -0
- package/dist/storage/migrations/types.d.ts +115 -0
- package/dist/storage/migrations/types.d.ts.map +1 -0
- package/dist/storage/objects/in-memory.d.ts +126 -0
- package/dist/storage/objects/in-memory.d.ts.map +1 -0
- package/dist/storage/objects/index.d.ts +2 -0
- package/dist/storage/objects/index.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +222 -0
- package/dist/storage/objects/types.d.ts.map +1 -0
- package/dist/storage/ontology/commits.d.ts +117 -0
- package/dist/storage/ontology/commits.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/commits.d.ts +12 -0
- package/dist/storage/ontology/in-memory/commits.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/index.d.ts +36 -0
- package/dist/storage/ontology/in-memory/index.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations-finalization.d.ts +5 -0
- package/dist/storage/ontology/in-memory/materializations-finalization.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations-state.d.ts +20 -0
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations-work.d.ts +6 -0
- package/dist/storage/ontology/in-memory/materializations-work.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations.d.ts +101 -0
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/outbox.d.ts +19 -0
- package/dist/storage/ontology/in-memory/outbox.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/shared-state.d.ts +48 -0
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/sources.d.ts +23 -0
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/testing.d.ts +11 -0
- package/dist/storage/ontology/in-memory/testing.d.ts.map +1 -0
- package/dist/storage/ontology/index.d.ts +16 -0
- package/dist/storage/ontology/index.d.ts.map +1 -0
- package/dist/storage/ontology/materializations.d.ts +333 -0
- package/dist/storage/ontology/materializations.d.ts.map +1 -0
- package/dist/storage/ontology/outbox.d.ts +66 -0
- package/dist/storage/ontology/outbox.d.ts.map +1 -0
- package/dist/storage/ontology/provider-header-validation.d.ts +4 -0
- package/dist/storage/ontology/provider-header-validation.d.ts.map +1 -0
- package/dist/storage/ontology/provider-validation.d.ts +6 -0
- package/dist/storage/ontology/provider-validation.d.ts.map +1 -0
- package/dist/storage/ontology/provider-work.d.ts +12 -0
- package/dist/storage/ontology/provider-work.d.ts.map +1 -0
- package/dist/storage/ontology/provider.d.ts +191 -0
- package/dist/storage/ontology/provider.d.ts.map +1 -0
- package/dist/storage/ontology/provider.js +115 -0
- package/dist/storage/ontology/provider.js.map +9 -0
- package/dist/storage/ontology/sources.d.ts +151 -0
- package/dist/storage/ontology/sources.d.ts.map +1 -0
- package/dist/storage/operation-scope.d.ts +32 -0
- package/dist/storage/operation-scope.d.ts.map +1 -0
- package/dist/storage/operation-scope.js +22 -0
- package/dist/storage/operation-scope.js.map +9 -0
- package/dist/storage/pagination.d.ts +11 -0
- package/dist/storage/pagination.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/errors.d.ts +7 -0
- package/dist/storage/pipeline-runs/errors.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/in-memory.d.ts +26 -0
- package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/index.d.ts +4 -0
- package/dist/storage/pipeline-runs/index.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/types.d.ts +133 -0
- package/dist/storage/pipeline-runs/types.d.ts.map +1 -0
- package/dist/storage/projection-runs/errors.d.ts +9 -0
- package/dist/storage/projection-runs/errors.d.ts.map +1 -0
- package/dist/storage/projection-runs/in-memory.d.ts +42 -0
- package/dist/storage/projection-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/projection-runs/index.d.ts +5 -0
- package/dist/storage/projection-runs/index.d.ts.map +1 -0
- package/dist/storage/projection-runs/lifecycle.d.ts +93 -0
- package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -0
- package/dist/storage/projection-runs/lifecycle.js +64 -0
- package/dist/storage/projection-runs/lifecycle.js.map +9 -0
- package/dist/storage/projection-runs/types.d.ts +175 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -0
- package/dist/storage/rules/in-memory.d.ts +26 -0
- package/dist/storage/rules/in-memory.d.ts.map +1 -0
- package/dist/storage/rules/index.d.ts +3 -0
- package/dist/storage/rules/index.d.ts.map +1 -0
- package/dist/storage/rules/types.d.ts +60 -0
- package/dist/storage/rules/types.d.ts.map +1 -0
- package/dist/storage/run-listing.d.ts +36 -0
- package/dist/storage/run-listing.d.ts.map +1 -0
- package/dist/storage/sync-runs/errors.d.ts +8 -0
- package/dist/storage/sync-runs/errors.d.ts.map +1 -0
- package/dist/storage/sync-runs/in-memory.d.ts +16 -0
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/sync-runs/index.d.ts +4 -0
- package/dist/storage/sync-runs/index.d.ts.map +1 -0
- package/dist/storage/sync-runs/types.d.ts +85 -0
- package/dist/storage/sync-runs/types.d.ts.map +1 -0
- package/dist/storage/timeseries/index.d.ts +2 -0
- package/dist/storage/timeseries/index.d.ts.map +1 -0
- package/dist/storage/timeseries/store.d.ts +46 -0
- package/dist/storage/timeseries/store.d.ts.map +1 -0
- package/dist/storage/timeseries/types.d.ts +50 -0
- package/dist/storage/timeseries/types.d.ts.map +1 -0
- package/dist/storage/transaction.d.ts +4 -0
- package/dist/storage/transaction.d.ts.map +1 -0
- package/dist/storage/types.d.ts +78 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/webhook-deliveries/in-memory.d.ts +18 -0
- package/dist/storage/webhook-deliveries/in-memory.d.ts.map +1 -0
- package/dist/storage/webhook-deliveries/index.d.ts +3 -0
- package/dist/storage/webhook-deliveries/index.d.ts.map +1 -0
- package/dist/storage/webhook-deliveries/types.d.ts +43 -0
- package/dist/storage/webhook-deliveries/types.d.ts.map +1 -0
- package/dist/storage/webhook-runs/errors.d.ts +7 -0
- package/dist/storage/webhook-runs/errors.d.ts.map +1 -0
- package/dist/storage/webhook-runs/in-memory.d.ts +16 -0
- package/dist/storage/webhook-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/webhook-runs/index.d.ts +4 -0
- package/dist/storage/webhook-runs/index.d.ts.map +1 -0
- package/dist/storage/webhook-runs/types.d.ts +66 -0
- package/dist/storage/webhook-runs/types.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/errors.d.ts +7 -0
- package/dist/storage/workflow-interventions/errors.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/in-memory.d.ts +18 -0
- package/dist/storage/workflow-interventions/in-memory.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/index.d.ts +4 -0
- package/dist/storage/workflow-interventions/index.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/types.d.ts +94 -0
- package/dist/storage/workflow-interventions/types.d.ts.map +1 -0
- package/dist/storage/workflow-runs/errors.d.ts +7 -0
- package/dist/storage/workflow-runs/errors.d.ts.map +1 -0
- package/dist/storage/workflow-runs/in-memory.d.ts +83 -0
- package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/workflow-runs/index.d.ts +4 -0
- package/dist/storage/workflow-runs/index.d.ts.map +1 -0
- package/dist/storage/workflow-runs/types.d.ts +305 -0
- package/dist/storage/workflow-runs/types.d.ts.map +1 -0
- package/dist/syncs/builders.d.ts +9 -0
- package/dist/syncs/builders.d.ts.map +1 -0
- package/dist/syncs/errors.d.ts +4 -0
- package/dist/syncs/errors.d.ts.map +1 -0
- package/dist/syncs/index.d.ts +7 -0
- package/dist/syncs/index.d.ts.map +1 -0
- package/dist/syncs/request.d.ts +41 -0
- package/dist/syncs/request.d.ts.map +1 -0
- package/dist/syncs/types.d.ts +76 -0
- package/dist/syncs/types.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts +16 -0
- package/dist/testing/agent-storage-contract.d.ts.map +1 -0
- package/dist/testing/auth-storage-contract.d.ts +16 -0
- package/dist/testing/auth-storage-contract.d.ts.map +1 -0
- package/dist/testing/blob-storage-contract.d.ts +10 -0
- package/dist/testing/blob-storage-contract.d.ts.map +1 -0
- package/dist/testing/broker-contract.d.ts +39 -0
- package/dist/testing/broker-contract.d.ts.map +1 -0
- package/dist/testing/effective-storage-contract.d.ts +7 -0
- package/dist/testing/effective-storage-contract.d.ts.map +1 -0
- package/dist/testing/index.d.ts +15 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +7000 -0
- package/dist/testing/index.js.map +24 -0
- package/dist/testing/lake-storage-contract.d.ts +29 -0
- package/dist/testing/lake-storage-contract.d.ts.map +1 -0
- package/dist/testing/materialization-failure-contract.d.ts +26 -0
- package/dist/testing/materialization-failure-contract.d.ts.map +1 -0
- package/dist/testing/materializer-fixture.d.ts +35 -0
- package/dist/testing/materializer-fixture.d.ts.map +1 -0
- package/dist/testing/materializer-storage-contract.d.ts +7 -0
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -0
- package/dist/testing/object-query-contract.d.ts +21 -0
- package/dist/testing/object-query-contract.d.ts.map +1 -0
- package/dist/testing/ontology-contract-fixture.d.ts +33 -0
- package/dist/testing/ontology-contract-fixture.d.ts.map +1 -0
- package/dist/testing/ontology-storage-contract.d.ts +21 -0
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -0
- package/dist/testing/projection-run-storage-contract.d.ts +10 -0
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -0
- package/dist/testing/queues-contract.d.ts +31 -0
- package/dist/testing/queues-contract.d.ts.map +1 -0
- package/dist/testing/sandboxes-contract.d.ts +31 -0
- package/dist/testing/sandboxes-contract.d.ts.map +1 -0
- package/dist/tsconfig.json +5 -0
- package/dist/webhooks/builders.d.ts +41 -0
- package/dist/webhooks/builders.d.ts.map +1 -0
- package/dist/webhooks/connector.d.ts +10 -0
- package/dist/webhooks/connector.d.ts.map +1 -0
- package/dist/webhooks/errors.d.ts +4 -0
- package/dist/webhooks/errors.d.ts.map +1 -0
- package/dist/webhooks/index.d.ts +9 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/registry.d.ts +7 -0
- package/dist/webhooks/registry.d.ts.map +1 -0
- package/dist/webhooks/types.d.ts +79 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/dist/webhooks/unverified.d.ts +57 -0
- package/dist/webhooks/unverified.d.ts.map +1 -0
- package/dist/workers/errors.d.ts +17 -0
- package/dist/workers/errors.d.ts.map +1 -0
- package/dist/workers/index.d.ts +7 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +506 -0
- package/dist/workers/index.js.map +13 -0
- package/dist/workers/queue-delivery.d.ts +38 -0
- package/dist/workers/queue-delivery.d.ts.map +1 -0
- package/dist/workers/queue-worker.d.ts +30 -0
- package/dist/workers/queue-worker.d.ts.map +1 -0
- package/dist/workers/worker.d.ts +14 -0
- package/dist/workers/worker.d.ts.map +1 -0
- package/dist/workflows/builders.d.ts +27 -0
- package/dist/workflows/builders.d.ts.map +1 -0
- package/dist/workflows/errors.d.ts +11 -0
- package/dist/workflows/errors.d.ts.map +1 -0
- package/dist/workflows/index.d.ts +9 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +108 -0
- package/dist/workflows/index.js.map +9 -0
- package/dist/workflows/request.d.ts +29 -0
- package/dist/workflows/request.d.ts.map +1 -0
- package/dist/workflows/runtime.d.ts +33 -0
- package/dist/workflows/runtime.d.ts.map +1 -0
- package/dist/workflows/snapshot.d.ts +55 -0
- package/dist/workflows/snapshot.d.ts.map +1 -0
- package/dist/workflows/types.d.ts +288 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/validation.d.ts +66 -0
- package/dist/workflows/validation.d.ts.map +1 -0
- package/package.json +312 -0
- package/src/actions/builders/define-action.ts +243 -0
- package/src/actions/builders/params.ts +48 -0
- package/src/actions/builders.ts +2 -0
- package/src/actions/commit-edits.ts +110 -0
- package/src/actions/errors.ts +15 -0
- package/src/actions/index.ts +75 -0
- package/src/actions/read-facade.ts +224 -0
- package/src/actions/registry.ts +135 -0
- package/src/actions/request.ts +407 -0
- package/src/actions/run-id.ts +17 -0
- package/src/actions/runtime.ts +31 -0
- package/src/actions/types/context.ts +224 -0
- package/src/actions/types/definitions.ts +181 -0
- package/src/actions/types/handlers.ts +68 -0
- package/src/actions/types/params.ts +82 -0
- package/src/actions/types.ts +4 -0
- package/src/actions/validation.ts +186 -0
- package/src/actions/validators.ts +56 -0
- package/src/actions/worker.ts +2 -0
- package/src/agents/adapters.ts +647 -0
- package/src/agents/api-gateway.ts +57 -0
- package/src/agents/builders.ts +46 -0
- package/src/agents/context-model.ts +41 -0
- package/src/agents/context-resolution.ts +43 -0
- package/src/agents/context.ts +185 -0
- package/src/agents/dispatch.ts +107 -0
- package/src/agents/errors.ts +40 -0
- package/src/agents/ids.ts +24 -0
- package/src/agents/index.ts +122 -0
- package/src/agents/message.ts +91 -0
- package/src/agents/prompt.ts +45 -0
- package/src/agents/request.ts +198 -0
- package/src/agents/runtime.ts +124 -0
- package/src/agents/streams.ts +194 -0
- package/src/agents/types.ts +70 -0
- package/src/agents/validation.ts +151 -0
- package/src/auth/access-tokens.ts +125 -0
- package/src/auth/audience.ts +28 -0
- package/src/auth/cookies.ts +263 -0
- package/src/auth/csrf.ts +41 -0
- package/src/auth/errors.ts +19 -0
- package/src/auth/index.ts +149 -0
- package/src/auth/runtime.ts +1642 -0
- package/src/auth/session-cache.ts +112 -0
- package/src/auth/sessions.ts +55 -0
- package/src/auth/strategy.ts +46 -0
- package/src/auth/types.ts +573 -0
- package/src/auth/validation.ts +241 -0
- package/src/authorization/application-access.ts +34 -0
- package/src/authorization/decision.ts +215 -0
- package/src/authorization/errors.ts +12 -0
- package/src/authorization/event-visibility.ts +99 -0
- package/src/authorization/grant-kinds.ts +149 -0
- package/src/authorization/index.ts +24 -0
- package/src/authorization/resolve.ts +101 -0
- package/src/authorization/run-visibility.ts +78 -0
- package/src/authorization/types.ts +52 -0
- package/src/blob-storage/browser.ts +28 -0
- package/src/blob-storage/constants.ts +9 -0
- package/src/blob-storage/derive.ts +13 -0
- package/src/blob-storage/errors.ts +6 -0
- package/src/blob-storage/in-memory.ts +74 -0
- package/src/blob-storage/index.ts +37 -0
- package/src/blob-storage/types.ts +143 -0
- package/src/blob-storage/utils.ts +126 -0
- package/src/blob-storage/validation.ts +58 -0
- package/src/bootstrap/discovery.ts +507 -0
- package/src/bootstrap/index.ts +26 -0
- package/src/bootstrap/ontology-type-manifest.ts +316 -0
- package/src/broker/errors.ts +15 -0
- package/src/broker/in-memory.ts +511 -0
- package/src/broker/index.ts +12 -0
- package/src/broker/types.ts +129 -0
- package/src/connectors/builders.ts +33 -0
- package/src/connectors/errors.ts +15 -0
- package/src/connectors/index.ts +9 -0
- package/src/connectors/runtime.ts +100 -0
- package/src/connectors/types.ts +64 -0
- package/src/datasets/builders.ts +233 -0
- package/src/datasets/errors.ts +3 -0
- package/src/datasets/index.ts +13 -0
- package/src/datasets/types.ts +52 -0
- package/src/datasets/validation.ts +251 -0
- package/src/edits/errors.ts +6 -0
- package/src/edits/index.ts +24 -0
- package/src/edits/normalize.ts +87 -0
- package/src/edits/properties.ts +153 -0
- package/src/edits/recorder.ts +312 -0
- package/src/edits/types.ts +275 -0
- package/src/error-reporting/capability.ts +160 -0
- package/src/error-reporting/internal.ts +13 -0
- package/src/error-reporting/normalize.ts +35 -0
- package/src/error-reporting/reporter.ts +65 -0
- package/src/error-reporting/types.ts +125 -0
- package/src/events/definitions.ts +241 -0
- package/src/events/envelope.ts +68 -0
- package/src/events/errors.ts +7 -0
- package/src/events/index.ts +167 -0
- package/src/events/outbox-dispatcher.ts +534 -0
- package/src/events/property-changes.ts +9 -0
- package/src/events/runtime.ts +401 -0
- package/src/events/scope.ts +71 -0
- package/src/events/selectors/builder.ts +531 -0
- package/src/events/selectors/index.ts +42 -0
- package/src/events/selectors/predicate.ts +91 -0
- package/src/events/selectors/types.ts +258 -0
- package/src/events/toStoredEvent.ts +35 -0
- package/src/events/types/actions.ts +42 -0
- package/src/events/types/datasets.ts +21 -0
- package/src/events/types/index.ts +206 -0
- package/src/events/types/links.ts +42 -0
- package/src/events/types/objects.ts +38 -0
- package/src/events/types/pipelines.ts +67 -0
- package/src/events/types/rules.ts +31 -0
- package/src/events/types/schedules.ts +15 -0
- package/src/events/types/syncs.ts +27 -0
- package/src/events/types/telemetry.ts +19 -0
- package/src/events/types/workflows.ts +172 -0
- package/src/http/api-routes.ts +384 -0
- package/src/http/index.ts +3 -0
- package/src/http/route-pattern.ts +37 -0
- package/src/index.ts +916 -0
- package/src/json.ts +137 -0
- package/src/lake-storage/definition-updates.ts +263 -0
- package/src/lake-storage/errors.ts +6 -0
- package/src/lake-storage/in-memory.ts +348 -0
- package/src/lake-storage/index.ts +48 -0
- package/src/lake-storage/sql-transforms.ts +67 -0
- package/src/lake-storage/types.ts +135 -0
- package/src/logging/console-logger.ts +63 -0
- package/src/logging/index.ts +43 -0
- package/src/logging/record.ts +126 -0
- package/src/logging/run-logger.ts +350 -0
- package/src/logging/runtime.ts +341 -0
- package/src/logging/stream.ts +38 -0
- package/src/logging/types.ts +156 -0
- package/src/maintenance/index.ts +9 -0
- package/src/maintenance/ontology-maintenance.ts +351 -0
- package/src/maintenance/types.ts +57 -0
- package/src/materialization/dataset-watermark.ts +52 -0
- package/src/materialization/errors.ts +73 -0
- package/src/materialization/events.ts +92 -0
- package/src/materialization/identity.ts +36 -0
- package/src/materialization/index.ts +75 -0
- package/src/materialization/model.ts +394 -0
- package/src/materialization/refs.ts +134 -0
- package/src/materializer/README.md +130 -0
- package/src/materializer/context.ts +75 -0
- package/src/materializer/edits/apply.ts +241 -0
- package/src/materializer/edits/commit.ts +311 -0
- package/src/materializer/edits/execution-units.ts +32 -0
- package/src/materializer/edits/load-state.ts +148 -0
- package/src/materializer/edits/operations.ts +298 -0
- package/src/materializer/edits/plan.ts +192 -0
- package/src/materializer/edits/read-set.ts +79 -0
- package/src/materializer/edits/working-state.ts +171 -0
- package/src/materializer/effective/build-events.ts +197 -0
- package/src/materializer/effective/diff.ts +169 -0
- package/src/materializer/effective/load-state.ts +75 -0
- package/src/materializer/effective/resolve.ts +96 -0
- package/src/materializer/effective/validate.ts +180 -0
- package/src/materializer/execution/commit-lifecycle.ts +57 -0
- package/src/materializer/execution/plan-stream.ts +97 -0
- package/src/materializer/execution/run-correlation.ts +73 -0
- package/src/materializer/execution/work-executor.ts +143 -0
- package/src/materializer/execution/work-records.ts +186 -0
- package/src/materializer/index.ts +109 -0
- package/src/materializer/materializer.ts +64 -0
- package/src/materializer/projections/entry-validator.ts +162 -0
- package/src/materializer/projections/finish-run.ts +194 -0
- package/src/materializer/projections/replace.ts +447 -0
- package/src/materializer/projections/replacement-plan.ts +376 -0
- package/src/materializer/projections/source-materialization.ts +99 -0
- package/src/materializer/shared/abort.ts +7 -0
- package/src/materializer/shared/batching.ts +32 -0
- package/src/materializer/shared/chunking.ts +27 -0
- package/src/materializer/shared/identity.ts +141 -0
- package/src/materializer/shared/normalize.ts +527 -0
- package/src/materializer/shared/projection-run.ts +61 -0
- package/src/materializer/telemetry/append.ts +503 -0
- package/src/materializer/telemetry/plan.ts +363 -0
- package/src/objects/action/errors.ts +56 -0
- package/src/objects/action/index.ts +3 -0
- package/src/objects/action/request.ts +63 -0
- package/src/objects/context/index.ts +6 -0
- package/src/objects/context/resolve.ts +51 -0
- package/src/objects/context/types.ts +31 -0
- package/src/objects/contexts.ts +64 -0
- package/src/objects/errors.ts +7 -0
- package/src/objects/helpers.ts +18 -0
- package/src/objects/index.ts +26 -0
- package/src/objects/link/authorization.ts +26 -0
- package/src/objects/link/endpoints.ts +66 -0
- package/src/objects/link/index.ts +3 -0
- package/src/objects/link/remove.ts +42 -0
- package/src/objects/link/upsert-batch.ts +80 -0
- package/src/objects/link/upsert.ts +56 -0
- package/src/objects/materializer-adapter.ts +307 -0
- package/src/objects/object/delete.ts +47 -0
- package/src/objects/object/index.ts +3 -0
- package/src/objects/object/upsert-batch.ts +57 -0
- package/src/objects/object/upsert.ts +38 -0
- package/src/objects/query/errors.ts +55 -0
- package/src/objects/query/executor.ts +1345 -0
- package/src/objects/query/explain-format.ts +34 -0
- package/src/objects/query/explain.ts +215 -0
- package/src/objects/query/index.ts +77 -0
- package/src/objects/query/ir.ts +211 -0
- package/src/objects/query/normalize.ts +245 -0
- package/src/objects/query/planner.ts +538 -0
- package/src/objects/query/scalar-values.ts +100 -0
- package/src/objects/query/validate.ts +1276 -0
- package/src/objects/runtime-batch.ts +105 -0
- package/src/objects/sdk/index.ts +2 -0
- package/src/objects/sdk/object-handle.ts +139 -0
- package/src/objects/sdk/object-set.ts +224 -0
- package/src/objects/sdk/query-builder.ts +386 -0
- package/src/objects/sdk/query-executor.ts +62 -0
- package/src/objects/sdk/runtime-query-executor.ts +88 -0
- package/src/objects/sdk/telemetry-channel.ts +81 -0
- package/src/objects/sdk/where.ts +87 -0
- package/src/objects/service/action-service.ts +40 -0
- package/src/objects/service/index.ts +6 -0
- package/src/objects/service/link-service.ts +74 -0
- package/src/objects/service/list-service.ts +89 -0
- package/src/objects/service/object-service.ts +28 -0
- package/src/objects/service/telemetry-service.ts +17 -0
- package/src/objects/telemetry/append-batch.ts +74 -0
- package/src/objects/telemetry/history.ts +32 -0
- package/src/objects/telemetry/index.ts +4 -0
- package/src/objects/telemetry/write-batch.ts +52 -0
- package/src/ontology/builders.ts +695 -0
- package/src/ontology/decimal.ts +120 -0
- package/src/ontology/errors.ts +25 -0
- package/src/ontology/index.ts +80 -0
- package/src/ontology/inference/index.ts +215 -0
- package/src/ontology/internal.ts +3 -0
- package/src/ontology/json-schema.ts +123 -0
- package/src/ontology/refs.ts +80 -0
- package/src/ontology/registry.ts +417 -0
- package/src/ontology/tokens.ts +113 -0
- package/src/ontology/types.ts +436 -0
- package/src/ontology/units/index.ts +115 -0
- package/src/ontology/units/quantitative-types.ts +608 -0
- package/src/ontology/units/types.ts +27 -0
- package/src/ontology/validation/index.ts +36 -0
- package/src/ontology/validation/links.ts +126 -0
- package/src/ontology/validation/normalize.ts +215 -0
- package/src/ontology/validation/properties.ts +235 -0
- package/src/ontology/validation/query.ts +300 -0
- package/src/ontology/validation/schema.ts +174 -0
- package/src/ontology/validation/telemetry.ts +53 -0
- package/src/pipelines/builders.ts +155 -0
- package/src/pipelines/errors.ts +3 -0
- package/src/pipelines/index.ts +26 -0
- package/src/pipelines/request.ts +71 -0
- package/src/pipelines/types.ts +199 -0
- package/src/predicates/builders.ts +152 -0
- package/src/predicates/evaluate.ts +107 -0
- package/src/predicates/index.ts +28 -0
- package/src/predicates/types.ts +124 -0
- package/src/predicates/validation.ts +152 -0
- package/src/projections/builders.ts +770 -0
- package/src/projections/errors.ts +3 -0
- package/src/projections/index.ts +32 -0
- package/src/projections/internal.ts +75 -0
- package/src/projections/ownership.ts +134 -0
- package/src/projections/registry.ts +269 -0
- package/src/projections/revision.ts +245 -0
- package/src/projections/types.ts +165 -0
- package/src/projections/validation.ts +531 -0
- package/src/provider-scope.ts +11 -0
- package/src/query.ts +75 -0
- package/src/queues/errors.ts +6 -0
- package/src/queues/in-memory.ts +364 -0
- package/src/queues/index.ts +23 -0
- package/src/queues/types.ts +230 -0
- package/src/rules/builders.ts +126 -0
- package/src/rules/dependencies.ts +76 -0
- package/src/rules/errors.ts +11 -0
- package/src/rules/index.ts +30 -0
- package/src/rules/internal.ts +8 -0
- package/src/rules/types.ts +113 -0
- package/src/rules/validation.ts +153 -0
- package/src/runtime/create.ts +163 -0
- package/src/runtime/errors.ts +8 -0
- package/src/runtime/index.ts +67 -0
- package/src/runtime/internal.ts +7 -0
- package/src/runtime/ontology-mutations.ts +90 -0
- package/src/runtime/scoped.ts +436 -0
- package/src/runtime/sixb.ts +822 -0
- package/src/runtime/storage-readiness.ts +91 -0
- package/src/runtime/types.ts +1401 -0
- package/src/sandboxes/errors.ts +22 -0
- package/src/sandboxes/exec.ts +102 -0
- package/src/sandboxes/index.ts +19 -0
- package/src/sandboxes/sandbox.ts +124 -0
- package/src/scheduler/errors.ts +7 -0
- package/src/scheduler/index.ts +3 -0
- package/src/scheduler/runtime.ts +174 -0
- package/src/schedules/builders.ts +257 -0
- package/src/schedules/cron.ts +166 -0
- package/src/schedules/errors.ts +7 -0
- package/src/schedules/index.ts +44 -0
- package/src/schedules/next-occurrence.ts +217 -0
- package/src/schedules/runtime.ts +241 -0
- package/src/schedules/types.ts +212 -0
- package/src/schedules/validation.ts +398 -0
- package/src/security/applications.ts +11 -0
- package/src/security/builders.ts +128 -0
- package/src/security/errors.ts +3 -0
- package/src/security/every.ts +108 -0
- package/src/security/grants.ts +215 -0
- package/src/security/index.ts +51 -0
- package/src/security/membership-policies.ts +101 -0
- package/src/security/runtime.ts +101 -0
- package/src/security/types.ts +156 -0
- package/src/security/validation.ts +430 -0
- package/src/storage/action-runs/errors.ts +13 -0
- package/src/storage/action-runs/idempotency.ts +68 -0
- package/src/storage/action-runs/in-memory.ts +420 -0
- package/src/storage/action-runs/index.ts +31 -0
- package/src/storage/action-runs/types.ts +169 -0
- package/src/storage/agents/errors.ts +22 -0
- package/src/storage/agents/in-memory.ts +498 -0
- package/src/storage/agents/index.ts +42 -0
- package/src/storage/agents/types.ts +348 -0
- package/src/storage/auth/errors.ts +40 -0
- package/src/storage/auth/in-memory/access-tokens.ts +123 -0
- package/src/storage/auth/in-memory/auth-storage.ts +559 -0
- package/src/storage/auth/in-memory/group-memberships.ts +46 -0
- package/src/storage/auth/in-memory/identities.ts +66 -0
- package/src/storage/auth/in-memory/index.ts +1 -0
- package/src/storage/auth/in-memory/invitations.ts +165 -0
- package/src/storage/auth/in-memory/magic-links.ts +98 -0
- package/src/storage/auth/in-memory/oidc-attempts.ts +75 -0
- package/src/storage/auth/in-memory/service-account-group-memberships.ts +102 -0
- package/src/storage/auth/in-memory/service-accounts.ts +80 -0
- package/src/storage/auth/in-memory/sessions.ts +177 -0
- package/src/storage/auth/in-memory/shared.ts +602 -0
- package/src/storage/auth/in-memory/users.ts +139 -0
- package/src/storage/auth/in-memory.ts +1 -0
- package/src/storage/auth/index.ts +58 -0
- package/src/storage/auth/types.ts +639 -0
- package/src/storage/errors.ts +45 -0
- package/src/storage/file-upload-sessions/errors.ts +24 -0
- package/src/storage/file-upload-sessions/in-memory.ts +161 -0
- package/src/storage/file-upload-sessions/index.ts +19 -0
- package/src/storage/file-upload-sessions/types.ts +61 -0
- package/src/storage/file-upload-sessions/utils.ts +49 -0
- package/src/storage/in-memory/index.ts +297 -0
- package/src/storage/in-memory/testing.ts +21 -0
- package/src/storage/index.ts +489 -0
- package/src/storage/migrations/check-schema.ts +49 -0
- package/src/storage/migrations/index.ts +23 -0
- package/src/storage/migrations/migrate-storage.ts +24 -0
- package/src/storage/migrations/migration-set.ts +270 -0
- package/src/storage/migrations/types.ts +129 -0
- package/src/storage/objects/in-memory.ts +1154 -0
- package/src/storage/objects/index.ts +24 -0
- package/src/storage/objects/types.ts +244 -0
- package/src/storage/ontology/commits.ts +132 -0
- package/src/storage/ontology/in-memory/commits.ts +122 -0
- package/src/storage/ontology/in-memory/index.ts +94 -0
- package/src/storage/ontology/in-memory/materializations-finalization.ts +484 -0
- package/src/storage/ontology/in-memory/materializations-state.ts +183 -0
- package/src/storage/ontology/in-memory/materializations-work.ts +62 -0
- package/src/storage/ontology/in-memory/materializations.ts +1192 -0
- package/src/storage/ontology/in-memory/outbox.ts +227 -0
- package/src/storage/ontology/in-memory/shared-state.ts +161 -0
- package/src/storage/ontology/in-memory/sources.ts +566 -0
- package/src/storage/ontology/in-memory/testing.ts +29 -0
- package/src/storage/ontology/index.ts +119 -0
- package/src/storage/ontology/materializations.ts +414 -0
- package/src/storage/ontology/outbox.ts +79 -0
- package/src/storage/ontology/provider-header-validation.ts +173 -0
- package/src/storage/ontology/provider-validation.ts +36 -0
- package/src/storage/ontology/provider-work.ts +330 -0
- package/src/storage/ontology/provider.ts +852 -0
- package/src/storage/ontology/sources.ts +195 -0
- package/src/storage/operation-scope.ts +248 -0
- package/src/storage/pagination.ts +23 -0
- package/src/storage/pipeline-runs/errors.ts +6 -0
- package/src/storage/pipeline-runs/in-memory.ts +307 -0
- package/src/storage/pipeline-runs/index.ts +19 -0
- package/src/storage/pipeline-runs/types.ts +148 -0
- package/src/storage/projection-runs/errors.ts +15 -0
- package/src/storage/projection-runs/in-memory.ts +321 -0
- package/src/storage/projection-runs/index.ts +36 -0
- package/src/storage/projection-runs/lifecycle.ts +793 -0
- package/src/storage/projection-runs/types.ts +254 -0
- package/src/storage/rules/in-memory.ts +191 -0
- package/src/storage/rules/index.ts +12 -0
- package/src/storage/rules/types.ts +80 -0
- package/src/storage/run-listing.ts +107 -0
- package/src/storage/sync-runs/errors.ts +7 -0
- package/src/storage/sync-runs/in-memory.ts +181 -0
- package/src/storage/sync-runs/index.ts +14 -0
- package/src/storage/sync-runs/types.ts +93 -0
- package/src/storage/timeseries/index.ts +7 -0
- package/src/storage/timeseries/store.ts +214 -0
- package/src/storage/timeseries/types.ts +57 -0
- package/src/storage/transaction.ts +56 -0
- package/src/storage/types.ts +299 -0
- package/src/storage/webhook-deliveries/in-memory.ts +108 -0
- package/src/storage/webhook-deliveries/index.ts +9 -0
- package/src/storage/webhook-deliveries/types.ts +41 -0
- package/src/storage/webhook-runs/errors.ts +6 -0
- package/src/storage/webhook-runs/in-memory.ts +131 -0
- package/src/storage/webhook-runs/index.ts +12 -0
- package/src/storage/webhook-runs/types.ts +69 -0
- package/src/storage/workflow-interventions/errors.ts +6 -0
- package/src/storage/workflow-interventions/in-memory.ts +192 -0
- package/src/storage/workflow-interventions/index.ts +14 -0
- package/src/storage/workflow-interventions/types.ts +100 -0
- package/src/storage/workflow-runs/errors.ts +6 -0
- package/src/storage/workflow-runs/in-memory.ts +777 -0
- package/src/storage/workflow-runs/index.ts +45 -0
- package/src/storage/workflow-runs/types.ts +344 -0
- package/src/syncs/builders.ts +101 -0
- package/src/syncs/errors.ts +3 -0
- package/src/syncs/index.ts +22 -0
- package/src/syncs/request.ts +91 -0
- package/src/syncs/types.ts +136 -0
- package/src/testing/agent-storage-contract.ts +824 -0
- package/src/testing/auth-storage-contract.ts +1932 -0
- package/src/testing/blob-storage-contract.ts +108 -0
- package/src/testing/broker-contract.ts +819 -0
- package/src/testing/effective-storage-contract.ts +182 -0
- package/src/testing/index.ts +65 -0
- package/src/testing/lake-storage-contract.ts +699 -0
- package/src/testing/materialization-failure-contract.ts +66 -0
- package/src/testing/materializer-fixture.ts +119 -0
- package/src/testing/materializer-storage-contract.ts +389 -0
- package/src/testing/object-query-contract.ts +1205 -0
- package/src/testing/ontology-contract-fixture.ts +192 -0
- package/src/testing/ontology-storage-contract.ts +922 -0
- package/src/testing/projection-run-storage-contract.ts +372 -0
- package/src/testing/queues-contract.ts +634 -0
- package/src/testing/sandboxes-contract.ts +404 -0
- package/src/webhooks/builders.ts +154 -0
- package/src/webhooks/connector.ts +19 -0
- package/src/webhooks/errors.ts +3 -0
- package/src/webhooks/index.ts +25 -0
- package/src/webhooks/registry.ts +127 -0
- package/src/webhooks/types.ts +98 -0
- package/src/webhooks/unverified.ts +82 -0
- package/src/workers/errors.ts +25 -0
- package/src/workers/index.ts +6 -0
- package/src/workers/queue-delivery.ts +309 -0
- package/src/workers/queue-worker.ts +260 -0
- package/src/workers/worker.ts +87 -0
- package/src/workflows/builders.ts +471 -0
- package/src/workflows/errors.ts +13 -0
- package/src/workflows/index.ts +94 -0
- package/src/workflows/request.ts +161 -0
- package/src/workflows/runtime.ts +68 -0
- package/src/workflows/snapshot.ts +383 -0
- package/src/workflows/types.ts +781 -0
- package/src/workflows/validation.ts +572 -0
|
@@ -0,0 +1,1642 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto"
|
|
2
|
+
import {
|
|
3
|
+
type AuthorizationContext,
|
|
4
|
+
canAccessApplication,
|
|
5
|
+
resolveAuthorizationContext,
|
|
6
|
+
} from "../authorization"
|
|
7
|
+
import {
|
|
8
|
+
canPerformMembershipOperation,
|
|
9
|
+
type GroupReference,
|
|
10
|
+
type MembershipOperation,
|
|
11
|
+
type MembershipPolicyScope,
|
|
12
|
+
missingMembershipGroupIds,
|
|
13
|
+
resolveMembershipPolicyScope,
|
|
14
|
+
type SecurityRegistry,
|
|
15
|
+
} from "../security"
|
|
16
|
+
import type { Storage } from "../storage"
|
|
17
|
+
import {
|
|
18
|
+
type AccessTokenRecord,
|
|
19
|
+
type AuthStorage,
|
|
20
|
+
AuthStorageError,
|
|
21
|
+
type InvitationRecord,
|
|
22
|
+
type ServiceAccountGroupMembershipRecord,
|
|
23
|
+
type ServiceAccountRecord,
|
|
24
|
+
type SessionRecord,
|
|
25
|
+
type UserRecord,
|
|
26
|
+
} from "../storage/auth"
|
|
27
|
+
import { paginate } from "../storage/pagination"
|
|
28
|
+
import {
|
|
29
|
+
createAccessTokenCredential,
|
|
30
|
+
getBearerAccessTokenValue,
|
|
31
|
+
hashAccessTokenSecret,
|
|
32
|
+
parseAccessTokenValue,
|
|
33
|
+
} from "./access-tokens"
|
|
34
|
+
import type { AuthSessionAudience } from "./audience"
|
|
35
|
+
import {
|
|
36
|
+
getCookie,
|
|
37
|
+
type ResolvedAuthCookieOptions,
|
|
38
|
+
resolveAuthCookieOptionsForAudience,
|
|
39
|
+
} from "./cookies"
|
|
40
|
+
import { AuthRuntimeError } from "./errors"
|
|
41
|
+
import { SessionCache } from "./session-cache"
|
|
42
|
+
import { hashSessionSecret, parseSessionCookieValue } from "./sessions"
|
|
43
|
+
import type {
|
|
44
|
+
AuthenticatedAuthSession,
|
|
45
|
+
AuthenticatedRequestAuthSession,
|
|
46
|
+
AuthenticatedUserRequestSession,
|
|
47
|
+
AuthRequestResult,
|
|
48
|
+
AuthSessionResolutionOptions,
|
|
49
|
+
AuthSessionResult,
|
|
50
|
+
AuthStrategy,
|
|
51
|
+
CreateAccessTokenResult,
|
|
52
|
+
CreatePersonalAccessTokenInput,
|
|
53
|
+
CreateServiceAccountAccessTokenInput,
|
|
54
|
+
CreateServiceAccountAccessTokenResult,
|
|
55
|
+
CreateServiceAccountInput,
|
|
56
|
+
CreateServiceAccountResult,
|
|
57
|
+
DisableServiceAccountInput,
|
|
58
|
+
DisableServiceAccountResult,
|
|
59
|
+
GetInvitationOptionsResult,
|
|
60
|
+
GetMembershipOptionsResult,
|
|
61
|
+
InvitationDeliveryAuthStrategy,
|
|
62
|
+
InvitationGroupOption,
|
|
63
|
+
InvitationRecipientStatus,
|
|
64
|
+
InviteDeliveryResult,
|
|
65
|
+
InviteDeliveryStatus,
|
|
66
|
+
InviteUserInput,
|
|
67
|
+
InviteUserOptions,
|
|
68
|
+
InviteUserResult,
|
|
69
|
+
ListInvitationsInput,
|
|
70
|
+
ListInvitationsResult,
|
|
71
|
+
ListMembersInput,
|
|
72
|
+
ListMembersResult,
|
|
73
|
+
ListPersonalAccessTokensResult,
|
|
74
|
+
ListServiceAccountAccessTokensInput,
|
|
75
|
+
ListServiceAccountAccessTokensResult,
|
|
76
|
+
ListServiceAccountsResult,
|
|
77
|
+
MemberSummary,
|
|
78
|
+
MembershipCapabilities,
|
|
79
|
+
Principal,
|
|
80
|
+
ReactivateMemberInput,
|
|
81
|
+
ReactivateMemberResult,
|
|
82
|
+
ResolvedAuthConfig,
|
|
83
|
+
RevokeAccessTokenResult,
|
|
84
|
+
RevokeInvitationInput,
|
|
85
|
+
RevokeInvitationResult,
|
|
86
|
+
RevokePersonalAccessTokenInput,
|
|
87
|
+
RevokeServiceAccountAccessTokenInput,
|
|
88
|
+
RevokeServiceAccountAccessTokenResult,
|
|
89
|
+
SecurityContext,
|
|
90
|
+
SixbAuthConfig,
|
|
91
|
+
SuspendMemberInput,
|
|
92
|
+
SuspendMemberResult,
|
|
93
|
+
UpdateMemberGroupsInput,
|
|
94
|
+
UpdateMemberGroupsResult,
|
|
95
|
+
} from "./types"
|
|
96
|
+
import {
|
|
97
|
+
assertNonEmpty,
|
|
98
|
+
isInvitationDeliveryAuthStrategy,
|
|
99
|
+
normalizePagination,
|
|
100
|
+
resolveAuthConfig,
|
|
101
|
+
resolveAuthSessionAudience,
|
|
102
|
+
resolveInvitationExpiresAt,
|
|
103
|
+
sanitizeReturnTo,
|
|
104
|
+
} from "./validation"
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
DEFAULT_AUTH_INVITATION_TTL_MS,
|
|
108
|
+
DEFAULT_AUTH_SESSION_CACHE_TTL_MS,
|
|
109
|
+
DEFAULT_AUTH_SESSION_IDLE_TIMEOUT_MS,
|
|
110
|
+
DEFAULT_AUTH_SESSION_RENEWAL_WINDOW_MS,
|
|
111
|
+
MAX_AUTH_INVITATION_TTL_MS,
|
|
112
|
+
resolveAuthConfig,
|
|
113
|
+
} from "./validation"
|
|
114
|
+
|
|
115
|
+
// Throttle `lastSeenAt` writes: only refresh when the previous value is older
|
|
116
|
+
// than this, so an active session does not incur a write on every request.
|
|
117
|
+
const SESSION_TOUCH_INTERVAL_MS = 60_000
|
|
118
|
+
const ACCESS_TOKEN_TOUCH_INTERVAL_MS = 60_000
|
|
119
|
+
|
|
120
|
+
export interface AuthRuntimeOptions {
|
|
121
|
+
readonly projectId: string
|
|
122
|
+
readonly storage: Storage
|
|
123
|
+
readonly security: SecurityRegistry
|
|
124
|
+
readonly config?: SixbAuthConfig
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export class AuthRuntime {
|
|
128
|
+
private readonly projectId: string
|
|
129
|
+
private readonly storage: Storage
|
|
130
|
+
private readonly security: SecurityRegistry
|
|
131
|
+
private readonly config: ResolvedAuthConfig
|
|
132
|
+
private readonly sessionCache: SessionCache | null
|
|
133
|
+
|
|
134
|
+
constructor(options: AuthRuntimeOptions) {
|
|
135
|
+
this.projectId = options.projectId
|
|
136
|
+
this.storage = options.storage
|
|
137
|
+
this.security = options.security
|
|
138
|
+
this.config = resolveAuthConfig(options.config)
|
|
139
|
+
this.sessionCache =
|
|
140
|
+
this.config.session.cacheTtlMs > 0 ? new SessionCache(this.config.session.cacheTtlMs) : null
|
|
141
|
+
|
|
142
|
+
if (this.isEnabled() && !this.storage.auth) {
|
|
143
|
+
throw new AuthRuntimeError(
|
|
144
|
+
"auth_storage_missing",
|
|
145
|
+
"[Sixb] Auth is enabled but storage.auth is not configured."
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
isEnabled(): boolean {
|
|
151
|
+
const strategy = this.config.strategy
|
|
152
|
+
return strategy !== null && strategy.kind !== "disabled" && strategy.disabled !== true
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getStrategy(): AuthStrategy | null {
|
|
156
|
+
return this.config.strategy
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
createSessionDeadlines(now: Date): {
|
|
160
|
+
readonly expiresAt: Date
|
|
161
|
+
readonly absoluteExpiresAt?: Date
|
|
162
|
+
} {
|
|
163
|
+
const absoluteTimeoutMs = this.config.session.absoluteTimeoutMs
|
|
164
|
+
return {
|
|
165
|
+
expiresAt: new Date(now.getTime() + this.config.session.idleTimeoutMs),
|
|
166
|
+
...(absoluteTimeoutMs === undefined
|
|
167
|
+
? {}
|
|
168
|
+
: { absoluteExpiresAt: new Date(now.getTime() + absoluteTimeoutMs) }),
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
getCookieOptions(options: AuthSessionResolutionOptions = {}): ResolvedAuthCookieOptions {
|
|
173
|
+
return resolveAuthCookieOptionsForAudience(this.config.cookies, options.audience)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
assertCanServeHttp(params: { readonly production: boolean }): void {
|
|
177
|
+
const strategy = this.config.strategy
|
|
178
|
+
|
|
179
|
+
if (!strategy) {
|
|
180
|
+
if (params.production) {
|
|
181
|
+
throw new AuthRuntimeError(
|
|
182
|
+
"production_auth_required",
|
|
183
|
+
"[SixbServer] Auth is required in production. Configure auth or use an explicit disabled auth strategy."
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (params.production && strategy.developmentOnly) {
|
|
190
|
+
throw new AuthRuntimeError(
|
|
191
|
+
"production_auth_required",
|
|
192
|
+
`[SixbServer] Auth strategy '${strategy.id}' is development-only and cannot be used in production.`
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (
|
|
197
|
+
params.production &&
|
|
198
|
+
(strategy.kind === "disabled" || strategy.disabled === true) &&
|
|
199
|
+
strategy.allowDisabledInProduction !== true
|
|
200
|
+
) {
|
|
201
|
+
throw new AuthRuntimeError(
|
|
202
|
+
"production_auth_required",
|
|
203
|
+
"[SixbServer] Disabled auth in production requires allowDisabledInProduction: true."
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async getSession(
|
|
209
|
+
request: Request,
|
|
210
|
+
options?: AuthSessionResolutionOptions & { readonly credentialSource?: "session" }
|
|
211
|
+
): Promise<AuthSessionResult>
|
|
212
|
+
async getSession(
|
|
213
|
+
request: Request,
|
|
214
|
+
options: AuthSessionResolutionOptions & { readonly credentialSource: "accessToken" | "any" }
|
|
215
|
+
): Promise<AuthRequestResult>
|
|
216
|
+
async getSession(
|
|
217
|
+
request: Request,
|
|
218
|
+
options: AuthSessionResolutionOptions
|
|
219
|
+
): Promise<AuthRequestResult>
|
|
220
|
+
async getSession(
|
|
221
|
+
request: Request,
|
|
222
|
+
options: AuthSessionResolutionOptions = {}
|
|
223
|
+
): Promise<AuthSessionResult | AuthRequestResult> {
|
|
224
|
+
if (!this.isEnabled()) {
|
|
225
|
+
return { authenticated: false, reason: "auth_disabled" }
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const audience = resolveAuthSessionAudience(options.audience)
|
|
229
|
+
const credentialSource = options.credentialSource ?? "session"
|
|
230
|
+
|
|
231
|
+
if (credentialSource !== "session") {
|
|
232
|
+
const authorizationHeader = request.headers.get("authorization")
|
|
233
|
+
const tokenValue = getBearerAccessTokenValue(request)
|
|
234
|
+
if (tokenValue) {
|
|
235
|
+
return this.resolveAccessTokenSession(request, tokenValue)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (authorizationHeader) {
|
|
239
|
+
return { authenticated: false, reason: "invalid_access_token" }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (credentialSource === "accessToken") {
|
|
243
|
+
return { authenticated: false, reason: "missing_access_token" }
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return this.resolveCookieSession(request, audience, options.sessionActivity)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private async resolveCookieSession(
|
|
251
|
+
request: Request,
|
|
252
|
+
audience: ReturnType<typeof resolveAuthSessionAudience>,
|
|
253
|
+
activity: AuthSessionResolutionOptions["sessionActivity"]
|
|
254
|
+
): Promise<AuthSessionResult> {
|
|
255
|
+
const cookieOptions = this.getCookieOptions({ audience })
|
|
256
|
+
const cookieValue = getCookie(request, cookieOptions.sessionCookieName)
|
|
257
|
+
if (!cookieValue) {
|
|
258
|
+
return { authenticated: false, reason: "missing_cookie" }
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const parts = parseSessionCookieValue(cookieValue)
|
|
262
|
+
if (!parts) {
|
|
263
|
+
return { authenticated: false, reason: "invalid_cookie" }
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const tokenHash = hashSessionSecret(parts.sessionSecret)
|
|
267
|
+
const nowMs = Date.now()
|
|
268
|
+
|
|
269
|
+
const cached = this.sessionCache?.get({
|
|
270
|
+
sessionId: parts.sessionId,
|
|
271
|
+
tokenHash,
|
|
272
|
+
audience,
|
|
273
|
+
nowMs,
|
|
274
|
+
})
|
|
275
|
+
if (cached) {
|
|
276
|
+
if (activity !== "foreground" || !this.canRenewSession(cached.session, nowMs)) {
|
|
277
|
+
return cached
|
|
278
|
+
}
|
|
279
|
+
this.sessionCache?.invalidate(parts.sessionId)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const storage = this.requireAuthStorage()
|
|
283
|
+
const now = new Date(nowMs)
|
|
284
|
+
let session = await storage.sessions.findValidByTokenHash({
|
|
285
|
+
projectId: this.projectId,
|
|
286
|
+
id: parts.sessionId,
|
|
287
|
+
audience,
|
|
288
|
+
tokenHash,
|
|
289
|
+
now,
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
if (!session) {
|
|
293
|
+
return { authenticated: false, reason: "invalid_session" }
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let sessionRenewed = false
|
|
297
|
+
if (activity === "foreground" && this.canRenewSession(session, nowMs)) {
|
|
298
|
+
const renewed = await storage.sessions.renewIfValid({
|
|
299
|
+
projectId: this.projectId,
|
|
300
|
+
id: parts.sessionId,
|
|
301
|
+
audience,
|
|
302
|
+
tokenHash,
|
|
303
|
+
now,
|
|
304
|
+
expiresAt: this.getRenewedSessionExpiresAt(session, nowMs),
|
|
305
|
+
})
|
|
306
|
+
if (!renewed) {
|
|
307
|
+
this.sessionCache?.invalidate(parts.sessionId)
|
|
308
|
+
return { authenticated: false, reason: "invalid_session" }
|
|
309
|
+
}
|
|
310
|
+
session = renewed
|
|
311
|
+
sessionRenewed = true
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const user = await storage.users.getById({
|
|
315
|
+
projectId: this.projectId,
|
|
316
|
+
id: session.userId,
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
if (!user) {
|
|
320
|
+
return { authenticated: false, reason: "missing_user" }
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (user.status === "suspended") {
|
|
324
|
+
return { authenticated: false, reason: "suspended_user" }
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const memberships = await storage.groupMemberships.listForUser({
|
|
328
|
+
projectId: this.projectId,
|
|
329
|
+
userId: user.id,
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
if (!sessionRenewed) {
|
|
333
|
+
await this.touchSessionLastSeen(storage, session, now)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const result: AuthenticatedAuthSession = {
|
|
337
|
+
authenticated: true,
|
|
338
|
+
credentialSource: "session",
|
|
339
|
+
principal: { type: "user", id: user.id },
|
|
340
|
+
user,
|
|
341
|
+
session,
|
|
342
|
+
groupIds: memberships.map((membership) => membership.groupId),
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
this.sessionCache?.set({
|
|
346
|
+
sessionId: parts.sessionId,
|
|
347
|
+
tokenHash,
|
|
348
|
+
audience,
|
|
349
|
+
session: result,
|
|
350
|
+
nowMs,
|
|
351
|
+
sessionExpiresAtMs: session.expiresAt.getTime(),
|
|
352
|
+
sessionAbsoluteExpiresAtMs: session.absoluteExpiresAt?.getTime(),
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
return sessionRenewed ? { ...result, sessionRenewed: true } : result
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private canRenewSession(session: SessionRecord, nowMs: number): boolean {
|
|
359
|
+
if (session.expiresAt.getTime() - nowMs > this.config.session.renewalWindowMs) {
|
|
360
|
+
return false
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return this.getRenewedSessionExpiresAt(session, nowMs).getTime() > session.expiresAt.getTime()
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private getRenewedSessionExpiresAt(session: SessionRecord, nowMs: number): Date {
|
|
367
|
+
const idleExpiresAtMs = nowMs + this.config.session.idleTimeoutMs
|
|
368
|
+
return new Date(
|
|
369
|
+
session.absoluteExpiresAt
|
|
370
|
+
? Math.min(idleExpiresAtMs, session.absoluteExpiresAt.getTime())
|
|
371
|
+
: idleExpiresAtMs
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private async resolveAccessTokenSession(
|
|
376
|
+
request: Request,
|
|
377
|
+
tokenValue: string
|
|
378
|
+
): Promise<AuthRequestResult> {
|
|
379
|
+
const parts = parseAccessTokenValue(tokenValue)
|
|
380
|
+
if (!parts) {
|
|
381
|
+
return { authenticated: false, reason: "invalid_access_token" }
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const storage = this.requireAuthStorage()
|
|
385
|
+
const now = new Date()
|
|
386
|
+
const accessToken = await storage.accessTokens.findValidByTokenHash({
|
|
387
|
+
projectId: this.projectId,
|
|
388
|
+
id: parts.tokenId,
|
|
389
|
+
kind: parts.kind,
|
|
390
|
+
tokenHash: hashAccessTokenSecret(parts.tokenSecret),
|
|
391
|
+
now,
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
if (!accessToken) {
|
|
395
|
+
return { authenticated: false, reason: "invalid_access_token" }
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
await this.touchAccessTokenLastUsed(storage, accessToken, request, now)
|
|
399
|
+
|
|
400
|
+
if (accessToken.subjectType === "user") {
|
|
401
|
+
const user = await storage.users.getById({
|
|
402
|
+
projectId: this.projectId,
|
|
403
|
+
id: accessToken.subjectId,
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
if (!user) {
|
|
407
|
+
return { authenticated: false, reason: "missing_user" }
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (user.status === "suspended") {
|
|
411
|
+
return { authenticated: false, reason: "suspended_user" }
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const memberships = await storage.groupMemberships.listForUser({
|
|
415
|
+
projectId: this.projectId,
|
|
416
|
+
userId: user.id,
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
return {
|
|
420
|
+
authenticated: true,
|
|
421
|
+
credentialSource: "accessToken",
|
|
422
|
+
principal: { type: "user", id: user.id },
|
|
423
|
+
user,
|
|
424
|
+
accessToken,
|
|
425
|
+
groupIds: constrainTokenGroupIds(
|
|
426
|
+
memberships.map((membership) => membership.groupId),
|
|
427
|
+
accessToken
|
|
428
|
+
),
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const serviceAccount = await storage.serviceAccounts.getById({
|
|
433
|
+
projectId: this.projectId,
|
|
434
|
+
id: accessToken.subjectId,
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
if (!serviceAccount) {
|
|
438
|
+
return { authenticated: false, reason: "missing_service_account" }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (serviceAccount.status === "suspended") {
|
|
442
|
+
return { authenticated: false, reason: "suspended_service_account" }
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const memberships = await storage.serviceAccountGroupMemberships.listForServiceAccount({
|
|
446
|
+
projectId: this.projectId,
|
|
447
|
+
serviceAccountId: serviceAccount.id,
|
|
448
|
+
})
|
|
449
|
+
|
|
450
|
+
return {
|
|
451
|
+
authenticated: true,
|
|
452
|
+
credentialSource: "accessToken",
|
|
453
|
+
principal: { type: "serviceAccount", id: serviceAccount.id },
|
|
454
|
+
serviceAccount,
|
|
455
|
+
accessToken,
|
|
456
|
+
groupIds: constrainTokenGroupIds(
|
|
457
|
+
memberships.map((membership) => membership.groupId),
|
|
458
|
+
accessToken
|
|
459
|
+
),
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Evict a session from the in-process cache. Call this when a session is revoked
|
|
465
|
+
* (e.g. sign-out) so the cached result is dropped before its TTL would expire.
|
|
466
|
+
*/
|
|
467
|
+
invalidateSession(sessionId: string): void {
|
|
468
|
+
this.sessionCache?.invalidate(sessionId)
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Best-effort refresh of `lastSeenAt` for the active-sessions view. Throttled,
|
|
472
|
+
// and never allowed to fail an otherwise-valid request.
|
|
473
|
+
private async touchSessionLastSeen(
|
|
474
|
+
storage: AuthStorage,
|
|
475
|
+
session: { readonly id: string; readonly lastSeenAt?: Date },
|
|
476
|
+
now: Date
|
|
477
|
+
): Promise<void> {
|
|
478
|
+
const lastSeen = session.lastSeenAt?.getTime() ?? 0
|
|
479
|
+
if (now.getTime() - lastSeen < SESSION_TOUCH_INTERVAL_MS) {
|
|
480
|
+
return
|
|
481
|
+
}
|
|
482
|
+
try {
|
|
483
|
+
await storage.sessions.touch({ projectId: this.projectId, id: session.id, lastSeenAt: now })
|
|
484
|
+
} catch {
|
|
485
|
+
// Touch is non-critical; ignore failures so auth still succeeds.
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
private async touchAccessTokenLastUsed(
|
|
490
|
+
storage: AuthStorage,
|
|
491
|
+
accessToken: AccessTokenRecord,
|
|
492
|
+
request: Request,
|
|
493
|
+
now: Date
|
|
494
|
+
): Promise<void> {
|
|
495
|
+
const lastUsed = accessToken.lastUsedAt?.getTime() ?? 0
|
|
496
|
+
if (now.getTime() - lastUsed < ACCESS_TOKEN_TOUCH_INTERVAL_MS) {
|
|
497
|
+
return
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
try {
|
|
501
|
+
await storage.accessTokens.touch({
|
|
502
|
+
projectId: this.projectId,
|
|
503
|
+
id: accessToken.id,
|
|
504
|
+
lastUsedAt: now,
|
|
505
|
+
userAgent: request.headers.get("user-agent")?.trim() || undefined,
|
|
506
|
+
ipAddress: resolveRequestIpAddress(request),
|
|
507
|
+
})
|
|
508
|
+
} catch {
|
|
509
|
+
// Touch is non-critical; ignore failures so auth still succeeds.
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
async requirePrincipal(
|
|
514
|
+
request: Request,
|
|
515
|
+
options: AuthSessionResolutionOptions = {}
|
|
516
|
+
): Promise<Principal> {
|
|
517
|
+
const session = await this.getSession(request, options)
|
|
518
|
+
if (!session.authenticated) {
|
|
519
|
+
throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.")
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return session.principal
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
async requireUser(
|
|
526
|
+
request: Request,
|
|
527
|
+
options: AuthSessionResolutionOptions = {}
|
|
528
|
+
): Promise<AuthenticatedAuthSession> {
|
|
529
|
+
const session = await this.getSession(request, { ...options, credentialSource: "session" })
|
|
530
|
+
if (!session.authenticated) {
|
|
531
|
+
throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.")
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return session
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
async requireUserRequest(
|
|
538
|
+
request: Request,
|
|
539
|
+
options: AuthSessionResolutionOptions = {}
|
|
540
|
+
): Promise<AuthenticatedUserRequestSession> {
|
|
541
|
+
const session = await this.getSession(request, { ...options, credentialSource: "any" })
|
|
542
|
+
if (!session.authenticated) {
|
|
543
|
+
throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.")
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (!isAuthenticatedUserRequestSession(session)) {
|
|
547
|
+
throw new AuthRuntimeError("authorization_denied", "[Sixb] User authentication is required.")
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
return session
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
async createSecurityContext(
|
|
554
|
+
request: Request,
|
|
555
|
+
options: AuthSessionResolutionOptions = {}
|
|
556
|
+
): Promise<SecurityContext> {
|
|
557
|
+
const session = await this.requireUser(request, options)
|
|
558
|
+
return {
|
|
559
|
+
principal: session.principal,
|
|
560
|
+
sessionId: session.session.id,
|
|
561
|
+
projectId: this.projectId,
|
|
562
|
+
correlationId: resolveCorrelationId(request),
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Resolve the authenticated principal's authorization context for a request.
|
|
568
|
+
*
|
|
569
|
+
* Grants resolve eagerly (`groups -> roles -> grants`, subtype-expanded), so
|
|
570
|
+
* the returned context supports synchronous set-lookup checks and `sixb.as()`.
|
|
571
|
+
*/
|
|
572
|
+
async createAuthorizationContext(
|
|
573
|
+
request: Request,
|
|
574
|
+
options: AuthSessionResolutionOptions = {}
|
|
575
|
+
): Promise<AuthorizationContext> {
|
|
576
|
+
const session = await this.getSession(request, options)
|
|
577
|
+
if (!session.authenticated) {
|
|
578
|
+
throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.")
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return this.contextFromSession(session)
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Build an authorization context from an already-resolved session, so callers
|
|
586
|
+
* that resolve the session themselves (e.g. the server auth guard) don't read
|
|
587
|
+
* the request twice.
|
|
588
|
+
*/
|
|
589
|
+
contextFromSession(session: AuthenticatedRequestAuthSession): AuthorizationContext {
|
|
590
|
+
return resolveAuthorizationContext({
|
|
591
|
+
principal: session.principal,
|
|
592
|
+
sessionId: session.credentialSource === "session" ? session.session.id : undefined,
|
|
593
|
+
groupIds: session.groupIds,
|
|
594
|
+
roles: this.security.listResolvedRoles(),
|
|
595
|
+
})
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
async listPersonalAccessTokens(
|
|
599
|
+
request: Request,
|
|
600
|
+
options: AuthSessionResolutionOptions = {}
|
|
601
|
+
): Promise<ListPersonalAccessTokensResult> {
|
|
602
|
+
const session = await this.requireUserRequest(request, options)
|
|
603
|
+
const storage = this.requireAuthStorage()
|
|
604
|
+
const result = await storage.accessTokens.list({
|
|
605
|
+
projectId: this.projectId,
|
|
606
|
+
kind: "personal",
|
|
607
|
+
subjectType: "user",
|
|
608
|
+
subjectId: session.user.id,
|
|
609
|
+
includeRevoked: true,
|
|
610
|
+
order: "desc",
|
|
611
|
+
limit: 100,
|
|
612
|
+
})
|
|
613
|
+
|
|
614
|
+
return { accessTokens: result.accessTokens }
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
async createPersonalAccessToken(
|
|
618
|
+
request: Request,
|
|
619
|
+
input: CreatePersonalAccessTokenInput,
|
|
620
|
+
options: AuthSessionResolutionOptions = {}
|
|
621
|
+
): Promise<CreateAccessTokenResult> {
|
|
622
|
+
const session = await this.requireUserRequest(request, options)
|
|
623
|
+
const storage = this.requireAuthStorage()
|
|
624
|
+
// A personal token can only carry groups the caller currently belongs to.
|
|
625
|
+
const groupIds = constrainRequestedGroupIds(input.groupIds, session.groupIds, {
|
|
626
|
+
subject: "personal access token",
|
|
627
|
+
})
|
|
628
|
+
const credential = createAccessTokenCredential("personal")
|
|
629
|
+
const accessToken = await storage.accessTokens.create({
|
|
630
|
+
id: credential.tokenId,
|
|
631
|
+
projectId: this.projectId,
|
|
632
|
+
name: input.name,
|
|
633
|
+
kind: "personal",
|
|
634
|
+
subjectType: "user",
|
|
635
|
+
subjectId: session.user.id,
|
|
636
|
+
tokenHash: credential.tokenHash,
|
|
637
|
+
groupIds,
|
|
638
|
+
createdByPrincipal: session.principal,
|
|
639
|
+
createdBySessionId: session.credentialSource === "session" ? session.session.id : undefined,
|
|
640
|
+
createdAt: new Date(),
|
|
641
|
+
expiresAt: input.expiresAt,
|
|
642
|
+
})
|
|
643
|
+
|
|
644
|
+
return { accessToken, tokenValue: credential.tokenValue }
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
async revokePersonalAccessToken(
|
|
648
|
+
request: Request,
|
|
649
|
+
input: RevokePersonalAccessTokenInput,
|
|
650
|
+
options: AuthSessionResolutionOptions = {}
|
|
651
|
+
): Promise<RevokeAccessTokenResult> {
|
|
652
|
+
const session = await this.requireUserRequest(request, options)
|
|
653
|
+
const storage = this.requireAuthStorage()
|
|
654
|
+
const token = await storage.accessTokens.getById({
|
|
655
|
+
projectId: this.projectId,
|
|
656
|
+
id: input.tokenId,
|
|
657
|
+
})
|
|
658
|
+
// Personal tokens are self-service only. A foreign or missing token id is
|
|
659
|
+
// reported identically so callers cannot probe other principals' tokens.
|
|
660
|
+
if (
|
|
661
|
+
!token ||
|
|
662
|
+
token.kind !== "personal" ||
|
|
663
|
+
token.subjectType !== "user" ||
|
|
664
|
+
token.subjectId !== session.user.id
|
|
665
|
+
) {
|
|
666
|
+
throw missingAccessTokenError(input.tokenId, this.projectId)
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
const accessToken = await storage.accessTokens.revoke({
|
|
670
|
+
projectId: this.projectId,
|
|
671
|
+
id: input.tokenId,
|
|
672
|
+
revokedAt: new Date(),
|
|
673
|
+
})
|
|
674
|
+
|
|
675
|
+
return { accessToken }
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
async listServiceAccounts(
|
|
679
|
+
request: Request,
|
|
680
|
+
options: AuthSessionResolutionOptions = {}
|
|
681
|
+
): Promise<ListServiceAccountsResult> {
|
|
682
|
+
const session = await this.requireUserRequest(request, options)
|
|
683
|
+
const storage = this.requireAuthStorage()
|
|
684
|
+
const result = await storage.serviceAccounts.list({
|
|
685
|
+
projectId: this.projectId,
|
|
686
|
+
order: "desc",
|
|
687
|
+
limit: 100,
|
|
688
|
+
})
|
|
689
|
+
const withGroups = await Promise.all(
|
|
690
|
+
result.serviceAccounts.map(async (serviceAccount) => ({
|
|
691
|
+
serviceAccount,
|
|
692
|
+
groupIds: await this.listServiceAccountGroupIds(storage, serviceAccount.id),
|
|
693
|
+
}))
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
// A caller only sees the service accounts it is allowed to manage, so
|
|
697
|
+
// listing never leaks the groups of more-privileged accounts.
|
|
698
|
+
return {
|
|
699
|
+
serviceAccounts: withGroups.filter(({ groupIds }) =>
|
|
700
|
+
callerCanManageServiceAccount(session.groupIds, groupIds)
|
|
701
|
+
),
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
async createServiceAccount(
|
|
706
|
+
request: Request,
|
|
707
|
+
input: CreateServiceAccountInput,
|
|
708
|
+
options: AuthSessionResolutionOptions = {}
|
|
709
|
+
): Promise<CreateServiceAccountResult> {
|
|
710
|
+
const session = await this.requireUserRequest(request, options)
|
|
711
|
+
const storage = this.requireAuthStorage()
|
|
712
|
+
// A caller can only place a service account in groups it itself belongs to.
|
|
713
|
+
const groupIds =
|
|
714
|
+
constrainRequestedGroupIds(input.groupIds, session.groupIds, {
|
|
715
|
+
subject: "service account",
|
|
716
|
+
}) ?? []
|
|
717
|
+
const now = new Date()
|
|
718
|
+
const serviceAccount = await storage.serviceAccounts.create({
|
|
719
|
+
id: input.id ?? `svc_${randomUUID()}`,
|
|
720
|
+
projectId: this.projectId,
|
|
721
|
+
name: input.name,
|
|
722
|
+
description: input.description,
|
|
723
|
+
createdByPrincipal: session.principal,
|
|
724
|
+
createdBySessionId: session.credentialSource === "session" ? session.session.id : undefined,
|
|
725
|
+
createdAt: now,
|
|
726
|
+
updatedAt: now,
|
|
727
|
+
})
|
|
728
|
+
const groupMemberships: ServiceAccountGroupMembershipRecord[] = []
|
|
729
|
+
for (const groupId of groupIds) {
|
|
730
|
+
groupMemberships.push(
|
|
731
|
+
await storage.serviceAccountGroupMemberships.upsert({
|
|
732
|
+
projectId: this.projectId,
|
|
733
|
+
serviceAccountId: serviceAccount.id,
|
|
734
|
+
groupId,
|
|
735
|
+
source: "manual",
|
|
736
|
+
createdAt: now,
|
|
737
|
+
})
|
|
738
|
+
)
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
return { serviceAccount, groupMemberships }
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
async disableServiceAccount(
|
|
745
|
+
request: Request,
|
|
746
|
+
input: DisableServiceAccountInput,
|
|
747
|
+
options: AuthSessionResolutionOptions = {}
|
|
748
|
+
): Promise<DisableServiceAccountResult> {
|
|
749
|
+
const session = await this.requireUserRequest(request, options)
|
|
750
|
+
const storage = this.requireAuthStorage()
|
|
751
|
+
const { serviceAccount, groupIds } = await this.requireManageableServiceAccount(
|
|
752
|
+
storage,
|
|
753
|
+
session.groupIds,
|
|
754
|
+
input.serviceAccountId
|
|
755
|
+
)
|
|
756
|
+
const updated = await storage.serviceAccounts.update({
|
|
757
|
+
projectId: this.projectId,
|
|
758
|
+
id: serviceAccount.id,
|
|
759
|
+
status: "suspended",
|
|
760
|
+
updatedAt: new Date(),
|
|
761
|
+
})
|
|
762
|
+
|
|
763
|
+
return { serviceAccount: updated, groupIds }
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
async listServiceAccountAccessTokens(
|
|
767
|
+
request: Request,
|
|
768
|
+
input: ListServiceAccountAccessTokensInput,
|
|
769
|
+
options: AuthSessionResolutionOptions = {}
|
|
770
|
+
): Promise<ListServiceAccountAccessTokensResult> {
|
|
771
|
+
const session = await this.requireUserRequest(request, options)
|
|
772
|
+
const storage = this.requireAuthStorage()
|
|
773
|
+
const { serviceAccount } = await this.requireManageableServiceAccount(
|
|
774
|
+
storage,
|
|
775
|
+
session.groupIds,
|
|
776
|
+
input.serviceAccountId
|
|
777
|
+
)
|
|
778
|
+
const result = await storage.accessTokens.list({
|
|
779
|
+
projectId: this.projectId,
|
|
780
|
+
kind: "serviceAccount",
|
|
781
|
+
subjectType: "serviceAccount",
|
|
782
|
+
subjectId: serviceAccount.id,
|
|
783
|
+
includeRevoked: true,
|
|
784
|
+
order: "desc",
|
|
785
|
+
limit: 100,
|
|
786
|
+
})
|
|
787
|
+
|
|
788
|
+
return { serviceAccount, accessTokens: result.accessTokens }
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
async createServiceAccountAccessToken(
|
|
792
|
+
request: Request,
|
|
793
|
+
input: CreateServiceAccountAccessTokenInput,
|
|
794
|
+
options: AuthSessionResolutionOptions = {}
|
|
795
|
+
): Promise<CreateServiceAccountAccessTokenResult> {
|
|
796
|
+
const session = await this.requireUserRequest(request, options)
|
|
797
|
+
const storage = this.requireAuthStorage()
|
|
798
|
+
const { serviceAccount, groupIds: serviceAccountGroupIds } =
|
|
799
|
+
await this.requireManageableServiceAccount(storage, session.groupIds, input.serviceAccountId)
|
|
800
|
+
|
|
801
|
+
if (serviceAccount.status === "suspended") {
|
|
802
|
+
throw new AuthStorageError(
|
|
803
|
+
"suspended_service_account",
|
|
804
|
+
`[Sixb] Service account '${input.serviceAccountId}' is suspended for project '${this.projectId}'.`
|
|
805
|
+
)
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// The token can only carry groups the service account already holds; the
|
|
809
|
+
// manageability check above guarantees those are a subset of the caller's
|
|
810
|
+
// own groups, so the caller can never mint privileges it lacks.
|
|
811
|
+
const groupIds = constrainRequestedGroupIds(input.groupIds, serviceAccountGroupIds, {
|
|
812
|
+
subject: "service account token",
|
|
813
|
+
})
|
|
814
|
+
const credential = createAccessTokenCredential("serviceAccount")
|
|
815
|
+
const accessToken = await storage.accessTokens.create({
|
|
816
|
+
id: credential.tokenId,
|
|
817
|
+
projectId: this.projectId,
|
|
818
|
+
name: input.name,
|
|
819
|
+
kind: "serviceAccount",
|
|
820
|
+
subjectType: "serviceAccount",
|
|
821
|
+
subjectId: serviceAccount.id,
|
|
822
|
+
tokenHash: credential.tokenHash,
|
|
823
|
+
groupIds,
|
|
824
|
+
createdByPrincipal: session.principal,
|
|
825
|
+
createdBySessionId: session.credentialSource === "session" ? session.session.id : undefined,
|
|
826
|
+
createdAt: new Date(),
|
|
827
|
+
expiresAt: input.expiresAt,
|
|
828
|
+
})
|
|
829
|
+
|
|
830
|
+
return { accessToken, tokenValue: credential.tokenValue, serviceAccount }
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
async revokeServiceAccountAccessToken(
|
|
834
|
+
request: Request,
|
|
835
|
+
input: RevokeServiceAccountAccessTokenInput,
|
|
836
|
+
options: AuthSessionResolutionOptions = {}
|
|
837
|
+
): Promise<RevokeServiceAccountAccessTokenResult> {
|
|
838
|
+
const session = await this.requireUserRequest(request, options)
|
|
839
|
+
const storage = this.requireAuthStorage()
|
|
840
|
+
const { serviceAccount } = await this.requireManageableServiceAccount(
|
|
841
|
+
storage,
|
|
842
|
+
session.groupIds,
|
|
843
|
+
input.serviceAccountId
|
|
844
|
+
)
|
|
845
|
+
const token = await storage.accessTokens.getById({
|
|
846
|
+
projectId: this.projectId,
|
|
847
|
+
id: input.tokenId,
|
|
848
|
+
})
|
|
849
|
+
// The token must belong to the service account named in the request.
|
|
850
|
+
if (
|
|
851
|
+
!token ||
|
|
852
|
+
token.kind !== "serviceAccount" ||
|
|
853
|
+
token.subjectType !== "serviceAccount" ||
|
|
854
|
+
token.subjectId !== serviceAccount.id
|
|
855
|
+
) {
|
|
856
|
+
throw missingAccessTokenError(input.tokenId, this.projectId)
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
const accessToken = await storage.accessTokens.revoke({
|
|
860
|
+
projectId: this.projectId,
|
|
861
|
+
id: input.tokenId,
|
|
862
|
+
revokedAt: new Date(),
|
|
863
|
+
})
|
|
864
|
+
|
|
865
|
+
return { serviceAccount, accessToken }
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Resolve a service account the caller is allowed to manage.
|
|
870
|
+
*
|
|
871
|
+
* A caller may manage a service account only when it belongs to every group
|
|
872
|
+
* the account is in ("you can manage what you could have created"). This
|
|
873
|
+
* confines token minting, disabling, and revocation to privileges the caller
|
|
874
|
+
* already holds and prevents a service-account token from outliving the
|
|
875
|
+
* caller's own access. Missing and non-manageable accounts raise the same
|
|
876
|
+
* error so callers cannot probe which privileged accounts exist.
|
|
877
|
+
*/
|
|
878
|
+
private async requireManageableServiceAccount(
|
|
879
|
+
storage: AuthStorage,
|
|
880
|
+
callerGroupIds: readonly string[],
|
|
881
|
+
serviceAccountId: string
|
|
882
|
+
): Promise<{
|
|
883
|
+
readonly serviceAccount: ServiceAccountRecord
|
|
884
|
+
readonly groupIds: readonly string[]
|
|
885
|
+
}> {
|
|
886
|
+
const serviceAccount = await storage.serviceAccounts.getById({
|
|
887
|
+
projectId: this.projectId,
|
|
888
|
+
id: serviceAccountId,
|
|
889
|
+
})
|
|
890
|
+
const groupIds = serviceAccount
|
|
891
|
+
? await this.listServiceAccountGroupIds(storage, serviceAccountId)
|
|
892
|
+
: []
|
|
893
|
+
|
|
894
|
+
if (!serviceAccount || !callerCanManageServiceAccount(callerGroupIds, groupIds)) {
|
|
895
|
+
throw new AuthStorageError(
|
|
896
|
+
"missing_service_account",
|
|
897
|
+
`[Sixb] Service account '${serviceAccountId}' not found for project '${this.projectId}'.`
|
|
898
|
+
)
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return { serviceAccount, groupIds }
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
private async listServiceAccountGroupIds(
|
|
905
|
+
storage: AuthStorage,
|
|
906
|
+
serviceAccountId: string
|
|
907
|
+
): Promise<readonly string[]> {
|
|
908
|
+
const memberships = await storage.serviceAccountGroupMemberships.listForServiceAccount({
|
|
909
|
+
projectId: this.projectId,
|
|
910
|
+
serviceAccountId,
|
|
911
|
+
})
|
|
912
|
+
return memberships.map((membership) => membership.groupId)
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
async getInvitationOptions(
|
|
916
|
+
request: Request,
|
|
917
|
+
options: AuthSessionResolutionOptions = {}
|
|
918
|
+
): Promise<GetInvitationOptionsResult> {
|
|
919
|
+
const session = await this.requireUser(request, options)
|
|
920
|
+
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds)
|
|
921
|
+
const inviteScope = scope.operations.invite
|
|
922
|
+
const groups = this.scopedGroupOptions(inviteScope.groupIds)
|
|
923
|
+
const hasInviteMembershipPolicy = inviteScope.policyIds.length > 0
|
|
924
|
+
|
|
925
|
+
return {
|
|
926
|
+
groups,
|
|
927
|
+
canInviteWithoutGroups: hasInviteMembershipPolicy,
|
|
928
|
+
capabilities: {
|
|
929
|
+
createInvitation: this.resolveCreateInvitationCapability({
|
|
930
|
+
canInvite: hasInviteMembershipPolicy,
|
|
931
|
+
}),
|
|
932
|
+
},
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Resolve what a caller's membership policies let it do, from its groups alone.
|
|
938
|
+
*
|
|
939
|
+
* This is the public form of the question the member-admin routes ask internally. It takes groups
|
|
940
|
+
* rather than a `Request` so project code and tests can ask it without a session — an
|
|
941
|
+
* `AuthorizationContext` carries `groupIds` for exactly this. Definitions and ids are both accepted,
|
|
942
|
+
* because a session hands you ids and your own code has the definition.
|
|
943
|
+
*/
|
|
944
|
+
getMembershipCapabilities(input: {
|
|
945
|
+
readonly callerGroups: readonly GroupReference[]
|
|
946
|
+
}): MembershipCapabilities {
|
|
947
|
+
return membershipCapabilities(
|
|
948
|
+
this.resolveMembershipPolicyScopeForUser(groupIdsOf(input.callerGroups))
|
|
949
|
+
)
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
async getMembershipOptions(
|
|
953
|
+
request: Request,
|
|
954
|
+
options: AuthSessionResolutionOptions = {}
|
|
955
|
+
): Promise<GetMembershipOptionsResult> {
|
|
956
|
+
const session = await this.requireUser(request, options)
|
|
957
|
+
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds)
|
|
958
|
+
|
|
959
|
+
return {
|
|
960
|
+
// The member-admin edit-groups dialog assigns from the `assignGroups` scope.
|
|
961
|
+
groups: this.scopedGroupOptions(scope.operations.assignGroups.groupIds),
|
|
962
|
+
capabilities: membershipCapabilities(scope).holds,
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
async listMembers(
|
|
967
|
+
request: Request,
|
|
968
|
+
input: ListMembersInput = {},
|
|
969
|
+
options: AuthSessionResolutionOptions = {}
|
|
970
|
+
): Promise<ListMembersResult> {
|
|
971
|
+
const session = await this.requireUser(request, options)
|
|
972
|
+
const storage = this.requireAuthStorage()
|
|
973
|
+
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds)
|
|
974
|
+
const { limit, offset } = normalizePagination(input)
|
|
975
|
+
|
|
976
|
+
// First slice loads all users, attaches groups, then filters and paginates in
|
|
977
|
+
// memory. Adequate for expected member counts; revisit with indexed queries if
|
|
978
|
+
// projects grow large.
|
|
979
|
+
const result = await storage.users.list({ projectId: this.projectId, order: input.order })
|
|
980
|
+
|
|
981
|
+
const members: MemberSummary[] = []
|
|
982
|
+
for (const user of result.users) {
|
|
983
|
+
const groupIds = (
|
|
984
|
+
await storage.groupMemberships.listForUser({ projectId: this.projectId, userId: user.id })
|
|
985
|
+
).map((membership) => membership.groupId)
|
|
986
|
+
|
|
987
|
+
// Visibility is scope-based: a member is listed when the caller can assign
|
|
988
|
+
// groups or suspend over the member's current groups. This keeps out-of-scope
|
|
989
|
+
// users' emails, status, and group shape hidden.
|
|
990
|
+
const canAssignGroups = canPerformMembershipOperation(scope, "assignGroups", groupIds)
|
|
991
|
+
const canSuspendScope = canPerformMembershipOperation(scope, "suspend", groupIds)
|
|
992
|
+
if (!canAssignGroups && !canSuspendScope) {
|
|
993
|
+
continue
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
const isSelf = user.id === session.user.id
|
|
997
|
+
members.push({
|
|
998
|
+
user,
|
|
999
|
+
groupIds,
|
|
1000
|
+
capabilities: {
|
|
1001
|
+
assignGroups: canAssignGroups,
|
|
1002
|
+
// A caller cannot suspend themselves; reactivation only applies to a
|
|
1003
|
+
// suspended member and never restores sessions.
|
|
1004
|
+
suspend: canSuspendScope && !isSelf && user.status === "active",
|
|
1005
|
+
reactivate: canSuspendScope && user.status === "suspended",
|
|
1006
|
+
},
|
|
1007
|
+
})
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const page = paginate(members, { limit, offset })
|
|
1011
|
+
return { members: page.page, hasMore: page.hasMore, total: page.total }
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
async updateMemberGroups(
|
|
1015
|
+
request: Request,
|
|
1016
|
+
input: UpdateMemberGroupsInput,
|
|
1017
|
+
options: AuthSessionResolutionOptions = {}
|
|
1018
|
+
): Promise<UpdateMemberGroupsResult> {
|
|
1019
|
+
const session = await this.requireUser(request, options)
|
|
1020
|
+
const storage = this.requireAuthStorage()
|
|
1021
|
+
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds)
|
|
1022
|
+
const userId = assertNonEmpty(input.userId, "User id")
|
|
1023
|
+
|
|
1024
|
+
// The target must exist and every group it currently holds must be assignable
|
|
1025
|
+
// by the caller. Missing and out-of-scope targets raise the same error so a
|
|
1026
|
+
// caller cannot probe which users exist.
|
|
1027
|
+
const { user, groupIds: currentGroupIds } = await this.requireManageableMember(
|
|
1028
|
+
storage,
|
|
1029
|
+
scope,
|
|
1030
|
+
"assignGroups",
|
|
1031
|
+
userId
|
|
1032
|
+
)
|
|
1033
|
+
|
|
1034
|
+
const requestedGroupIds = this.resolveMemberGroupIds(input.groupIds)
|
|
1035
|
+
// Every requested group must fall within the caller's assign scope.
|
|
1036
|
+
const missing = missingMembershipGroupIds(scope, "assignGroups", requestedGroupIds)
|
|
1037
|
+
if (missing.length > 0) {
|
|
1038
|
+
throw new AuthRuntimeError(
|
|
1039
|
+
"authorization_denied",
|
|
1040
|
+
`[Sixb] The current user is not allowed to assign group(s): ${missing.join(", ")}.`
|
|
1041
|
+
)
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
const current = new Set(currentGroupIds)
|
|
1045
|
+
const requested = new Set(requestedGroupIds)
|
|
1046
|
+
const additions = requestedGroupIds.filter((groupId) => !current.has(groupId))
|
|
1047
|
+
const removals = currentGroupIds.filter((groupId) => !requested.has(groupId))
|
|
1048
|
+
|
|
1049
|
+
// Self-protection: a caller may add in-scope groups to themselves but may not
|
|
1050
|
+
// remove any of their own current groups, so they cannot lock themselves out.
|
|
1051
|
+
if (user.id === session.user.id && removals.length > 0) {
|
|
1052
|
+
throw new AuthRuntimeError(
|
|
1053
|
+
"authorization_denied",
|
|
1054
|
+
"[Sixb] The current user cannot remove their own groups."
|
|
1055
|
+
)
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
const now = new Date()
|
|
1059
|
+
for (const groupId of additions) {
|
|
1060
|
+
await storage.groupMemberships.upsert({
|
|
1061
|
+
projectId: this.projectId,
|
|
1062
|
+
userId: user.id,
|
|
1063
|
+
groupId,
|
|
1064
|
+
source: "manual",
|
|
1065
|
+
createdAt: now,
|
|
1066
|
+
})
|
|
1067
|
+
}
|
|
1068
|
+
for (const groupId of removals) {
|
|
1069
|
+
await storage.groupMemberships.remove({
|
|
1070
|
+
projectId: this.projectId,
|
|
1071
|
+
userId: user.id,
|
|
1072
|
+
groupId,
|
|
1073
|
+
})
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// The user's cached session carries its old groups; drop it so the next
|
|
1077
|
+
// request resolves the updated membership.
|
|
1078
|
+
this.invalidateUserSessions(user.id)
|
|
1079
|
+
|
|
1080
|
+
const groupIds = (
|
|
1081
|
+
await storage.groupMemberships.listForUser({ projectId: this.projectId, userId: user.id })
|
|
1082
|
+
).map((membership) => membership.groupId)
|
|
1083
|
+
|
|
1084
|
+
return { user, groupIds }
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
async suspendMember(
|
|
1088
|
+
request: Request,
|
|
1089
|
+
input: SuspendMemberInput,
|
|
1090
|
+
options: AuthSessionResolutionOptions = {}
|
|
1091
|
+
): Promise<SuspendMemberResult> {
|
|
1092
|
+
const session = await this.requireUser(request, options)
|
|
1093
|
+
const storage = this.requireAuthStorage()
|
|
1094
|
+
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds)
|
|
1095
|
+
const userId = assertNonEmpty(input.userId, "User id")
|
|
1096
|
+
const { user, groupIds } = await this.requireManageableMember(storage, scope, "suspend", userId)
|
|
1097
|
+
|
|
1098
|
+
if (user.id === session.user.id) {
|
|
1099
|
+
throw new AuthRuntimeError(
|
|
1100
|
+
"authorization_denied",
|
|
1101
|
+
"[Sixb] The current user cannot suspend themselves."
|
|
1102
|
+
)
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
const suspended = await storage.suspendUserAndRevokeSessions({
|
|
1106
|
+
projectId: this.projectId,
|
|
1107
|
+
userId: user.id,
|
|
1108
|
+
suspendedAt: new Date(),
|
|
1109
|
+
})
|
|
1110
|
+
// Storage revoked the user's sessions; drop cached copies so the suspended
|
|
1111
|
+
// user stops authenticating immediately.
|
|
1112
|
+
this.invalidateUserSessions(user.id)
|
|
1113
|
+
|
|
1114
|
+
return { user: suspended, groupIds }
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
async reactivateMember(
|
|
1118
|
+
request: Request,
|
|
1119
|
+
input: ReactivateMemberInput,
|
|
1120
|
+
options: AuthSessionResolutionOptions = {}
|
|
1121
|
+
): Promise<ReactivateMemberResult> {
|
|
1122
|
+
const session = await this.requireUser(request, options)
|
|
1123
|
+
const storage = this.requireAuthStorage()
|
|
1124
|
+
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds)
|
|
1125
|
+
const userId = assertNonEmpty(input.userId, "User id")
|
|
1126
|
+
const { user, groupIds } = await this.requireManageableMember(storage, scope, "suspend", userId)
|
|
1127
|
+
|
|
1128
|
+
// Reactivation restores access but not sessions; the user signs in again.
|
|
1129
|
+
const reactivated = await storage.users.updateStatus({
|
|
1130
|
+
projectId: this.projectId,
|
|
1131
|
+
id: user.id,
|
|
1132
|
+
status: "active",
|
|
1133
|
+
updatedAt: new Date(),
|
|
1134
|
+
})
|
|
1135
|
+
|
|
1136
|
+
return { user: reactivated, groupIds }
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/** Drop cached sessions for a user after a membership or status change. */
|
|
1140
|
+
invalidateUserSessions(userId: string): void {
|
|
1141
|
+
this.sessionCache?.invalidateUser(userId)
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
private scopedGroupOptions(groupIds: ReadonlySet<string>): InvitationGroupOption[] {
|
|
1145
|
+
return this.security
|
|
1146
|
+
.listGroups()
|
|
1147
|
+
.filter((group) => groupIds.has(group.id))
|
|
1148
|
+
.map((group) => ({
|
|
1149
|
+
id: group.id,
|
|
1150
|
+
...(group.label !== undefined ? { label: group.label } : {}),
|
|
1151
|
+
...(group.description !== undefined ? { description: group.description } : {}),
|
|
1152
|
+
}))
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Resolve a member the caller may act on for the given operation.
|
|
1157
|
+
*
|
|
1158
|
+
* A member is manageable only when every group they currently hold is within
|
|
1159
|
+
* the caller's scope for that operation (a group-less member is manageable by
|
|
1160
|
+
* any holder of the operation). Missing and out-of-scope members raise the same
|
|
1161
|
+
* error so callers cannot probe which users exist or how they are grouped.
|
|
1162
|
+
*/
|
|
1163
|
+
private async requireManageableMember(
|
|
1164
|
+
storage: AuthStorage,
|
|
1165
|
+
scope: MembershipPolicyScope,
|
|
1166
|
+
operation: MembershipOperation,
|
|
1167
|
+
userId: string
|
|
1168
|
+
): Promise<{ readonly user: UserRecord; readonly groupIds: readonly string[] }> {
|
|
1169
|
+
const user = await storage.users.getById({ projectId: this.projectId, id: userId })
|
|
1170
|
+
const groupIds = user
|
|
1171
|
+
? (await storage.groupMemberships.listForUser({ projectId: this.projectId, userId })).map(
|
|
1172
|
+
(membership) => membership.groupId
|
|
1173
|
+
)
|
|
1174
|
+
: []
|
|
1175
|
+
|
|
1176
|
+
if (!user || !canPerformMembershipOperation(scope, operation, groupIds)) {
|
|
1177
|
+
throw new AuthStorageError(
|
|
1178
|
+
"missing_user",
|
|
1179
|
+
`[Sixb] User '${userId}' not found for project '${this.projectId}'.`
|
|
1180
|
+
)
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
return { user, groupIds }
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
private resolveMemberGroupIds(input: readonly string[]): readonly string[] {
|
|
1187
|
+
const groupIds = [...new Set(input.map((groupId) => assertNonEmpty(groupId, "Group id")))]
|
|
1188
|
+
for (const groupId of groupIds) {
|
|
1189
|
+
if (!this.security.getGroupById(groupId)) {
|
|
1190
|
+
throw new AuthRuntimeError(
|
|
1191
|
+
"invalid_auth_input",
|
|
1192
|
+
`[Sixb] Unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`
|
|
1193
|
+
)
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
return groupIds
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
async invite(
|
|
1200
|
+
request: Request,
|
|
1201
|
+
input: InviteUserInput,
|
|
1202
|
+
options: InviteUserOptions = {}
|
|
1203
|
+
): Promise<InviteUserResult> {
|
|
1204
|
+
const session = await this.requireUser(request, options)
|
|
1205
|
+
const authStorage = this.requireAuthStorage()
|
|
1206
|
+
const now = new Date()
|
|
1207
|
+
const groupIds = this.resolveInviteGroupIds(input)
|
|
1208
|
+
this.assertCanManageInvitationGroups(session.groupIds, groupIds)
|
|
1209
|
+
|
|
1210
|
+
const strategy = this.getStrategy()
|
|
1211
|
+
if (!isInvitationDeliveryAuthStrategy(strategy)) {
|
|
1212
|
+
throw new AuthRuntimeError(
|
|
1213
|
+
"invalid_auth_config",
|
|
1214
|
+
"[Sixb] The active auth strategy does not support invitations."
|
|
1215
|
+
)
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
await this.assertCanInviteRecipient(strategy, authStorage, input.email, now)
|
|
1219
|
+
const deliveryAudience = resolveAuthSessionAudience(
|
|
1220
|
+
options.delivery?.audience ?? options.audience
|
|
1221
|
+
)
|
|
1222
|
+
this.assertInvitationApplicationAccess(groupIds, deliveryAudience)
|
|
1223
|
+
|
|
1224
|
+
const invitation = await authStorage.invitations.createOrUpdateActive({
|
|
1225
|
+
id: `inv_${randomUUID()}`,
|
|
1226
|
+
projectId: this.projectId,
|
|
1227
|
+
email: input.email,
|
|
1228
|
+
groupIds,
|
|
1229
|
+
createdByPrincipal: session.principal,
|
|
1230
|
+
createdBySessionId: session.session.id,
|
|
1231
|
+
createdAt: now,
|
|
1232
|
+
updatedAt: now,
|
|
1233
|
+
expiresAt: resolveInvitationExpiresAt(input.expiresAt, now),
|
|
1234
|
+
})
|
|
1235
|
+
|
|
1236
|
+
let delivery: InviteDeliveryResult
|
|
1237
|
+
try {
|
|
1238
|
+
delivery = await strategy.deliverInvitation({
|
|
1239
|
+
projectId: this.projectId,
|
|
1240
|
+
authStorage,
|
|
1241
|
+
invitation,
|
|
1242
|
+
audience: deliveryAudience,
|
|
1243
|
+
returnTo: options.delivery?.returnTo ?? sanitizeReturnTo(input.returnTo),
|
|
1244
|
+
requestOrigin: options.delivery?.requestOrigin ?? new URL(request.url).origin,
|
|
1245
|
+
now,
|
|
1246
|
+
})
|
|
1247
|
+
} catch (error) {
|
|
1248
|
+
await this.revokeInvitationAfterDeliveryFailure(authStorage, invitation, now)
|
|
1249
|
+
throw error
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
if (delivery.status === "not_supported") {
|
|
1253
|
+
return { invitation, delivery }
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
if (delivery.status !== "sent") {
|
|
1257
|
+
await this.revokeInvitationAfterDeliveryFailure(authStorage, invitation, now)
|
|
1258
|
+
throw this.createInvitationDeliveryError(delivery.status)
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
return { invitation, delivery }
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
async listInvitations(
|
|
1265
|
+
request: Request,
|
|
1266
|
+
input: ListInvitationsInput = {},
|
|
1267
|
+
options: AuthSessionResolutionOptions = {}
|
|
1268
|
+
): Promise<ListInvitationsResult> {
|
|
1269
|
+
const session = await this.requireUser(request, options)
|
|
1270
|
+
const authStorage = this.requireAuthStorage()
|
|
1271
|
+
const { limit, offset } = normalizePagination(input)
|
|
1272
|
+
const result = await authStorage.invitations.list({
|
|
1273
|
+
projectId: this.projectId,
|
|
1274
|
+
email: input.email,
|
|
1275
|
+
statuses: input.statuses,
|
|
1276
|
+
order: input.order,
|
|
1277
|
+
})
|
|
1278
|
+
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds)
|
|
1279
|
+
const manageable = result.invitations.filter((invitation) =>
|
|
1280
|
+
canPerformMembershipOperation(scope, "invite", invitation.groupIds)
|
|
1281
|
+
)
|
|
1282
|
+
const page = paginate(manageable, { limit, offset })
|
|
1283
|
+
|
|
1284
|
+
return {
|
|
1285
|
+
invitations: page.page,
|
|
1286
|
+
hasMore: page.hasMore,
|
|
1287
|
+
total: page.total,
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
async revokeInvitation(
|
|
1292
|
+
request: Request,
|
|
1293
|
+
input: RevokeInvitationInput,
|
|
1294
|
+
options: AuthSessionResolutionOptions = {}
|
|
1295
|
+
): Promise<RevokeInvitationResult> {
|
|
1296
|
+
const session = await this.requireUser(request, options)
|
|
1297
|
+
const authStorage = this.requireAuthStorage()
|
|
1298
|
+
const invitationId = assertNonEmpty(input.invitationId, "Invitation id")
|
|
1299
|
+
const invitation = await authStorage.invitations.getById({
|
|
1300
|
+
projectId: this.projectId,
|
|
1301
|
+
id: invitationId,
|
|
1302
|
+
})
|
|
1303
|
+
|
|
1304
|
+
if (!invitation) {
|
|
1305
|
+
throw new AuthStorageError(
|
|
1306
|
+
"missing_invitation",
|
|
1307
|
+
`[Sixb] Invitation '${invitationId}' not found for project '${this.projectId}'.`
|
|
1308
|
+
)
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
this.assertCanManageInvitationGroups(session.groupIds, invitation.groupIds)
|
|
1312
|
+
|
|
1313
|
+
if (invitation.status !== "pending") {
|
|
1314
|
+
throw new AuthRuntimeError(
|
|
1315
|
+
"invalid_auth_input",
|
|
1316
|
+
`[Sixb] Invitation '${invitationId}' is already ${invitation.status} and cannot be revoked.`
|
|
1317
|
+
)
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
return {
|
|
1321
|
+
invitation: await authStorage.invitations.revoke({
|
|
1322
|
+
projectId: this.projectId,
|
|
1323
|
+
id: invitation.id,
|
|
1324
|
+
revokedAt: new Date(),
|
|
1325
|
+
}),
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
private requireAuthStorage() {
|
|
1330
|
+
if (!this.storage.auth) {
|
|
1331
|
+
throw new AuthRuntimeError(
|
|
1332
|
+
"auth_storage_missing",
|
|
1333
|
+
"[Sixb] Auth is enabled but storage.auth is not configured."
|
|
1334
|
+
)
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
return this.storage.auth
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
private resolveInviteGroupIds(input: InviteUserInput): readonly string[] {
|
|
1341
|
+
if (input.groups && input.groupIds) {
|
|
1342
|
+
throw new AuthRuntimeError(
|
|
1343
|
+
"invalid_auth_input",
|
|
1344
|
+
"[Sixb] Invitation input cannot provide both groups and groupIds."
|
|
1345
|
+
)
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
const rawGroupIds =
|
|
1349
|
+
input.groupIds ?? input.groups?.map((group) => assertNonEmpty(group.id, "Group id")) ?? []
|
|
1350
|
+
const groupIds = [...new Set(rawGroupIds.map((groupId) => assertNonEmpty(groupId, "Group id")))]
|
|
1351
|
+
|
|
1352
|
+
for (const groupId of groupIds) {
|
|
1353
|
+
if (!this.security.getGroupById(groupId)) {
|
|
1354
|
+
throw new AuthRuntimeError(
|
|
1355
|
+
"invalid_auth_input",
|
|
1356
|
+
`[Sixb] Unknown invitation group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`
|
|
1357
|
+
)
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
return groupIds
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
private resolveMembershipPolicyScopeForUser(callerGroupIds: readonly string[]) {
|
|
1365
|
+
return resolveMembershipPolicyScope({
|
|
1366
|
+
membershipPolicies: this.security.listMembershipPolicies(),
|
|
1367
|
+
callerGroupIds,
|
|
1368
|
+
})
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
private resolveCreateInvitationCapability(input: {
|
|
1372
|
+
readonly canInvite: boolean
|
|
1373
|
+
}): GetInvitationOptionsResult["capabilities"]["createInvitation"] {
|
|
1374
|
+
if (!isInvitationDeliveryAuthStrategy(this.getStrategy())) {
|
|
1375
|
+
return { state: "disabled", reason: "invitation_delivery_not_supported" }
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
if (!input.canInvite) {
|
|
1379
|
+
return { state: "disabled", reason: "missing_membership_policy" }
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
return { state: "enabled" }
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
private assertInvitationApplicationAccess(
|
|
1386
|
+
groupIds: readonly string[],
|
|
1387
|
+
audience: AuthSessionAudience
|
|
1388
|
+
): void {
|
|
1389
|
+
// Check only the groups this invitation assigns. Existing memberships may
|
|
1390
|
+
// be outside the caller's policy scope and must not affect this response.
|
|
1391
|
+
const roles = this.security.listResolvedRoles()
|
|
1392
|
+
const authorization = resolveAuthorizationContext({
|
|
1393
|
+
principal: { type: "user", id: "invited-user" },
|
|
1394
|
+
groupIds,
|
|
1395
|
+
roles,
|
|
1396
|
+
})
|
|
1397
|
+
|
|
1398
|
+
if (canAccessApplication(authorization, roles, audience)) return
|
|
1399
|
+
|
|
1400
|
+
throw new AuthRuntimeError(
|
|
1401
|
+
"authorization_denied",
|
|
1402
|
+
`[Sixb] Invitation groups do not grant access to application '${audience}'.`
|
|
1403
|
+
)
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
private async assertCanInviteRecipient(
|
|
1407
|
+
strategy: InvitationDeliveryAuthStrategy,
|
|
1408
|
+
authStorage: AuthStorage,
|
|
1409
|
+
email: string,
|
|
1410
|
+
now: Date
|
|
1411
|
+
): Promise<void> {
|
|
1412
|
+
if (!strategy.validateInvitationRecipient) {
|
|
1413
|
+
return
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
const result = await strategy.validateInvitationRecipient({
|
|
1417
|
+
projectId: this.projectId,
|
|
1418
|
+
authStorage,
|
|
1419
|
+
email,
|
|
1420
|
+
now,
|
|
1421
|
+
})
|
|
1422
|
+
|
|
1423
|
+
if (result.status === "allowed") {
|
|
1424
|
+
return
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
throw createInvitationRecipientError(result.status, result.email ?? email)
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
private async revokeInvitationAfterDeliveryFailure(
|
|
1431
|
+
authStorage: AuthStorage,
|
|
1432
|
+
invitation: InvitationRecord,
|
|
1433
|
+
failedAt: Date
|
|
1434
|
+
): Promise<void> {
|
|
1435
|
+
await authStorage.invitations.revoke({
|
|
1436
|
+
projectId: this.projectId,
|
|
1437
|
+
id: invitation.id,
|
|
1438
|
+
revokedAt: failedAt,
|
|
1439
|
+
})
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
private createInvitationDeliveryError(
|
|
1443
|
+
status: Exclude<InviteDeliveryStatus, "sent" | "not_supported">
|
|
1444
|
+
) {
|
|
1445
|
+
if (status === "rate_limited") {
|
|
1446
|
+
return new AuthRuntimeError(
|
|
1447
|
+
"rate_limited",
|
|
1448
|
+
"[Sixb] Invitation delivery is rate limited. Try again later."
|
|
1449
|
+
)
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
return new AuthRuntimeError(
|
|
1453
|
+
"invalid_auth_input",
|
|
1454
|
+
"[Sixb] Invitation delivery was skipped by the active auth strategy."
|
|
1455
|
+
)
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
private assertCanManageInvitationGroups(
|
|
1459
|
+
callerGroupIds: readonly string[],
|
|
1460
|
+
groupIds: readonly string[]
|
|
1461
|
+
): void {
|
|
1462
|
+
const scope = this.resolveMembershipPolicyScopeForUser(callerGroupIds)
|
|
1463
|
+
|
|
1464
|
+
if (canPerformMembershipOperation(scope, "invite", groupIds)) {
|
|
1465
|
+
return
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
if (groupIds.length === 0) {
|
|
1469
|
+
throw new AuthRuntimeError(
|
|
1470
|
+
"authorization_denied",
|
|
1471
|
+
"[Sixb] The current user is not allowed to create or manage invitations without groups."
|
|
1472
|
+
)
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
const missing = missingMembershipGroupIds(scope, "invite", groupIds)
|
|
1476
|
+
throw new AuthRuntimeError(
|
|
1477
|
+
"authorization_denied",
|
|
1478
|
+
`[Sixb] The current user is not allowed to create or manage invitations for group(s): ${missing.join(", ")}.`
|
|
1479
|
+
)
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
function resolveCorrelationId(request: Request): string {
|
|
1484
|
+
return (
|
|
1485
|
+
request.headers.get("x-correlation-id") ?? request.headers.get("x-request-id") ?? randomUUID()
|
|
1486
|
+
)
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
function isAuthenticatedUserRequestSession(
|
|
1490
|
+
session: AuthenticatedRequestAuthSession
|
|
1491
|
+
): session is AuthenticatedUserRequestSession {
|
|
1492
|
+
return session.principal.type === "user"
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
function resolveRequestIpAddress(request: Request): string | undefined {
|
|
1496
|
+
return (
|
|
1497
|
+
request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ||
|
|
1498
|
+
request.headers.get("x-real-ip")?.trim() ||
|
|
1499
|
+
undefined
|
|
1500
|
+
)
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
function constrainTokenGroupIds(
|
|
1504
|
+
principalGroupIds: readonly string[],
|
|
1505
|
+
accessToken: AccessTokenRecord
|
|
1506
|
+
): readonly string[] {
|
|
1507
|
+
if (accessToken.groupIds === undefined) {
|
|
1508
|
+
return principalGroupIds
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
const allowed = new Set(accessToken.groupIds)
|
|
1512
|
+
return principalGroupIds.filter((groupId) => allowed.has(groupId))
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// A caller may manage a service account only when it belongs to every group the
|
|
1516
|
+
// account is in, so managing it can never grant more than the caller already
|
|
1517
|
+
// has. An account with no groups is powerless and therefore freely manageable.
|
|
1518
|
+
function callerCanManageServiceAccount(
|
|
1519
|
+
callerGroupIds: readonly string[],
|
|
1520
|
+
serviceAccountGroupIds: readonly string[]
|
|
1521
|
+
): boolean {
|
|
1522
|
+
const callerGroups = new Set(callerGroupIds)
|
|
1523
|
+
return serviceAccountGroupIds.every((groupId) => callerGroups.has(groupId))
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
function missingAccessTokenError(tokenId: string, projectId: string): AuthStorageError {
|
|
1527
|
+
return new AuthStorageError(
|
|
1528
|
+
"missing_access_token",
|
|
1529
|
+
`[Sixb] Access token '${tokenId}' not found for project '${projectId}'.`
|
|
1530
|
+
)
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Restrict the groups requested for a credential to a set the caller is allowed
|
|
1535
|
+
* to grant. Returns undefined when no groups were requested (an unconstrained
|
|
1536
|
+
* credential) and throws when a requested group falls outside the allowed set.
|
|
1537
|
+
*/
|
|
1538
|
+
function constrainRequestedGroupIds(
|
|
1539
|
+
input: readonly string[] | undefined,
|
|
1540
|
+
allowedGroupIds: readonly string[],
|
|
1541
|
+
options: { readonly subject: string }
|
|
1542
|
+
): readonly string[] | undefined {
|
|
1543
|
+
const groupIds = normalizeRequestedGroupIds(input)
|
|
1544
|
+
if (!groupIds) {
|
|
1545
|
+
return undefined
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
const allowed = new Set(allowedGroupIds)
|
|
1549
|
+
for (const groupId of groupIds) {
|
|
1550
|
+
if (!allowed.has(groupId)) {
|
|
1551
|
+
throw new AuthRuntimeError(
|
|
1552
|
+
"authorization_denied",
|
|
1553
|
+
`[Sixb] Group '${groupId}' cannot be assigned to this ${options.subject}.`
|
|
1554
|
+
)
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
return groupIds
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
function normalizeRequestedGroupIds(
|
|
1562
|
+
input: readonly string[] | undefined
|
|
1563
|
+
): readonly string[] | null {
|
|
1564
|
+
if (input === undefined) {
|
|
1565
|
+
return null
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
const groupIds: string[] = []
|
|
1569
|
+
for (const raw of input) {
|
|
1570
|
+
const groupId = raw.trim()
|
|
1571
|
+
if (!groupId) {
|
|
1572
|
+
throw new AuthRuntimeError(
|
|
1573
|
+
"invalid_auth_input",
|
|
1574
|
+
"[Sixb] Group ids cannot be empty when creating auth credentials."
|
|
1575
|
+
)
|
|
1576
|
+
}
|
|
1577
|
+
if (!groupIds.includes(groupId)) {
|
|
1578
|
+
groupIds.push(groupId)
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
return groupIds
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
function createInvitationRecipientError(
|
|
1586
|
+
status: Exclude<InvitationRecipientStatus, "allowed">,
|
|
1587
|
+
email: string
|
|
1588
|
+
): AuthRuntimeError {
|
|
1589
|
+
if (status === "rate_limited") {
|
|
1590
|
+
return new AuthRuntimeError(
|
|
1591
|
+
"rate_limited",
|
|
1592
|
+
"[Sixb] Invitation delivery is rate limited. Try again later."
|
|
1593
|
+
)
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
if (status === "invalid_email") {
|
|
1597
|
+
return new AuthRuntimeError("invalid_auth_input", "[Sixb] Invitation email is invalid.")
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
if (status === "disallowed_domain") {
|
|
1601
|
+
return new AuthRuntimeError(
|
|
1602
|
+
"invalid_auth_input",
|
|
1603
|
+
`[Sixb] Invitation email '${email}' is not allowed by the active auth strategy.`
|
|
1604
|
+
)
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
return new AuthRuntimeError(
|
|
1608
|
+
"invalid_auth_input",
|
|
1609
|
+
`[Sixb] Invitation email '${email}' belongs to a suspended user.`
|
|
1610
|
+
)
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* The public shape of a resolved membership policy scope.
|
|
1615
|
+
*
|
|
1616
|
+
* `holds` answers "does any policy grant this at all", which is what a UI needs to enable a control;
|
|
1617
|
+
* `covers` answers the scoped question for one member. Neither is the authorization decision — the
|
|
1618
|
+
* runtime methods add rules on top, which is why the third is named for coverage and not for permission.
|
|
1619
|
+
*/
|
|
1620
|
+
function membershipCapabilities(scope: MembershipPolicyScope): MembershipCapabilities {
|
|
1621
|
+
return {
|
|
1622
|
+
holds: {
|
|
1623
|
+
invite: scope.operations.invite.policyIds.length > 0,
|
|
1624
|
+
assignGroups: scope.operations.assignGroups.policyIds.length > 0,
|
|
1625
|
+
suspend: scope.operations.suspend.policyIds.length > 0,
|
|
1626
|
+
},
|
|
1627
|
+
assignableGroupIds: [...scope.operations.assignGroups.groupIds],
|
|
1628
|
+
covers: (operation, memberGroups) =>
|
|
1629
|
+
canPerformMembershipOperation(scope, operation, groupIdsOf(memberGroups)),
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Normalize the two ways a caller can name a group.
|
|
1635
|
+
*
|
|
1636
|
+
* Ids come from sessions and stored memberships, definitions come from code. Every entry point that
|
|
1637
|
+
* takes `GroupReference` funnels through here, so nothing downstream ever sees a definition where an
|
|
1638
|
+
* id belongs.
|
|
1639
|
+
*/
|
|
1640
|
+
function groupIdsOf(groups: readonly GroupReference[]): readonly string[] {
|
|
1641
|
+
return groups.map((group) => (typeof group === "string" ? group : group.id))
|
|
1642
|
+
}
|