firebase-admin 9.100.0-alpha.0 → 10.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/lib/app/core.d.ts +15 -22
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +17 -33
- package/lib/app/credential-factory.js +17 -33
- package/lib/app/credential-internal.d.ts +10 -9
- package/lib/app/credential-internal.js +15 -13
- package/lib/app/credential.d.ts +3 -9
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +6 -30
- package/lib/app/firebase-app.js +72 -216
- package/lib/app/firebase-namespace.d.ts +28 -34
- package/lib/app/firebase-namespace.js +119 -99
- package/lib/app/index.d.ts +6 -1
- package/lib/app/index.js +1 -1
- package/lib/app/lifecycle.d.ts +24 -3
- package/lib/app/lifecycle.js +119 -25
- package/lib/app-check/app-check-api-client-internal.d.ts +32 -0
- package/lib/app-check/app-check-api-client-internal.js +197 -0
- package/lib/app-check/app-check-api.d.ts +95 -0
- package/lib/app-check/app-check-api.js +19 -0
- package/lib/app-check/app-check-namespace.d.ts +65 -0
- package/lib/app-check/app-check-namespace.js +18 -0
- package/lib/app-check/app-check.d.ts +49 -0
- package/lib/app-check/app-check.js +82 -0
- package/lib/app-check/index.d.ts +53 -0
- package/lib/app-check/index.js +63 -0
- package/lib/app-check/token-generator.d.ts +25 -0
- package/lib/app-check/token-generator.js +159 -0
- package/lib/app-check/token-verifier.d.ts +17 -0
- package/lib/app-check/token-verifier.js +151 -0
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +2 -2
- package/lib/auth/auth-api-request.d.ts +28 -32
- package/lib/auth/auth-api-request.js +167 -125
- package/lib/auth/auth-config.d.ts +123 -21
- package/lib/auth/auth-config.js +85 -34
- package/lib/auth/auth-namespace.d.ts +157 -4
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +5 -3
- package/lib/auth/auth.js +6 -4
- package/lib/auth/base-auth.d.ts +134 -116
- package/lib/auth/base-auth.js +213 -143
- package/lib/auth/identifier.d.ts +5 -5
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +10 -5
- package/lib/auth/index.js +9 -4
- package/lib/auth/tenant-manager.d.ts +19 -19
- package/lib/auth/tenant-manager.js +21 -25
- package/lib/auth/tenant.d.ts +14 -5
- package/lib/auth/tenant.js +19 -11
- package/lib/auth/token-generator.d.ts +7 -108
- package/lib/auth/token-generator.js +52 -145
- package/lib/auth/token-verifier.d.ts +3 -4
- package/lib/auth/token-verifier.js +96 -145
- package/lib/auth/user-import-builder.d.ts +11 -11
- package/lib/auth/user-import-builder.js +9 -9
- package/lib/auth/user-record.d.ts +23 -15
- package/lib/auth/user-record.js +30 -20
- package/lib/credential/index.d.ts +18 -35
- package/lib/credential/index.js +17 -33
- package/lib/database/database-namespace.d.ts +39 -10
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +16 -6
- package/lib/database/database.js +61 -6
- package/lib/database/index.d.ts +19 -18
- package/lib/database/index.js +21 -23
- package/lib/default-namespace.d.ts +7 -1
- package/lib/default-namespace.js +4 -4
- package/lib/esm/app/index.js +10 -0
- package/lib/esm/app-check/index.js +4 -0
- package/lib/esm/auth/index.js +14 -0
- package/lib/esm/database/index.js +6 -0
- package/lib/esm/firestore/index.js +24 -0
- package/lib/esm/installations/index.js +4 -0
- package/lib/esm/instance-id/index.js +4 -0
- package/lib/esm/machine-learning/index.js +5 -0
- package/lib/esm/messaging/index.js +4 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/project-management/index.js +8 -0
- package/lib/esm/remote-config/index.js +4 -0
- package/lib/esm/security-rules/index.js +6 -0
- package/lib/esm/storage/index.js +4 -0
- package/lib/firebase-namespace-api.d.ts +12 -6
- package/lib/firebase-namespace-api.js +5 -1
- package/lib/firestore/firestore-internal.d.ts +2 -2
- package/lib/firestore/firestore-internal.js +2 -2
- package/lib/firestore/firestore-namespace.d.ts +6 -1
- package/lib/firestore/firestore-namespace.js +2 -1
- package/lib/firestore/index.d.ts +36 -4
- package/lib/firestore/index.js +29 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +52 -0
- package/lib/installations/index.js +62 -0
- package/lib/installations/installations-namespace.d.ts +55 -0
- package/lib/installations/installations-namespace.js +18 -0
- package/lib/{instance-id/instance-id-request-internal.d.ts → installations/installations-request-handler.d.ts} +8 -8
- package/lib/{instance-id/instance-id-request-internal.js → installations/installations-request-handler.js} +23 -23
- package/lib/installations/installations.d.ts +38 -0
- package/lib/installations/installations.js +63 -0
- package/lib/instance-id/index.d.ts +20 -9
- package/lib/instance-id/index.js +20 -9
- package/lib/instance-id/instance-id-namespace.d.ts +9 -8
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +8 -6
- package/lib/instance-id/instance-id.js +20 -11
- package/lib/machine-learning/index.d.ts +29 -27
- package/lib/machine-learning/index.js +29 -27
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +4 -4
- package/lib/machine-learning/machine-learning-namespace.d.ts +33 -8
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.d.ts +19 -19
- package/lib/machine-learning/machine-learning.js +20 -20
- package/lib/messaging/batch-request-internal.d.ts +3 -3
- package/lib/messaging/batch-request-internal.js +9 -9
- package/lib/messaging/index.d.ts +11 -9
- package/lib/messaging/index.js +11 -9
- package/lib/messaging/messaging-api-request-internal.d.ts +8 -8
- package/lib/messaging/messaging-api-request-internal.js +8 -8
- package/lib/messaging/messaging-api.d.ts +79 -75
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +5 -5
- package/lib/messaging/messaging-errors-internal.js +7 -7
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +6 -31
- package/lib/messaging/messaging-namespace.d.ts +105 -8
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +70 -86
- package/lib/messaging/messaging.js +76 -89
- package/lib/project-management/android-app.d.ts +11 -12
- package/lib/project-management/android-app.js +13 -14
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +11 -9
- package/lib/project-management/index.js +11 -9
- package/lib/project-management/ios-app.d.ts +6 -7
- package/lib/project-management/ios-app.js +6 -7
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -80
- package/lib/project-management/project-management-api-request-internal.js +14 -14
- package/lib/project-management/project-management-namespace.d.ts +31 -9
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +18 -21
- package/lib/project-management/project-management.js +19 -22
- package/lib/remote-config/index.d.ts +12 -10
- package/lib/remote-config/index.js +11 -9
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +2 -2
- package/lib/remote-config/remote-config-api.d.ts +12 -2
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +50 -9
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +19 -21
- package/lib/remote-config/remote-config.js +25 -25
- package/lib/security-rules/index.d.ts +12 -10
- package/lib/security-rules/index.js +12 -10
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +43 -28
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +39 -42
- package/lib/security-rules/security-rules.js +38 -39
- package/lib/storage/index.d.ts +9 -7
- package/lib/storage/index.js +9 -7
- package/lib/storage/storage-namespace.d.ts +7 -6
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +3 -3
- package/lib/storage/storage.js +14 -4
- package/lib/utils/api-request.d.ts +24 -24
- package/lib/utils/api-request.js +25 -25
- package/lib/utils/crypto-signer.d.ts +128 -0
- package/lib/utils/crypto-signer.js +237 -0
- package/lib/utils/deep-copy.d.ts +6 -6
- package/lib/utils/deep-copy.js +6 -6
- package/lib/utils/error.d.ts +69 -36
- package/lib/utils/error.js +98 -43
- package/lib/utils/index.d.ts +30 -19
- package/lib/utils/index.js +47 -20
- package/lib/utils/jwt.d.ts +131 -0
- package/lib/utils/jwt.js +355 -0
- package/lib/utils/validator.d.ts +37 -37
- package/lib/utils/validator.js +37 -37
- package/package.json +126 -53
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright 2018 Google Inc.
|
|
4
4
|
*
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
|
-
* Interface representing base properties of a user
|
|
18
|
+
* Interface representing base properties of a user-enrolled second factor for a
|
|
19
19
|
* `CreateRequest`.
|
|
20
20
|
*/
|
|
21
|
-
export interface
|
|
21
|
+
export interface BaseCreateMultiFactorInfoRequest {
|
|
22
22
|
/**
|
|
23
23
|
* The optional display name for an enrolled second factor.
|
|
24
24
|
*/
|
|
@@ -29,20 +29,25 @@ export interface CreateMultiFactorInfoRequest {
|
|
|
29
29
|
factorId: string;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Interface representing a phone specific user
|
|
32
|
+
* Interface representing a phone specific user-enrolled second factor for a
|
|
33
33
|
* `CreateRequest`.
|
|
34
34
|
*/
|
|
35
|
-
export interface CreatePhoneMultiFactorInfoRequest extends
|
|
35
|
+
export interface CreatePhoneMultiFactorInfoRequest extends BaseCreateMultiFactorInfoRequest {
|
|
36
36
|
/**
|
|
37
37
|
* The phone number associated with a phone second factor.
|
|
38
38
|
*/
|
|
39
39
|
phoneNumber: string;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Type representing the properties of a user-enrolled second factor
|
|
43
|
+
* for a `CreateRequest`.
|
|
44
|
+
*/
|
|
45
|
+
export declare type CreateMultiFactorInfoRequest = CreatePhoneMultiFactorInfoRequest;
|
|
46
|
+
/**
|
|
47
|
+
* Interface representing common properties of a user-enrolled second factor
|
|
43
48
|
* for an `UpdateRequest`.
|
|
44
49
|
*/
|
|
45
|
-
export interface
|
|
50
|
+
export interface BaseUpdateMultiFactorInfoRequest {
|
|
46
51
|
/**
|
|
47
52
|
* The ID of the enrolled second factor. This ID is unique to the user. When not provided,
|
|
48
53
|
* a new one is provisioned by the Auth server.
|
|
@@ -62,15 +67,20 @@ export interface UpdateMultiFactorInfoRequest {
|
|
|
62
67
|
factorId: string;
|
|
63
68
|
}
|
|
64
69
|
/**
|
|
65
|
-
* Interface representing a phone specific user
|
|
70
|
+
* Interface representing a phone specific user-enrolled second factor
|
|
66
71
|
* for an `UpdateRequest`.
|
|
67
72
|
*/
|
|
68
|
-
export interface UpdatePhoneMultiFactorInfoRequest extends
|
|
73
|
+
export interface UpdatePhoneMultiFactorInfoRequest extends BaseUpdateMultiFactorInfoRequest {
|
|
69
74
|
/**
|
|
70
75
|
* The phone number associated with a phone second factor.
|
|
71
76
|
*/
|
|
72
77
|
phoneNumber: string;
|
|
73
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Type representing the properties of a user-enrolled second factor
|
|
81
|
+
* for an `UpdateRequest`.
|
|
82
|
+
*/
|
|
83
|
+
export declare type UpdateMultiFactorInfoRequest = UpdatePhoneMultiFactorInfoRequest;
|
|
74
84
|
/**
|
|
75
85
|
* The multi-factor related user settings for create operations.
|
|
76
86
|
*/
|
|
@@ -128,6 +138,53 @@ export interface UpdateRequest {
|
|
|
128
138
|
* The user's updated multi-factor related properties.
|
|
129
139
|
*/
|
|
130
140
|
multiFactor?: MultiFactorUpdateSettings;
|
|
141
|
+
/**
|
|
142
|
+
* Links this user to the specified provider.
|
|
143
|
+
*
|
|
144
|
+
* Linking a provider to an existing user account does not invalidate the
|
|
145
|
+
* refresh token of that account. In other words, the existing account
|
|
146
|
+
* would continue to be able to access resources, despite not having used
|
|
147
|
+
* the newly linked provider to log in. If you wish to force the user to
|
|
148
|
+
* authenticate with this new provider, you need to (a) revoke their
|
|
149
|
+
* refresh token (see
|
|
150
|
+
* https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens),
|
|
151
|
+
* and (b) ensure no other authentication methods are present on this
|
|
152
|
+
* account.
|
|
153
|
+
*/
|
|
154
|
+
providerToLink?: UserProvider;
|
|
155
|
+
/**
|
|
156
|
+
* Unlinks this user from the specified providers.
|
|
157
|
+
*/
|
|
158
|
+
providersToUnlink?: string[];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Represents a user identity provider that can be associated with a Firebase user.
|
|
162
|
+
*/
|
|
163
|
+
export interface UserProvider {
|
|
164
|
+
/**
|
|
165
|
+
* The user identifier for the linked provider.
|
|
166
|
+
*/
|
|
167
|
+
uid?: string;
|
|
168
|
+
/**
|
|
169
|
+
* The display name for the linked provider.
|
|
170
|
+
*/
|
|
171
|
+
displayName?: string;
|
|
172
|
+
/**
|
|
173
|
+
* The email for the linked provider.
|
|
174
|
+
*/
|
|
175
|
+
email?: string;
|
|
176
|
+
/**
|
|
177
|
+
* The phone number for the linked provider.
|
|
178
|
+
*/
|
|
179
|
+
phoneNumber?: string;
|
|
180
|
+
/**
|
|
181
|
+
* The photo URL for the linked provider.
|
|
182
|
+
*/
|
|
183
|
+
photoURL?: string;
|
|
184
|
+
/**
|
|
185
|
+
* The linked provider ID (for example, "google.com" for the Google provider).
|
|
186
|
+
*/
|
|
187
|
+
providerId?: string;
|
|
131
188
|
}
|
|
132
189
|
/**
|
|
133
190
|
* Interface representing the properties to set on a new user record to be
|
|
@@ -146,7 +203,7 @@ export interface CreateRequest extends UpdateRequest {
|
|
|
146
203
|
/**
|
|
147
204
|
* The response interface for listing provider configs. This is only available
|
|
148
205
|
* when listing all identity providers' configurations via
|
|
149
|
-
* {@link
|
|
206
|
+
* {@link BaseAuth.listProviderConfigs}.
|
|
150
207
|
*/
|
|
151
208
|
export interface ListProviderConfigResults {
|
|
152
209
|
/**
|
|
@@ -161,7 +218,7 @@ export interface ListProviderConfigResults {
|
|
|
161
218
|
/**
|
|
162
219
|
* The filter interface used for listing provider configurations. This is used
|
|
163
220
|
* when specifying how to list configured identity providers via
|
|
164
|
-
* {@link
|
|
221
|
+
* {@link BaseAuth.listProviderConfigs}.
|
|
165
222
|
*/
|
|
166
223
|
export interface AuthProviderConfigFilter {
|
|
167
224
|
/**
|
|
@@ -184,7 +241,7 @@ export interface AuthProviderConfigFilter {
|
|
|
184
241
|
/**
|
|
185
242
|
* The request interface for updating a SAML Auth provider. This is used
|
|
186
243
|
* when updating a SAML provider's configuration via
|
|
187
|
-
* {@link
|
|
244
|
+
* {@link BaseAuth.updateProviderConfig}.
|
|
188
245
|
*/
|
|
189
246
|
export interface SAMLUpdateAuthProviderRequest {
|
|
190
247
|
/**
|
|
@@ -226,7 +283,7 @@ export interface SAMLUpdateAuthProviderRequest {
|
|
|
226
283
|
/**
|
|
227
284
|
* The request interface for updating an OIDC Auth provider. This is used
|
|
228
285
|
* when updating an OIDC provider's configuration via
|
|
229
|
-
* {@link
|
|
286
|
+
* {@link BaseAuth.updateProviderConfig}.
|
|
230
287
|
*/
|
|
231
288
|
export interface OIDCUpdateAuthProviderRequest {
|
|
232
289
|
/**
|
|
@@ -249,6 +306,15 @@ export interface OIDCUpdateAuthProviderRequest {
|
|
|
249
306
|
* configuration's value is not modified.
|
|
250
307
|
*/
|
|
251
308
|
issuer?: string;
|
|
309
|
+
/**
|
|
310
|
+
* The OIDC provider's client secret to enable OIDC code flow.
|
|
311
|
+
* If not provided, the existing configuration's value is not modified.
|
|
312
|
+
*/
|
|
313
|
+
clientSecret?: string;
|
|
314
|
+
/**
|
|
315
|
+
* The OIDC provider's response object for OAuth authorization flow.
|
|
316
|
+
*/
|
|
317
|
+
responseType?: OAuthResponseType;
|
|
252
318
|
}
|
|
253
319
|
export declare type UpdateAuthProviderRequest = SAMLUpdateAuthProviderRequest | OIDCUpdateAuthProviderRequest;
|
|
254
320
|
/** A maximum of 10 test phone number / code pairs can be configured. */
|
|
@@ -295,6 +361,8 @@ export interface OIDCConfigServerRequest {
|
|
|
295
361
|
issuer?: string;
|
|
296
362
|
displayName?: string;
|
|
297
363
|
enabled?: boolean;
|
|
364
|
+
clientSecret?: string;
|
|
365
|
+
responseType?: OAuthResponseType;
|
|
298
366
|
[key: string]: any;
|
|
299
367
|
}
|
|
300
368
|
/** The server side OIDC configuration response interface. */
|
|
@@ -304,6 +372,8 @@ export interface OIDCConfigServerResponse {
|
|
|
304
372
|
issuer?: string;
|
|
305
373
|
displayName?: string;
|
|
306
374
|
enabled?: boolean;
|
|
375
|
+
clientSecret?: string;
|
|
376
|
+
responseType?: OAuthResponseType;
|
|
307
377
|
}
|
|
308
378
|
/** The server side email configuration request interface. */
|
|
309
379
|
export interface EmailSignInConfigServerRequest {
|
|
@@ -351,15 +421,15 @@ export declare class MultiFactorAuthConfig implements MultiFactorConfig {
|
|
|
351
421
|
/**
|
|
352
422
|
* Validates the MultiFactorConfig options object. Throws an error on failure.
|
|
353
423
|
*
|
|
354
|
-
* @param options The options object to validate.
|
|
424
|
+
* @param options - The options object to validate.
|
|
355
425
|
*/
|
|
356
426
|
private static validate;
|
|
357
|
-
/** @
|
|
427
|
+
/** @returns The plain object representation of the multi-factor config instance. */
|
|
358
428
|
toJSON(): object;
|
|
359
429
|
}
|
|
360
430
|
/**
|
|
361
431
|
* Validates the provided map of test phone number / code pairs.
|
|
362
|
-
* @param testPhoneNumbers The phone number / code pairs to validate.
|
|
432
|
+
* @param testPhoneNumbers - The phone number / code pairs to validate.
|
|
363
433
|
*/
|
|
364
434
|
export declare function validateTestPhoneNumbers(testPhoneNumbers: {
|
|
365
435
|
[phoneNumber: string]: string;
|
|
@@ -381,7 +451,7 @@ export interface EmailSignInProviderConfig {
|
|
|
381
451
|
/**
|
|
382
452
|
* The base Auth provider configuration interface.
|
|
383
453
|
*/
|
|
384
|
-
export interface
|
|
454
|
+
export interface BaseAuthProviderConfig {
|
|
385
455
|
/**
|
|
386
456
|
* The provider ID defined by the developer.
|
|
387
457
|
* For a SAML provider, this is always prefixed by `saml.`.
|
|
@@ -403,9 +473,9 @@ export interface AuthProviderConfig {
|
|
|
403
473
|
* The
|
|
404
474
|
* [SAML](http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html)
|
|
405
475
|
* Auth provider configuration interface. A SAML provider can be created via
|
|
406
|
-
* {@link
|
|
476
|
+
* {@link BaseAuth.createProviderConfig}.
|
|
407
477
|
*/
|
|
408
|
-
export interface SAMLAuthProviderConfig extends
|
|
478
|
+
export interface SAMLAuthProviderConfig extends BaseAuthProviderConfig {
|
|
409
479
|
/**
|
|
410
480
|
* The SAML IdP entity identifier.
|
|
411
481
|
*/
|
|
@@ -439,12 +509,31 @@ export interface SAMLAuthProviderConfig extends AuthProviderConfig {
|
|
|
439
509
|
*/
|
|
440
510
|
callbackURL?: string;
|
|
441
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* The interface representing OIDC provider's response object for OAuth
|
|
514
|
+
* authorization flow.
|
|
515
|
+
* One of the following settings is required:
|
|
516
|
+
* <ul>
|
|
517
|
+
* <li>Set <code>code</code> to <code>true</code> for the code flow.</li>
|
|
518
|
+
* <li>Set <code>idToken</code> to <code>true</code> for the ID token flow.</li>
|
|
519
|
+
* </ul>
|
|
520
|
+
*/
|
|
521
|
+
export interface OAuthResponseType {
|
|
522
|
+
/**
|
|
523
|
+
* Whether ID token is returned from IdP's authorization endpoint.
|
|
524
|
+
*/
|
|
525
|
+
idToken?: boolean;
|
|
526
|
+
/**
|
|
527
|
+
* Whether authorization code is returned from IdP's authorization endpoint.
|
|
528
|
+
*/
|
|
529
|
+
code?: boolean;
|
|
530
|
+
}
|
|
442
531
|
/**
|
|
443
532
|
* The [OIDC](https://openid.net/specs/openid-connect-core-1_0-final.html) Auth
|
|
444
533
|
* provider configuration interface. An OIDC provider can be created via
|
|
445
|
-
* {@link
|
|
534
|
+
* {@link BaseAuth.createProviderConfig}.
|
|
446
535
|
*/
|
|
447
|
-
export interface OIDCAuthProviderConfig extends
|
|
536
|
+
export interface OIDCAuthProviderConfig extends BaseAuthProviderConfig {
|
|
448
537
|
/**
|
|
449
538
|
* This is the required client ID used to confirm the audience of an OIDC
|
|
450
539
|
* provider's
|
|
@@ -469,5 +558,18 @@ export interface OIDCAuthProviderConfig extends AuthProviderConfig {
|
|
|
469
558
|
* [spec](https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation).
|
|
470
559
|
*/
|
|
471
560
|
issuer: string;
|
|
561
|
+
/**
|
|
562
|
+
* The OIDC provider's client secret to enable OIDC code flow.
|
|
563
|
+
*/
|
|
564
|
+
clientSecret?: string;
|
|
565
|
+
/**
|
|
566
|
+
* The OIDC provider's response object for OAuth authorization flow.
|
|
567
|
+
*/
|
|
568
|
+
responseType?: OAuthResponseType;
|
|
472
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* The Auth provider configuration type.
|
|
572
|
+
* {@link BaseAuth.createProviderConfig}.
|
|
573
|
+
*/
|
|
574
|
+
export declare type AuthProviderConfig = SAMLAuthProviderConfig | OIDCAuthProviderConfig;
|
|
473
575
|
export {};
|
package/lib/auth/auth-config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2018 Google Inc.
|
|
@@ -40,7 +40,7 @@ var MultiFactorAuthConfig = /** @class */ (function () {
|
|
|
40
40
|
/**
|
|
41
41
|
* The MultiFactorAuthConfig constructor.
|
|
42
42
|
*
|
|
43
|
-
* @param response The server side response used to initialize the
|
|
43
|
+
* @param response - The server side response used to initialize the
|
|
44
44
|
* MultiFactorAuthConfig object.
|
|
45
45
|
* @constructor
|
|
46
46
|
* @internal
|
|
@@ -64,8 +64,8 @@ var MultiFactorAuthConfig = /** @class */ (function () {
|
|
|
64
64
|
* Static method to convert a client side request to a MultiFactorAuthServerConfig.
|
|
65
65
|
* Throws an error if validation fails.
|
|
66
66
|
*
|
|
67
|
-
* @param options The options object to convert to a server request.
|
|
68
|
-
* @
|
|
67
|
+
* @param options - The options object to convert to a server request.
|
|
68
|
+
* @returns The resulting server request.
|
|
69
69
|
* @internal
|
|
70
70
|
*/
|
|
71
71
|
MultiFactorAuthConfig.buildServerRequest = function (options) {
|
|
@@ -91,7 +91,7 @@ var MultiFactorAuthConfig = /** @class */ (function () {
|
|
|
91
91
|
/**
|
|
92
92
|
* Validates the MultiFactorConfig options object. Throws an error on failure.
|
|
93
93
|
*
|
|
94
|
-
* @param options The options object to validate.
|
|
94
|
+
* @param options - The options object to validate.
|
|
95
95
|
*/
|
|
96
96
|
MultiFactorAuthConfig.validate = function (options) {
|
|
97
97
|
var validKeys = {
|
|
@@ -125,7 +125,7 @@ var MultiFactorAuthConfig = /** @class */ (function () {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
/** @
|
|
128
|
+
/** @returns The plain object representation of the multi-factor config instance. */
|
|
129
129
|
MultiFactorAuthConfig.prototype.toJSON = function () {
|
|
130
130
|
return {
|
|
131
131
|
state: this.state,
|
|
@@ -137,7 +137,7 @@ var MultiFactorAuthConfig = /** @class */ (function () {
|
|
|
137
137
|
exports.MultiFactorAuthConfig = MultiFactorAuthConfig;
|
|
138
138
|
/**
|
|
139
139
|
* Validates the provided map of test phone number / code pairs.
|
|
140
|
-
* @param testPhoneNumbers The phone number / code pairs to validate.
|
|
140
|
+
* @param testPhoneNumbers - The phone number / code pairs to validate.
|
|
141
141
|
*/
|
|
142
142
|
function validateTestPhoneNumbers(testPhoneNumbers) {
|
|
143
143
|
if (!validator.isObject(testPhoneNumbers)) {
|
|
@@ -169,7 +169,7 @@ var EmailSignInConfig = /** @class */ (function () {
|
|
|
169
169
|
/**
|
|
170
170
|
* The EmailSignInConfig constructor.
|
|
171
171
|
*
|
|
172
|
-
* @param
|
|
172
|
+
* @param response - The server side response used to initialize the
|
|
173
173
|
* EmailSignInConfig object.
|
|
174
174
|
* @constructor
|
|
175
175
|
*/
|
|
@@ -184,8 +184,8 @@ var EmailSignInConfig = /** @class */ (function () {
|
|
|
184
184
|
* Static method to convert a client side request to a EmailSignInConfigServerRequest.
|
|
185
185
|
* Throws an error if validation fails.
|
|
186
186
|
*
|
|
187
|
-
* @param
|
|
188
|
-
* @
|
|
187
|
+
* @param options - The options object to convert to a server request.
|
|
188
|
+
* @returns The resulting server request.
|
|
189
189
|
* @internal
|
|
190
190
|
*/
|
|
191
191
|
EmailSignInConfig.buildServerRequest = function (options) {
|
|
@@ -202,7 +202,7 @@ var EmailSignInConfig = /** @class */ (function () {
|
|
|
202
202
|
/**
|
|
203
203
|
* Validates the EmailSignInConfig options object. Throws an error on failure.
|
|
204
204
|
*
|
|
205
|
-
* @param
|
|
205
|
+
* @param options - The options object to validate.
|
|
206
206
|
*/
|
|
207
207
|
EmailSignInConfig.validate = function (options) {
|
|
208
208
|
// TODO: Validate the request.
|
|
@@ -229,7 +229,7 @@ var EmailSignInConfig = /** @class */ (function () {
|
|
|
229
229
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"EmailSignInConfig.passwordRequired" must be a boolean.');
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
|
-
/** @
|
|
232
|
+
/** @returns The plain object representation of the email sign-in config. */
|
|
233
233
|
EmailSignInConfig.prototype.toJSON = function () {
|
|
234
234
|
return {
|
|
235
235
|
enabled: this.enabled,
|
|
@@ -249,7 +249,7 @@ var SAMLConfig = /** @class */ (function () {
|
|
|
249
249
|
/**
|
|
250
250
|
* The SAMLConfig constructor.
|
|
251
251
|
*
|
|
252
|
-
* @param response The server side response used to initialize the SAMLConfig object.
|
|
252
|
+
* @param response - The server side response used to initialize the SAMLConfig object.
|
|
253
253
|
* @constructor
|
|
254
254
|
*/
|
|
255
255
|
function SAMLConfig(response) {
|
|
@@ -294,9 +294,9 @@ var SAMLConfig = /** @class */ (function () {
|
|
|
294
294
|
* Throws an error if validation fails. If the request is not a SAMLConfig request,
|
|
295
295
|
* returns null.
|
|
296
296
|
*
|
|
297
|
-
* @param
|
|
298
|
-
* @param
|
|
299
|
-
* @
|
|
297
|
+
* @param options - The options object to convert to a server request.
|
|
298
|
+
* @param ignoreMissingFields - Whether to ignore missing fields.
|
|
299
|
+
* @returns The resulting server request or null if not valid.
|
|
300
300
|
*/
|
|
301
301
|
SAMLConfig.buildServerRequest = function (options, ignoreMissingFields) {
|
|
302
302
|
if (ignoreMissingFields === void 0) { ignoreMissingFields = false; }
|
|
@@ -337,8 +337,8 @@ var SAMLConfig = /** @class */ (function () {
|
|
|
337
337
|
/**
|
|
338
338
|
* Returns the provider ID corresponding to the resource name if available.
|
|
339
339
|
*
|
|
340
|
-
* @param
|
|
341
|
-
* @
|
|
340
|
+
* @param resourceName - The server side resource name.
|
|
341
|
+
* @returns The provider ID corresponding to the resource, null otherwise.
|
|
342
342
|
*/
|
|
343
343
|
SAMLConfig.getProviderIdFromResourceName = function (resourceName) {
|
|
344
344
|
// name is of form projects/project1/inboundSamlConfigs/providerId1
|
|
@@ -349,8 +349,8 @@ var SAMLConfig = /** @class */ (function () {
|
|
|
349
349
|
return matchProviderRes[1];
|
|
350
350
|
};
|
|
351
351
|
/**
|
|
352
|
-
* @param
|
|
353
|
-
* @
|
|
352
|
+
* @param providerId - The provider ID to check.
|
|
353
|
+
* @returns Whether the provider ID corresponds to a SAML provider.
|
|
354
354
|
*/
|
|
355
355
|
SAMLConfig.isProviderId = function (providerId) {
|
|
356
356
|
return validator.isNonEmptyString(providerId) && providerId.indexOf('saml.') === 0;
|
|
@@ -358,8 +358,8 @@ var SAMLConfig = /** @class */ (function () {
|
|
|
358
358
|
/**
|
|
359
359
|
* Validates the SAMLConfig options object. Throws an error on failure.
|
|
360
360
|
*
|
|
361
|
-
* @param
|
|
362
|
-
* @param
|
|
361
|
+
* @param options - The options object to validate.
|
|
362
|
+
* @param ignoreMissingFields - Whether to ignore missing fields.
|
|
363
363
|
*/
|
|
364
364
|
SAMLConfig.validate = function (options, ignoreMissingFields) {
|
|
365
365
|
if (ignoreMissingFields === void 0) { ignoreMissingFields = false; }
|
|
@@ -432,7 +432,7 @@ var SAMLConfig = /** @class */ (function () {
|
|
|
432
432
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"SAMLAuthProviderConfig.displayName" must be a valid string.');
|
|
433
433
|
}
|
|
434
434
|
};
|
|
435
|
-
/** @
|
|
435
|
+
/** @returns The plain object representation of the SAMLConfig. */
|
|
436
436
|
SAMLConfig.prototype.toJSON = function () {
|
|
437
437
|
return {
|
|
438
438
|
enabled: this.enabled,
|
|
@@ -459,7 +459,7 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
459
459
|
/**
|
|
460
460
|
* The OIDCConfig constructor.
|
|
461
461
|
*
|
|
462
|
-
* @param response The server side response used to initialize the OIDCConfig object.
|
|
462
|
+
* @param response - The server side response used to initialize the OIDCConfig object.
|
|
463
463
|
* @constructor
|
|
464
464
|
*/
|
|
465
465
|
function OIDCConfig(response) {
|
|
@@ -481,6 +481,12 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
481
481
|
// When enabled is undefined, it takes its default value of false.
|
|
482
482
|
this.enabled = !!response.enabled;
|
|
483
483
|
this.displayName = response.displayName;
|
|
484
|
+
if (typeof response.clientSecret !== 'undefined') {
|
|
485
|
+
this.clientSecret = response.clientSecret;
|
|
486
|
+
}
|
|
487
|
+
if (typeof response.responseType !== 'undefined') {
|
|
488
|
+
this.responseType = response.responseType;
|
|
489
|
+
}
|
|
484
490
|
}
|
|
485
491
|
/**
|
|
486
492
|
* Converts a client side request to a OIDCConfigServerRequest which is the format
|
|
@@ -488,9 +494,9 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
488
494
|
* Throws an error if validation fails. If the request is not a OIDCConfig request,
|
|
489
495
|
* returns null.
|
|
490
496
|
*
|
|
491
|
-
* @param options The options object to convert to a server request.
|
|
492
|
-
* @param ignoreMissingFields Whether to ignore missing fields.
|
|
493
|
-
* @
|
|
497
|
+
* @param options - The options object to convert to a server request.
|
|
498
|
+
* @param ignoreMissingFields - Whether to ignore missing fields.
|
|
499
|
+
* @returns The resulting server request or null if not valid.
|
|
494
500
|
*/
|
|
495
501
|
OIDCConfig.buildServerRequest = function (options, ignoreMissingFields) {
|
|
496
502
|
if (ignoreMissingFields === void 0) { ignoreMissingFields = false; }
|
|
@@ -506,13 +512,19 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
506
512
|
request.displayName = options.displayName;
|
|
507
513
|
request.issuer = options.issuer;
|
|
508
514
|
request.clientId = options.clientId;
|
|
515
|
+
if (typeof options.clientSecret !== 'undefined') {
|
|
516
|
+
request.clientSecret = options.clientSecret;
|
|
517
|
+
}
|
|
518
|
+
if (typeof options.responseType !== 'undefined') {
|
|
519
|
+
request.responseType = options.responseType;
|
|
520
|
+
}
|
|
509
521
|
return request;
|
|
510
522
|
};
|
|
511
523
|
/**
|
|
512
524
|
* Returns the provider ID corresponding to the resource name if available.
|
|
513
525
|
*
|
|
514
|
-
* @param
|
|
515
|
-
* @
|
|
526
|
+
* @param resourceName - The server side resource name
|
|
527
|
+
* @returns The provider ID corresponding to the resource, null otherwise.
|
|
516
528
|
*/
|
|
517
529
|
OIDCConfig.getProviderIdFromResourceName = function (resourceName) {
|
|
518
530
|
// name is of form projects/project1/oauthIdpConfigs/providerId1
|
|
@@ -523,8 +535,8 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
523
535
|
return matchProviderRes[1];
|
|
524
536
|
};
|
|
525
537
|
/**
|
|
526
|
-
* @param
|
|
527
|
-
* @
|
|
538
|
+
* @param providerId - The provider ID to check.
|
|
539
|
+
* @returns Whether the provider ID corresponds to an OIDC provider.
|
|
528
540
|
*/
|
|
529
541
|
OIDCConfig.isProviderId = function (providerId) {
|
|
530
542
|
return validator.isNonEmptyString(providerId) && providerId.indexOf('oidc.') === 0;
|
|
@@ -532,8 +544,8 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
532
544
|
/**
|
|
533
545
|
* Validates the OIDCConfig options object. Throws an error on failure.
|
|
534
546
|
*
|
|
535
|
-
* @param options The options object to validate.
|
|
536
|
-
* @param ignoreMissingFields Whether to ignore missing fields.
|
|
547
|
+
* @param options - The options object to validate.
|
|
548
|
+
* @param ignoreMissingFields - Whether to ignore missing fields.
|
|
537
549
|
*/
|
|
538
550
|
OIDCConfig.validate = function (options, ignoreMissingFields) {
|
|
539
551
|
if (ignoreMissingFields === void 0) { ignoreMissingFields = false; }
|
|
@@ -543,6 +555,12 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
543
555
|
providerId: true,
|
|
544
556
|
clientId: true,
|
|
545
557
|
issuer: true,
|
|
558
|
+
clientSecret: true,
|
|
559
|
+
responseType: true,
|
|
560
|
+
};
|
|
561
|
+
var validResponseTypes = {
|
|
562
|
+
idToken: true,
|
|
563
|
+
code: true,
|
|
546
564
|
};
|
|
547
565
|
if (!validator.isNonNullObject(options)) {
|
|
548
566
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"OIDCAuthProviderConfig" must be a valid non-null object.');
|
|
@@ -578,8 +596,39 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
578
596
|
!validator.isString(options.displayName)) {
|
|
579
597
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"OIDCAuthProviderConfig.displayName" must be a valid string.');
|
|
580
598
|
}
|
|
599
|
+
if (typeof options.clientSecret !== 'undefined' &&
|
|
600
|
+
!validator.isNonEmptyString(options.clientSecret)) {
|
|
601
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"OIDCAuthProviderConfig.clientSecret" must be a valid string.');
|
|
602
|
+
}
|
|
603
|
+
if (validator.isNonNullObject(options.responseType) && typeof options.responseType !== 'undefined') {
|
|
604
|
+
Object.keys(options.responseType).forEach(function (key) {
|
|
605
|
+
if (!(key in validResponseTypes)) {
|
|
606
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, "\"" + key + "\" is not a valid OAuthResponseType parameter.");
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
var idToken = options.responseType.idToken;
|
|
610
|
+
if (typeof idToken !== 'undefined' && !validator.isBoolean(idToken)) {
|
|
611
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"OIDCAuthProviderConfig.responseType.idToken" must be a boolean.');
|
|
612
|
+
}
|
|
613
|
+
var code = options.responseType.code;
|
|
614
|
+
if (typeof code !== 'undefined') {
|
|
615
|
+
if (!validator.isBoolean(code)) {
|
|
616
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"OIDCAuthProviderConfig.responseType.code" must be a boolean.');
|
|
617
|
+
}
|
|
618
|
+
// If code flow is enabled, client secret must be provided.
|
|
619
|
+
if (code && typeof options.clientSecret === 'undefined') {
|
|
620
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MISSING_OAUTH_CLIENT_SECRET, 'The OAuth configuration client secret is required to enable OIDC code flow.');
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
var allKeys = Object.keys(options.responseType).length;
|
|
624
|
+
var enabledCount = Object.values(options.responseType).filter(Boolean).length;
|
|
625
|
+
// Only one of OAuth response types can be set to true.
|
|
626
|
+
if (allKeys > 1 && enabledCount != 1) {
|
|
627
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_OAUTH_RESPONSETYPE, 'Only exactly one OAuth responseType should be set to true.');
|
|
628
|
+
}
|
|
629
|
+
}
|
|
581
630
|
};
|
|
582
|
-
/** @
|
|
631
|
+
/** @returns The plain object representation of the OIDCConfig. */
|
|
583
632
|
OIDCConfig.prototype.toJSON = function () {
|
|
584
633
|
return {
|
|
585
634
|
enabled: this.enabled,
|
|
@@ -587,6 +636,8 @@ var OIDCConfig = /** @class */ (function () {
|
|
|
587
636
|
providerId: this.providerId,
|
|
588
637
|
issuer: this.issuer,
|
|
589
638
|
clientId: this.clientId,
|
|
639
|
+
clientSecret: deep_copy_1.deepCopy(this.clientSecret),
|
|
640
|
+
responseType: deep_copy_1.deepCopy(this.responseType),
|
|
590
641
|
};
|
|
591
642
|
};
|
|
592
643
|
return OIDCConfig;
|