11import {
22 getSessionGraceMs ,
3+ isWaitingRoomBypassedForEmail ,
34 isWaitingRoomEnabled ,
45} from './config'
56import {
@@ -79,10 +80,16 @@ async function viewForRow(
7980 */
8081export async function requestSession ( params : {
8182 userId : string
83+ userEmail ?: string | null | undefined
8284 deps ?: SessionDeps
8385} ) : Promise < SessionStateResponse > {
8486 const deps = params . deps ?? defaultDeps
85- if ( ! deps . isWaitingRoomEnabled ( ) ) return { status : 'disabled' }
87+ if (
88+ ! deps . isWaitingRoomEnabled ( ) ||
89+ isWaitingRoomBypassedForEmail ( params . userEmail )
90+ ) {
91+ return { status : 'disabled' }
92+ }
8693
8794 const row = await deps . joinOrTakeOver ( { userId : params . userId , now : nowOf ( deps ) } )
8895 const view = await viewForRow ( params . userId , deps , row )
@@ -109,11 +116,17 @@ export async function requestSession(params: {
109116 */
110117export async function getSessionState ( params : {
111118 userId : string
119+ userEmail ?: string | null | undefined
112120 claimedInstanceId ?: string | null | undefined
113121 deps ?: SessionDeps
114122} ) : Promise < FreebuffSessionServerResponse > {
115123 const deps = params . deps ?? defaultDeps
116- if ( ! deps . isWaitingRoomEnabled ( ) ) return { status : 'disabled' }
124+ if (
125+ ! deps . isWaitingRoomEnabled ( ) ||
126+ isWaitingRoomBypassedForEmail ( params . userEmail )
127+ ) {
128+ return { status : 'disabled' }
129+ }
117130 const row = await deps . getSessionRow ( params . userId )
118131 if ( ! row ) return { status : 'none' }
119132
@@ -132,10 +145,16 @@ export async function getSessionState(params: {
132145
133146export async function endUserSession ( params : {
134147 userId : string
148+ userEmail ?: string | null | undefined
135149 deps ?: SessionDeps
136150} ) : Promise < void > {
137151 const deps = params . deps ?? defaultDeps
138- if ( ! deps . isWaitingRoomEnabled ( ) ) return
152+ if (
153+ ! deps . isWaitingRoomEnabled ( ) ||
154+ isWaitingRoomBypassedForEmail ( params . userEmail )
155+ ) {
156+ return
157+ }
139158 await deps . endSession ( params . userId )
140159}
141160
@@ -169,11 +188,17 @@ export type SessionGateResult =
169188 */
170189export async function checkSessionAdmissible ( params : {
171190 userId : string
191+ userEmail ?: string | null | undefined
172192 claimedInstanceId : string | null | undefined
173193 deps ?: SessionDeps
174194} ) : Promise < SessionGateResult > {
175195 const deps = params . deps ?? defaultDeps
176- if ( ! deps . isWaitingRoomEnabled ( ) ) return { ok : true , reason : 'disabled' }
196+ if (
197+ ! deps . isWaitingRoomEnabled ( ) ||
198+ isWaitingRoomBypassedForEmail ( params . userEmail )
199+ ) {
200+ return { ok : true , reason : 'disabled' }
201+ }
177202
178203 // Pre-waiting-room CLIs never send a freebuff_instance_id. Classify that up
179204 // front so the caller gets a distinct code (→ 426 Upgrade Required) and the
0 commit comments