export default defineEventHandler(async (event) => {
  //@ts-ignore
  const idempiereRefreshToken = getCookie(event, 'logship_rt')

  const logshipSession = getCookie(event, 'logship_session')

  //@ts-ignore
  const token = getCookie(event, 'logship_it') //await useStorage().getItem('logship_token_'+logshipSession)
  //@ts-ignore
  const userName = getCookie(event, 'logship_xu') //await useStorage().getItem('logship_username_'+logshipSession)
  //@ts-ignore
  const password = getCookie(event, 'logship_py') //await useStorage().getItem('logship_password_'+logshipSession)
  
  const clients = getCookie(event, 'logship_clients')
  const user = getCookie(event, 'logship_user')

  const clientId = getCookie(event, 'logship_client_id')
  const roleId = getCookie(event, 'logship_role_id')
  const organizationId = getCookie(event, 'logship_organization_id')
  const warehouseId = getCookie(event, 'logship_warehouse_id')
  const language = getCookie(event, 'logship_language')
  const userId = getCookie(event, 'logship_user_id')

  event.context.auth = {
    token,
    refreshToken: idempiereRefreshToken, 
    userName,
    password,
    clients,
    clientId,
    roleId,
    organizationId,
    warehouseId,
    user,
    userId,
    language
  }
})