@processfocus/runtime-local 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +28 -0
- package/README.md +290 -0
- package/dist/authentication-server.mjs +188 -0
- package/dist/chunk-2sb4v2sx.js +70 -0
- package/dist/chunk-9weqs8n8.js +56031 -0
- package/dist/chunk-mvkr77wp.js +54113 -0
- package/dist/chunk-tkn4cnc8.js +453 -0
- package/dist/chunk-vpsm84e8.js +85 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/app-icons/[...path]/route.ts +63 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/health/page.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/public-form-branding/[...path]/route.ts +95 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +248 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +751 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +375 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +73 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +11 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/abandon-execution-dialog.tsx +137 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/execution-card-menu.tsx +233 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +1549 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-dialog.tsx +91 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-modal-client.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +31 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-route-fallback.tsx +18 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/restart-execution-feedback.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +129 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +215 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +678 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/loading.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +228 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +147 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +246 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +71 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +315 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +259 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-detail-title.ts +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +26 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/loading.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/org-chart-client.tsx +74 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +120 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +188 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +320 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +152 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +105 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-submit-button.tsx +81 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +282 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/lib/mobile-process-catalog.ts +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/lib/start-process-actions.ts +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/loading.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +504 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +153 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +39 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/loading.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +131 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/process-documentation.tsx +209 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/use-workflow-auto-refresh.ts +120 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +319 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +98 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/loading.tsx +1 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +100 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/access-handbook.tsx +110 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/authorization-loading.tsx +25 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/authorization-tabs.tsx +47 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +261 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-helpers.ts +17 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-source.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +79 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/evaluate-cedar.ts +43 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +526 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-cedar.ts +174 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +390 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/org-data.ts +70 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +594 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-skeleton.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +186 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +69 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers-table.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles-table.tsx +62 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +244 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +329 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +39 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +82 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/error.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/not-found.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +84 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/stats-data-fetcher.tsx +93 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +143 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +50 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +131 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +50 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +172 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +233 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +26 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +58 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +154 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +1317 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +259 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +127 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +49 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +33 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/auth-options/route.ts +79 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/auth-verify/route.ts +142 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/register/route.ts +103 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/register-verify/route.ts +136 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/registration-session/route.ts +129 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +153 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +122 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +177 -0
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-completed/route.ts +22 -0
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +38 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +266 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +118 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/test-host/route.ts +125 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/calendar-slots/route.ts +44 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/complete/route.ts +56 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +61 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/request-fresh-link/route.ts +41 -0
- package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +61 -0
- package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +100 -0
- package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +261 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +393 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/loading.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +51 -0
- package/dist/dashboard-source/apps/frontend/app/embed/embedded.css +48 -0
- package/dist/dashboard-source/apps/frontend/app/embed/layout.tsx +15 -0
- package/dist/dashboard-source/apps/frontend/app/global.css +13 -0
- package/dist/dashboard-source/apps/frontend/app/layout.tsx +102 -0
- package/dist/dashboard-source/apps/frontend/app/login/layout.tsx +9 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-button.tsx +35 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-form-content.tsx +117 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-form.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/app/login/page.tsx +52 -0
- package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +226 -0
- package/dist/dashboard-source/apps/frontend/app/login/secret-login-form.tsx +91 -0
- package/dist/dashboard-source/apps/frontend/app/manifest.ts +7 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/error.tsx +63 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/layout.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/page.tsx +129 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-card.tsx +42 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-context.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-html.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +553 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-state-content.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/app/public.css +33 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/layout.tsx +49 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/page.tsx +36 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +292 -0
- package/dist/dashboard-source/apps/frontend/app/theme.css +117 -0
- package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +693 -0
- package/dist/dashboard-source/apps/frontend/components/Header.tsx +481 -0
- package/dist/dashboard-source/apps/frontend/components/OrgUnitNode.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +245 -0
- package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +158 -0
- package/dist/dashboard-source/apps/frontend/components/collections/collection-table-card.tsx +218 -0
- package/dist/dashboard-source/apps/frontend/components/collections/collection-table-header-row.tsx +97 -0
- package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/copy-button.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/components/dashboard-activity.tsx +35 -0
- package/dist/dashboard-source/apps/frontend/components/dashboard-skeleton.tsx +17 -0
- package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/components/feature-permissions-provider.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +66 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-host.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-identify.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-provider.tsx +55 -0
- package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +378 -0
- package/dist/dashboard-source/apps/frontend/components/mobile-home-switchboard.tsx +98 -0
- package/dist/dashboard-source/apps/frontend/components/mocks-provider.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +137 -0
- package/dist/dashboard-source/apps/frontend/components/org-settings-provider.tsx +26 -0
- package/dist/dashboard-source/apps/frontend/components/process-workflow-link.tsx +36 -0
- package/dist/dashboard-source/apps/frontend/components/session-reissue.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +89 -0
- package/dist/dashboard-source/apps/frontend/components/sidebar-stats-views.tsx +65 -0
- package/dist/dashboard-source/apps/frontend/components/theme-provider.tsx +132 -0
- package/dist/dashboard-source/apps/frontend/components/todo-count-badge.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +304 -0
- package/dist/dashboard-source/apps/frontend/components/ui/checkbox.tsx +31 -0
- package/dist/dashboard-source/apps/frontend/components/ui/dialog.tsx +142 -0
- package/dist/dashboard-source/apps/frontend/components/ui/dropdown-menu.tsx +256 -0
- package/dist/dashboard-source/apps/frontend/components/ui/input.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/components/ui/pagination.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/components/ui/sheet.tsx +138 -0
- package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +741 -0
- package/dist/dashboard-source/apps/frontend/components/ui/skeleton.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/components/ui/table.tsx +115 -0
- package/dist/dashboard-source/apps/frontend/components/ui/tooltip.tsx +60 -0
- package/dist/dashboard-source/apps/frontend/components/without-waiting-badge.tsx +24 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +116 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/swimlane-node.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +172 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +189 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +79 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +74 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-mobile.ts +27 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-notification-preference.ts +246 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +56 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +101 -0
- package/dist/dashboard-source/apps/frontend/index.d.ts +12 -0
- package/dist/dashboard-source/apps/frontend/instrumentation.node.ts +25 -0
- package/dist/dashboard-source/apps/frontend/instrumentation.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/app-icons-metadata.ts +66 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +128 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +355 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/config.ts +18 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/reconnect-registry.ts +34 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/act-on-behalf-menu.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/callback-error.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +32 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/client.ts +46 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/config.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +62 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/issuer.ts +164 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/jwt.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +35 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys-menu.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +117 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +52 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +62 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/redirect.ts +105 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/secret-login-presentation.ts +33 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session-cache-scope.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session-role.ts +6 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +277 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +95 -0
- package/dist/dashboard-source/apps/frontend/lib/authorization-tabs.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/cedar-highlight.ts +116 -0
- package/dist/dashboard-source/apps/frontend/lib/client-plugin-error-reporting.ts +28 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +1119 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-scope.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/database-error-ui.tsx +61 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution-collection-provider.tsx +32 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +161 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/execution-collection-provider.tsx +42 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +215 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +123 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +123 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +394 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-registry.ts +196 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-database-name.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-lifecycle.ts +368 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-provider.tsx +577 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/todo-collection-provider.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +133 -0
- package/dist/dashboard-source/apps/frontend/lib/current-provider-user.ts +30 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/frontend-port-file.ts +41 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-events.ts +21 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +62 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +40 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/error-boundary.tsx +84 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/index.ts +31 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +57 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +168 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +206 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +36 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +94 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/index.ts +21 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest-store.ts +20 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +152 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-request-origin.ts +39 -0
- package/dist/dashboard-source/apps/frontend/lib/errors/get-display-error-message.ts +22 -0
- package/dist/dashboard-source/apps/frontend/lib/execution-menu-actions-registry.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/feature-permissions.ts +13 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-boot-health.tsx +161 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-client-plugin-registry.ts +45 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest-store.ts +214 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +74 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-plugin-loaders.ts +191 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/fragment-masking.ts +87 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +292 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +443 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-consumer.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-error-reporting.ts +268 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-provider.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dashboard-activity.ts +7 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +78 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/endpoint.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/execution-queries.ts +70 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/file-upload-provider.tsx +82 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/graphql-identifiers.ts +10 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +327 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +81 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +63 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-queries.ts +67 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/provider-user-queries.ts +65 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +80 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +15 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +634 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/stats-views-server.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/stats-views.ts +33 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +138 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +54 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/mobile-home-view-model.ts +74 -0
- package/dist/dashboard-source/apps/frontend/lib/mobile-shell-policy.ts +124 -0
- package/dist/dashboard-source/apps/frontend/lib/mock-data.ts +364 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +251 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +178 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notifications-runtime.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/use-todo-notifications.tsx +103 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-depth-config.ts +71 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-layout.ts +149 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-types.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +57 -0
- package/dist/dashboard-source/apps/frontend/lib/organisation-plugin-loaders.ts +13 -0
- package/dist/dashboard-source/apps/frontend/lib/organisation-plugin-preparation.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/plugins-client.tsx +99 -0
- package/dist/dashboard-source/apps/frontend/lib/plugins.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-graphql-errors.ts +45 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +200 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +209 -0
- package/dist/dashboard-source/apps/frontend/lib/query-client.ts +41 -0
- package/dist/dashboard-source/apps/frontend/lib/restart-execution-action.ts +76 -0
- package/dist/dashboard-source/apps/frontend/lib/runtime-config.ts +23 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/constants.ts +5 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/otlp-config.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/register-otel.ts +308 -0
- package/dist/dashboard-source/apps/frontend/lib/theme.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/todo-types.ts +64 -0
- package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +144 -0
- package/dist/dashboard-source/apps/frontend/lib/types/org-identity.ts +7 -0
- package/dist/dashboard-source/apps/frontend/lib/utils.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/constants.ts +118 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/edge-routing.ts +195 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/form-preview.ts +8 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +878 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/types.ts +63 -0
- package/dist/dashboard-source/apps/frontend/next.config.ts +238 -0
- package/dist/dashboard-source/apps/frontend/package.json +71 -0
- package/dist/dashboard-source/apps/frontend/postcss.config.mjs +5 -0
- package/dist/dashboard-source/apps/frontend/proxy.ts +293 -0
- package/dist/dashboard-source/apps/frontend/public/.gitkeep +0 -0
- package/dist/dashboard-source/apps/frontend/public/favicon.ico +0 -0
- package/dist/dashboard-source/apps/frontend/public/processfocus-embed.js +553 -0
- package/dist/dashboard-source/apps/frontend/tsconfig.json +35 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +7 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +1397 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +18 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +346 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +172 -0
- package/dist/dashboard-source/modules/auth-policy/src/index.ts +4 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +263 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +34 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/errors.ts +47 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +595 -0
- package/dist/dashboard-source/modules/auth-session/src/index.ts +22 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/issuer-url.ts +192 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +76 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/session-cache-scope.ts +24 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +54 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/url.ts +2 -0
- package/dist/dashboard-source/modules/aws-common/src/index.ts +3 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/acm.ts +50 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/otlp-config.ts +66 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/runtime-ssm.ts +28 -0
- package/dist/dashboard-source/modules/effect-json-logger/src/index.ts +1 -0
- package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +65 -0
- package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +78 -0
- package/dist/dashboard-source/modules/form/src/index.ts +20 -0
- package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +152 -0
- package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +1421 -0
- package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +85 -0
- package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +58 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +34 -0
- package/dist/dashboard-source/modules/form/src/lib/walker.tsx +1554 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +440 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +13 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +336 -0
- package/dist/dashboard-source/modules/form-rule/src/index.ts +21 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +531 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +102 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +121 -0
- package/dist/dashboard-source/modules/form-schema/src/index.ts +8 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +44 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/deferred-value.ts +21 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +50 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +82 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +58 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +975 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +60 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +45 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/endpoint.ts +137 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/index.ts +11 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/port-files.ts +219 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/index.ts +2 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +201 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +408 -0
- package/dist/dashboard-source/modules/frontend-plugin-host/src/index.ts +29 -0
- package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +288 -0
- package/dist/dashboard-source/modules/openauth/src/client.ts +1045 -0
- package/dist/dashboard-source/modules/openauth/src/error.ts +140 -0
- package/dist/dashboard-source/modules/openauth/src/pkce.ts +40 -0
- package/dist/dashboard-source/modules/openauth/src/random.ts +24 -0
- package/dist/dashboard-source/modules/openauth/src/subject.ts +132 -0
- package/dist/dashboard-source/modules/openauth/src/util.ts +13 -0
- package/dist/dashboard-source/modules/request-time/src/index.ts +1 -0
- package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +30 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/draft-process-execution-schema.json +45 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +217 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/process-schema.json +77 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/todo-schema.json +94 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/index.ts +2 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +181 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +166 -0
- package/dist/dashboard-source/modules/shadcn-components/src/index.ts +60 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/boolean-field.tsx +73 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/calendar-slot-field.tsx +808 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +127 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/field-set.tsx +14 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/file-field.tsx +321 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/file-upload-context.tsx +45 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/form-context.tsx +19 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +394 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/radio-field.tsx +96 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/select-field.tsx +106 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/text-field.tsx +245 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/button.tsx +63 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/checkbox.tsx +31 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/command.tsx +101 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/field.tsx +275 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/input.tsx +29 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/label.tsx +23 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +31 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/separator.tsx +27 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/textarea.tsx +19 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/utils/utils.ts +4 -0
- package/dist/dashboard-source.json +70 -0
- package/dist/graphql-server.mjs +1319 -0
- package/dist/job-worker.mjs +989 -0
- package/dist/main.mjs +495 -0
- package/dist/prepare-dashboard.mjs +35 -0
- package/dist/resources/cedar/policies.cedar +315 -0
- package/dist/resources/cedar/schema.cedarschema +276 -0
- package/dist/resources/graphql-schema/rxdb.graphql +401 -0
- package/dist/resources/graphql-schema/system.graphql +1200 -0
- package/package.json +98 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Session } from "../../../../modules/auth-session/src/index.ts"
|
|
2
|
+
|
|
3
|
+
/** Consistency check only. The server still verifies and authorizes the JWT. */
|
|
4
|
+
export function matchesRealtimeSessionToken(
|
|
5
|
+
token: string | undefined,
|
|
6
|
+
session: Session,
|
|
7
|
+
expiresAt: number,
|
|
8
|
+
): boolean {
|
|
9
|
+
try {
|
|
10
|
+
const payload = token?.split(".")[1]
|
|
11
|
+
if (!payload) return false
|
|
12
|
+
const decoded: unknown = JSON.parse(
|
|
13
|
+
new TextDecoder().decode(
|
|
14
|
+
Uint8Array.from(
|
|
15
|
+
atob(payload.replaceAll("-", "+").replaceAll("_", "/")),
|
|
16
|
+
(character) => character.charCodeAt(0),
|
|
17
|
+
),
|
|
18
|
+
),
|
|
19
|
+
)
|
|
20
|
+
if (
|
|
21
|
+
typeof decoded !== "object" ||
|
|
22
|
+
decoded === null ||
|
|
23
|
+
!("exp" in decoded) ||
|
|
24
|
+
decoded.exp !== expiresAt ||
|
|
25
|
+
!Number.isSafeInteger(expiresAt) ||
|
|
26
|
+
Date.now() >= expiresAt * 1000 ||
|
|
27
|
+
!("properties" in decoded)
|
|
28
|
+
)
|
|
29
|
+
return false
|
|
30
|
+
const properties = decoded.properties
|
|
31
|
+
if (typeof properties !== "object" || properties === null) return false
|
|
32
|
+
// Compare only addressing facts, not human authentication evidence omitted
|
|
33
|
+
// from the browser session. Never project a missing delegation into a human.
|
|
34
|
+
const delegation: unknown = Reflect.get(properties, "delegation")
|
|
35
|
+
const expected = "clientId" in session ? undefined : session.delegation
|
|
36
|
+
if (expected) {
|
|
37
|
+
if (
|
|
38
|
+
typeof delegation !== "object" ||
|
|
39
|
+
delegation === null ||
|
|
40
|
+
!["id", "generationId", "name", "expiresAt"].every(
|
|
41
|
+
(key) => Reflect.get(delegation, key) === Reflect.get(expected, key),
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
return false
|
|
45
|
+
} else if (delegation !== undefined) return false
|
|
46
|
+
return [
|
|
47
|
+
"userId",
|
|
48
|
+
"clientId",
|
|
49
|
+
"email",
|
|
50
|
+
"roles",
|
|
51
|
+
"orgUnitId",
|
|
52
|
+
"orgUnitPath",
|
|
53
|
+
"delegationRoleSelection",
|
|
54
|
+
].every(
|
|
55
|
+
(key) =>
|
|
56
|
+
JSON.stringify(Reflect.get(properties, key)) ===
|
|
57
|
+
JSON.stringify(Reflect.get(session, key)),
|
|
58
|
+
)
|
|
59
|
+
} catch {
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Either, Schema } from "effect"
|
|
2
|
+
|
|
3
|
+
// The prior signed access token binds a ceremony to its initiating identity.
|
|
4
|
+
const ReauthenticationState = Schema.Struct({
|
|
5
|
+
state: Schema.NonEmptyString,
|
|
6
|
+
accessToken: Schema.NonEmptyString,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export function readReauthenticationState(
|
|
10
|
+
value: string | undefined,
|
|
11
|
+
): typeof ReauthenticationState.Type | null {
|
|
12
|
+
const parsed = Schema.decodeUnknownEither(
|
|
13
|
+
Schema.parseJson(ReauthenticationState),
|
|
14
|
+
)(value)
|
|
15
|
+
return Either.isRight(parsed) ? parsed.right : null
|
|
16
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates and sanitizes a redirect URL to prevent open redirect attacks.
|
|
3
|
+
*
|
|
4
|
+
* Rules:
|
|
5
|
+
* - Must be a relative path (starts with /)
|
|
6
|
+
* - Must not be a protocol-relative URL (starts with //)
|
|
7
|
+
* - Must not redirect to API routes
|
|
8
|
+
* - Must not redirect to login/logout pages
|
|
9
|
+
*
|
|
10
|
+
* @param redirect - A root-relative URL with escaped components, or a legacy
|
|
11
|
+
* whole-URL-encoded value. Once the leading / is exposed, component escapes
|
|
12
|
+
* are preserved. The returned URL is safe to validate again.
|
|
13
|
+
* @returns An object with the validated redirect URL and whether it was rejected
|
|
14
|
+
*/
|
|
15
|
+
export function validateRedirect(redirect: string | undefined | null): {
|
|
16
|
+
url: string
|
|
17
|
+
rejected: boolean
|
|
18
|
+
reason?: string
|
|
19
|
+
} {
|
|
20
|
+
if (!redirect) return { url: "/", rejected: false }
|
|
21
|
+
|
|
22
|
+
const MAX_DECODE_ITERATIONS = 5
|
|
23
|
+
let canonical = redirect
|
|
24
|
+
try {
|
|
25
|
+
// Preserve the shipped whole-path encoding API without decoding query data.
|
|
26
|
+
for (let i = 0; !canonical.startsWith("/"); i++) {
|
|
27
|
+
if (i === MAX_DECODE_ITERATIONS) {
|
|
28
|
+
return { url: "/", rejected: true, reason: "excessive_encoding" }
|
|
29
|
+
}
|
|
30
|
+
const next = decodeURIComponent(canonical)
|
|
31
|
+
if (next === canonical) break
|
|
32
|
+
canonical = next
|
|
33
|
+
}
|
|
34
|
+
// Check encoding syntax, but never use decoded query/fragment values as URLs.
|
|
35
|
+
decodeURIComponent(canonical)
|
|
36
|
+
} catch {
|
|
37
|
+
return { url: "/", rejected: true, reason: "invalid_encoding" }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Decode only a separate pathname for conservative security inspection.
|
|
41
|
+
let decoded = canonical.split(/[?#]/, 1)[0] ?? ""
|
|
42
|
+
try {
|
|
43
|
+
for (let i = 0; i < MAX_DECODE_ITERATIONS; i++) {
|
|
44
|
+
const next = decodeURIComponent(decoded)
|
|
45
|
+
if (next === decoded) break // No more encoding to decode
|
|
46
|
+
decoded = next
|
|
47
|
+
if (i === MAX_DECODE_ITERATIONS - 1) {
|
|
48
|
+
// Still changing after max iterations - reject
|
|
49
|
+
return { url: "/", rejected: true, reason: "excessive_encoding" }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
// Invalid encoding, reject
|
|
54
|
+
return { url: "/", rejected: true, reason: "invalid_encoding" }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Must start with / (relative path)
|
|
58
|
+
if (!decoded.startsWith("/")) {
|
|
59
|
+
return { url: "/", rejected: true, reason: "not_relative_path" }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Must not be protocol-relative URL (//evil.com)
|
|
63
|
+
if (decoded.startsWith("//")) {
|
|
64
|
+
return { url: "/", rejected: true, reason: "protocol_relative" }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (
|
|
68
|
+
decoded.includes("\\") ||
|
|
69
|
+
[...decoded, ...canonical].some(
|
|
70
|
+
(character) =>
|
|
71
|
+
character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127,
|
|
72
|
+
)
|
|
73
|
+
) {
|
|
74
|
+
return { url: "/", rejected: true, reason: "host_manipulation" }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Check both normalized pathnames: decoding %3F/%23 can hide traversal in
|
|
78
|
+
// an apparent query/fragment that is still part of the canonical pathname.
|
|
79
|
+
try {
|
|
80
|
+
for (const candidate of [canonical, decoded]) {
|
|
81
|
+
const asUrl = new URL(candidate, "http://localhost")
|
|
82
|
+
if (asUrl.origin !== "http://localhost") {
|
|
83
|
+
return { url: "/", rejected: true, reason: "host_manipulation" }
|
|
84
|
+
}
|
|
85
|
+
if (asUrl.pathname.startsWith("/api/")) {
|
|
86
|
+
return { url: "/", rejected: true, reason: "api_route" }
|
|
87
|
+
}
|
|
88
|
+
if (asUrl.pathname === "/login" || asUrl.pathname === "/logout") {
|
|
89
|
+
return { url: "/", rejected: true, reason: "auth_route" }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} catch {
|
|
93
|
+
return { url: "/", rejected: true, reason: "invalid_url" }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return { url: canonical, rejected: false }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Simple version that just returns the URL string.
|
|
101
|
+
* Use validateRedirect when you need to log rejections.
|
|
102
|
+
*/
|
|
103
|
+
export function getValidRedirect(redirect: string | undefined | null): string {
|
|
104
|
+
return validateRedirect(redirect).url
|
|
105
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "server-only"
|
|
2
|
+
import { getFrontendAuthClientConfig } from "./issuer.ts"
|
|
3
|
+
|
|
4
|
+
export async function isSecretLoginEnabled(): Promise<boolean> {
|
|
5
|
+
try {
|
|
6
|
+
const { issuer, jwt } = getFrontendAuthClientConfig()
|
|
7
|
+
const url = new URL(issuer)
|
|
8
|
+
if (
|
|
9
|
+
url.protocol !== "https:" &&
|
|
10
|
+
!["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)
|
|
11
|
+
)
|
|
12
|
+
return false
|
|
13
|
+
const response = await fetch(`${issuer}/oauth/delegation/availability`, {
|
|
14
|
+
method: "GET",
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${jwt}`,
|
|
17
|
+
},
|
|
18
|
+
cache: "no-store",
|
|
19
|
+
redirect: "error",
|
|
20
|
+
signal: AbortSignal.timeout(5_000),
|
|
21
|
+
})
|
|
22
|
+
if (!response.ok) return false
|
|
23
|
+
const presentation: unknown = await response.json()
|
|
24
|
+
return (
|
|
25
|
+
typeof presentation === "object" &&
|
|
26
|
+
presentation !== null &&
|
|
27
|
+
"secretLoginEnabled" in presentation &&
|
|
28
|
+
presentation.secretLoginEnabled === true
|
|
29
|
+
)
|
|
30
|
+
} catch {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSessionCacheScope } from "../../../../modules/auth-session/src/lib/session-cache-scope.ts"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Session } from "../../../../modules/auth-session/src/index.ts"
|
|
2
|
+
|
|
3
|
+
export function getActiveRoleCacheKey(session: Pick<Session, "roles">): string {
|
|
4
|
+
// Auth sessions encode the active role as the first role in the token.
|
|
5
|
+
return session.roles?.[0] ?? "no-role"
|
|
6
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { Data, Effect } from "effect"
|
|
2
|
+
import { io } from "next/cache"
|
|
3
|
+
import { cookies, headers } from "next/headers"
|
|
4
|
+
import { type Session, subjects } from "../../../../modules/auth-session/src/index.ts"
|
|
5
|
+
import { getAuthClient } from "./client.ts"
|
|
6
|
+
import {
|
|
7
|
+
DEFAULT_ACCESS_TOKEN_MAX_AGE,
|
|
8
|
+
DEFAULT_REFRESH_TOKEN_MAX_AGE,
|
|
9
|
+
} from "./config.ts"
|
|
10
|
+
import { decodeJwtPayload } from "./jwt.ts"
|
|
11
|
+
import { acceptVerifiedSession } from "./ssr-session.ts"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Compute port-suffixed cookie names when running on localhost.
|
|
15
|
+
* This prevents cookie collisions between multiple local runtime instances
|
|
16
|
+
* running on different ports (e.g. localhost:3000 and localhost:3001).
|
|
17
|
+
*/
|
|
18
|
+
export async function getCookieNames() {
|
|
19
|
+
const h = await headers()
|
|
20
|
+
const host = h.get("host") ?? ""
|
|
21
|
+
return getCookieNamesFromHost(host)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sync variant for use in proxy.ts / login route where the host string is already available.
|
|
26
|
+
*/
|
|
27
|
+
export function getCookieNamesFromHost(host: string) {
|
|
28
|
+
let suffix = ""
|
|
29
|
+
|
|
30
|
+
if (host) {
|
|
31
|
+
try {
|
|
32
|
+
const url = new URL(`http://${host}`)
|
|
33
|
+
if (
|
|
34
|
+
(url.hostname === "localhost" || url.hostname === "127.0.0.1") &&
|
|
35
|
+
url.port
|
|
36
|
+
) {
|
|
37
|
+
suffix = `_${url.port}`
|
|
38
|
+
}
|
|
39
|
+
} catch {
|
|
40
|
+
suffix = ""
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
accessToken: `access_token${suffix}`,
|
|
46
|
+
refreshToken: `refresh_token${suffix}`,
|
|
47
|
+
oauthState: `oauth_state${suffix}`,
|
|
48
|
+
passkeyAuthCookies: `passkey_auth_cookies${suffix}`,
|
|
49
|
+
/**
|
|
50
|
+
* Registration Session bearer from a Registration Link exchange.
|
|
51
|
+
* Path-restricted to passkey registration endpoints.
|
|
52
|
+
*/
|
|
53
|
+
registrationSession: `registration_session${suffix}`,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type CookieNames = Awaited<ReturnType<typeof getCookieNames>>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Hide JWT tokens from JavaScript, unless we are using AppSync Events websockets.
|
|
61
|
+
*
|
|
62
|
+
* For AppSync we must surface our cookies, as we need access to the
|
|
63
|
+
* JWT token in order to send the proper websocket authentication.
|
|
64
|
+
*
|
|
65
|
+
* @returns true if access token should be exposed to JavaScript, false otherwise
|
|
66
|
+
*/
|
|
67
|
+
const shouldExposeAccessTokenToJavaScript = (): boolean => {
|
|
68
|
+
return !!process.env["APPSYNC_EVENTS_HTTP_HOST"]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Error when no access token is found in cookies
|
|
73
|
+
*/
|
|
74
|
+
class NoAccessTokenError extends Data.TaggedError("NoAccessTokenError")<{
|
|
75
|
+
message: string
|
|
76
|
+
}> {}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Error when JWT verification fails
|
|
80
|
+
*/
|
|
81
|
+
class JWTVerificationError extends Data.TaggedError("JWTVerificationError")<{
|
|
82
|
+
message: string
|
|
83
|
+
}> {}
|
|
84
|
+
|
|
85
|
+
type SessionWithToken = Session & {
|
|
86
|
+
accessToken: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type SessionWithTokenAndExpiry = Session & {
|
|
90
|
+
accessToken: string
|
|
91
|
+
/** Unix timestamp in seconds when the access token expires */
|
|
92
|
+
expiresAt: number
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get the current session with access token and expiry time.
|
|
97
|
+
* Used by the root layout when it needs both the token (for API calls)
|
|
98
|
+
* and expiry (for client-side refresh scheduling).
|
|
99
|
+
*
|
|
100
|
+
* Returns session + accessToken + expiresAt or null if not authenticated.
|
|
101
|
+
*/
|
|
102
|
+
export const getSessionWithTokenAndExpiry =
|
|
103
|
+
async (): Promise<SessionWithTokenAndExpiry | null> => {
|
|
104
|
+
const cookieStore = await cookies()
|
|
105
|
+
const { accessToken: AT } = await getCookieNames()
|
|
106
|
+
const accessToken = cookieStore.get(AT)?.value
|
|
107
|
+
|
|
108
|
+
if (!accessToken) {
|
|
109
|
+
return null
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Partial prerenders can already have cookies. Keep the client-cache clock
|
|
113
|
+
// and live session verification outside prerendering without caching results.
|
|
114
|
+
await io()
|
|
115
|
+
const authClient = getAuthClient()
|
|
116
|
+
const verified = await authClient.verify(subjects, accessToken, undefined)
|
|
117
|
+
|
|
118
|
+
if (verified.err) {
|
|
119
|
+
return null
|
|
120
|
+
}
|
|
121
|
+
const session = await acceptVerifiedSession(
|
|
122
|
+
verified.subject.properties,
|
|
123
|
+
accessToken,
|
|
124
|
+
)
|
|
125
|
+
if (!session) return null
|
|
126
|
+
|
|
127
|
+
// Decode JWT to get expiry time
|
|
128
|
+
const payload = decodeJwtPayload(accessToken)
|
|
129
|
+
if (!payload?.exp) {
|
|
130
|
+
return null
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
...session,
|
|
135
|
+
accessToken,
|
|
136
|
+
expiresAt: payload.exp,
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get the current session with access token
|
|
142
|
+
* Only use this from server-side code (Server Components, API routes, Server Actions)
|
|
143
|
+
* that needs to make authenticated API calls with Authorization headers
|
|
144
|
+
*
|
|
145
|
+
* The token is cryptographically verified against the (cached) issuer
|
|
146
|
+
* key. Delegated sessions additionally require live issuer facts on every call.
|
|
147
|
+
* We do not refresh the token if it is expired.
|
|
148
|
+
*
|
|
149
|
+
* For client-side code, use getSession() and rely on httpOnly cookies
|
|
150
|
+
*
|
|
151
|
+
* Returns an Effect that must be run with Effect.runPromise or provided in a layer.
|
|
152
|
+
* Error types: NoAccessTokenError | ConfigError | JWTVerificationError | ParseError
|
|
153
|
+
*/
|
|
154
|
+
export const getSessionWithToken = Effect.gen(function* () {
|
|
155
|
+
const cookieStore = yield* Effect.promise(() => cookies())
|
|
156
|
+
const { accessToken: AT } = yield* Effect.promise(() => getCookieNames())
|
|
157
|
+
const accessToken = cookieStore.get(AT)?.value
|
|
158
|
+
|
|
159
|
+
if (!accessToken) {
|
|
160
|
+
return yield* Effect.fail(
|
|
161
|
+
new NoAccessTokenError({ message: "No access token found in cookies" }),
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Match the async session entry point: cookies alone are not an IO boundary
|
|
166
|
+
// when Next.js resumes a partial prerender with request data.
|
|
167
|
+
yield* Effect.promise(() => io())
|
|
168
|
+
const authClient = getAuthClient()
|
|
169
|
+
const verified = yield* Effect.tryPromise({
|
|
170
|
+
try: () => authClient.verify(subjects, accessToken, undefined),
|
|
171
|
+
catch: (error) =>
|
|
172
|
+
new JWTVerificationError({
|
|
173
|
+
message: error instanceof Error ? error.message : String(error),
|
|
174
|
+
}),
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
if (verified.err) {
|
|
178
|
+
return yield* Effect.fail(
|
|
179
|
+
new JWTVerificationError({
|
|
180
|
+
message: "Session is unavailable or invalid",
|
|
181
|
+
}),
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
const session = yield* Effect.promise(() =>
|
|
185
|
+
acceptVerifiedSession(verified.subject.properties, accessToken),
|
|
186
|
+
)
|
|
187
|
+
if (!session)
|
|
188
|
+
return yield* new JWTVerificationError({
|
|
189
|
+
message: "Session is unavailable or invalid",
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
...session,
|
|
194
|
+
accessToken: accessToken,
|
|
195
|
+
} satisfies SessionWithToken
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Cookie options for access token.
|
|
200
|
+
*/
|
|
201
|
+
export const getAccessTokenCookieOptions = (maxAge: number) => ({
|
|
202
|
+
httpOnly: !shouldExposeAccessTokenToJavaScript(),
|
|
203
|
+
secure: process.env["NODE_ENV"] === "production",
|
|
204
|
+
sameSite: "lax" as const,
|
|
205
|
+
maxAge,
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Cookie options for refresh token.
|
|
210
|
+
*/
|
|
211
|
+
export const getRefreshTokenCookieOptions = (maxAge: number) => ({
|
|
212
|
+
httpOnly: true,
|
|
213
|
+
secure: process.env["NODE_ENV"] === "production",
|
|
214
|
+
sameSite: "lax" as const,
|
|
215
|
+
maxAge,
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Set session cookies with tokens.
|
|
220
|
+
* Used by oauth callback, refresh route, and proxy middleware.
|
|
221
|
+
*/
|
|
222
|
+
export const setTokenCookies = async (
|
|
223
|
+
cookieStore: Awaited<ReturnType<typeof cookies>>,
|
|
224
|
+
tokens: {
|
|
225
|
+
access: string
|
|
226
|
+
refresh?: string
|
|
227
|
+
expiresIn?: number
|
|
228
|
+
refreshExpiresIn?: number
|
|
229
|
+
},
|
|
230
|
+
cookieNames?: CookieNames,
|
|
231
|
+
) => {
|
|
232
|
+
const { accessToken: AT, refreshToken: RT } =
|
|
233
|
+
cookieNames ?? (await getCookieNames())
|
|
234
|
+
|
|
235
|
+
cookieStore.set(
|
|
236
|
+
AT,
|
|
237
|
+
tokens.access,
|
|
238
|
+
getAccessTokenCookieOptions(
|
|
239
|
+
tokens.expiresIn ?? DEFAULT_ACCESS_TOKEN_MAX_AGE,
|
|
240
|
+
),
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
if (tokens.refresh) {
|
|
244
|
+
cookieStore.set(
|
|
245
|
+
RT,
|
|
246
|
+
tokens.refresh,
|
|
247
|
+
getRefreshTokenCookieOptions(
|
|
248
|
+
tokens.refreshExpiresIn ?? DEFAULT_REFRESH_TOKEN_MAX_AGE,
|
|
249
|
+
),
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Set session cookies with tokens.
|
|
256
|
+
*
|
|
257
|
+
* This is the place where we set cookies for the first time (after oauth login).
|
|
258
|
+
*/
|
|
259
|
+
export const setSessionCookies = async (tokens: {
|
|
260
|
+
access: string
|
|
261
|
+
refresh?: string
|
|
262
|
+
expiresIn?: number
|
|
263
|
+
refreshExpiresIn?: number
|
|
264
|
+
}) => {
|
|
265
|
+
const cookieStore = await cookies()
|
|
266
|
+
await setTokenCookies(cookieStore, tokens)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Clear session cookies
|
|
271
|
+
*/
|
|
272
|
+
export const clearSession = async () => {
|
|
273
|
+
const cookieStore = await cookies()
|
|
274
|
+
const { accessToken: AT, refreshToken: RT } = await getCookieNames()
|
|
275
|
+
cookieStore.delete(AT)
|
|
276
|
+
cookieStore.delete(RT)
|
|
277
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import "server-only"
|
|
2
|
+
import { type Session, subjects } from "../../../../modules/auth-session/src/index.ts"
|
|
3
|
+
import { getFrontendAuthClientConfig } from "./issuer.ts"
|
|
4
|
+
import { decodeJwtPayload } from "./jwt.ts"
|
|
5
|
+
|
|
6
|
+
/** Call only after signature, issuer, audience and expiry verification. No caching. */
|
|
7
|
+
export async function acceptVerifiedSession(
|
|
8
|
+
session: Session,
|
|
9
|
+
accessToken: string,
|
|
10
|
+
): Promise<Session | null> {
|
|
11
|
+
const claims = decodeJwtPayload(accessToken)
|
|
12
|
+
const properties = claims?.properties
|
|
13
|
+
const tokenHasDelegation =
|
|
14
|
+
typeof properties === "object" &&
|
|
15
|
+
properties !== null &&
|
|
16
|
+
"delegation" in properties
|
|
17
|
+
// A frontend-supplied marker cannot upgrade a human token, and schema
|
|
18
|
+
// projection must not strip a signed marker into a human/service session.
|
|
19
|
+
if (tokenHasDelegation !== "delegation" in session) return null
|
|
20
|
+
if (!("delegation" in session)) {
|
|
21
|
+
return "delegationRoleSelection" in session ? null : session
|
|
22
|
+
}
|
|
23
|
+
if (
|
|
24
|
+
!("email" in session) ||
|
|
25
|
+
!session.delegation ||
|
|
26
|
+
session.humanAuthentication !== undefined
|
|
27
|
+
)
|
|
28
|
+
return null
|
|
29
|
+
try {
|
|
30
|
+
const { issuer, jwt } = getFrontendAuthClientConfig()
|
|
31
|
+
const url = new URL(issuer)
|
|
32
|
+
if (
|
|
33
|
+
url.protocol !== "https:" &&
|
|
34
|
+
!["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)
|
|
35
|
+
)
|
|
36
|
+
return null
|
|
37
|
+
const response = await fetch(`${issuer}/oauth/delegation/session`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
Authorization: `Bearer ${jwt}`,
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify({ accessToken }),
|
|
44
|
+
cache: "no-store",
|
|
45
|
+
redirect: "error",
|
|
46
|
+
signal: AbortSignal.timeout(10_000),
|
|
47
|
+
})
|
|
48
|
+
if (!response.ok) return null
|
|
49
|
+
const body: unknown = await response.json()
|
|
50
|
+
if (typeof body !== "object" || body === null || !("session" in body))
|
|
51
|
+
return null
|
|
52
|
+
const parsed = await subjects.providerUser["~standard"].validate(
|
|
53
|
+
body.session,
|
|
54
|
+
)
|
|
55
|
+
if (parsed.issues) return null
|
|
56
|
+
const current = parsed.value
|
|
57
|
+
const expiry = claims?.exp
|
|
58
|
+
if (
|
|
59
|
+
!current.delegation ||
|
|
60
|
+
current.humanAuthentication !== undefined ||
|
|
61
|
+
current.userId !== session.userId ||
|
|
62
|
+
current.email !== session.email ||
|
|
63
|
+
current.delegation.id !== session.delegation.id ||
|
|
64
|
+
current.delegation.generationId !== session.delegation.generationId ||
|
|
65
|
+
current.delegation.expiresAt !== session.delegation.expiresAt ||
|
|
66
|
+
Date.now() >= current.delegation.expiresAt ||
|
|
67
|
+
!expiry ||
|
|
68
|
+
expiry * 1000 > current.delegation.expiresAt
|
|
69
|
+
)
|
|
70
|
+
return null
|
|
71
|
+
return current
|
|
72
|
+
} catch {
|
|
73
|
+
// Never propagate credential-bearing transport/schema error objects.
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WebAuthnAbortService,
|
|
3
|
+
startAuthentication,
|
|
4
|
+
} from "@simplewebauthn/browser"
|
|
5
|
+
|
|
6
|
+
/** Run the existing OAuth/WebAuthn ceremony. Only the callback sets session cookies. */
|
|
7
|
+
export async function authenticateWithPasskey({
|
|
8
|
+
redirect,
|
|
9
|
+
purpose,
|
|
10
|
+
inPlace = false,
|
|
11
|
+
signal,
|
|
12
|
+
}: {
|
|
13
|
+
redirect: string | undefined
|
|
14
|
+
purpose: "signin" | "reauthenticate"
|
|
15
|
+
inPlace?: boolean
|
|
16
|
+
signal?: AbortSignal
|
|
17
|
+
}): Promise<void> {
|
|
18
|
+
const start = await fetch("/api/auth/passkey/start", {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: { "Content-Type": "application/json" },
|
|
21
|
+
body: JSON.stringify({ redirect, purpose }),
|
|
22
|
+
credentials: "include",
|
|
23
|
+
...(signal ? { signal } : {}),
|
|
24
|
+
})
|
|
25
|
+
if (!start.ok)
|
|
26
|
+
throw new Error("Unable to start passkey verification. Please try again.")
|
|
27
|
+
const optionsResponse = await fetch("/api/auth/passkey/auth-options", {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: { "Content-Type": "application/json" },
|
|
30
|
+
body: "{}",
|
|
31
|
+
credentials: "include",
|
|
32
|
+
...(signal ? { signal } : {}),
|
|
33
|
+
})
|
|
34
|
+
if (!optionsResponse.ok)
|
|
35
|
+
throw new Error("Unable to start passkey verification. Please try again.")
|
|
36
|
+
const { challengeId, options } = await optionsResponse.json()
|
|
37
|
+
signal?.throwIfAborted()
|
|
38
|
+
const cancelCeremony = () => WebAuthnAbortService.cancelCeremony()
|
|
39
|
+
signal?.addEventListener("abort", cancelCeremony, { once: true })
|
|
40
|
+
let assertion: Awaited<ReturnType<typeof startAuthentication>>
|
|
41
|
+
try {
|
|
42
|
+
assertion = await startAuthentication({ optionsJSON: options })
|
|
43
|
+
} finally {
|
|
44
|
+
signal?.removeEventListener("abort", cancelCeremony)
|
|
45
|
+
}
|
|
46
|
+
signal?.throwIfAborted()
|
|
47
|
+
const verify = await fetch("/api/auth/passkey/auth-verify", {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: { "Content-Type": "application/json" },
|
|
50
|
+
body: JSON.stringify({ challengeId, response: assertion }),
|
|
51
|
+
credentials: "include",
|
|
52
|
+
...(signal ? { signal } : {}),
|
|
53
|
+
})
|
|
54
|
+
const data: unknown = await verify.json()
|
|
55
|
+
if (
|
|
56
|
+
!verify.ok ||
|
|
57
|
+
typeof data !== "object" ||
|
|
58
|
+
data === null ||
|
|
59
|
+
!("redirectUrl" in data) ||
|
|
60
|
+
typeof data.redirectUrl !== "string"
|
|
61
|
+
)
|
|
62
|
+
throw new Error("Passkey verification failed. Your token was not changed.")
|
|
63
|
+
const callback = new URL(data.redirectUrl, window.location.origin)
|
|
64
|
+
if (
|
|
65
|
+
callback.origin !== window.location.origin ||
|
|
66
|
+
callback.pathname !== "/api/auth/callback"
|
|
67
|
+
)
|
|
68
|
+
throw new Error(
|
|
69
|
+
"Unable to complete passkey verification. Please try again.",
|
|
70
|
+
)
|
|
71
|
+
if (!inPlace) {
|
|
72
|
+
window.location.href = callback.href
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
// Complete the redirect-based OAuth exchange in this document. Drafts and
|
|
76
|
+
// pending intent stay in memory; reload never replays an action or a secret.
|
|
77
|
+
const completed = await fetch(callback.href, {
|
|
78
|
+
headers: { Accept: "application/json" },
|
|
79
|
+
credentials: "include",
|
|
80
|
+
...(signal ? { signal } : {}),
|
|
81
|
+
redirect: "error",
|
|
82
|
+
cache: "no-store",
|
|
83
|
+
})
|
|
84
|
+
const result: unknown = await completed.json()
|
|
85
|
+
if (
|
|
86
|
+
!completed.ok ||
|
|
87
|
+
typeof result !== "object" ||
|
|
88
|
+
result === null ||
|
|
89
|
+
!("success" in result) ||
|
|
90
|
+
result.success !== true
|
|
91
|
+
)
|
|
92
|
+
throw new Error(
|
|
93
|
+
"Verification failed. Use the same account's passkey and try again. Your token was not changed.",
|
|
94
|
+
)
|
|
95
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const AUTHORIZATION_TABS = [
|
|
2
|
+
{ id: "access", label: "Access" },
|
|
3
|
+
{ id: "explorer", label: "Explorer" },
|
|
4
|
+
{ id: "policies", label: "Policies" },
|
|
5
|
+
{ id: "schema", label: "Schema" },
|
|
6
|
+
] as const
|
|
7
|
+
|
|
8
|
+
export type AuthorizationTabId = (typeof AUTHORIZATION_TABS)[number]["id"]
|
|
9
|
+
|
|
10
|
+
export const parseAuthorizationTab = (
|
|
11
|
+
segment: string | undefined,
|
|
12
|
+
): AuthorizationTabId | null => {
|
|
13
|
+
if (segment === undefined) return "access"
|
|
14
|
+
const match = AUTHORIZATION_TABS.find((tab) => tab.id === segment)
|
|
15
|
+
return match?.id ?? null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const authorizationTabHref = (tab: AuthorizationTabId): string =>
|
|
19
|
+
`/settings/cedar/${tab}`
|