( sessionData: string, cookiePassword: string, )
| 170 | }; |
| 171 | |
| 172 | const 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 | |
| 190 | const getWorkOSSessionJwks = (() => { |
| 191 | const resolvers = new Map<string, CachedRemoteJWKSet>(); |
no test coverage detected