( params: AgiloftBaseParams, resolvedIP: string )
| 36 | * the actual TCP connection. |
| 37 | */ |
| 38 | export async function agiloftLoginPinned( |
| 39 | params: AgiloftBaseParams, |
| 40 | resolvedIP: string |
| 41 | ): Promise<string> { |
| 42 | const base = params.instanceUrl.replace(/\/$/, '') |
| 43 | const kb = encodeURIComponent(params.knowledgeBase) |
| 44 | const login = encodeURIComponent(params.login) |
| 45 | const password = encodeURIComponent(params.password) |
| 46 | |
| 47 | const url = `${base}/ewws/EWLogin?$KB=${kb}&$login=${login}&$password=${password}` |
| 48 | const response = await secureFetchWithPinnedIP(url, resolvedIP, { method: 'POST' }) |
| 49 | |
| 50 | if (!response.ok) { |
| 51 | const errorText = await response.text() |
| 52 | throw new Error(`Agiloft login failed: ${response.status} - ${errorText}`) |
| 53 | } |
| 54 | |
| 55 | const data = (await response.json()) as { access_token?: string } |
| 56 | const token = data.access_token |
| 57 | |
| 58 | if (!token) { |
| 59 | throw new Error('Agiloft login did not return an access token') |
| 60 | } |
| 61 | |
| 62 | return token |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * DNS-pinned variant of agiloftLogout. Best-effort — failures are logged but |
no test coverage detected