import { LocalStorage } from '@dfinity/auth-client';
import { DelegationChain, DelegationIdentity, Ed25519KeyIdentity } from '@dfinity/identity';
export const internetIdentityAuth = async () => {
  const storage = new LocalStorage('ic-');
  const identityKey = await storage.get('identity');
  const delegationChain = await storage.get('delegation');
  return {
    identityKey,
    delegationChain
  };
};
export const initIdentity = ({ identityKey, delegationChain }) => {
  const chain = DelegationChain.fromJSON(delegationChain);
  const key = Ed25519KeyIdentity.fromJSON(identityKey);
  return DelegationIdentity.fromDelegation(key, chain);
};
