@@ -75,8 +75,18 @@ export interface RawDataConnectEvent<T> extends CloudEvent<T> {
75
75
schema : string ;
76
76
connector : string ;
77
77
operation : string ;
78
+ authtype : AuthType ;
79
+ authid ?: string ;
78
80
}
79
81
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
+
80
90
/** OperationOptions extend EventHandlerOptions with a provided service, connector, and operation. */
81
91
export interface OperationOptions extends EventHandlerOptions {
82
92
/** Firebase Data Connect service ID */
@@ -97,6 +107,10 @@ export interface DataConnectEvent<T, Params = Record<string, string>> extends Cl
97
107
* Only named capture groups will be populated - {key}, {key=*}, {key=**}.
98
108
*/
99
109
params : Params ;
110
+ /** The type of principal that triggered the event */
111
+ authType : AuthType ;
112
+ /** The unique identifier for the principal */
113
+ authId ?: string ;
100
114
}
101
115
102
116
/**
@@ -261,8 +275,12 @@ function onOperation<V, R>(
261
275
262
276
const dataConnectEvent : DataConnectEvent < MutationEventData < V , R > > = {
263
277
...event ,
278
+ authType : event . authtype ,
279
+ authId : event . authid ,
264
280
params,
265
281
} ;
282
+ delete ( dataConnectEvent as any ) . authtype ;
283
+ delete ( dataConnectEvent as any ) . authid ;
266
284
267
285
return wrapTraceContext ( withInit ( handler ) ) ( dataConnectEvent ) ;
268
286
} ;
0 commit comments