Skip to content

Commit c5a8cdd

Browse files
authored
Merge 9b8aa99 into 62ed2bb
2 parents 62ed2bb + 9b8aa99 commit c5a8cdd

File tree

2 files changed

+91
-75
lines changed

2 files changed

+91
-75
lines changed

.changeset/curly-lamps-rescue.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"firebase": patch
3+
---
4+
5+
Fix database.useEmulator typing.

packages/firebase/index.d.ts

+86-75
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,81 @@ declare namespace firebase {
10061006
uid: string;
10071007
}
10081008

1009+
type FirebaseSignInProvider =
1010+
| 'custom'
1011+
| 'email'
1012+
| 'password'
1013+
| 'phone'
1014+
| 'anonymous'
1015+
| 'google.com'
1016+
| 'facebook.com'
1017+
| 'github.com'
1018+
| 'twitter.com'
1019+
| 'microsoft.com'
1020+
| 'apple.com';
1021+
1022+
interface FirebaseIdToken {
1023+
/** Always set to https://securetoken.google.com/PROJECT_ID */
1024+
iss: string;
1025+
1026+
/** Always set to PROJECT_ID */
1027+
aud: string;
1028+
1029+
/** The user's unique id */
1030+
sub: string;
1031+
1032+
/** The token issue time, in seconds since epoch */
1033+
iat: number;
1034+
1035+
/** The token expiry time, normally 'iat' + 3600 */
1036+
exp: number;
1037+
1038+
/** The user's unique id, must be equal to 'sub' */
1039+
user_id: string;
1040+
1041+
/** The time the user authenticated, normally 'iat' */
1042+
auth_time: number;
1043+
1044+
/** The sign in provider, only set when the provider is 'anonymous' */
1045+
provider_id?: 'anonymous';
1046+
1047+
/** The user's primary email */
1048+
email?: string;
1049+
1050+
/** The user's email verification status */
1051+
email_verified?: boolean;
1052+
1053+
/** The user's primary phone number */
1054+
phone_number?: string;
1055+
1056+
/** The user's display name */
1057+
name?: string;
1058+
1059+
/** The user's profile photo URL */
1060+
picture?: string;
1061+
1062+
/** Information on all identities linked to this user */
1063+
firebase: {
1064+
/** The primary sign-in provider */
1065+
sign_in_provider: FirebaseSignInProvider;
1066+
1067+
/** A map of providers to the user's list of unique identifiers from each provider */
1068+
identities?: { [provider in FirebaseSignInProvider]?: string[] };
1069+
};
1070+
1071+
/** Custom claims set by the developer */
1072+
[claim: string]: unknown;
1073+
1074+
// NO LONGER SUPPORTED. Use "sub" instead. (Not a jsdoc comment to avoid generating docs.)
1075+
uid?: never;
1076+
}
1077+
1078+
export type EmulatorMockTokenOptions = (
1079+
| { user_id: string }
1080+
| { sub: string }
1081+
) &
1082+
Partial<FirebaseIdToken>;
1083+
10091084
/**
10101085
* Retrieves a Firebase {@link firebase.app.App app} instance.
10111086
*
@@ -5711,8 +5786,15 @@ declare namespace firebase.database {
57115786
*
57125787
* @param host the emulator host (ex: localhost)
57135788
* @param port the emulator port (ex: 8080)
5789+
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
57145790
*/
5715-
useEmulator(host: string, port: number): void;
5791+
useEmulator(
5792+
host: string,
5793+
port: number,
5794+
options?: {
5795+
mockUserToken?: EmulatorMockTokenOptions;
5796+
}
5797+
): void;
57165798
/**
57175799
* Disconnects from the server (all Database operations will be completed
57185800
* offline).
@@ -7054,6 +7136,8 @@ declare namespace firebase.database {
70547136
logger?: boolean | ((a: string) => any),
70557137
persistent?: boolean
70567138
): any;
7139+
7140+
export type EmulatorMockTokenOptions = firebase.EmulatorMockTokenOptions;
70577141
}
70587142

70597143
declare namespace firebase.database.ServerValue {
@@ -9985,80 +10069,7 @@ declare namespace firebase.firestore {
998510069
stack?: string;
998610070
}
998710071

9988-
type FirebaseSignInProvider =
9989-
| 'custom'
9990-
| 'email'
9991-
| 'password'
9992-
| 'phone'
9993-
| 'anonymous'
9994-
| 'google.com'
9995-
| 'facebook.com'
9996-
| 'github.com'
9997-
| 'twitter.com'
9998-
| 'microsoft.com'
9999-
| 'apple.com';
10000-
10001-
interface FirebaseIdToken {
10002-
/** Always set to https://securetoken.google.com/PROJECT_ID */
10003-
iss: string;
10004-
10005-
/** Always set to PROJECT_ID */
10006-
aud: string;
10007-
10008-
/** The user's unique id */
10009-
sub: string;
10010-
10011-
/** The token issue time, in seconds since epoch */
10012-
iat: number;
10013-
10014-
/** The token expiry time, normally 'iat' + 3600 */
10015-
exp: number;
10016-
10017-
/** The user's unique id, must be equal to 'sub' */
10018-
user_id: string;
10019-
10020-
/** The time the user authenticated, normally 'iat' */
10021-
auth_time: number;
10022-
10023-
/** The sign in provider, only set when the provider is 'anonymous' */
10024-
provider_id?: 'anonymous';
10025-
10026-
/** The user's primary email */
10027-
email?: string;
10028-
10029-
/** The user's email verification status */
10030-
email_verified?: boolean;
10031-
10032-
/** The user's primary phone number */
10033-
phone_number?: string;
10034-
10035-
/** The user's display name */
10036-
name?: string;
10037-
10038-
/** The user's profile photo URL */
10039-
picture?: string;
10040-
10041-
/** Information on all identities linked to this user */
10042-
firebase: {
10043-
/** The primary sign-in provider */
10044-
sign_in_provider: FirebaseSignInProvider;
10045-
10046-
/** A map of providers to the user's list of unique identifiers from each provider */
10047-
identities?: { [provider in FirebaseSignInProvider]?: string[] };
10048-
};
10049-
10050-
/** Custom claims set by the developer */
10051-
[claim: string]: unknown;
10052-
10053-
// NO LONGER SUPPORTED. Use "sub" instead. (Not a jsdoc comment to avoid generating docs.)
10054-
uid?: never;
10055-
}
10056-
10057-
export type EmulatorMockTokenOptions = (
10058-
| { user_id: string }
10059-
| { sub: string }
10060-
) &
10061-
Partial<FirebaseIdToken>;
10072+
export type EmulatorMockTokenOptions = firebase.EmulatorMockTokenOptions;
1006210073
}
1006310074

1006410075
export default firebase;

0 commit comments

Comments
 (0)