Skip to content

Commit 5e6ebfa

Browse files
authored
fix(auth): Fix several typing inconsistencies (#966)
* Perform several typing fixes
1 parent fdd968f commit 5e6ebfa

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

src/auth/auth-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export interface EmailSignInConfigServerRequest {
166166
* to a format that is understood by the Auth server.
167167
*/
168168
export class EmailSignInConfig implements EmailSignInProviderConfig {
169-
public readonly enabled?: boolean;
169+
public readonly enabled: boolean;
170170
public readonly passwordRequired?: boolean;
171171

172172
/**

src/auth/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export interface DecodedIdToken {
107107
picture?: string;
108108
sub: string;
109109
tenant?: string;
110+
uid: string;
110111
[key: string]: any;
111112
}
112113

src/auth/user-record.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export enum MultiFactorId {
148148
*/
149149
export abstract class MultiFactorInfo {
150150
public readonly uid: string;
151-
public readonly displayName: string | null;
151+
public readonly displayName: string;
152152
public readonly factorId: MultiFactorId;
153153
public readonly enrollmentTime: string;
154154

@@ -213,7 +213,7 @@ export abstract class MultiFactorInfo {
213213
}
214214
utils.addReadonlyGetter(this, 'uid', response.mfaEnrollmentId);
215215
utils.addReadonlyGetter(this, 'factorId', factorId);
216-
utils.addReadonlyGetter(this, 'displayName', response.displayName || null);
216+
utils.addReadonlyGetter(this, 'displayName', response.displayName);
217217
// Encoded using [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format.
218218
// For example, "2017-01-15T01:30:15.01Z".
219219
// This can be parsed directly via Date constructor.
@@ -265,7 +265,7 @@ export class PhoneMultiFactorInfo extends MultiFactorInfo {
265265

266266
/** Class representing multi-factor related properties of a user. */
267267
export class MultiFactor {
268-
public readonly enrolledFactors: ReadonlyArray<MultiFactorInfo>;
268+
public enrolledFactors: MultiFactorInfo[];
269269

270270
/**
271271
* Initializes the MultiFactor object using the server side or JWT format response.

test/unit/auth/auth.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ function getDecodedIdToken(uid: string, authTime: Date, tenantId?: string): Deco
161161
sign_in_provider: 'custom', // eslint-disable-line @typescript-eslint/camelcase
162162
tenant: tenantId,
163163
},
164+
uid,
164165
};
165166
}
166167

@@ -186,6 +187,7 @@ function getDecodedSessionCookie(uid: string, authTime: Date, tenantId?: string)
186187
sign_in_provider: 'custom', // eslint-disable-line @typescript-eslint/camelcase
187188
tenant: tenantId,
188189
},
190+
uid,
189191
};
190192
}
191193

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function getUserJSON(tenantId?: string): object {
173173
},
174174
{
175175
uid: 'enrollmentId2',
176-
displayName: null,
176+
displayName: undefined,
177177
enrollmentTime: now.toUTCString(),
178178
phoneNumber: '+16505556789',
179179
factorId: 'phone',
@@ -294,7 +294,7 @@ describe('PhoneMultiFactorInfo', () => {
294294
describe('getters', () => {
295295
it('should set missing optional fields to null', () => {
296296
expect(phoneMultiFactorInfoMissingFields.uid).to.equal(serverResponse.mfaEnrollmentId);
297-
expect(phoneMultiFactorInfoMissingFields.displayName).to.be.null;
297+
expect(phoneMultiFactorInfoMissingFields.displayName).to.be.undefined;
298298
expect(phoneMultiFactorInfoMissingFields.phoneNumber).to.equal(serverResponse.phoneInfo);
299299
expect(phoneMultiFactorInfoMissingFields.enrollmentTime).to.be.null;
300300
expect(phoneMultiFactorInfoMissingFields.factorId).to.equal('phone');
@@ -365,7 +365,7 @@ describe('PhoneMultiFactorInfo', () => {
365365
it('should return expected JSON object with missing fields set to null', () => {
366366
expect(phoneMultiFactorInfoMissingFields.toJSON()).to.deep.equal({
367367
uid: 'enrollmentId1',
368-
displayName: null,
368+
displayName: undefined,
369369
enrollmentTime: null,
370370
phoneNumber: '+16505551234',
371371
factorId: 'phone',

0 commit comments

Comments
 (0)