Better data key for window

This commit is contained in:
Gregory Schier
2025-02-24 22:34:10 -08:00
parent 52937c3097
commit c0dbe46318
5 changed files with 37 additions and 9 deletions

View File

@@ -22,10 +22,24 @@ export async function deleteToken(ctx: Context, contextId: string) {
return ctx.store.delete(tokenStoreKey(contextId));
}
export async function resetDataDirKey(ctx: Context, contextId: string) {
const key = new Date().toISOString();
return ctx.store.set<string>(dataDirStoreKey(contextId), key);
}
export async function getDataDirKey(ctx: Context, contextId: string) {
const key = (await ctx.store.get<string>(dataDirStoreKey(contextId))) ?? 'default';
return `${contextId}::${key}`;
}
function tokenStoreKey(context_id: string) {
return ['token', context_id].join('::');
}
function dataDirStoreKey(context_id: string) {
return ['data_dir', context_id].join('::');
}
export interface AccessToken {
response: AccessTokenRawResponse,
expiresAt: number | null;