@@ -75,8 +75,18 @@ export interface RawDataConnectEvent<T> extends CloudEvent<T> {
7575 schema : string ;
7676 connector : string ;
7777 operation : string ;
78+ authtype : AuthType ;
79+ authid ?: string ;
7880}
7981
82+ /**
83+ * AuthType defines the possible values for the authType field in a Firebase Data Connect event.
84+ * - app_user: an end user of an application..
85+ * - admin: an admin user of an application. In the context of impersonate endpoints used by the admin SDK, the impersonator.
86+ * - unknown: a general type to capture all other principals not captured in the other auth types.
87+ */
88+ export type AuthType = "app_user" | "admin" | "unknown" ;
89+
8090/** OperationOptions extend EventHandlerOptions with a provided service, connector, and operation. */
8191export interface OperationOptions extends EventHandlerOptions {
8292 /** Firebase Data Connect service ID */
@@ -97,6 +107,10 @@ export interface DataConnectEvent<T, Params = Record<string, string>> extends Cl
97107 * Only named capture groups will be populated - {key}, {key=*}, {key=**}.
98108 */
99109 params : Params ;
110+ /** The type of principal that triggered the event */
111+ authType : AuthType ;
112+ /** The unique identifier for the principal */
113+ authId ?: string ;
100114}
101115
102116/**
@@ -261,8 +275,12 @@ function onOperation<V, R>(
261275
262276 const dataConnectEvent : DataConnectEvent < MutationEventData < V , R > > = {
263277 ...event ,
278+ authType : event . authtype ,
279+ authId : event . authid ,
264280 params,
265281 } ;
282+ delete ( dataConnectEvent as any ) . authtype ;
283+ delete ( dataConnectEvent as any ) . authid ;
266284
267285 return wrapTraceContext ( withInit ( handler ) ) ( dataConnectEvent ) ;
268286 } ;
0 commit comments