Skip to content

Commit da7aa6e

Browse files
committed
lint and api-extractor fixes
1 parent c5045b5 commit da7aa6e

File tree

4 files changed

+39
-24
lines changed

4 files changed

+39
-24
lines changed

etc/firebase-admin.auth.api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,14 @@ export interface PasskeyConfigRequest {
365365
expectedOrigins?: string[];
366366
}
367367

368+
// @public
369+
export class PasskeyInfo {
370+
readonly credentialId: string;
371+
readonly displayName?: string;
372+
readonly name: string;
373+
toJSON(): object;
374+
}
375+
368376
// @public
369377
export interface PasswordPolicyConfig {
370378
constraints?: CustomStrengthOptionsConfig;
@@ -664,6 +672,7 @@ export class UserRecord {
664672
readonly emailVerified: boolean;
665673
readonly metadata: UserMetadata;
666674
readonly multiFactor?: MultiFactorSettings;
675+
readonly passkeyInfo?: PasskeyInfo[];
667676
readonly passwordHash?: string;
668677
readonly passwordSalt?: string;
669678
readonly phoneNumber?: string;

src/auth/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,5 @@ export {
172172
UserInfo,
173173
UserMetadata,
174174
UserRecord,
175+
PasskeyInfo,
175176
} from './user-record';

src/auth/user-record.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export class PasskeyInfo {
372372
/**
373373
* The name of the user.
374374
*/
375-
public readonly name?: string;
375+
public readonly name: string;
376376
/**
377377
* Identifier for the registered credential.
378378
*/
@@ -382,6 +382,13 @@ export class PasskeyInfo {
382382
*/
383383
public readonly displayName?: string;
384384

385+
/**
386+
* Initializes the PasskeyInfo object using the server side response.
387+
*
388+
* @param response - The server side response.
389+
* @constructor
390+
* @internal
391+
*/
385392
constructor(response: PasskeyInfoResponse) {
386393
if (!isNonNullObject(response)) {
387394
throw new FirebaseAuthError(
@@ -399,14 +406,12 @@ export class PasskeyInfo {
399406
* @returns A JSON-serializable representation of this passkey info object.
400407
*/
401408
public toJSON(): object {
402-
const json: any = {
409+
return {
403410
name: this.name,
404411
credentialId: this.credentialId,
405412
displayName: this.displayName,
406-
}
407-
return json;
408-
}
409-
413+
};
414+
}
410415
}
411416

412417
/**
@@ -694,12 +699,12 @@ export class UserRecord {
694699
if (multiFactor.enrolledFactors.length > 0) {
695700
utils.addReadonlyGetter(this, 'multiFactor', multiFactor);
696701
}
697-
if(response.passkeyInfo) {
698-
let passkeys: PasskeyInfo[] = [];
702+
if (response.passkeyInfo) {
703+
const passkeys: PasskeyInfo[] = [];
699704
response.passkeyInfo.forEach((passkey) => {
700705
passkeys.push(new PasskeyInfo(passkey));
701706
});
702-
if(passkeys.length > 0) {
707+
if (passkeys.length > 0) {
703708
utils.addReadonlyGetter(this, 'passkeyInfo', passkeys);
704709
}
705710
}
@@ -730,7 +735,7 @@ export class UserRecord {
730735
if (this.multiFactor) {
731736
json.multiFactor = this.multiFactor.toJSON();
732737
}
733-
if(this.passkeyInfo) {
738+
if (this.passkeyInfo) {
734739
json.passkeyInfo = [];
735740
this.passkeyInfo.forEach((passkey) => {
736741
json.passkeyInfo.push(passkey.toJSON());

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ function getValidUserResponse(tenantId?: string): GetAccountInfoUserResponse {
102102
],
103103
passkeyInfo: [
104104
{
105-
106-
credentialId: "credentialId1",
107-
displayName: "passkey1",
105+
106+
credentialId: 'credentialId1',
107+
displayName: 'passkey1',
108108
},
109109
{
110-
111-
credentialId: "credentialId2",
112-
displayName: "passkey2",
110+
111+
credentialId: 'credentialId2',
112+
displayName: 'passkey2',
113113
}
114114
]
115115
};
@@ -199,14 +199,14 @@ function getUserJSON(tenantId?: string): object {
199199
},
200200
passkeyInfo: [
201201
{
202-
203-
credentialId: "credentialId1",
204-
displayName: "passkey1",
202+
203+
credentialId: 'credentialId1',
204+
displayName: 'passkey1',
205205
},
206206
{
207-
208-
credentialId: "credentialId2",
209-
displayName: "passkey2",
207+
208+
credentialId: 'credentialId2',
209+
displayName: 'passkey2',
210210
}
211211
]
212212
};
@@ -699,10 +699,10 @@ describe('PasskeyInfo', () => {
699699
it('should create a PasskeyInfo object with valid data', () => {
700700
expect(passkeyInfo).to.be.an.instanceOf(PasskeyInfo);
701701
});
702-
702+
703703
it('should throw when missing required fields', () => {
704704
expect(() => {
705-
return new PasskeyInfo({});
705+
return new PasskeyInfo(null as any);
706706
}).to.throw('INTERNAL ASSERT FAILED: Invalid passkey info response');
707707
});
708708
});

0 commit comments

Comments
 (0)