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