(value: unknown)
| 110 | } |
| 111 | |
| 112 | function extractSessionId(value: unknown): string | null { |
| 113 | if (!isObject(value)) { |
| 114 | return null; |
| 115 | } |
| 116 | const record = value as Record<string, unknown>; |
| 117 | const direct = getString(record.sessionId) |
| 118 | || getString(record.sessionID) |
| 119 | || getString(record.session_id) |
| 120 | || (isObject(record.session) ? getString((record.session as Record<string, unknown>).id) : null); |
| 121 | if (direct) { |
| 122 | return direct; |
| 123 | } |
| 124 | if (isObject(record.part)) { |
| 125 | const nested = extractSessionId(record.part); |
| 126 | if (nested) { |
| 127 | return nested; |
| 128 | } |
| 129 | } |
| 130 | if (isObject(record.info)) { |
| 131 | const nested = extractSessionId(record.info); |
| 132 | if (nested) { |
| 133 | return nested; |
| 134 | } |
| 135 | } |
| 136 | return null; |
| 137 | } |
| 138 | |
| 139 | function unwrapMessage(payload: unknown): Record<string, unknown> | null { |
| 140 | if (!isObject(payload)) { |
no test coverage detected