← Public packages
@charlesmatte/granola
Search and read Granola meeting notes, summaries and transcripts from any agent; manage webhooks and legal holds safely.
src/lib/account.ts
25 lines · 1.1 KB · TypeScript/**
* Accounts are stateless: an account name maps to the Kody user secret `granola-<account>` that
* holds a Granola API key (`grn_…`). There is no registry and no default account — every call
* names the account so an agent can never silently use the wrong workspace's key.
*/
export const GRANOLA_ORIGIN = 'https://public-api.granola.ai'
export const GRANOLA_HOST = 'public-api.granola.ai'
export const SECRET_PREFIX = 'granola-'
export type Account = { account: string; secretName: string }
export function secretNameFor(account: string): string {
return `${SECRET_PREFIX}${account}`
}
export function resolveAccount(input: { account: string; secretName?: string }): Account {
return { account: input.account, secretName: input.secretName ?? secretNameFor(input.account) }
}
/** `granola-acme` → `acme`; null when the secret does not follow the convention. */
export function accountFromSecretName(name: string): string | null {
if (!name.startsWith(SECRET_PREFIX)) return null
const account = name.slice(SECRET_PREFIX.length)
return /^[a-z0-9][a-z0-9_-]{0,39}$/.test(account) ? account : null
}