This commit is contained in:
seb
2026-10-12 22:32:21 +02:00
parent 28e62093b3
commit 8a8aeaedd7
21 changed files with 786 additions and 4 deletions

View File

@@ -0,0 +1,34 @@
import { INSERT_REFRESH_TOKEN as MSSQL_INSERT } from '../../providers/mssql/queries/mcp.js';
import { INSERT_REFRESH_TOKEN as SQLITE_INSERT } from '../../providers/sqlite3/queries/mcp.js';
export default function createRefreshToken(provider) {
const sql = provider.dialect === 'sqlite3' ? SQLITE_INSERT : MSSQL_INSERT;
/**
* Stores an OAuth 2.1 refresh token.
*
* @param {object} input
* @param {string} input.refreshToken - The refresh token string.
* @param {string} input.clientId - The client ID.
* @param {number} input.googleAuthId - The user ID.
* @param {string|null} [input.scope] - Scopes granted.
* @param {string|Date} input.expiresAt - Expiration Date or ISO string.
* @returns {Promise<object>} Created token record or id.
*/
return async ({
refreshToken,
clientId,
googleAuthId,
scope = 'mcp:tools',
expiresAt,
}) => {
const exp = expiresAt instanceof Date ? expiresAt.toISOString() : expiresAt;
const result = await provider.query(sql, {
refreshToken,
clientId,
googleAuthId,
scope,
expiresAt: exp,
});
return result.rows[0]?.id ?? result.insertId;
};
}