u
This commit is contained in:
16
src/store/mcp/listAuthorizations.js
Normal file
16
src/store/mcp/listAuthorizations.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { LIST_AUTHORIZATIONS_BY_USER as MSSQL_LIST } from '../../providers/mssql/queries/mcp.js';
|
||||
import { LIST_AUTHORIZATIONS_BY_USER as SQLITE_LIST } from '../../providers/sqlite3/queries/mcp.js';
|
||||
|
||||
export default function listAuthorizations(provider) {
|
||||
const sql = provider.dialect === 'sqlite3' ? SQLITE_LIST : MSSQL_LIST;
|
||||
/**
|
||||
* Lists active authorizations for a Google Auth user.
|
||||
*
|
||||
* @param {number} googleAuthId - The user ID.
|
||||
* @returns {Promise<Array<object>>} List of authorized clients and token counts.
|
||||
*/
|
||||
return async (googleAuthId) => {
|
||||
const result = await provider.query(sql, { googleAuthId });
|
||||
return result.rows ?? [];
|
||||
};
|
||||
}
|
||||
17
src/store/mcp/revokeAuthorizations.js
Normal file
17
src/store/mcp/revokeAuthorizations.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { REVOKE_USER_AUTHORIZATIONS as MSSQL_REVOKE } from '../../providers/mssql/queries/mcp.js';
|
||||
import { REVOKE_USER_AUTHORIZATIONS as SQLITE_REVOKE } from '../../providers/sqlite3/queries/mcp.js';
|
||||
|
||||
export default function revokeAuthorizations(provider) {
|
||||
const sql = provider.dialect === 'sqlite3' ? SQLITE_REVOKE : MSSQL_REVOKE;
|
||||
/**
|
||||
* Revokes all active authorizations (tokens) for a user and MCP client.
|
||||
*
|
||||
* @param {number} googleAuthId - The user ID.
|
||||
* @param {string} clientId - The MCP client ID.
|
||||
* @returns {Promise<boolean>} True once revoked.
|
||||
*/
|
||||
return async (googleAuthId, clientId) => {
|
||||
await provider.query(sql, { googleAuthId, clientId });
|
||||
return true;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user