feat(access): add private room password entry (#77)
Adds bounded per-room Viewer password entry while preserving grant/public paths and Native v2 wire compatibility.
This commit is contained in:
1 parent
2930e4c788
commit
ded55bcd7d
16 files changed
+1210
-96
No files matched your search
@@ -16,6 +16,8 @@ export const VIEWER_QUALITY_EVIDENCE_INTERVAL_MS = 2_000;
|
||||
export const VIEWER_QUALITY_EVIDENCE_EXPIRY_MS = 5_000;
|
||||
export const MAX_DISPLAY_NAME_CODE_POINTS = 24;
|
||||
export const DEFAULT_VIEWER_DISPLAY_NAME = "访客";
|
||||
export const MIN_VIEWER_PASSWORD_LENGTH = 1;
|
||||
export const MAX_VIEWER_PASSWORD_LENGTH = 64;
|
||||
|
||||
const FORBIDDEN_DISPLAY_NAME_CHARACTERS =
|
||||
/[\p{Cc}\p{Zl}\p{Zp}\u061c\u200b\u200e\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/u;
|
||||
@@ -82,6 +84,13 @@ export const viewerGrantSchema = z
|
||||
.max(96)
|
||||
.regex(/^g1\.[1-9]\d{0,11}\.[1-9]\d{0,12}\.[A-Za-z0-9_-]{43}$/);
|
||||
|
||||
export const viewerPasswordSchema = z
|
||||
.string()
|
||||
.min(MIN_VIEWER_PASSWORD_LENGTH)
|
||||
.max(MAX_VIEWER_PASSWORD_LENGTH)
|
||||
.regex(/^[\x21-\x7e]+$/);
|
||||
export type ViewerPassword = z.infer<typeof viewerPasswordSchema>;
|
||||
|
||||
export const viewerAccessPolicySchema = z.enum([
|
||||
"private-link",
|
||||
"public-watch",
|
||||
@@ -466,6 +475,7 @@ const authenticateMessageSchema = z.discriminatedUnion("role", [
|
||||
clientId: opaqueIdSchema,
|
||||
shareGeneration: opaqueIdSchema.optional(),
|
||||
viewerPresence: z.literal(true).optional(),
|
||||
viewerPasswordSettings: z.literal(true).optional(),
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
@@ -476,6 +486,7 @@ const authenticateMessageSchema = z.discriminatedUnion("role", [
|
||||
role: z.literal("viewer"),
|
||||
clientId: opaqueIdSchema,
|
||||
viewerGrant: viewerGrantSchema.optional(),
|
||||
viewerPassword: viewerPasswordSchema.optional(),
|
||||
displayName: displayNameSchema.optional(),
|
||||
})
|
||||
.strict(),
|
||||
@@ -545,6 +556,12 @@ export const clientMessageSchema = z.union([
|
||||
action: z.enum(["public-watch", "rotate", "revoke"]),
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
type: z.literal("set-viewer-password"),
|
||||
password: viewerPasswordSchema.nullable(),
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
type: z.literal("stop-sharing"),
|
||||
@@ -721,6 +738,12 @@ export const serverMessageSchema = z.union([
|
||||
viewerAuthorizationGeneration: opaqueIdSchema,
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
type: z.literal("viewer-password-updated"),
|
||||
enabled: z.boolean(),
|
||||
})
|
||||
.strict(),
|
||||
z.object({ type: z.literal("sharing-stopped") }).strict(),
|
||||
z
|
||||
.object({
|
||||
|
||||
Reference in new issue
Block a user