@@ -53,32 +53,13 @@ import { AlertCircle, Bot, KeyRound, ShieldCheck } from 'lucide-react';
5353import { useAuth } from '@object-ui/auth' ;
5454import { formatDate , formatDateTime , useObjectTranslation } from '@object-ui/i18n' ;
5555import { notifyDataChanged , useAdapter , useDataInvalidation } from '@object-ui/react' ;
56-
57- /** The `sys_api_key` columns the list reads; the key's secret is never among them. */
58- export const API_KEY_LIST_FIELDS = [
59- 'id' ,
60- 'name' ,
61- 'prefix' ,
62- 'created_at' ,
63- 'last_used_at' ,
64- 'expires_at' ,
65- 'revoked' ,
66- ] as const ;
67-
68- export interface ApiKeyRow {
69- id : string ;
70- name ?: string | null ;
71- prefix ?: string | null ;
72- created_at ?: string | null ;
73- last_used_at ?: string | null ;
74- expires_at ?: string | null ;
75- revoked ?: boolean | null ;
76- }
77-
78- type ShellClient = ReturnType < NonNullable < ReturnType < typeof useAdapter > > [ 'getClient' ] > ;
79- /** What `oauth.authorizedClients.list()` answers, read off the adapter's own client. */
80- export type AuthorizedClientsList = Awaited < ReturnType < ShellClient [ 'oauth' ] [ 'authorizedClients' ] [ 'list' ] > > ;
81- export type AuthorizedClient = AuthorizedClientsList [ 'clients' ] [ number ] ;
56+ import {
57+ API_KEY_LIST_FIELDS ,
58+ isExpired ,
59+ type ApiKeyRow ,
60+ type AuthorizedClient ,
61+ type AuthorizedClientsList ,
62+ } from './accessRecords.js' ;
8263
8364type Translate = ( key : string , options ?: Record < string , unknown > ) => string ;
8465
@@ -103,18 +84,11 @@ function describeGrantedScope(scope: string, t: Translate): string {
10384 return key ? t ( key ) : t ( 'oauth.consent.scope.unrecognised' , { scope } ) ;
10485}
10586
106- /** A key past its `expires_at` no longer authenticates, revoked or not. */
107- export function isExpired ( row : ApiKeyRow , now : number ) : boolean {
108- if ( ! row . expires_at ) return false ;
109- const at = Date . parse ( row . expires_at ) ;
110- return Number . isFinite ( at ) && at <= now ;
111- }
112-
113- export function errorText ( e : unknown ) : string {
87+ function errorText ( e : unknown ) : string {
11488 return e instanceof Error ? e . message : String ( e ) ;
11589}
11690
117- export function assistantName ( c : AuthorizedClient , t : Translate ) : string {
91+ function assistantName ( c : AuthorizedClient , t : Translate ) : string {
11892 return c . name ?? t ( 'connectAgent.access.unnamed' ) ;
11993}
12094
0 commit comments