feat(SW-2116): RefId instead of confirmationNumber

This commit is contained in:
Arvid Norlin
2025-04-25 13:44:49 +02:00
committed by Michael Zetterberg
parent 7eeb0bbcac
commit 74d37dad93
61 changed files with 1032 additions and 843 deletions

View File

@@ -3,7 +3,9 @@ import { trace, type Tracer } from "@opentelemetry/api"
import { env } from "@/env/server"
import { createCounter } from "@/server/telemetry"
import { auth } from "@/auth"
import { getCacheClient } from "@/services/dataCache"
import { isValidSession } from "@/utils/session"
import type { ServiceTokenResponse } from "@/types/tokens"
@@ -117,3 +119,12 @@ async function fetchServiceToken(scopes: string[]) {
function getServiceTokenCacheKey(scopes: string[]): string {
return `serviceToken:${scopes.join(",")}`
}
export async function getUserOrServiceToken() {
const serviceToken = await getServiceToken()
const session = await auth()
return isValidSession(session)
? session.token.access_token
: serviceToken.access_token
}