Files
overleaf-cep/services/real-time/app/js/schemas.js
T
Jakob Ackermann f6bb5ce1bd [real-time] adopt strict zod types and extend test coverage (#36031)
* [editor-core] extend coverage of zod schemas

* [real-time] adopt strict zod types and extend test coverage

* [project-history] make type check happy

* [web] make type check happy

GitOrigin-RevId: e1a65b9b3560b31ad2af817067a4b549865a5bb1
2026-09-17 11:42:50 +00:00

16 lines
900 B
JavaScript

import { z } from '@overleaf/validation-tools'
// A socket.io client id, as generated by this service's pinned socket.io
// fork's Manager.prototype.generateId (node_modules/socket.io/lib/
// manager.js): 15 random bytes, base64-encoded, with '/'->'_' and '+'->'-'
// substituted -- i.e. RFC 4648 base64url, always exactly 20 characters (15
// is a multiple of 3, so standard base64 of it never needs '=' padding).
// Used by HttpController.getConnectedClient and
// HttpApiController.disconnectClient for a dynamic-property lookup into
// socket.io's internal client map (`io.sockets.sockets[clientId]`), so both
// constraints matter: the base64url charset alone still contains
// '__proto__', 'constructor', and 'prototype' as valid strings, but none of
// those is 20 characters long, so the length check is what actually
// excludes them.
export const clientIdSchema = z.base64url().length(20)