MCPcopy Create free account
hub / github.com/TheNetsky/Microsoft-Rewards-Script / loadSession

Function loadSession

src/util/SessionStore.ts:53–74  ·  view source on GitHub ↗
(
    sessionPath: string,
    email: string,
    isMobile: boolean,
    maxAgeMs?: number
)

Source from the content-addressed store, hash-verified

51}
52
53export function loadSession(
54 sessionPath: string,
55 email: string,
56 isMobile: boolean,
57 maxAgeMs?: number
58): LoadedSession | null {
59 const row = getDb(sessionPath)
60 .prepare('SELECT storage_state, fingerprint, updated_at FROM sessions WHERE email = ? AND platform = ?')
61 .get(email, platformOf(isMobile)) as SessionRow | undefined
62
63 if (!row) return null
64
65 if (maxAgeMs && Date.now() - row.updated_at > maxAgeMs) {
66 return null
67 }
68
69 return {
70 storageState: row.storage_state ? (JSON.parse(row.storage_state) as StorageState) : null,
71 fingerprint: row.fingerprint ? (JSON.parse(row.fingerprint) as BrowserFingerprintWithHeaders) : null,
72 updatedAt: row.updated_at
73 }
74}
75
76export function saveStorageState(
77 sessionPath: string,

Callers 1

createBrowserMethod · 0.90

Calls 4

getDbFunction · 0.85
platformOfFunction · 0.85
getMethod · 0.80
prepareMethod · 0.65

Tested by

no test coverage detected