(tokens: OAuthTokens)
| 1702 | } |
| 1703 | |
| 1704 | async saveTokens(tokens: OAuthTokens): Promise<void> { |
| 1705 | this._pendingStepUpScope = undefined |
| 1706 | const storage = getSecureStorage() |
| 1707 | const existingData = storage.read() || {} |
| 1708 | const serverKey = getServerKey(this.serverName, this.serverConfig) |
| 1709 | |
| 1710 | logMCPDebug(this.serverName, `Saving tokens`) |
| 1711 | logMCPDebug(this.serverName, `Token expires in: ${tokens.expires_in}`) |
| 1712 | logMCPDebug(this.serverName, `Has refresh token: ${!!tokens.refresh_token}`) |
| 1713 | |
| 1714 | const updatedData: SecureStorageData = { |
| 1715 | ...existingData, |
| 1716 | mcpOAuth: { |
| 1717 | ...existingData.mcpOAuth, |
| 1718 | [serverKey]: { |
| 1719 | ...existingData.mcpOAuth?.[serverKey], |
| 1720 | serverName: this.serverName, |
| 1721 | serverUrl: this.serverConfig.url, |
| 1722 | accessToken: tokens.access_token, |
| 1723 | refreshToken: tokens.refresh_token, |
| 1724 | expiresAt: Date.now() + (tokens.expires_in || 3600) * 1000, |
| 1725 | scope: tokens.scope, |
| 1726 | }, |
| 1727 | }, |
| 1728 | } |
| 1729 | |
| 1730 | storage.update(updatedData) |
| 1731 | } |
| 1732 | |
| 1733 | /** |
| 1734 | * XAA silent refresh: cached id_token → Layer-2 exchange → new access_token. |
no test coverage detected