Skip to content

Commit bec70e4

Browse files
authored
fix(auth): Fixing some public API signatures to be consistent with the current API (#1221)
* fix(auth): Making UserMetadata.lastRefreshTime field optional * fix(auth): Fixing the toJSON signature on MultiFactorSettings
1 parent 0ed3e1c commit bec70e4

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

etc/firebase-admin.auth.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export abstract class MultiFactorInfo {
195195
// @public
196196
export class MultiFactorSettings {
197197
enrolledFactors: MultiFactorInfo[];
198-
toJSON(): any;
198+
toJSON(): object;
199199
}
200200

201201
// @public
@@ -394,7 +394,7 @@ export class UserInfo {
394394
// @public
395395
export class UserMetadata {
396396
readonly creationTime: string;
397-
readonly lastRefreshTime: string | null;
397+
readonly lastRefreshTime?: string | null;
398398
readonly lastSignInTime: string;
399399
toJSON(): object;
400400
}

src/auth/user-record.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export interface GetAccountInfoUserResponse {
7878
mfaInfo?: MultiFactorInfoResponse[];
7979
createdAt?: string;
8080
lastLoginAt?: string;
81+
lastRefreshAt?: string;
8182
[key: string]: any;
8283
}
8384

@@ -277,7 +278,7 @@ export class MultiFactorSettings {
277278
/**
278279
* @return A JSON-serializable representation of this multi-factor object.
279280
*/
280-
public toJSON(): any {
281+
public toJSON(): object {
281282
return {
282283
enrolledFactors: this.enrolledFactors.map((info) => info.toJSON()),
283284
};
@@ -304,7 +305,7 @@ export class UserMetadata {
304305
* formatted as a UTC Date string (eg 'Sat, 03 Feb 2001 04:05:06 GMT').
305306
* Returns null if the user was never active.
306307
*/
307-
public readonly lastRefreshTime: string | null;
308+
public readonly lastRefreshTime?: string | null;
308309

309310
/**
310311
* @param response The server side response returned from the getAccountInfo

test/unit/auth/user-record.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,15 @@ describe('UserMetadata', () => {
685685
it('should return expected lastRefreshTime', () => {
686686
expect(actualMetadata.lastRefreshTime).to.equal(new Date(expectedLastRefreshAt).toUTCString())
687687
});
688+
689+
it('should return null when lastRefreshTime is not available', () => {
690+
const metadata: UserMetadata = new UserMetadata({
691+
localId: 'uid123',
692+
lastLoginAt: expectedLastLoginAt.toString(),
693+
createdAt: expectedCreatedAt.toString(),
694+
});
695+
expect(metadata.lastRefreshTime).to.be.null;
696+
});
688697
});
689698

690699
describe('toJSON', () => {

0 commit comments

Comments
 (0)