| 83 | } |
| 84 | |
| 85 | function decodeCursor(cursor?: string): CursorState { |
| 86 | if (!cursor) return { boardIndex: 0 } |
| 87 | try { |
| 88 | const json = Buffer.from(cursor, 'base64url').toString('utf8') |
| 89 | const parsed = JSON.parse(json) as Partial<CursorState> |
| 90 | return { |
| 91 | boardIndex: Number(parsed.boardIndex) || 0, |
| 92 | itemsCursor: typeof parsed.itemsCursor === 'string' ? parsed.itemsCursor : undefined, |
| 93 | } |
| 94 | } catch { |
| 95 | return { boardIndex: 0 } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * monday.com uses the raw access token in the `Authorization` header — it is NOT |