firebase-admin 9.12.0 → 10.0.1
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 +188 -0
- package/lib/app/core.js +19 -0
- package/lib/app/credential-factory.d.ts +123 -0
- package/lib/app/credential-factory.js +150 -0
- package/lib/app/credential-internal.d.ts +90 -0
- package/lib/{credential → app}/credential-internal.js +15 -13
- package/lib/app/credential.d.ts +45 -0
- package/lib/app/credential.js +19 -0
- package/lib/app/firebase-app.d.ts +51 -0
- package/lib/{firebase-app.js → app/firebase-app.js} +26 -156
- package/lib/app/firebase-namespace.d.ts +163 -0
- package/lib/{firebase-namespace.js → app/firebase-namespace.js} +99 -111
- package/lib/app/index.d.ts +27 -0
- package/lib/app/index.js +31 -0
- package/lib/app/lifecycle.d.ts +60 -0
- package/lib/app/lifecycle.js +165 -0
- package/lib/app-check/app-check-api-client-internal.d.ts +32 -0
- package/lib/app-check/app-check-api-client-internal.js +10 -10
- 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 +13 -10
- package/lib/app-check/index.d.ts +19 -126
- package/lib/app-check/index.js +45 -1
- package/lib/app-check/token-generator.d.ts +25 -0
- package/lib/app-check/token-generator.js +9 -9
- package/lib/app-check/token-verifier.d.ts +17 -0
- package/lib/app-check/token-verifier.js +6 -6
- package/lib/auth/action-code-settings-builder.d.ts +87 -0
- package/lib/auth/action-code-settings-builder.js +4 -2
- package/lib/auth/auth-api-request.d.ts +174 -0
- package/lib/auth/auth-api-request.js +202 -127
- package/lib/auth/auth-config.d.ts +575 -0
- package/lib/auth/auth-config.js +43 -34
- package/lib/auth/auth-namespace.d.ts +255 -0
- package/lib/auth/auth-namespace.js +18 -0
- package/lib/auth/auth.d.ts +40 -0
- package/lib/auth/auth.js +12 -772
- package/lib/auth/base-auth.d.ts +613 -0
- package/lib/auth/base-auth.js +951 -0
- package/lib/auth/identifier.d.ts +57 -0
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +25 -1897
- package/lib/auth/index.js +54 -1
- package/lib/auth/tenant-manager.d.ts +146 -0
- package/lib/auth/tenant-manager.js +151 -39
- package/lib/auth/tenant.d.ts +130 -0
- package/lib/auth/tenant.js +62 -16
- package/lib/auth/token-generator.d.ts +44 -0
- package/lib/auth/token-generator.js +11 -9
- package/lib/auth/token-verifier.d.ts +150 -0
- package/lib/auth/token-verifier.js +27 -15
- package/lib/auth/user-import-builder.d.ts +322 -0
- package/lib/auth/user-import-builder.js +9 -9
- package/lib/auth/user-record.d.ts +265 -0
- package/lib/auth/user-record.js +80 -45
- package/lib/credential/index.d.ts +24 -66
- package/lib/credential/index.js +101 -1
- package/lib/database/database-namespace.d.ts +95 -0
- package/lib/database/database-namespace.js +23 -0
- package/lib/database/database.d.ts +66 -0
- package/lib/database/{database-internal.js → database.js} +16 -9
- package/lib/database/index.d.ts +55 -54
- package/lib/database/index.js +84 -13
- package/lib/{firebase-namespace.d.ts → default-namespace.d.ts} +7 -14
- package/lib/default-namespace.js +4 -5
- 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 +34 -186
- package/lib/firebase-namespace-api.js +37 -2
- package/lib/firestore/firestore-internal.d.ts +32 -0
- package/lib/firestore/firestore-internal.js +3 -3
- package/lib/firestore/firestore-namespace.d.ts +55 -0
- package/lib/firestore/firestore-namespace.js +48 -0
- package/lib/firestore/index.d.ts +37 -35
- package/lib/firestore/index.js +62 -30
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +34 -63
- package/lib/installations/index.js +45 -1
- package/lib/installations/installations-namespace.d.ts +55 -0
- package/lib/installations/installations-namespace.js +18 -0
- package/lib/installations/installations-request-handler.d.ts +43 -0
- package/lib/installations/installations-request-handler.js +4 -4
- package/lib/installations/installations.d.ts +38 -0
- package/lib/installations/installations.js +6 -5
- package/lib/instance-id/index.d.ts +23 -45
- package/lib/instance-id/index.js +54 -1
- package/lib/instance-id/instance-id-namespace.d.ts +38 -0
- package/lib/instance-id/instance-id-namespace.js +3 -0
- package/lib/instance-id/instance-id.d.ts +47 -0
- package/lib/instance-id/instance-id.js +14 -19
- package/lib/machine-learning/index.d.ts +19 -216
- package/lib/machine-learning/index.js +46 -1
- package/lib/machine-learning/machine-learning-api-client.d.ts +102 -0
- package/lib/machine-learning/machine-learning-api-client.js +6 -6
- package/lib/machine-learning/machine-learning-namespace.d.ts +85 -0
- package/lib/machine-learning/machine-learning-namespace.js +18 -0
- package/lib/machine-learning/machine-learning-utils.d.ts +22 -0
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.d.ts +181 -0
- package/lib/machine-learning/machine-learning.js +72 -37
- package/lib/messaging/batch-request-internal.d.ts +55 -0
- package/lib/messaging/batch-request-internal.js +9 -9
- package/lib/messaging/index.d.ts +18 -1140
- package/lib/messaging/index.js +45 -1
- package/lib/messaging/messaging-api-request-internal.d.ts +50 -0
- package/lib/messaging/messaging-api-request-internal.js +8 -8
- package/lib/messaging/messaging-api.d.ts +980 -0
- package/lib/messaging/messaging-api.js +19 -0
- package/lib/messaging/messaging-errors-internal.d.ts +31 -0
- package/lib/messaging/messaging-errors-internal.js +7 -7
- package/lib/messaging/messaging-internal.d.ts +27 -0
- package/lib/messaging/messaging-internal.js +2 -2
- package/lib/messaging/messaging-namespace.d.ts +181 -0
- package/lib/messaging/messaging-namespace.js +18 -0
- package/lib/messaging/messaging.d.ts +269 -0
- package/lib/messaging/messaging.js +83 -91
- package/lib/project-management/android-app.d.ts +110 -0
- package/lib/project-management/android-app.js +24 -15
- package/lib/project-management/app-metadata.d.ts +85 -0
- package/lib/project-management/app-metadata.js +37 -0
- package/lib/project-management/index.d.ts +21 -331
- package/lib/project-management/index.js +51 -24
- package/lib/project-management/ios-app.d.ts +66 -0
- package/lib/project-management/ios-app.js +15 -8
- package/lib/project-management/project-management-api-request-internal.d.ts +17 -0
- package/lib/project-management/project-management-api-request-internal.js +15 -15
- package/lib/project-management/project-management-namespace.d.ts +82 -0
- package/lib/project-management/project-management-namespace.js +18 -0
- package/lib/project-management/project-management.d.ts +115 -0
- package/lib/project-management/project-management.js +22 -25
- package/lib/remote-config/index.d.ts +19 -336
- package/lib/remote-config/index.js +45 -1
- package/lib/remote-config/remote-config-api-client-internal.d.ts +28 -0
- package/lib/remote-config/remote-config-api-client-internal.js +3 -3
- package/lib/remote-config/remote-config-api.d.ts +258 -0
- package/lib/remote-config/remote-config-api.js +18 -0
- package/lib/remote-config/remote-config-namespace.d.ts +105 -0
- package/lib/remote-config/remote-config-namespace.js +18 -0
- package/lib/remote-config/remote-config.d.ts +94 -0
- package/lib/remote-config/remote-config.js +27 -26
- package/lib/security-rules/index.d.ts +18 -184
- package/lib/security-rules/index.js +46 -1
- package/lib/security-rules/security-rules-api-client-internal.d.ts +73 -0
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +21 -0
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +69 -0
- package/lib/security-rules/security-rules-namespace.js +18 -0
- package/lib/security-rules/security-rules.d.ts +196 -0
- package/lib/security-rules/security-rules.js +73 -55
- package/lib/storage/index.d.ts +16 -32
- package/lib/storage/index.js +38 -1
- package/lib/storage/storage-namespace.d.ts +45 -0
- package/lib/storage/storage-namespace.js +18 -0
- package/lib/storage/storage.d.ts +42 -0
- package/lib/storage/storage.js +9 -6
- package/lib/utils/api-request.d.ts +230 -0
- package/lib/utils/api-request.js +25 -25
- package/lib/utils/crypto-signer.d.ts +128 -0
- package/lib/utils/crypto-signer.js +9 -9
- package/lib/utils/deep-copy.d.ts +40 -0
- package/lib/utils/deep-copy.js +6 -6
- package/lib/utils/error.d.ts +650 -0
- package/lib/utils/error.js +36 -34
- package/lib/utils/index.d.ts +105 -0
- package/lib/utils/index.js +22 -21
- package/lib/utils/jwt.d.ts +131 -0
- package/lib/utils/jwt.js +11 -11
- package/lib/utils/validator.d.ts +144 -0
- package/lib/utils/validator.js +37 -37
- package/package.json +112 -10
- package/lib/credential/credential.js +0 -44
package/lib/auth/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2020 Google Inc.
|
|
@@ -16,3 +16,56 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.getAuth = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* Firebase Authentication.
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
var index_1 = require("../app/index");
|
|
26
|
+
var auth_1 = require("./auth");
|
|
27
|
+
/**
|
|
28
|
+
* Gets the {@link Auth} service for the default app or a
|
|
29
|
+
* given app.
|
|
30
|
+
*
|
|
31
|
+
* `getAuth()` can be called with no arguments to access the default app's
|
|
32
|
+
* {@link Auth} service or as `getAuth(app)` to access the
|
|
33
|
+
* {@link Auth} service associated with a specific app.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```javascript
|
|
37
|
+
* // Get the Auth service for the default app
|
|
38
|
+
* const defaultAuth = getAuth();
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```javascript
|
|
43
|
+
* // Get the Auth service for a given app
|
|
44
|
+
* const otherAuth = getAuth(otherApp);
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
function getAuth(app) {
|
|
49
|
+
if (typeof app === 'undefined') {
|
|
50
|
+
app = index_1.getApp();
|
|
51
|
+
}
|
|
52
|
+
var firebaseApp = app;
|
|
53
|
+
return firebaseApp.getOrInitService('auth', function (app) { return new auth_1.Auth(app); });
|
|
54
|
+
}
|
|
55
|
+
exports.getAuth = getAuth;
|
|
56
|
+
var auth_2 = require("./auth");
|
|
57
|
+
Object.defineProperty(exports, "Auth", { enumerable: true, get: function () { return auth_2.Auth; } });
|
|
58
|
+
var base_auth_1 = require("./base-auth");
|
|
59
|
+
Object.defineProperty(exports, "BaseAuth", { enumerable: true, get: function () { return base_auth_1.BaseAuth; } });
|
|
60
|
+
var tenant_1 = require("./tenant");
|
|
61
|
+
Object.defineProperty(exports, "Tenant", { enumerable: true, get: function () { return tenant_1.Tenant; } });
|
|
62
|
+
var tenant_manager_1 = require("./tenant-manager");
|
|
63
|
+
Object.defineProperty(exports, "TenantAwareAuth", { enumerable: true, get: function () { return tenant_manager_1.TenantAwareAuth; } });
|
|
64
|
+
Object.defineProperty(exports, "TenantManager", { enumerable: true, get: function () { return tenant_manager_1.TenantManager; } });
|
|
65
|
+
var user_record_1 = require("./user-record");
|
|
66
|
+
Object.defineProperty(exports, "MultiFactorInfo", { enumerable: true, get: function () { return user_record_1.MultiFactorInfo; } });
|
|
67
|
+
Object.defineProperty(exports, "MultiFactorSettings", { enumerable: true, get: function () { return user_record_1.MultiFactorSettings; } });
|
|
68
|
+
Object.defineProperty(exports, "PhoneMultiFactorInfo", { enumerable: true, get: function () { return user_record_1.PhoneMultiFactorInfo; } });
|
|
69
|
+
Object.defineProperty(exports, "UserInfo", { enumerable: true, get: function () { return user_record_1.UserInfo; } });
|
|
70
|
+
Object.defineProperty(exports, "UserMetadata", { enumerable: true, get: function () { return user_record_1.UserMetadata; } });
|
|
71
|
+
Object.defineProperty(exports, "UserRecord", { enumerable: true, get: function () { return user_record_1.UserRecord; } });
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*! firebase-admin v10.0.1 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2019 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { BaseAuth, SessionCookieOptions } from './base-auth';
|
|
18
|
+
import { Tenant, CreateTenantRequest, UpdateTenantRequest } from './tenant';
|
|
19
|
+
import { DecodedIdToken } from './token-verifier';
|
|
20
|
+
/**
|
|
21
|
+
* Interface representing the object returned from a
|
|
22
|
+
* {@link TenantManager.listTenants}
|
|
23
|
+
* operation.
|
|
24
|
+
* Contains the list of tenants for the current batch and the next page token if available.
|
|
25
|
+
*/
|
|
26
|
+
export interface ListTenantsResult {
|
|
27
|
+
/**
|
|
28
|
+
* The list of {@link Tenant} objects for the downloaded batch.
|
|
29
|
+
*/
|
|
30
|
+
tenants: Tenant[];
|
|
31
|
+
/**
|
|
32
|
+
* The next page token if available. This is needed for the next batch download.
|
|
33
|
+
*/
|
|
34
|
+
pageToken?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Tenant-aware `Auth` interface used for managing users, configuring SAML/OIDC providers,
|
|
38
|
+
* generating email links for password reset, email verification, etc for specific tenants.
|
|
39
|
+
*
|
|
40
|
+
* Multi-tenancy support requires Google Cloud's Identity Platform
|
|
41
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
42
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
43
|
+
*
|
|
44
|
+
* Each tenant contains its own identity providers, settings and sets of users.
|
|
45
|
+
* Using `TenantAwareAuth`, users for a specific tenant and corresponding OIDC/SAML
|
|
46
|
+
* configurations can also be managed, ID tokens for users signed in to a specific tenant
|
|
47
|
+
* can be verified, and email action links can also be generated for users belonging to the
|
|
48
|
+
* tenant.
|
|
49
|
+
*
|
|
50
|
+
* `TenantAwareAuth` instances for a specific `tenantId` can be instantiated by calling
|
|
51
|
+
* {@link TenantManager.authForTenant}.
|
|
52
|
+
*/
|
|
53
|
+
export declare class TenantAwareAuth extends BaseAuth {
|
|
54
|
+
/**
|
|
55
|
+
* The tenant identifier corresponding to this `TenantAwareAuth` instance.
|
|
56
|
+
* All calls to the user management APIs, OIDC/SAML provider management APIs, email link
|
|
57
|
+
* generation APIs, etc will only be applied within the scope of this tenant.
|
|
58
|
+
*/
|
|
59
|
+
readonly tenantId: string;
|
|
60
|
+
/**
|
|
61
|
+
* {@inheritdoc BaseAuth.verifyIdToken}
|
|
62
|
+
*/
|
|
63
|
+
verifyIdToken(idToken: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
|
|
64
|
+
/**
|
|
65
|
+
* {@inheritdoc BaseAuth.createSessionCookie}
|
|
66
|
+
*/
|
|
67
|
+
createSessionCookie(idToken: string, sessionCookieOptions: SessionCookieOptions): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* {@inheritdoc BaseAuth.verifySessionCookie}
|
|
70
|
+
*/
|
|
71
|
+
verifySessionCookie(sessionCookie: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Defines the tenant manager used to help manage tenant related operations.
|
|
75
|
+
* This includes:
|
|
76
|
+
* <ul>
|
|
77
|
+
* <li>The ability to create, update, list, get and delete tenants for the underlying
|
|
78
|
+
* project.</li>
|
|
79
|
+
* <li>Getting a `TenantAwareAuth` instance for running Auth related operations
|
|
80
|
+
* (user management, provider configuration management, token verification,
|
|
81
|
+
* email link generation, etc) in the context of a specified tenant.</li>
|
|
82
|
+
* </ul>
|
|
83
|
+
*/
|
|
84
|
+
export declare class TenantManager {
|
|
85
|
+
private readonly app;
|
|
86
|
+
private readonly authRequestHandler;
|
|
87
|
+
private readonly tenantsMap;
|
|
88
|
+
/**
|
|
89
|
+
* Returns a `TenantAwareAuth` instance bound to the given tenant ID.
|
|
90
|
+
*
|
|
91
|
+
* @param tenantId - The tenant ID whose `TenantAwareAuth` instance is to be returned.
|
|
92
|
+
*
|
|
93
|
+
* @returns The `TenantAwareAuth` instance corresponding to this tenant identifier.
|
|
94
|
+
*/
|
|
95
|
+
authForTenant(tenantId: string): TenantAwareAuth;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the tenant configuration for the tenant corresponding to a given `tenantId`.
|
|
98
|
+
*
|
|
99
|
+
* @param tenantId - The tenant identifier corresponding to the tenant whose data to fetch.
|
|
100
|
+
*
|
|
101
|
+
* @returns A promise fulfilled with the tenant configuration to the provided `tenantId`.
|
|
102
|
+
*/
|
|
103
|
+
getTenant(tenantId: string): Promise<Tenant>;
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves a list of tenants (single batch only) with a size of `maxResults`
|
|
106
|
+
* starting from the offset as specified by `pageToken`. This is used to
|
|
107
|
+
* retrieve all the tenants of a specified project in batches.
|
|
108
|
+
*
|
|
109
|
+
* @param maxResults - The page size, 1000 if undefined. This is also
|
|
110
|
+
* the maximum allowed limit.
|
|
111
|
+
* @param pageToken - The next page token. If not specified, returns
|
|
112
|
+
* tenants starting without any offset.
|
|
113
|
+
*
|
|
114
|
+
* @returns A promise that resolves with
|
|
115
|
+
* a batch of downloaded tenants and the next page token.
|
|
116
|
+
*/
|
|
117
|
+
listTenants(maxResults?: number, pageToken?: string): Promise<ListTenantsResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Deletes an existing tenant.
|
|
120
|
+
*
|
|
121
|
+
* @param tenantId - The `tenantId` corresponding to the tenant to delete.
|
|
122
|
+
*
|
|
123
|
+
* @returns An empty promise fulfilled once the tenant has been deleted.
|
|
124
|
+
*/
|
|
125
|
+
deleteTenant(tenantId: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new tenant.
|
|
128
|
+
* When creating new tenants, tenants that use separate billing and quota will require their
|
|
129
|
+
* own project and must be defined as `full_service`.
|
|
130
|
+
*
|
|
131
|
+
* @param tenantOptions - The properties to set on the new tenant configuration to be created.
|
|
132
|
+
*
|
|
133
|
+
* @returns A promise fulfilled with the tenant configuration corresponding to the newly
|
|
134
|
+
* created tenant.
|
|
135
|
+
*/
|
|
136
|
+
createTenant(tenantOptions: CreateTenantRequest): Promise<Tenant>;
|
|
137
|
+
/**
|
|
138
|
+
* Updates an existing tenant configuration.
|
|
139
|
+
*
|
|
140
|
+
* @param tenantId - The `tenantId` corresponding to the tenant to delete.
|
|
141
|
+
* @param tenantOptions - The properties to update on the provided tenant.
|
|
142
|
+
*
|
|
143
|
+
* @returns A promise fulfilled with the update tenant data.
|
|
144
|
+
*/
|
|
145
|
+
updateTenant(tenantId: string, tenantOptions: UpdateTenantRequest): Promise<Tenant>;
|
|
146
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2019 Google Inc.
|
|
@@ -15,24 +15,129 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
+
var __extends = (this && this.__extends) || (function () {
|
|
19
|
+
var extendStatics = function (d, b) {
|
|
20
|
+
extendStatics = Object.setPrototypeOf ||
|
|
21
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
22
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
23
|
+
return extendStatics(d, b);
|
|
24
|
+
};
|
|
25
|
+
return function (d, b) {
|
|
26
|
+
extendStatics(d, b);
|
|
27
|
+
function __() { this.constructor = d; }
|
|
28
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
18
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.TenantManager = void 0;
|
|
20
|
-
var auth_api_request_1 = require("./auth-api-request");
|
|
21
|
-
var auth_1 = require("./auth");
|
|
22
|
-
var tenant_1 = require("./tenant");
|
|
23
|
-
var error_1 = require("../utils/error");
|
|
32
|
+
exports.TenantManager = exports.TenantAwareAuth = void 0;
|
|
24
33
|
var validator = require("../utils/validator");
|
|
34
|
+
var utils = require("../utils/index");
|
|
35
|
+
var error_1 = require("../utils/error");
|
|
36
|
+
var base_auth_1 = require("./base-auth");
|
|
37
|
+
var tenant_1 = require("./tenant");
|
|
38
|
+
var auth_api_request_1 = require("./auth-api-request");
|
|
25
39
|
/**
|
|
26
|
-
*
|
|
40
|
+
* Tenant-aware `Auth` interface used for managing users, configuring SAML/OIDC providers,
|
|
41
|
+
* generating email links for password reset, email verification, etc for specific tenants.
|
|
42
|
+
*
|
|
43
|
+
* Multi-tenancy support requires Google Cloud's Identity Platform
|
|
44
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
45
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
46
|
+
*
|
|
47
|
+
* Each tenant contains its own identity providers, settings and sets of users.
|
|
48
|
+
* Using `TenantAwareAuth`, users for a specific tenant and corresponding OIDC/SAML
|
|
49
|
+
* configurations can also be managed, ID tokens for users signed in to a specific tenant
|
|
50
|
+
* can be verified, and email action links can also be generated for users belonging to the
|
|
51
|
+
* tenant.
|
|
52
|
+
*
|
|
53
|
+
* `TenantAwareAuth` instances for a specific `tenantId` can be instantiated by calling
|
|
54
|
+
* {@link TenantManager.authForTenant}.
|
|
55
|
+
*/
|
|
56
|
+
var TenantAwareAuth = /** @class */ (function (_super) {
|
|
57
|
+
__extends(TenantAwareAuth, _super);
|
|
58
|
+
/**
|
|
59
|
+
* The TenantAwareAuth class constructor.
|
|
60
|
+
*
|
|
61
|
+
* @param app - The app that created this tenant.
|
|
62
|
+
* @param tenantId - The corresponding tenant ID.
|
|
63
|
+
* @constructor
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
function TenantAwareAuth(app, tenantId) {
|
|
67
|
+
var _this = _super.call(this, app, new auth_api_request_1.TenantAwareAuthRequestHandler(app, tenantId), base_auth_1.createFirebaseTokenGenerator(app, tenantId)) || this;
|
|
68
|
+
utils.addReadonlyGetter(_this, 'tenantId', tenantId);
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritdoc BaseAuth.verifyIdToken}
|
|
73
|
+
*/
|
|
74
|
+
TenantAwareAuth.prototype.verifyIdToken = function (idToken, checkRevoked) {
|
|
75
|
+
var _this = this;
|
|
76
|
+
if (checkRevoked === void 0) { checkRevoked = false; }
|
|
77
|
+
return _super.prototype.verifyIdToken.call(this, idToken, checkRevoked)
|
|
78
|
+
.then(function (decodedClaims) {
|
|
79
|
+
// Validate tenant ID.
|
|
80
|
+
if (decodedClaims.firebase.tenant !== _this.tenantId) {
|
|
81
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MISMATCHING_TENANT_ID);
|
|
82
|
+
}
|
|
83
|
+
return decodedClaims;
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* {@inheritdoc BaseAuth.createSessionCookie}
|
|
88
|
+
*/
|
|
89
|
+
TenantAwareAuth.prototype.createSessionCookie = function (idToken, sessionCookieOptions) {
|
|
90
|
+
var _this = this;
|
|
91
|
+
// Validate arguments before processing.
|
|
92
|
+
if (!validator.isNonEmptyString(idToken)) {
|
|
93
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ID_TOKEN));
|
|
94
|
+
}
|
|
95
|
+
if (!validator.isNonNullObject(sessionCookieOptions) ||
|
|
96
|
+
!validator.isNumber(sessionCookieOptions.expiresIn)) {
|
|
97
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_SESSION_COOKIE_DURATION));
|
|
98
|
+
}
|
|
99
|
+
// This will verify the ID token and then match the tenant ID before creating the session cookie.
|
|
100
|
+
return this.verifyIdToken(idToken)
|
|
101
|
+
.then(function () {
|
|
102
|
+
return _super.prototype.createSessionCookie.call(_this, idToken, sessionCookieOptions);
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* {@inheritdoc BaseAuth.verifySessionCookie}
|
|
107
|
+
*/
|
|
108
|
+
TenantAwareAuth.prototype.verifySessionCookie = function (sessionCookie, checkRevoked) {
|
|
109
|
+
var _this = this;
|
|
110
|
+
if (checkRevoked === void 0) { checkRevoked = false; }
|
|
111
|
+
return _super.prototype.verifySessionCookie.call(this, sessionCookie, checkRevoked)
|
|
112
|
+
.then(function (decodedClaims) {
|
|
113
|
+
if (decodedClaims.firebase.tenant !== _this.tenantId) {
|
|
114
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MISMATCHING_TENANT_ID);
|
|
115
|
+
}
|
|
116
|
+
return decodedClaims;
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return TenantAwareAuth;
|
|
120
|
+
}(base_auth_1.BaseAuth));
|
|
121
|
+
exports.TenantAwareAuth = TenantAwareAuth;
|
|
122
|
+
/**
|
|
123
|
+
* Defines the tenant manager used to help manage tenant related operations.
|
|
27
124
|
* This includes:
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
125
|
+
* <ul>
|
|
126
|
+
* <li>The ability to create, update, list, get and delete tenants for the underlying
|
|
127
|
+
* project.</li>
|
|
128
|
+
* <li>Getting a `TenantAwareAuth` instance for running Auth related operations
|
|
129
|
+
* (user management, provider configuration management, token verification,
|
|
130
|
+
* email link generation, etc) in the context of a specified tenant.</li>
|
|
131
|
+
* </ul>
|
|
31
132
|
*/
|
|
32
133
|
var TenantManager = /** @class */ (function () {
|
|
33
134
|
/**
|
|
34
135
|
* Initializes a TenantManager instance for a specified FirebaseApp.
|
|
35
|
-
*
|
|
136
|
+
*
|
|
137
|
+
* @param app - The app for this TenantManager instance.
|
|
138
|
+
*
|
|
139
|
+
* @constructor
|
|
140
|
+
* @internal
|
|
36
141
|
*/
|
|
37
142
|
function TenantManager(app) {
|
|
38
143
|
this.app = app;
|
|
@@ -40,26 +145,27 @@ var TenantManager = /** @class */ (function () {
|
|
|
40
145
|
this.tenantsMap = {};
|
|
41
146
|
}
|
|
42
147
|
/**
|
|
43
|
-
* Returns a TenantAwareAuth instance
|
|
148
|
+
* Returns a `TenantAwareAuth` instance bound to the given tenant ID.
|
|
149
|
+
*
|
|
150
|
+
* @param tenantId - The tenant ID whose `TenantAwareAuth` instance is to be returned.
|
|
44
151
|
*
|
|
45
|
-
* @
|
|
46
|
-
* @return The corresponding TenantAwareAuth instance.
|
|
152
|
+
* @returns The `TenantAwareAuth` instance corresponding to this tenant identifier.
|
|
47
153
|
*/
|
|
48
154
|
TenantManager.prototype.authForTenant = function (tenantId) {
|
|
49
155
|
if (!validator.isNonEmptyString(tenantId)) {
|
|
50
156
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_TENANT_ID);
|
|
51
157
|
}
|
|
52
158
|
if (typeof this.tenantsMap[tenantId] === 'undefined') {
|
|
53
|
-
this.tenantsMap[tenantId] = new
|
|
159
|
+
this.tenantsMap[tenantId] = new TenantAwareAuth(this.app, tenantId);
|
|
54
160
|
}
|
|
55
161
|
return this.tenantsMap[tenantId];
|
|
56
162
|
};
|
|
57
163
|
/**
|
|
58
|
-
*
|
|
59
|
-
* fulfilled with the corresponding tenant if it is found.
|
|
164
|
+
* Gets the tenant configuration for the tenant corresponding to a given `tenantId`.
|
|
60
165
|
*
|
|
61
|
-
* @param tenantId The tenant
|
|
62
|
-
*
|
|
166
|
+
* @param tenantId - The tenant identifier corresponding to the tenant whose data to fetch.
|
|
167
|
+
*
|
|
168
|
+
* @returns A promise fulfilled with the tenant configuration to the provided `tenantId`.
|
|
63
169
|
*/
|
|
64
170
|
TenantManager.prototype.getTenant = function (tenantId) {
|
|
65
171
|
return this.authRequestHandler.getTenant(tenantId)
|
|
@@ -68,16 +174,17 @@ var TenantManager = /** @class */ (function () {
|
|
|
68
174
|
});
|
|
69
175
|
};
|
|
70
176
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
177
|
+
* Retrieves a list of tenants (single batch only) with a size of `maxResults`
|
|
178
|
+
* starting from the offset as specified by `pageToken`. This is used to
|
|
179
|
+
* retrieve all the tenants of a specified project in batches.
|
|
180
|
+
*
|
|
181
|
+
* @param maxResults - The page size, 1000 if undefined. This is also
|
|
182
|
+
* the maximum allowed limit.
|
|
183
|
+
* @param pageToken - The next page token. If not specified, returns
|
|
184
|
+
* tenants starting without any offset.
|
|
73
185
|
*
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
76
|
-
* @param pageToken The next page token. If not specified, returns users starting
|
|
77
|
-
* without any offset.
|
|
78
|
-
* @return A promise that resolves with
|
|
79
|
-
* the current batch of downloaded tenants and the next page token. For the last page, an
|
|
80
|
-
* empty list of tenants and no page token are returned.
|
|
186
|
+
* @returns A promise that resolves with
|
|
187
|
+
* a batch of downloaded tenants and the next page token.
|
|
81
188
|
*/
|
|
82
189
|
TenantManager.prototype.listTenants = function (maxResults, pageToken) {
|
|
83
190
|
return this.authRequestHandler.listTenants(maxResults, pageToken)
|
|
@@ -101,20 +208,24 @@ var TenantManager = /** @class */ (function () {
|
|
|
101
208
|
});
|
|
102
209
|
};
|
|
103
210
|
/**
|
|
104
|
-
* Deletes
|
|
105
|
-
*
|
|
211
|
+
* Deletes an existing tenant.
|
|
212
|
+
*
|
|
213
|
+
* @param tenantId - The `tenantId` corresponding to the tenant to delete.
|
|
106
214
|
*
|
|
107
|
-
* @
|
|
108
|
-
* @return A promise that resolves when the tenant is successfully deleted.
|
|
215
|
+
* @returns An empty promise fulfilled once the tenant has been deleted.
|
|
109
216
|
*/
|
|
110
217
|
TenantManager.prototype.deleteTenant = function (tenantId) {
|
|
111
218
|
return this.authRequestHandler.deleteTenant(tenantId);
|
|
112
219
|
};
|
|
113
220
|
/**
|
|
114
|
-
* Creates a new tenant
|
|
221
|
+
* Creates a new tenant.
|
|
222
|
+
* When creating new tenants, tenants that use separate billing and quota will require their
|
|
223
|
+
* own project and must be defined as `full_service`.
|
|
115
224
|
*
|
|
116
|
-
* @param tenantOptions The properties to set on the new tenant to be created.
|
|
117
|
-
*
|
|
225
|
+
* @param tenantOptions - The properties to set on the new tenant configuration to be created.
|
|
226
|
+
*
|
|
227
|
+
* @returns A promise fulfilled with the tenant configuration corresponding to the newly
|
|
228
|
+
* created tenant.
|
|
118
229
|
*/
|
|
119
230
|
TenantManager.prototype.createTenant = function (tenantOptions) {
|
|
120
231
|
return this.authRequestHandler.createTenant(tenantOptions)
|
|
@@ -123,11 +234,12 @@ var TenantManager = /** @class */ (function () {
|
|
|
123
234
|
});
|
|
124
235
|
};
|
|
125
236
|
/**
|
|
126
|
-
* Updates an existing tenant
|
|
237
|
+
* Updates an existing tenant configuration.
|
|
238
|
+
*
|
|
239
|
+
* @param tenantId - The `tenantId` corresponding to the tenant to delete.
|
|
240
|
+
* @param tenantOptions - The properties to update on the provided tenant.
|
|
127
241
|
*
|
|
128
|
-
* @
|
|
129
|
-
* @param tenantOptions The properties to update on the existing tenant.
|
|
130
|
-
* @return A promise that resolves with the modified tenant.
|
|
242
|
+
* @returns A promise fulfilled with the update tenant data.
|
|
131
243
|
*/
|
|
132
244
|
TenantManager.prototype.updateTenant = function (tenantId, tenantOptions) {
|
|
133
245
|
return this.authRequestHandler.updateTenant(tenantId, tenantOptions)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*! firebase-admin v10.0.1 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2019 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { EmailSignInConfigServerRequest, MultiFactorAuthServerConfig, MultiFactorConfig, EmailSignInProviderConfig } from './auth-config';
|
|
18
|
+
/**
|
|
19
|
+
* Interface representing the properties to update on the provided tenant.
|
|
20
|
+
*/
|
|
21
|
+
export interface UpdateTenantRequest {
|
|
22
|
+
/**
|
|
23
|
+
* The tenant display name.
|
|
24
|
+
*/
|
|
25
|
+
displayName?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The email sign in configuration.
|
|
28
|
+
*/
|
|
29
|
+
emailSignInConfig?: EmailSignInProviderConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the anonymous provider is enabled.
|
|
32
|
+
*/
|
|
33
|
+
anonymousSignInEnabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The multi-factor auth configuration to update on the tenant.
|
|
36
|
+
*/
|
|
37
|
+
multiFactorConfig?: MultiFactorConfig;
|
|
38
|
+
/**
|
|
39
|
+
* The updated map containing the test phone number / code pairs for the tenant.
|
|
40
|
+
* Passing null clears the previously save phone number / code pairs.
|
|
41
|
+
*/
|
|
42
|
+
testPhoneNumbers?: {
|
|
43
|
+
[phoneNumber: string]: string;
|
|
44
|
+
} | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Interface representing the properties to set on a new tenant.
|
|
48
|
+
*/
|
|
49
|
+
export declare type CreateTenantRequest = UpdateTenantRequest;
|
|
50
|
+
/** The corresponding server side representation of a TenantOptions object. */
|
|
51
|
+
export interface TenantOptionsServerRequest extends EmailSignInConfigServerRequest {
|
|
52
|
+
displayName?: string;
|
|
53
|
+
enableAnonymousUser?: boolean;
|
|
54
|
+
mfaConfig?: MultiFactorAuthServerConfig;
|
|
55
|
+
testPhoneNumbers?: {
|
|
56
|
+
[key: string]: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** The tenant server response interface. */
|
|
60
|
+
export interface TenantServerResponse {
|
|
61
|
+
name: string;
|
|
62
|
+
displayName?: string;
|
|
63
|
+
allowPasswordSignup?: boolean;
|
|
64
|
+
enableEmailLinkSignin?: boolean;
|
|
65
|
+
enableAnonymousUser?: boolean;
|
|
66
|
+
mfaConfig?: MultiFactorAuthServerConfig;
|
|
67
|
+
testPhoneNumbers?: {
|
|
68
|
+
[key: string]: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Represents a tenant configuration.
|
|
73
|
+
*
|
|
74
|
+
* Multi-tenancy support requires Google Cloud's Identity Platform
|
|
75
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
76
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
77
|
+
*
|
|
78
|
+
* Before multi-tenancy can be used on a Google Cloud Identity Platform project,
|
|
79
|
+
* tenants must be allowed on that project via the Cloud Console UI.
|
|
80
|
+
*
|
|
81
|
+
* A tenant configuration provides information such as the display name, tenant
|
|
82
|
+
* identifier and email authentication configuration.
|
|
83
|
+
* For OIDC/SAML provider configuration management, `TenantAwareAuth` instances should
|
|
84
|
+
* be used instead of a `Tenant` to retrieve the list of configured IdPs on a tenant.
|
|
85
|
+
* When configuring these providers, note that tenants will inherit
|
|
86
|
+
* whitelisted domains and authenticated redirect URIs of their parent project.
|
|
87
|
+
*
|
|
88
|
+
* All other settings of a tenant will also be inherited. These will need to be managed
|
|
89
|
+
* from the Cloud Console UI.
|
|
90
|
+
*/
|
|
91
|
+
export declare class Tenant {
|
|
92
|
+
/**
|
|
93
|
+
* The tenant identifier.
|
|
94
|
+
*/
|
|
95
|
+
readonly tenantId: string;
|
|
96
|
+
/**
|
|
97
|
+
* The tenant display name.
|
|
98
|
+
*/
|
|
99
|
+
readonly displayName?: string;
|
|
100
|
+
readonly anonymousSignInEnabled: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* The map containing the test phone number / code pairs for the tenant.
|
|
103
|
+
*/
|
|
104
|
+
readonly testPhoneNumbers?: {
|
|
105
|
+
[phoneNumber: string]: string;
|
|
106
|
+
};
|
|
107
|
+
private readonly emailSignInConfig_?;
|
|
108
|
+
private readonly multiFactorConfig_?;
|
|
109
|
+
/**
|
|
110
|
+
* Validates a tenant options object. Throws an error on failure.
|
|
111
|
+
*
|
|
112
|
+
* @param request - The tenant options object to validate.
|
|
113
|
+
* @param createRequest - Whether this is a create request.
|
|
114
|
+
*/
|
|
115
|
+
private static validate;
|
|
116
|
+
/**
|
|
117
|
+
* The email sign in provider configuration.
|
|
118
|
+
*/
|
|
119
|
+
get emailSignInConfig(): EmailSignInProviderConfig | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* The multi-factor auth configuration on the current tenant.
|
|
122
|
+
*/
|
|
123
|
+
get multiFactorConfig(): MultiFactorConfig | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Returns a JSON-serializable representation of this object.
|
|
126
|
+
*
|
|
127
|
+
* @returns A JSON-serializable representation of this object.
|
|
128
|
+
*/
|
|
129
|
+
toJSON(): object;
|
|
130
|
+
}
|