import { Firestore, Timestamp } from "firebase-admin/firestore"; import * as akashic from "../akashic"; import * as types from "../types"; export function storeAkashicTokenProperty(firestore: Firestore, token: akashic.AuthToken) { const now = Timestamp.now(); const firestoreToken: types.AkashicProperty = { idToken: token.idToken, accessToken: token.accessToken, createdAt: now, expireAt: Timestamp.fromMillis(now.toMillis() + token.expiresIn * 1000), }; return firestore.collection("/properties").doc("akashic").set(firestoreToken, { merge: true, }); }