1 import type { Address, DecryptedKey, KeyTransparencyVerify } from '../../interfaces';
2 import { getPrimaryKey } from '../getPrimaryKey';
3 import { getHasMigratedAddressKeys } from '../keyMigration';
4 import type { ImportKeysProcessLegacyArguments } from './importKeysProcessLegacy';
5 import importKeysProcessLegacy from './importKeysProcessLegacy';
6 import type { ImportKeysProcessV2Arguments } from './importKeysProcessV2';
7 import importKeysProcessV2 from './importKeysProcessV2';
9 interface Arguments extends Omit<ImportKeysProcessV2Arguments, 'userKey'>, ImportKeysProcessLegacyArguments {
11 userKeys: DecryptedKey[];
12 keyTransparencyVerify: KeyTransparencyVerify;
15 export const importKeysProcess = async ({
24 keyTransparencyVerify,
26 const hasMigratedAddressKeys = getHasMigratedAddressKeys(addresses);
28 if (hasMigratedAddressKeys) {
29 const primaryPrivateUserKey = getPrimaryKey(userKeys)?.privateKey;
30 if (!primaryPrivateUserKey) {
31 throw new Error('Missing primary private user key');
33 return importKeysProcessV2({
40 userKey: primaryPrivateUserKey,
41 keyTransparencyVerify,
45 return importKeysProcessLegacy({
52 keyTransparencyVerify,