import { fetchTime } from "../plugins/syncServerTime";
import { getAuthorization } from "../plugins/crypto";
import { PLATFORM, DEVICE_ID } from "../constants/app";

export function getAuthInfo(data) {
  const timestamp = fetchTime();
  const authorization = getAuthorization(
    {
      token: data.token,
      timestamp,
      account: data.sessionId,
      uri: data.url,
      method: data.method
    },
    "token"
  );

  return {
    authorization,
    time: timestamp,
    deviceId: DEVICE_ID,
    platform: PLATFORM,
    domain: window.location.origin
  };
}
