Skip to content

Commit 93a7699

Browse files
authored
fix(auth): Updated API docs for firebase-admin/auth (#1170)
1 parent 5a0f2fb commit 93a7699

10 files changed

+730
-289
lines changed

etc/firebase-admin.auth.api.md

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,13 @@ export interface AuthProviderConfigFilter {
155155
}
156156

157157
// @public
158-
export class BaseAuth {
158+
export abstract class BaseAuth {
159159
createCustomToken(uid: string, developerClaims?: object): Promise<string>;
160160
createProviderConfig(config: AuthProviderConfig): Promise<AuthProviderConfig>;
161161
createSessionCookie(idToken: string, sessionCookieOptions: SessionCookieOptions): Promise<string>;
162162
createUser(properties: CreateRequest): Promise<UserRecord>;
163163
deleteProviderConfig(providerId: string): Promise<void>;
164164
deleteUser(uid: string): Promise<void>;
165-
// (undocumented)
166165
deleteUsers(uids: string[]): Promise<DeleteUsersResult>;
167166
generateEmailVerificationLink(email: string, actionCodeSettings?: ActionCodeSettings): Promise<string>;
168167
generatePasswordResetLink(email: string, actionCodeSettings?: ActionCodeSettings): Promise<string>;
@@ -205,7 +204,6 @@ export type CreateTenantRequest = UpdateTenantRequest;
205204

206205
// @public
207206
export interface DecodedIdToken {
208-
// (undocumented)
209207
[key: string]: any;
210208
aud: string;
211209
auth_time: number;
@@ -250,7 +248,7 @@ export interface EmailSignInProviderConfig {
250248
passwordRequired?: boolean;
251249
}
252250

253-
// @public (undocumented)
251+
// @public
254252
export function getAuth(app?: App): Auth;
255253

256254
// @public
@@ -280,7 +278,7 @@ export interface ListUsersResult {
280278
users: UserRecord[];
281279
}
282280

283-
// @public (undocumented)
281+
// @public
284282
export interface MultiFactorConfig {
285283
factorIds?: AuthFactorType[];
286284
state: MultiFactorConfigState;
@@ -296,20 +294,15 @@ export interface MultiFactorCreateSettings {
296294

297295
// @public
298296
export abstract class MultiFactorInfo {
299-
// (undocumented)
300297
readonly displayName?: string;
301-
// (undocumented)
302298
readonly enrollmentTime?: string;
303-
// (undocumented)
304299
readonly factorId: string;
305-
toJSON(): any;
306-
// (undocumented)
300+
toJSON(): object;
307301
readonly uid: string;
308302
}
309303

310304
// @public
311305
export class MultiFactorSettings {
312-
// (undocumented)
313306
enrolledFactors: MultiFactorInfo[];
314307
toJSON(): any;
315308
}
@@ -341,9 +334,8 @@ export interface PhoneIdentifier {
341334

342335
// @public
343336
export class PhoneMultiFactorInfo extends MultiFactorInfo {
344-
// (undocumented)
345337
readonly phoneNumber: string;
346-
toJSON(): any;
338+
toJSON(): object;
347339
}
348340

349341
// @public
@@ -381,15 +373,10 @@ export interface SessionCookieOptions {
381373

382374
// @public
383375
export class Tenant {
384-
// (undocumented)
385376
readonly displayName?: string;
386-
// (undocumented)
387377
get emailSignInConfig(): EmailSignInProviderConfig | undefined;
388-
// (undocumented)
389378
get multiFactorConfig(): MultiFactorConfig | undefined;
390-
// (undocumented)
391379
readonly tenantId: string;
392-
// (undocumented)
393380
readonly testPhoneNumbers?: {
394381
[phoneNumber: string]: string;
395382
};
@@ -399,7 +386,6 @@ export class Tenant {
399386
// @public
400387
export class TenantAwareAuth extends BaseAuth {
401388
createSessionCookie(idToken: string, sessionCookieOptions: SessionCookieOptions): Promise<string>;
402-
// (undocumented)
403389
readonly tenantId: string;
404390
verifyIdToken(idToken: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
405391
verifySessionCookie(sessionCookie: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
@@ -505,27 +491,19 @@ export interface UserImportResult {
505491

506492
// @public
507493
export class UserInfo {
508-
// (undocumented)
509494
readonly displayName: string;
510-
// (undocumented)
511495
readonly email: string;
512-
// (undocumented)
513496
readonly phoneNumber: string;
514-
// (undocumented)
515497
readonly photoURL: string;
516-
// (undocumented)
517498
readonly providerId: string;
518499
toJSON(): object;
519-
// (undocumented)
520500
readonly uid: string;
521501
}
522502

523503
// @public
524504
export class UserMetadata {
525-
// (undocumented)
526505
readonly creationTime: string;
527506
readonly lastRefreshTime: string | null;
528-
// (undocumented)
529507
readonly lastSignInTime: string;
530508
toJSON(): object;
531509
}
@@ -548,38 +526,23 @@ export interface UserProviderRequest {
548526

549527
// @public
550528
export class UserRecord {
551-
// (undocumented)
552-
readonly customClaims: {
529+
readonly customClaims?: {
553530
[key: string]: any;
554531
};
555-
// (undocumented)
556532
readonly disabled: boolean;
557-
// (undocumented)
558-
readonly displayName: string;
559-
// (undocumented)
560-
readonly email: string;
561-
// (undocumented)
533+
readonly displayName?: string;
534+
readonly email?: string;
562535
readonly emailVerified: boolean;
563-
// (undocumented)
564536
readonly metadata: UserMetadata;
565-
// (undocumented)
566537
readonly multiFactor?: MultiFactorSettings;
567-
// (undocumented)
568538
readonly passwordHash?: string;
569-
// (undocumented)
570539
readonly passwordSalt?: string;
571-
// (undocumented)
572-
readonly phoneNumber: string;
573-
// (undocumented)
574-
readonly photoURL: string;
575-
// (undocumented)
540+
readonly phoneNumber?: string;
541+
readonly photoURL?: string;
576542
readonly providerData: UserInfo[];
577-
// (undocumented)
578543
readonly tenantId?: string | null;
579544
toJSON(): object;
580-
// (undocumented)
581545
readonly tokensValidAfterTime?: string;
582-
// (undocumented)
583546
readonly uid: string;
584547
}
585548

src/auth/auth-config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ export type AuthFactorType = 'phone';
406406
*/
407407
export type MultiFactorConfigState = 'ENABLED' | 'DISABLED';
408408

409+
/**
410+
* Interface representing a multi-factor configuration.
411+
* This can be used to define whether multi-factor authentication is enabled
412+
* or disabled and the list of second factor challenges that are supported.
413+
*/
409414
export interface MultiFactorConfig {
410415
/**
411416
* The multi-factor config state.
@@ -584,7 +589,7 @@ export function validateTestPhoneNumbers(
584589
}
585590

586591
/**
587-
* The email sign in configuration.
592+
* The email sign in provider configuration.
588593
*/
589594
export interface EmailSignInProviderConfig {
590595
/**
@@ -1010,7 +1015,7 @@ export class SAMLConfig implements SAMLAuthProviderConfig {
10101015
/**
10111016
* The SAMLConfig constructor.
10121017
*
1013-
* @param {any} response The server side response used to initialize the SAMLConfig object.
1018+
* @param response The server side response used to initialize the SAMLConfig object.
10141019
* @constructor
10151020
*/
10161021
constructor(response: SAMLConfigServerResponse) {
@@ -1211,7 +1216,7 @@ export class OIDCConfig implements OIDCAuthProviderConfig {
12111216
/**
12121217
* The OIDCConfig constructor.
12131218
*
1214-
* @param {any} response The server side response used to initialize the OIDCConfig object.
1219+
* @param response The server side response used to initialize the OIDCConfig object.
12151220
* @constructor
12161221
*/
12171222
constructor(response: OIDCConfigServerResponse) {

src/auth/auth-namespace.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ import {
9595
UserRecord as TUserRecord,
9696
} from './user-record';
9797

98+
/**
99+
* Gets the {@link auth.Auth `Auth`} service for the default app or a
100+
* given app.
101+
*
102+
* `getAuth()` can be called with no arguments to access the default app's
103+
* {@link auth.Auth `Auth`} service or as `getAuth(app)` to access the
104+
* {@link auth.Auth `Auth`} service associated with a specific app.
105+
*
106+
* @example
107+
* ```javascript
108+
* // Get the Auth service for the default app
109+
* const defaultAuth = getAuth();
110+
* ```
111+
*
112+
* @example
113+
* ```javascript
114+
* // Get the Auth service for a given app
115+
* const otherAuth = getAuth(otherApp);
116+
* ```
117+
*
118+
*/
98119
export function getAuth(app?: App): Auth {
99120
if (typeof app === 'undefined') {
100121
app = getApp();

src/auth/auth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ export class Auth extends BaseAuth {
4949
return this.app_;
5050
}
5151

52-
/** @return The current Auth instance's tenant manager. */
52+
/**
53+
* @return The tenant manager instance associated with the current project.
54+
*/
5355
public tenantManager(): TenantManager {
5456
return this.tenantManager_;
5557
}

0 commit comments

Comments
 (0)