| 37 | } |
| 38 | |
| 39 | function getSessionData(token?: string): { userId: string; sessionId: string } { |
| 40 | try { |
| 41 | if (token) { |
| 42 | const splited = token.split('.'); |
| 43 | if (splited.length === 3) { |
| 44 | const { userId, sessionId } = JSON.parse( |
| 45 | Buffer.from(splited[1], 'base64').toString('utf-8'), |
| 46 | ); |
| 47 | return { userId, sessionId }; |
| 48 | } |
| 49 | } |
| 50 | } catch (err) { |
| 51 | Logger.error(`Error to get session data: ${err}`, getSessionData.name); |
| 52 | } |
| 53 | return { userId: '', sessionId: '' }; |
| 54 | } |
| 55 | |
| 56 | function deepMerge(target: Record<string, any>, source: Record<string, any>) { |
| 57 | if (Array.isArray(target) && Array.isArray(source)) { |