import { DEFAULT_COOKIE_STATE_EXPIRES_MS, } from "./store.js";
import { getExpiresAt } from "../expiring-kv.js";
import { setAuthenticationState } from "./set-authentication-state.js";
import { addAnonymousUser } from "../user/index.js";
export async function addCookieState(data) {
    return addAuthenticationState({
        ...data,
        type: "cookie",
        expiresAt: getExpiresAt(DEFAULT_COOKIE_STATE_EXPIRES_MS, data.expiresAt),
    });
}
export async function addAuthenticationState(data) {
    return setAuthenticationState(data);
}
export async function addAnonymousCookieState() {
    const user = await addAnonymousUser();
    return addCookieState({
        userId: user.userId,
        roles: [
            "anonymous"
        ],
        from: {
            type: "anonymous",
            createdAt: new Date().toISOString()
        }
    });
}
//# sourceMappingURL=add-authentication-state.js.map