( sessionData: string, cookiePassword: string, )
| 148 | }; |
| 149 | |
| 150 | const 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 | |
| 168 | const getWorkOSSessionJwks = (() => { |
| 169 | const resolvers = new Map<string, CachedRemoteJWKSet>(); |
no test coverage detected