MCPcopy Create free account
hub / github.com/garrytan/gstack / createSetupKey

Function createSetupKey

browse/src/token-registry.ts:250–271  ·  view source on GitHub ↗
(opts: Omit<CreateTokenOptions, 'clientId'> & { clientId?: string })

Source from the content-addressed store, hash-verified

248 * Setup keys expire in 5 minutes and can only be exchanged once.
249 */
250export function createSetupKey(opts: Omit<CreateTokenOptions, 'clientId'> & { clientId?: string }): TokenInfo {
251 const token = generateToken('gsk_setup_');
252 const now = new Date();
253 const expiresAt = new Date(now.getTime() + 5 * 60 * 1000).toISOString(); // 5 min
254
255 const info: TokenInfo = {
256 token,
257 clientId: opts.clientId || `remote-${Date.now()}`,
258 type: 'setup',
259 scopes: opts.scopes || ['read', 'write'],
260 domains: opts.domains,
261 tabPolicy: opts.tabPolicy || 'own-only',
262 rateLimit: opts.rateLimit || 10,
263 expiresAt,
264 createdAt: now.toISOString(),
265 usesRemaining: 1,
266 commandCount: 0,
267 };
268
269 tokens.set(token, info);
270 return info;
271}
272
273/**
274 * Exchange a setup key for a session token.

Callers 2

makeFetchHandlerFunction · 0.90

Calls 2

generateTokenFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected