Skip to content

Commit fe82128

Browse files
authored
Merge branch 'master' into dl-no-todo
2 parents 031b117 + 422ac30 commit fe82128

File tree

5 files changed

+72
-2
lines changed

5 files changed

+72
-2
lines changed

spec/logger.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,50 @@ describe("logger", () => {
118118
});
119119
});
120120

121+
it("should not detect duplicate object as circular", () => {
122+
const obj: any = { a: "foo" };
123+
const entry: logger.LogEntry = {
124+
severity: "ERROR",
125+
message: "testing circular",
126+
a: obj,
127+
b: obj,
128+
};
129+
logger.write(entry);
130+
expectStderr({
131+
severity: "ERROR",
132+
message: "testing circular",
133+
a: { a: "foo" },
134+
b: { a: "foo" },
135+
});
136+
});
137+
138+
it("should not detect duplicate object in array as circular", () => {
139+
const obj: any = { a: "foo" };
140+
const arr: any = [
141+
{ a: obj, b: obj },
142+
{ a: obj, b: obj },
143+
];
144+
const entry: logger.LogEntry = {
145+
severity: "ERROR",
146+
message: "testing circular",
147+
a: arr,
148+
b: arr,
149+
};
150+
logger.write(entry);
151+
expectStderr({
152+
severity: "ERROR",
153+
message: "testing circular",
154+
a: [
155+
{ a: { a: "foo" }, b: { a: "foo" } },
156+
{ a: { a: "foo" }, b: { a: "foo" } },
157+
],
158+
b: [
159+
{ a: { a: "foo" }, b: { a: "foo" } },
160+
{ a: { a: "foo" }, b: { a: "foo" } },
161+
],
162+
});
163+
});
164+
121165
it("should not break on objects that override toJSON", () => {
122166
const obj: any = { a: new Date("August 26, 1994 12:24:00Z") };
123167

src/common/providers/database.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export class DataSnapshot implements database.DataSnapshot {
126126
val(): any {
127127
const parts = pathParts(this._childPath);
128128
let source = this._data;
129+
if (source === null) {
130+
return null;
131+
}
129132
if (parts.length) {
130133
for (const part of parts) {
131134
if (source[part] === undefined) {

src/logger/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function removeCircular(obj: any, refs: any[] = []): any {
7878
returnObj[k] = removeCircular(obj[k], refs);
7979
}
8080
}
81+
refs.pop();
8182
return returnObj;
8283
}
8384

src/v1/cloud-functions.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ export interface EventContext<Params = Record<string, string>> {
104104
* does not exist.
105105
*/
106106
auth?: {
107-
token: object;
108107
uid: string;
108+
token: EventContextAuthToken;
109109
};
110110

111111
/**
@@ -207,6 +207,29 @@ export interface EventContext<Params = Record<string, string>> {
207207
timestamp: string;
208208
}
209209

210+
/**
211+
* https://firebase.google.com/docs/reference/security/database#authtoken
212+
*/
213+
export interface EventContextAuthToken {
214+
iss: string;
215+
aud: string;
216+
auth_time: number;
217+
iat: number;
218+
exp: number;
219+
sub: string;
220+
email?: string;
221+
email_verified?: boolean;
222+
phone_number?: string;
223+
name?: string;
224+
firebase?: {
225+
identities?: {
226+
[key: string]: string[];
227+
};
228+
sign_in_provider?: string;
229+
tenant?: string;
230+
};
231+
}
232+
210233
/**
211234
* Resource is a standard format for defining a resource
212235
* (google.rpc.context.AttributeContext.Resource). In Cloud Functions, it is the

src/v2/providers/tasks.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ export function onTaskDispatched<Args = any>(
282282
convertInvoker
283283
);
284284
convertIfPresent(func.__endpoint.taskQueueTrigger, opts, "invoker", "invoker", convertInvoker);
285-
copyIfPresent(func.__endpoint.taskQueueTrigger, opts, "retry", "retry");
286285

287286
func.__requiredAPIs = [
288287
{

0 commit comments

Comments
 (0)