@better-auth-ui/core
Version:
Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.
38 lines (37 loc) • 1.51 kB
TypeScript
/**
* The parts of a Better Auth OAuth consent record this package reads.
*
* Structural on purpose: the same helper works with records that came
* straight from `oauth2.getConsents()` and with records that were serialized
* through SSR, where dates arrive as strings.
*/
export interface OAuthConsentRecord {
id: string;
clientId: string;
scopes?: readonly string[] | null;
createdAt?: Date | string | number | null;
updatedAt?: Date | string | number | null;
}
/**
* One authorized application, built from every consent record Better Auth
* stores for that OAuth client.
*/
export interface AuthorizedOAuthApplication {
/** The OAuth client ID. Stable identity for the row. */
clientId: string;
/** Every consent record backing this application, in encounter order. */
consentIds: string[];
/** The union of granted scopes across those records. */
scopes: string[];
/** The most recent authorization time, when any record carries one. */
updatedAt?: Date;
}
/**
* Group consent records by OAuth client so one application renders as one row.
*
* Better Auth can store several consent records for a single client (for
* example when a later authorization requests additional scopes). Scopes are
* unioned, consent IDs are preserved so all of them can be deleted together,
* and the newest `updatedAt` wins.
*/
export declare function groupOAuthConsents(consents: readonly OAuthConsentRecord[] | null | undefined): AuthorizedOAuthApplication[];