export const storeIdentity = (storage, identity) => {
  storage.setItem('hypergraph:app-identity-address', identity.address);
  storage.setItem('hypergraph:app-identity-address-private-key', identity.addressPrivateKey);
  storage.setItem('hypergraph:app-identity-account-address', identity.accountAddress);
  storage.setItem('hypergraph:signature-public-key', identity.signaturePublicKey);
  storage.setItem('hypergraph:signature-private-key', identity.signaturePrivateKey);
  storage.setItem('hypergraph:encryption-public-key', identity.encryptionPublicKey);
  storage.setItem('hypergraph:encryption-private-key', identity.encryptionPrivateKey);
  storage.setItem('hypergraph:session-token', identity.sessionToken);
  storage.setItem('hypergraph:session-token-expires', identity.sessionTokenExpires.toISOString());
  storage.setItem('hypergraph:permission-id', identity.permissionId);
};
export const storePrivyIdentity = (storage, identity) => {
  storage.setItem('hypergraph:privy-auth-identity-token', identity.privyIdentityToken);
  storage.setItem('hypergraph:privy-auth-signature-public-key', identity.signaturePublicKey);
  storage.setItem('hypergraph:privy-auth-signature-private-key', identity.signaturePrivateKey);
  storage.setItem('hypergraph:privy-auth-encryption-public-key', identity.encryptionPublicKey);
  storage.setItem('hypergraph:privy-auth-encryption-private-key', identity.encryptionPrivateKey);
  storage.setItem('hypergraph:privy-auth-account-address', identity.accountAddress);
};
export const loadPrivyIdentity = storage => {
  const privyIdentityToken = storage.getItem('hypergraph:privy-auth-identity-token');
  const signaturePublicKey = storage.getItem('hypergraph:privy-auth-signature-public-key');
  const signaturePrivateKey = storage.getItem('hypergraph:privy-auth-signature-private-key');
  const encryptionPublicKey = storage.getItem('hypergraph:privy-auth-encryption-public-key');
  const encryptionPrivateKey = storage.getItem('hypergraph:privy-auth-encryption-private-key');
  const accountAddress = storage.getItem('hypergraph:privy-auth-account-address');
  return privyIdentityToken && signaturePublicKey && signaturePrivateKey && encryptionPublicKey && encryptionPrivateKey && accountAddress ? {
    privyIdentityToken,
    signaturePublicKey,
    signaturePrivateKey,
    encryptionPublicKey,
    encryptionPrivateKey,
    accountAddress
  } : null;
};
export const loadIdentity = storage => {
  const address = storage.getItem('hypergraph:app-identity-address');
  const addressPrivateKey = storage.getItem('hypergraph:app-identity-address-private-key');
  const accountAddress = storage.getItem('hypergraph:app-identity-account-address');
  const signaturePublicKey = storage.getItem('hypergraph:signature-public-key');
  const signaturePrivateKey = storage.getItem('hypergraph:signature-private-key');
  const encryptionPublicKey = storage.getItem('hypergraph:encryption-public-key');
  const encryptionPrivateKey = storage.getItem('hypergraph:encryption-private-key');
  const sessionToken = storage.getItem('hypergraph:session-token');
  const sessionTokenExpires = storage.getItem('hypergraph:session-token-expires');
  const permissionId = storage.getItem('hypergraph:permission-id');
  if (!address || !addressPrivateKey || !accountAddress || !signaturePublicKey || !signaturePrivateKey || !encryptionPublicKey || !encryptionPrivateKey || !sessionToken || !sessionTokenExpires || !permissionId) {
    return null;
  }
  return {
    address,
    addressPrivateKey,
    accountAddress,
    signaturePublicKey,
    signaturePrivateKey,
    encryptionPublicKey,
    encryptionPrivateKey,
    sessionToken,
    sessionTokenExpires: new Date(sessionTokenExpires),
    permissionId
  };
};
export const wipeIdentity = storage => {
  storage.removeItem('hypergraph:app-identity-address');
  storage.removeItem('hypergraph:app-identity-address-private-key');
  storage.removeItem('hypergraph:app-identity-account-address');
  storage.removeItem('hypergraph:signature-public-key');
  storage.removeItem('hypergraph:signature-private-key');
  storage.removeItem('hypergraph:encryption-public-key');
  storage.removeItem('hypergraph:encryption-private-key');
  storage.removeItem('hypergraph:session-token');
  storage.removeItem('hypergraph:session-token-expires');
  storage.removeItem('hypergraph:permission-id');
};
export const wipePrivyIdentity = storage => {
  storage.removeItem('hypergraph:privy-auth-identity-token');
  storage.removeItem('hypergraph:privy-auth-signature-public-key');
  storage.removeItem('hypergraph:privy-auth-signature-private-key');
  storage.removeItem('hypergraph:privy-auth-encryption-public-key');
  storage.removeItem('hypergraph:privy-auth-encryption-private-key');
  storage.removeItem('hypergraph:privy-auth-account-address');
};
//# sourceMappingURL=auth-storage.js.map