summaryrefslogtreecommitdiff
path: root/packages/sw/src/scripts/get-account-from-id.ts
blob: 157dbd005e194982bf5fa9e1175a6c18b77842ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * 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);
}