@camstack/server 1.2.592 → 1.2.594
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/dist/addon-root-inventory.js +11 -50
- package/dist/agent/addon-scan.js +6 -44
- package/dist/agent/agent-addon-runtime.js +3 -8
- package/dist/agent/agent-addon-updates.js +12 -52
- package/dist/agent/agent-cap-dispatch-service.js +3 -5
- package/dist/agent/agent-config.js +7 -42
- package/dist/agent/agent-deploy-swap.js +5 -41
- package/dist/agent/agent-group-runner.js +8 -47
- package/dist/agent/agent-http-auth.js +10 -22
- package/dist/agent/agent-http.js +69 -115
- package/dist/agent/agent-hub-addon-update.js +10 -16
- package/dist/agent/agent-hub-registration.js +4 -7
- package/dist/agent/agent-infra-capabilities.js +5 -9
- package/dist/agent/agent-json-file.js +5 -42
- package/dist/agent/agent-mesh-gate.js +5 -8
- package/dist/agent/agent-node-certificates.js +25 -28
- package/dist/agent/agent-pairing-local.js +10 -47
- package/dist/agent/agent-pairing-routes.js +16 -20
- package/dist/agent/agent-pairing-store.js +18 -58
- package/dist/agent/agent-reconnect.js +1 -4
- package/dist/agent/agent-service.js +42 -78
- package/dist/agent/agent-sniffing-listener.js +11 -48
- package/dist/agent/agent-undeploy.js +5 -41
- package/dist/agent/agent-update-routes.js +14 -19
- package/dist/agent/agent-update-service.js +38 -80
- package/dist/agent/apply-model-distribution.js +1 -4
- package/dist/agent/apply-stage-dev-uploads.js +6 -9
- package/dist/agent/derive-hub-url.js +3 -8
- package/dist/agent/fetch-bundle-from-hub.js +6 -9
- package/dist/agent/hubs-found.js +6 -43
- package/dist/agent/infra-boot-guard.js +1 -4
- package/dist/agent/infra-boot-plan.js +2 -6
- package/dist/agent/main.js +158 -186
- package/dist/agent/register-agent-cap-dispatch.js +3 -6
- package/dist/agent/serial-queue.js +2 -7
- package/dist/agent-status-page.js +1 -4
- package/dist/api/addon-upload.js +22 -61
- package/dist/api/agent-addon-delivery.js +6 -11
- package/dist/api/auth-whoami.js +1 -4
- package/dist/api/backup-download-pump.js +5 -9
- package/dist/api/backup-download.js +7 -10
- package/dist/api/core/addon-settings.router.js +16 -19
- package/dist/api/core/agent-pairing.router.js +76 -79
- package/dist/api/core/agents.router.js +21 -24
- package/dist/api/core/auth-admin-tokens.procedures.js +48 -52
- package/dist/api/core/auth-device-cert.procedures.js +62 -67
- package/dist/api/core/auth-limits.js +16 -25
- package/dist/api/core/auth-reauth.procedures.js +32 -37
- package/dist/api/core/auth-revoke-credentials.procedures.js +22 -26
- package/dist/api/core/auth-sessions.procedures.js +52 -56
- package/dist/api/core/auth.router.js +300 -304
- package/dist/api/core/cap-providers.js +74 -121
- package/dist/api/core/capabilities.router.js +34 -37
- package/dist/api/core/capability-preference-writes.js +10 -17
- package/dist/api/core/certificates.router.js +106 -109
- package/dist/api/core/cluster-nodes.router.js +15 -18
- package/dist/api/core/collection-preference.js +2 -6
- package/dist/api/core/event-bus-proxy.router.js +34 -37
- package/dist/api/core/failure-contributions.js +4 -8
- package/dist/api/core/hwaccel.router.js +17 -20
- package/dist/api/core/integration-secrets.js +8 -12
- package/dist/api/core/lifecycle-job-runner.js +13 -49
- package/dist/api/core/live-events.router.js +29 -32
- package/dist/api/core/load-contributions.js +4 -8
- package/dist/api/core/logging-settings.js +30 -43
- package/dist/api/core/logs.router.js +40 -43
- package/dist/api/core/notifications.router.js +15 -18
- package/dist/api/core/public-event-filter.js +4 -8
- package/dist/api/core/repl.router.js +18 -21
- package/dist/api/core/request-census-settings.js +11 -16
- package/dist/api/core/server-management.provider.js +1 -4
- package/dist/api/core/server-name.js +9 -17
- package/dist/api/core/site-location.js +16 -24
- package/dist/api/core/stream-probe.router.js +21 -24
- package/dist/api/core/system-events.router.js +23 -26
- package/dist/api/cors/cors-policy.js +20 -29
- package/dist/api/cors/register-cors-policy.js +9 -14
- package/dist/api/deploy-stage-registry.js +6 -10
- package/dist/api/dev-uploads-bundle.js +12 -50
- package/dist/api/health/adaptive-probe.routes.js +9 -13
- package/dist/api/health/health.routes.js +8 -13
- package/dist/api/hub-cluster-url.js +3 -9
- package/dist/api/model-distributor.js +12 -50
- package/dist/api/oauth2/consent-page.js +10 -13
- package/dist/api/oauth2/oauth2-routes.js +17 -25
- package/dist/api/oauth2/private-host.js +1 -4
- package/dist/api/server-upload-propagate.js +15 -51
- package/dist/api/server-upload.js +13 -50
- package/dist/api/sse-no-compression.js +1 -4
- package/dist/api/static/frame-policy.js +4 -9
- package/dist/api/static/precompressed-asset.js +15 -57
- package/dist/api/static/spa-mount.js +8 -47
- package/dist/api/static/spa-static.js +5 -12
- package/dist/api/tarball-manifest.js +7 -44
- package/dist/api/trpc/cap-mount-helpers.js +7 -12
- package/dist/api/trpc/cap-route-error-formatter.js +10 -13
- package/dist/api/trpc/cap-router-runtime.js +40 -51
- package/dist/api/trpc/client-ip.js +9 -20
- package/dist/api/trpc/core-cap-bridge.js +32 -42
- package/dist/api/trpc/device-collection-dispatch.js +23 -27
- package/dist/api/trpc/device-config-secret-redaction.js +24 -40
- package/dist/api/trpc/generated-cap-mounts.js +219 -221
- package/dist/api/trpc/generated-cap-routers.js +4878 -4726
- package/dist/api/trpc/http-request-census-hook.js +8 -11
- package/dist/api/trpc/http-request-census.js +34 -41
- package/dist/api/trpc/http-request-census.singleton.js +4 -8
- package/dist/api/trpc/localized-schema-paths.js +1 -4
- package/dist/api/trpc/principal-visibility.js +14 -22
- package/dist/api/trpc/remote-addon-update-grant.js +1 -4
- package/dist/api/trpc/scope-access.js +10 -15
- package/dist/api/trpc/server-provided-caps.js +3 -7
- package/dist/api/trpc/share-view-access.js +6 -14
- package/dist/api/trpc/trpc-error-device-tags.js +3 -6
- package/dist/api/trpc/trpc-error-principal.js +2 -6
- package/dist/api/trpc/trpc.context.js +20 -25
- package/dist/api/trpc/trpc.middleware.js +38 -46
- package/dist/api/trpc/trpc.router.js +58 -99
- package/dist/api/trpc/user-error.js +5 -8
- package/dist/api/trpc/ws-request-census.js +17 -24
- package/dist/api/trpc/ws-slow-consumer-guard.js +11 -16
- package/dist/api/upload-auth.js +5 -9
- package/dist/auth/addon-route-jwt-gate.js +4 -7
- package/dist/auth/addon-route-share-gate.js +7 -12
- package/dist/auth/app-confirm-page.js +17 -22
- package/dist/auth/app-confirm-routes.js +26 -31
- package/dist/auth/app-confirmations.js +7 -44
- package/dist/auth/app-page-shell.js +17 -30
- package/dist/auth/app-page-strings.js +11 -17
- package/dist/auth/app-passkey-page.js +16 -21
- package/dist/auth/app-passkey-routes.js +37 -41
- package/dist/auth/app-refused-route.js +13 -18
- package/dist/auth/auth-network-policy.js +11 -15
- package/dist/auth/auth-provider-gate.js +4 -9
- package/dist/auth/auth-rate-limit.js +3 -7
- package/dist/auth/client-address.js +6 -9
- package/dist/auth/device-enroll-proofs.js +6 -43
- package/dist/auth/external-link-intents.js +3 -7
- package/dist/auth/hub-sessions.js +6 -12
- package/dist/auth/native-link-completions.js +7 -11
- package/dist/auth/native-return.js +9 -13
- package/dist/auth/passkey-provider.js +26 -32
- package/dist/auth/second-factors.js +6 -10
- package/dist/auth/session-connections.js +6 -12
- package/dist/auth/session-cookie.js +12 -23
- package/dist/auth/session-lifetimes.js +8 -12
- package/dist/auth/session-mint.js +4 -11
- package/dist/auth/sso-finish-app.js +13 -16
- package/dist/auth/sso-finish-deps.js +21 -27
- package/dist/auth/sso-finish.js +28 -38
- package/dist/auth/sso-routes.js +22 -25
- package/dist/auth/used-bridge-ids.js +1 -5
- package/dist/boot/boot-config.js +16 -55
- package/dist/boot/init-sequence.js +1 -4
- package/dist/boot/integration-id-backfill.js +3 -8
- package/dist/boot/platform-keychain-key.js +5 -42
- package/dist/boot/post-boot.service.js +14 -18
- package/dist/boot/reconcile-lifecycle-jobs.js +3 -6
- package/dist/boot/retired-public-url-env.js +4 -8
- package/dist/bootstrap-packages.js +1 -4
- package/dist/closure-node-modules.js +2 -38
- package/dist/closure-patches/patch-reach.json +6 -2
- package/dist/core/addon/addon-call-gateway.js +1 -5
- package/dist/core/addon/addon-package.service.js +83 -123
- package/dist/core/addon/addon-process-view.js +2 -6
- package/dist/core/addon/addon-realign-plan.js +1 -4
- package/dist/core/addon/addon-registry.service.js +254 -197
- package/dist/core/addon/addon-row-manifest.js +1 -4
- package/dist/core/addon/addon-search.service.js +3 -7
- package/dist/core/addon/addon-settings-provider.js +1 -3
- package/dist/core/addon/addon-uninstall.js +4 -11
- package/dist/core/addon/addon.tokens.js +2 -5
- package/dist/core/addon/device-meta-mirror.js +8 -13
- package/dist/core/addon/forked-custom-actions.js +6 -11
- package/dist/core/addon/integration-visibility.js +3 -6
- package/dist/core/addon/materialize-route-path.js +1 -4
- package/dist/core/addon/package-dir-utils.js +8 -45
- package/dist/core/addon/prune-misplaced-addons.js +5 -43
- package/dist/core/addon/runner-convergence.js +1 -4
- package/dist/core/addon/runner-serialization.js +1 -4
- package/dist/core/addon/runner-spawn-fanout.js +3 -8
- package/dist/core/addon/settings-door-wiring.js +5 -8
- package/dist/core/addon/single-flight-refresh.js +1 -4
- package/dist/core/addon-bridge/addon-bridge.service.js +7 -44
- package/dist/core/addon-pages/addon-pages.service.js +3 -40
- package/dist/core/addon-widgets/addon-widgets.service.js +4 -42
- package/dist/core/agent/agent-addon-backfill.js +9 -17
- package/dist/core/agent/agent-delivery-ledger.js +3 -7
- package/dist/core/agent/agent-liveness-event.js +2 -6
- package/dist/core/agent/agent-pairing-http.js +41 -45
- package/dist/core/agent/agent-registry.service.js +53 -92
- package/dist/core/agent/cluster-node-history-mirror.js +3 -7
- package/dist/core/agent/cluster-node-history-store.js +113 -58
- package/dist/core/agent/hub-agent-pairing.js +1 -5
- package/dist/core/agent/node-certificates-client.js +3 -6
- package/dist/core/agent/node-directory.js +1 -4
- package/dist/core/app-links/well-known-app-links.js +2 -6
- package/dist/core/auth/auth.service.js +3 -8
- package/dist/core/auth/handoff-code.service.js +11 -49
- package/dist/core/auth/record-kinds.js +35 -0
- package/dist/core/auth/share-token.service.js +174 -122
- package/dist/core/capability/capability.service.js +1 -5
- package/dist/core/config/config.schema.js +1 -6
- package/dist/core/config/config.service.js +2 -6
- package/dist/core/events/event-bus.service.js +3 -7
- package/dist/core/feature/feature.service.js +2 -6
- package/dist/core/lifecycle/lifecycle-runner.singleton.js +5 -10
- package/dist/core/lifecycle/lifecycle-state-machine.js +1 -5
- package/dist/core/logging/log-ring-buffer.js +1 -5
- package/dist/core/logging/logging.service.js +5 -9
- package/dist/core/logging/scoped-logger.js +1 -5
- package/dist/core/moleculer/agent-readiness-pull.js +1 -4
- package/dist/core/moleculer/agent-registration-request.js +3 -7
- package/dist/core/moleculer/cap-call-fn.js +39 -5
- package/dist/core/moleculer/cap-route-authority.js +3 -8
- package/dist/core/moleculer/hub-mesh-guard.js +5 -9
- package/dist/core/moleculer/moleculer.service.js +108 -119
- package/dist/core/network/network-quality.service.js +2 -6
- package/dist/core/notification/notification-wrapper.service.js +3 -7
- package/dist/core/notification/toast-wrapper.service.js +3 -7
- package/dist/core/provider/provider.tokens.js +1 -4
- package/dist/core/repl/repl-engine.service.js +4 -8
- package/dist/core/runner-health/runner-boot-check.js +7 -15
- package/dist/core/runner-health/update-preflight.js +9 -14
- package/dist/core/server-update/server-update.service.js +12 -49
- package/dist/core/server-update/system-apply-closure-patches.js +6 -42
- package/dist/core/server-update/system-ensure-prebuilds.js +3 -6
- package/dist/core/server-update/system-exec-npm.js +2 -5
- package/dist/core/storage/fs-storage-backend.js +1 -5
- package/dist/core/storage/storage-location-manager.js +1 -5
- package/dist/core/storage/storage.service.js +2 -6
- package/dist/core/streaming/ffmpeg-stream-info.js +3 -8
- package/dist/core/streaming/stream-probe.service.js +12 -16
- package/dist/core/streaming/ttl-cache.js +1 -5
- package/dist/core/topology/topology-emitter.service.js +19 -23
- package/dist/core/update-availability-emitter.js +3 -7
- package/dist/core/update-availability-store.js +8 -45
- package/dist/core/updates/agent-installed-packages.js +5 -9
- package/dist/core/updates/restart-marker.js +3 -8
- package/dist/core/updates/update-check-scheduler.js +13 -18
- package/dist/core/updates/wrapper-update-checker.js +3 -7
- package/dist/first-boot-addon-plan.js +2 -6
- package/dist/framework-nodepath.js +2 -38
- package/dist/i18n/request-lang.js +7 -11
- package/dist/launcher.js +30 -65
- package/dist/lifecycle-journal-path.js +2 -38
- package/dist/main.js +287 -324
- package/dist/manual-boot.js +120 -157
- package/dist/node-role.js +1 -4
- package/dist/package-inventory.js +7 -48
- package/dist/pending-restore.js +7 -43
- package/dist/single-copy-cleanup-runner.js +9 -45
- package/dist/single-copy-cleanup.js +7 -15
- package/dist/sqlite-restore.js +9 -48
- package/dist/starter.js +4 -39
- package/dist/ui-serving/lazy-ui-serving.js +3 -39
- package/package.json +13 -13
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const hub_sessions_js_1 = require("../../auth/hub-sessions.js");
|
|
9
|
-
const session_mint_js_1 = require("../../auth/session-mint.js");
|
|
10
|
-
const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
|
|
11
|
-
const user_error_js_1 = require("../trpc/user-error.js");
|
|
1
|
+
import { TRPCError } from '@trpc/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { DEVICE_REFRESH_REFUSAL_PREFIX } from '@camstack/types';
|
|
4
|
+
import { userManagementInternal } from '../../auth/hub-sessions.js';
|
|
5
|
+
import { SessionRefreshRefusedError, SessionUserGoneError, } from '../../auth/session-mint.js';
|
|
6
|
+
import { adminProcedure, protectedProcedure, } from '../trpc/trpc.middleware.js';
|
|
7
|
+
import { trpcUserError } from '../trpc/user-error.js';
|
|
12
8
|
/** One login session as the UI lists it. */
|
|
13
|
-
|
|
14
|
-
id:
|
|
15
|
-
userId:
|
|
16
|
-
method:
|
|
17
|
-
refreshable:
|
|
18
|
-
createdAt:
|
|
19
|
-
lastUsedAt:
|
|
20
|
-
expiresAt:
|
|
21
|
-
client:
|
|
22
|
-
ip:
|
|
9
|
+
export const LoginSessionSchema = z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
userId: z.string(),
|
|
12
|
+
method: z.string(),
|
|
13
|
+
refreshable: z.boolean(),
|
|
14
|
+
createdAt: z.number(),
|
|
15
|
+
lastUsedAt: z.number(),
|
|
16
|
+
expiresAt: z.number(),
|
|
17
|
+
client: z.string().nullable(),
|
|
18
|
+
ip: z.string().nullable(),
|
|
23
19
|
/** The session this request was made with. */
|
|
24
|
-
current:
|
|
20
|
+
current: z.boolean(),
|
|
25
21
|
});
|
|
26
22
|
/** What a refresh returns: a new access token and the rotated refresh token. */
|
|
27
|
-
|
|
28
|
-
token:
|
|
29
|
-
refreshToken:
|
|
30
|
-
expiresAt:
|
|
31
|
-
sessionId:
|
|
32
|
-
sessionExpiresAt:
|
|
33
|
-
user:
|
|
23
|
+
export const RefreshResultSchema = z.object({
|
|
24
|
+
token: z.string(),
|
|
25
|
+
refreshToken: z.string(),
|
|
26
|
+
expiresAt: z.number(),
|
|
27
|
+
sessionId: z.string(),
|
|
28
|
+
sessionExpiresAt: z.number(),
|
|
29
|
+
user: z.object({ id: z.string(), username: z.string(), isAdmin: z.boolean() }),
|
|
34
30
|
});
|
|
35
31
|
/** Refresh refusals caused by the device credential behind the session, as wire reasons. */
|
|
36
32
|
const DEVICE_REFRESH_REASONS = {
|
|
@@ -40,9 +36,9 @@ const DEVICE_REFRESH_REASONS = {
|
|
|
40
36
|
'credential-unavailable': 'unavailable',
|
|
41
37
|
};
|
|
42
38
|
function requireSessions(registry) {
|
|
43
|
-
const internal = registry === null ? null :
|
|
39
|
+
const internal = registry === null ? null : userManagementInternal(registry);
|
|
44
40
|
if (internal === null) {
|
|
45
|
-
throw new
|
|
41
|
+
throw new TRPCError({
|
|
46
42
|
code: 'PRECONDITION_FAILED',
|
|
47
43
|
message: 'Login sessions are not available',
|
|
48
44
|
});
|
|
@@ -52,10 +48,10 @@ function requireSessions(registry) {
|
|
|
52
48
|
/** Real user sessions only — a scoped or share token has no login session to manage. */
|
|
53
49
|
function assertLoginSession(user) {
|
|
54
50
|
if (user.isScoped === true || user.shareView !== undefined || user.adminTokenId !== undefined) {
|
|
55
|
-
throw
|
|
51
|
+
throw trpcUserError('FORBIDDEN', 'auth.session-required', undefined, 'Requires a signed-in user session');
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
|
-
function createSessionProcedures(deps) {
|
|
54
|
+
export function createSessionProcedures(deps) {
|
|
59
55
|
const list = (userId, currentId) => {
|
|
60
56
|
const sessions = requireSessions(deps.registry);
|
|
61
57
|
const rows = userId === null ? sessions.listActive() : sessions.listForUser(userId);
|
|
@@ -80,8 +76,8 @@ function createSessionProcedures(deps) {
|
|
|
80
76
|
* the session. Any refusal is a 401: the client signs in again.
|
|
81
77
|
*/
|
|
82
78
|
refreshSession: deps.credentialProcedure
|
|
83
|
-
.input(
|
|
84
|
-
.output(
|
|
79
|
+
.input(z.object({ refreshToken: z.string().min(1).max(512) }))
|
|
80
|
+
.output(RefreshResultSchema)
|
|
85
81
|
.mutation(async ({ input }) => {
|
|
86
82
|
try {
|
|
87
83
|
const minted = await deps.minter.refresh(input.refreshToken);
|
|
@@ -89,7 +85,7 @@ function createSessionProcedures(deps) {
|
|
|
89
85
|
minted.sessionId === undefined ||
|
|
90
86
|
minted.expiresAt === undefined ||
|
|
91
87
|
minted.sessionExpiresAt === undefined) {
|
|
92
|
-
throw new
|
|
88
|
+
throw new SessionRefreshRefusedError('unknown');
|
|
93
89
|
}
|
|
94
90
|
return {
|
|
95
91
|
token: minted.token,
|
|
@@ -101,19 +97,19 @@ function createSessionProcedures(deps) {
|
|
|
101
97
|
};
|
|
102
98
|
}
|
|
103
99
|
catch (error) {
|
|
104
|
-
if (error instanceof
|
|
100
|
+
if (error instanceof SessionRefreshRefusedError) {
|
|
105
101
|
// A session opened by a device certificate says WHY, in a typed
|
|
106
102
|
// message the app switches on (`deviceRefusalFromMessage`).
|
|
107
103
|
const credentialReason = DEVICE_REFRESH_REASONS[error.reason];
|
|
108
|
-
throw new
|
|
104
|
+
throw new TRPCError({
|
|
109
105
|
code: 'UNAUTHORIZED',
|
|
110
106
|
message: credentialReason === undefined
|
|
111
107
|
? 'Session expired — sign in again'
|
|
112
|
-
: `${
|
|
108
|
+
: `${DEVICE_REFRESH_REFUSAL_PREFIX}${credentialReason}`,
|
|
113
109
|
});
|
|
114
110
|
}
|
|
115
|
-
if (error instanceof
|
|
116
|
-
throw new
|
|
111
|
+
if (error instanceof SessionUserGoneError) {
|
|
112
|
+
throw new TRPCError({
|
|
117
113
|
code: 'UNAUTHORIZED',
|
|
118
114
|
message: 'Session expired — sign in again',
|
|
119
115
|
});
|
|
@@ -126,9 +122,9 @@ function createSessionProcedures(deps) {
|
|
|
126
122
|
* stop working at once). `everywhere: true` ends every session of the
|
|
127
123
|
* user, and their pre-session tokens.
|
|
128
124
|
*/
|
|
129
|
-
logout:
|
|
130
|
-
.input(
|
|
131
|
-
.output(
|
|
125
|
+
logout: protectedProcedure
|
|
126
|
+
.input(z.object({ everywhere: z.boolean().optional() }).optional())
|
|
127
|
+
.output(z.object({ success: z.literal(true), revoked: z.number() }))
|
|
132
128
|
.mutation(async ({ ctx, input }) => {
|
|
133
129
|
assertLoginSession(ctx.user);
|
|
134
130
|
const sessions = requireSessions(deps.registry);
|
|
@@ -143,17 +139,17 @@ function createSessionProcedures(deps) {
|
|
|
143
139
|
return { success: true, revoked: revoked ? 1 : 0 };
|
|
144
140
|
}),
|
|
145
141
|
/** The caller's live sessions, newest first; `current` marks this one. */
|
|
146
|
-
listOwnSessions:
|
|
147
|
-
.input(
|
|
148
|
-
.output(
|
|
142
|
+
listOwnSessions: protectedProcedure
|
|
143
|
+
.input(z.void())
|
|
144
|
+
.output(z.array(LoginSessionSchema))
|
|
149
145
|
.query(({ ctx }) => {
|
|
150
146
|
assertLoginSession(ctx.user);
|
|
151
147
|
return list(ctx.user.id, ctx.user.sessionId);
|
|
152
148
|
}),
|
|
153
149
|
/** End one of the caller's own sessions (another device). */
|
|
154
|
-
revokeOwnSession:
|
|
155
|
-
.input(
|
|
156
|
-
.output(
|
|
150
|
+
revokeOwnSession: protectedProcedure
|
|
151
|
+
.input(z.object({ id: z.string().min(1) }))
|
|
152
|
+
.output(z.object({ success: z.boolean() }))
|
|
157
153
|
.mutation(async ({ ctx, input }) => {
|
|
158
154
|
assertLoginSession(ctx.user);
|
|
159
155
|
const sessions = requireSessions(deps.registry);
|
|
@@ -164,14 +160,14 @@ function createSessionProcedures(deps) {
|
|
|
164
160
|
return { success: await sessions.revoke(input.id, 'revoked-by-user') };
|
|
165
161
|
}),
|
|
166
162
|
/** ADMIN — live sessions of one user, or of everyone. */
|
|
167
|
-
listSessions:
|
|
168
|
-
.input(
|
|
169
|
-
.output(
|
|
163
|
+
listSessions: adminProcedure
|
|
164
|
+
.input(z.object({ userId: z.string().min(1).optional() }).optional())
|
|
165
|
+
.output(z.array(LoginSessionSchema))
|
|
170
166
|
.query(({ ctx, input }) => list(input?.userId ?? null, ctx.user.sessionId)),
|
|
171
167
|
/** ADMIN — end one session, or every session of a user. */
|
|
172
|
-
revokeSessions:
|
|
173
|
-
.input(
|
|
174
|
-
.output(
|
|
168
|
+
revokeSessions: adminProcedure
|
|
169
|
+
.input(z.union([z.object({ id: z.string().min(1) }), z.object({ userId: z.string().min(1) })]))
|
|
170
|
+
.output(z.object({ revoked: z.number() }))
|
|
175
171
|
.mutation(async ({ input }) => {
|
|
176
172
|
const sessions = requireSessions(deps.registry);
|
|
177
173
|
if ('id' in input) {
|