(baseUrl: string, remoteSessionId: string, params: FetchParams)
| 28 | // ==================== Helpers ==================== |
| 29 | |
| 30 | export function buildPullUrl(baseUrl: string, remoteSessionId: string, params: FetchParams): string { |
| 31 | const base = `${baseUrl}/sessions/${remoteSessionId}/messages` |
| 32 | const qs: string[] = ['format=chatlab'] |
| 33 | if (params.since !== undefined && params.since > 0) qs.push(`since=${params.since}`) |
| 34 | if (params.offset !== undefined && params.offset > 0) qs.push(`offset=${params.offset}`) |
| 35 | if (params.limit !== undefined && params.limit > 0) qs.push(`limit=${params.limit}`) |
| 36 | return base + '?' + qs.join('&') |
| 37 | } |
| 38 | |
| 39 | export function deriveLocalSessionId(baseUrl: string, remoteSessionId: string): string { |
| 40 | const hash = crypto.createHash('sha256').update(`${baseUrl}\0${remoteSessionId}`).digest('hex').slice(0, 12) |
no outgoing calls
no test coverage detected