puyoskey/packages/sw/src/scripts/get-account-from-id.ts
zyoshoka 8be624aa44
refactor(sw): fix type errors (#14478)
* style(sw): lint fixes

* refactor(sw): fix type errors

* chore(sw): disable `noImplicitAny`

* ci(sw): enable typecheck ci

* ci(sw): build `misskey-js` before typecheck
2024-08-30 15:53:04 +09:00

16 lines
523 B
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { get } from 'idb-keyval';
import * as Misskey from 'misskey-js';
export async function getAccountFromId(id: string): Promise<Pick<Misskey.entities.SignupResponse, 'id' | 'token'> | undefined> {
const accounts = await get<Pick<Misskey.entities.SignupResponse, 'id' | 'token'>[]>('accounts');
if (!accounts) {
console.log('Accounts are not recorded');
return;
}
return accounts.find(e => e.id === id);
}