refactor: create function to read admin SDK JSON
This commit is contained in:
@@ -3,6 +3,7 @@ import { SignJWT, importPKCS8 } from "jose";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
import { lazy } from "../lazy";
|
||||
import type { AdminSdkCredentials } from "./getAdminSdkCredentials";
|
||||
|
||||
export async function getGoogleAuthToken(adminSdkJson: AdminSdkCredentials) {
|
||||
const { privateKey, clientEmail } = adminSdkJson;
|
||||
@@ -11,7 +12,10 @@ export async function getGoogleAuthToken(adminSdkJson: AdminSdkCredentials) {
|
||||
{
|
||||
key: privateKey,
|
||||
email: clientEmail,
|
||||
scope: ["https://www.googleapis.com/auth/firebase.messaging"],
|
||||
scope: [
|
||||
"https://www.googleapis.com/auth/firebase.messaging",
|
||||
"https://www.googleapis.com/auth/cloud-tasks",
|
||||
],
|
||||
},
|
||||
adminSdkJson,
|
||||
);
|
||||
@@ -155,17 +159,3 @@ interface TokenData {
|
||||
token: GoogleTokenData;
|
||||
expiresAt: DateTime;
|
||||
}
|
||||
|
||||
export interface AdminSdkCredentials {
|
||||
type: string;
|
||||
projectId: string;
|
||||
privateKeyId: string;
|
||||
privateKey: string;
|
||||
clientEmail: string;
|
||||
clientID: string;
|
||||
authURI: string;
|
||||
tokenURI: string;
|
||||
authProviderX509CertUrl: string;
|
||||
clientX509CertUrl: string;
|
||||
universeDomain: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user