// document.cookie const fs = require('fs') const path = require('node:path') function cookieToJSON (cookieString) { // 分割多个cookie const cookies = cookieString.split(';') const cookieArray = [] cookies.forEach(cookie => { // 处理每个cookie const parts = cookie.trim().split('=') if (parts.length >= 2) { const name = parts[0].trim() // 使用parts.slice(1).join('=')来处理value中可能包含=的情况 const value = parts.slice(1).join('=').trim() // 创建cookie对象 const cookieObj = { name: name, value: value, domain: 'bitget.com', path: '/', expires: Math.floor(Date.now() / 1000) + 86400, // 默认24小时后过期 size: (name + value).length, httpOnly: name.toLowerCase().includes('token') || name.toLowerCase().includes('bmsc'), secure: name.toLowerCase().includes('token') || name.toLowerCase().includes('bmsc'), session: false, sameSite: 'Lax', priority: 'Medium', sameParty: false, sourceScheme: 'Secure', sourcePort: 443, partitionKey: '', partitionKeyOpaque: false, } cookieArray.push(cookieObj) } }) return cookieArray } module.exports = { cookieToJSON, }