MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / unsealWorkOSSession

Function unsealWorkOSSession

apps/cloud/src/auth/workos.ts:172–188  ·  view source on GitHub ↗
(
  sessionData: string,
  cookiePassword: string,
)

Source from the content-addressed store, hash-verified

170};
171
172const unsealWorkOSSession = async (
173 sessionData: string,
174 cookiePassword: string,
175): Promise<unknown> => {
176 const { sealWithoutVersion, tokenVersion } = parseWorkOSSeal(sessionData);
177 const data =
178 (await unsealIron(sealWithoutVersion, { 1: cookiePassword }, { ...ironDefaults, ttl: 0 })) ??
179 {};
180 // Mirrors the SDK's unsealData version handling: current (v2) seals hold the
181 // payload directly, OTHER versioned seals nest it under `persistent`, and an
182 // unversioned seal is the payload itself.
183 if (tokenVersion === 2 || tokenVersion === null) return data;
184 return Option.match(decodeLegacySealedSessionPayload(data), {
185 onNone: () => data,
186 onSome: (legacy) => legacy.persistent,
187 });
188};
189
190const getWorkOSSessionJwks = (() => {
191 const resolvers = new Map<string, CachedRemoteJWKSet>();

Callers 2

workos.tsFile · 0.85

Calls 1

parseWorkOSSealFunction · 0.85

Tested by

no test coverage detected