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

Function unsealWorkOSSession

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

Source from the content-addressed store, hash-verified

148};
149
150const unsealWorkOSSession = async (
151 sessionData: string,
152 cookiePassword: string,
153): Promise<unknown> => {
154 const { sealWithoutVersion, tokenVersion } = parseWorkOSSeal(sessionData);
155 const data =
156 (await unsealIron(sealWithoutVersion, { 1: cookiePassword }, { ...ironDefaults, ttl: 0 })) ??
157 {};
158 // Mirrors the SDK's unsealData version handling: current (v2) seals hold the
159 // payload directly, OTHER versioned seals nest it under `persistent`, and an
160 // unversioned seal is the payload itself.
161 if (tokenVersion === 2 || tokenVersion === null) return data;
162 return Option.match(decodeLegacySealedSessionPayload(data), {
163 onNone: () => data,
164 onSome: (legacy) => legacy.persistent,
165 });
166};
167
168const getWorkOSSessionJwks = (() => {
169 const resolvers = new Map<string, CachedRemoteJWKSet>();

Callers 1

Calls 1

parseWorkOSSealFunction · 0.85

Tested by

no test coverage detected