chore: improve supermemory maintenance path

This commit is contained in:
Kai Tanaka 2026-06-08 20:57:31 +00:00
parent 819090ae9d
commit 821c7b31b6
2 changed files with 16 additions and 1 deletions

15
apps/mcp/src/auth.test.ts Normal file
View file

@ -0,0 +1,15 @@
import { describe, expect, it } from "vitest"
import { isApiKey } from "./auth"
describe("isApiKey", () => {
it("returns true for keys with the sm_ prefix and length > 3", () => {
expect(isApiKey("sm_valid_key")).toBe(true)
expect(isApiKey("sm_123")).toBe(true)
})
it("returns false for the bare prefix or missing prefix", () => {
expect(isApiKey("sm_")).toBe(false)
expect(isApiKey("")).toBe(false)
expect(isApiKey("oauth_token")).toBe(false)
})
})

View file

@ -15,7 +15,7 @@ export interface AuthUser {
* Check if a token is an API key (starts with "sm_")
*/
export function isApiKey(token: string): boolean {
return token.startsWith("sm_")
return token.startsWith("sm_") && token.length > 3
}
/**