mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 01:57:57 +00:00
* refactor(cloud): share PostgreSQL schema startup between services * feat(cloud): add durable native push notification gateway * infra(push): define dedicated gateway resources and operational checks * fix(push): bound cross-host admission and simplify gateway configuration * fix(push): validate deploy configuration and preserve topic-error registrations
16 lines
632 B
TypeScript
16 lines
632 B
TypeScript
import { GoogleAuth } from 'google-auth-library'
|
|
import { FCM_SCOPE } from './fcm-client.js'
|
|
|
|
// Resolves the runtime service account credential from the GCE metadata server
|
|
// in Cloud Run and from GOOGLE_APPLICATION_CREDENTIALS locally; the library
|
|
// caches and refreshes the token itself.
|
|
export function createFcmAccessTokenProvider(): () => Promise<string> {
|
|
const auth = new GoogleAuth({ scopes: [FCM_SCOPE] })
|
|
return async () => {
|
|
const client = await auth.getClient()
|
|
const token = await client.getAccessToken()
|
|
if (!token.token) throw new Error('fcm_access_token_unavailable')
|
|
return token.token
|
|
}
|
|
}
|