@@ -2,10 +2,10 @@ import { AuthSessionId, type AuthClientMetadata, type AuthClientSession } from "
22import { Clock , DateTime , Duration , Effect , Layer , PubSub , Ref , Schema , Stream } from "effect" ;
33import { Option } from "effect" ;
44
5+ import { ServerConfig } from "../../config.ts" ;
56import { AuthSessionRepositoryLive } from "../../persistence/Layers/AuthSessions.ts" ;
67import { AuthSessionRepository } from "../../persistence/Services/AuthSessions.ts" ;
78import { ServerSecretStore } from "../Services/ServerSecretStore.ts" ;
8- import { SESSION_COOKIE_NAME } from "../utils.ts" ;
99import {
1010 SessionCredentialError ,
1111 SessionCredentialService ,
@@ -17,6 +17,7 @@ import {
1717import {
1818 base64UrlDecodeUtf8 ,
1919 base64UrlEncode ,
20+ resolveSessionCookieName ,
2021 signPayload ,
2122 timingSafeEqualBase64Url ,
2223} from "../utils.ts" ;
@@ -81,11 +82,16 @@ function toAuthClientSession(input: Omit<AuthClientSession, "current">): AuthCli
8182}
8283
8384export const makeSessionCredentialService = Effect . gen ( function * ( ) {
85+ const serverConfig = yield * ServerConfig ;
8486 const secretStore = yield * ServerSecretStore ;
8587 const authSessions = yield * AuthSessionRepository ;
8688 const signingSecret = yield * secretStore . getOrCreateRandom ( SIGNING_SECRET_NAME , 32 ) ;
8789 const connectedSessionsRef = yield * Ref . make ( new Map < string , number > ( ) ) ;
8890 const changesPubSub = yield * PubSub . unbounded < SessionCredentialChange > ( ) ;
91+ const cookieName = resolveSessionCookieName ( {
92+ mode : serverConfig . mode ,
93+ port : serverConfig . port ,
94+ } ) ;
8995
9096 const toSessionCredentialError = ( message : string ) => ( cause : unknown ) =>
9197 new SessionCredentialError ( {
@@ -472,7 +478,7 @@ export const makeSessionCredentialService = Effect.gen(function* () {
472478 } ) . pipe ( Effect . mapError ( toSessionCredentialError ( "Failed to revoke other sessions." ) ) ) ;
473479
474480 return {
475- cookieName : SESSION_COOKIE_NAME ,
481+ cookieName,
476482 issue,
477483 verify,
478484 issueWebSocketToken,
0 commit comments