firebase-admin 10.1.0 → 11.0.0
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 +1 -1
- package/lib/app/core.d.ts +1 -1
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +8 -8
- package/lib/app/credential-internal.d.ts +3 -1
- package/lib/app/credential-internal.js +103 -95
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +76 -91
- package/lib/app/firebase-namespace.d.ts +1 -1
- package/lib/app/firebase-namespace.js +209 -279
- package/lib/app/index.d.ts +1 -1
- package/lib/app/index.js +4 -4
- package/lib/app/lifecycle.d.ts +1 -1
- package/lib/app/lifecycle.js +37 -43
- package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
- package/lib/app-check/app-check-api-client-internal.js +54 -73
- package/lib/app-check/app-check-api.d.ts +1 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check-namespace.d.ts +1 -1
- package/lib/app-check/app-check-namespace.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +17 -19
- package/lib/app-check/index.d.ts +1 -1
- package/lib/app-check/index.js +7 -7
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +47 -52
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +46 -50
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +10 -11
- package/lib/auth/auth-api-request.d.ts +1 -1
- package/lib/auth/auth-api-request.js +355 -382
- package/lib/auth/auth-config.d.ts +1 -1
- package/lib/auth/auth-config.js +95 -106
- package/lib/auth/auth-namespace.d.ts +1 -1
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +20 -40
- package/lib/auth/base-auth.d.ts +26 -1
- package/lib/auth/base-auth.js +162 -142
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +2 -2
- package/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +7 -7
- package/lib/auth/tenant-manager.d.ts +1 -1
- package/lib/auth/tenant-manager.js +49 -71
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +44 -55
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +49 -53
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +83 -91
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +70 -73
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +61 -84
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +2 -2
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +92 -108
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +10 -10
- package/lib/default-namespace.d.ts +1 -1
- package/lib/default-namespace.js +2 -2
- package/lib/esm/eventarc/index.js +5 -0
- package/lib/esm/functions/index.js +5 -0
- package/lib/eventarc/cloudevent.d.ts +84 -0
- package/lib/eventarc/cloudevent.js +19 -0
- package/lib/eventarc/eventarc-client-internal.d.ts +18 -0
- package/lib/eventarc/eventarc-client-internal.js +139 -0
- package/lib/eventarc/eventarc-utils.d.ts +31 -0
- package/lib/eventarc/eventarc-utils.js +125 -0
- package/lib/eventarc/eventarc.d.ts +107 -0
- package/lib/eventarc/eventarc.js +125 -0
- package/lib/eventarc/index.d.ts +53 -0
- package/lib/eventarc/index.js +64 -0
- package/lib/firebase-namespace-api.d.ts +1 -1
- package/lib/firebase-namespace-api.js +8 -3
- package/lib/firestore/firestore-internal.d.ts +1 -1
- package/lib/firestore/firestore-internal.js +28 -37
- package/lib/firestore/firestore-namespace.d.ts +9 -1
- package/lib/firestore/firestore-namespace.js +2 -2
- package/lib/firestore/index.d.ts +2 -2
- package/lib/firestore/index.js +7 -7
- package/lib/functions/functions-api-client-internal.d.ts +32 -0
- package/lib/functions/functions-api-client-internal.js +257 -0
- package/lib/functions/functions-api.d.ts +67 -0
- package/lib/functions/functions-api.js +19 -0
- package/lib/functions/functions.d.ts +63 -0
- package/lib/functions/functions.js +97 -0
- package/lib/functions/index.d.ts +53 -0
- package/lib/functions/index.js +64 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +14 -4
- package/lib/installations/index.d.ts +1 -1
- package/lib/installations/index.js +6 -6
- package/lib/installations/installations-namespace.d.ts +1 -1
- package/lib/installations/installations-namespace.js +1 -1
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +33 -36
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +17 -22
- package/lib/instance-id/index.d.ts +1 -1
- package/lib/instance-id/index.js +6 -6
- package/lib/instance-id/instance-id-namespace.d.ts +1 -1
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +1 -1
- package/lib/instance-id/instance-id.js +21 -26
- package/lib/machine-learning/index.d.ts +1 -1
- package/lib/machine-learning/index.js +7 -7
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +110 -124
- package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
- 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 +9 -24
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +146 -207
- package/lib/messaging/batch-request-internal.d.ts +1 -1
- package/lib/messaging/batch-request-internal.js +33 -35
- package/lib/messaging/index.d.ts +1 -1
- package/lib/messaging/index.js +7 -7
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +38 -40
- package/lib/messaging/messaging-api.d.ts +1 -1
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +1 -1
- package/lib/messaging/messaging-errors-internal.js +12 -13
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +51 -51
- package/lib/messaging/messaging-namespace.d.ts +1 -1
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +184 -208
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +41 -43
- 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 +1 -1
- package/lib/project-management/index.js +7 -7
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +25 -26
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +84 -89
- package/lib/project-management/project-management-namespace.d.ts +1 -1
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +80 -87
- package/lib/remote-config/index.d.ts +1 -1
- package/lib/remote-config/index.js +7 -7
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +116 -154
- package/lib/remote-config/remote-config-api.d.ts +1 -1
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +1 -1
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +1 -1
- package/lib/remote-config/remote-config.js +51 -59
- package/lib/security-rules/index.d.ts +1 -1
- package/lib/security-rules/index.js +7 -7
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +95 -107
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +6 -21
- package/lib/security-rules/security-rules-namespace.d.ts +1 -1
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +82 -91
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +7 -7
- package/lib/storage/storage-namespace.d.ts +1 -1
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +25 -30
- package/lib/utils/api-request.d.ts +3 -1
- package/lib/utils/api-request.js +278 -356
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +58 -93
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +3 -3
- package/lib/utils/error.d.ts +5 -1
- package/lib/utils/error.js +613 -677
- package/lib/utils/index.d.ts +43 -1
- package/lib/utils/index.js +99 -34
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +97 -123
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +13 -13
- package/package.json +43 -11
package/lib/auth/user-record.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v11.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -16,29 +16,16 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
var __extends = (this && this.__extends) || (function () {
|
|
20
|
-
var extendStatics = function (d, b) {
|
|
21
|
-
extendStatics = Object.setPrototypeOf ||
|
|
22
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
23
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
24
|
-
return extendStatics(d, b);
|
|
25
|
-
};
|
|
26
|
-
return function (d, b) {
|
|
27
|
-
extendStatics(d, b);
|
|
28
|
-
function __() { this.constructor = d; }
|
|
29
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
-
};
|
|
31
|
-
})();
|
|
32
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
20
|
exports.UserRecord = exports.UserInfo = exports.UserMetadata = exports.MultiFactorSettings = exports.PhoneMultiFactorInfo = exports.MultiFactorInfo = void 0;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
const deep_copy_1 = require("../utils/deep-copy");
|
|
22
|
+
const validator_1 = require("../utils/validator");
|
|
23
|
+
const utils = require("../utils");
|
|
24
|
+
const error_1 = require("../utils/error");
|
|
38
25
|
/**
|
|
39
26
|
* 'REDACTED', encoded as a base64 string.
|
|
40
27
|
*/
|
|
41
|
-
|
|
28
|
+
const B64_REDACTED = Buffer.from('REDACTED').toString('base64');
|
|
42
29
|
/**
|
|
43
30
|
* Parses a time stamp string or number and returns the corresponding date if valid.
|
|
44
31
|
*
|
|
@@ -47,7 +34,7 @@ var B64_REDACTED = Buffer.from('REDACTED').toString('base64');
|
|
|
47
34
|
*/
|
|
48
35
|
function parseDate(time) {
|
|
49
36
|
try {
|
|
50
|
-
|
|
37
|
+
const date = new Date(parseInt(time, 10));
|
|
51
38
|
if (!isNaN(date.getTime())) {
|
|
52
39
|
return date.toUTCString();
|
|
53
40
|
}
|
|
@@ -64,7 +51,7 @@ var MultiFactorId;
|
|
|
64
51
|
/**
|
|
65
52
|
* Interface representing the common properties of a user-enrolled second factor.
|
|
66
53
|
*/
|
|
67
|
-
|
|
54
|
+
class MultiFactorInfo {
|
|
68
55
|
/**
|
|
69
56
|
* Initializes the MultiFactorInfo object using the server side response.
|
|
70
57
|
*
|
|
@@ -72,7 +59,7 @@ var MultiFactorInfo = /** @class */ (function () {
|
|
|
72
59
|
* @constructor
|
|
73
60
|
* @internal
|
|
74
61
|
*/
|
|
75
|
-
|
|
62
|
+
constructor(response) {
|
|
76
63
|
this.initFromServerResponse(response);
|
|
77
64
|
}
|
|
78
65
|
/**
|
|
@@ -82,8 +69,8 @@ var MultiFactorInfo = /** @class */ (function () {
|
|
|
82
69
|
* @param response - The server side response.
|
|
83
70
|
* @internal
|
|
84
71
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
static initMultiFactorInfo(response) {
|
|
73
|
+
let multiFactorInfo = null;
|
|
87
74
|
// Only PhoneMultiFactorInfo currently available.
|
|
88
75
|
try {
|
|
89
76
|
multiFactorInfo = new PhoneMultiFactorInfo(response);
|
|
@@ -92,27 +79,27 @@ var MultiFactorInfo = /** @class */ (function () {
|
|
|
92
79
|
// Ignore error.
|
|
93
80
|
}
|
|
94
81
|
return multiFactorInfo;
|
|
95
|
-
}
|
|
82
|
+
}
|
|
96
83
|
/**
|
|
97
84
|
* Returns a JSON-serializable representation of this object.
|
|
98
85
|
*
|
|
99
86
|
* @returns A JSON-serializable representation of this object.
|
|
100
87
|
*/
|
|
101
|
-
|
|
88
|
+
toJSON() {
|
|
102
89
|
return {
|
|
103
90
|
uid: this.uid,
|
|
104
91
|
displayName: this.displayName,
|
|
105
92
|
factorId: this.factorId,
|
|
106
93
|
enrollmentTime: this.enrollmentTime,
|
|
107
94
|
};
|
|
108
|
-
}
|
|
95
|
+
}
|
|
109
96
|
/**
|
|
110
97
|
* Initializes the MultiFactorInfo object using the provided server response.
|
|
111
98
|
*
|
|
112
99
|
* @param response - The server side response.
|
|
113
100
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
initFromServerResponse(response) {
|
|
102
|
+
const factorId = response && this.getFactorId(response);
|
|
116
103
|
if (!factorId || !response || !response.mfaEnrollmentId) {
|
|
117
104
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid multi-factor info response');
|
|
118
105
|
}
|
|
@@ -129,15 +116,13 @@ var MultiFactorInfo = /** @class */ (function () {
|
|
|
129
116
|
else {
|
|
130
117
|
utils.addReadonlyGetter(this, 'enrollmentTime', null);
|
|
131
118
|
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
}());
|
|
119
|
+
}
|
|
120
|
+
}
|
|
135
121
|
exports.MultiFactorInfo = MultiFactorInfo;
|
|
136
122
|
/**
|
|
137
123
|
* Interface representing a phone specific user-enrolled second factor.
|
|
138
124
|
*/
|
|
139
|
-
|
|
140
|
-
__extends(PhoneMultiFactorInfo, _super);
|
|
125
|
+
class PhoneMultiFactorInfo extends MultiFactorInfo {
|
|
141
126
|
/**
|
|
142
127
|
* Initializes the PhoneMultiFactorInfo object using the server side response.
|
|
143
128
|
*
|
|
@@ -145,19 +130,18 @@ var PhoneMultiFactorInfo = /** @class */ (function (_super) {
|
|
|
145
130
|
* @constructor
|
|
146
131
|
* @internal
|
|
147
132
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
utils.addReadonlyGetter(
|
|
151
|
-
return _this;
|
|
133
|
+
constructor(response) {
|
|
134
|
+
super(response);
|
|
135
|
+
utils.addReadonlyGetter(this, 'phoneNumber', response.phoneInfo);
|
|
152
136
|
}
|
|
153
137
|
/**
|
|
154
138
|
* {@inheritdoc MultiFactorInfo.toJSON}
|
|
155
139
|
*/
|
|
156
|
-
|
|
157
|
-
return Object.assign(
|
|
140
|
+
toJSON() {
|
|
141
|
+
return Object.assign(super.toJSON(), {
|
|
158
142
|
phoneNumber: this.phoneNumber,
|
|
159
143
|
});
|
|
160
|
-
}
|
|
144
|
+
}
|
|
161
145
|
/**
|
|
162
146
|
* Returns the factor ID based on the response provided.
|
|
163
147
|
*
|
|
@@ -167,16 +151,15 @@ var PhoneMultiFactorInfo = /** @class */ (function (_super) {
|
|
|
167
151
|
*
|
|
168
152
|
* @internal
|
|
169
153
|
*/
|
|
170
|
-
|
|
154
|
+
getFactorId(response) {
|
|
171
155
|
return (response && response.phoneInfo) ? MultiFactorId.Phone : null;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
}(MultiFactorInfo));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
175
158
|
exports.PhoneMultiFactorInfo = PhoneMultiFactorInfo;
|
|
176
159
|
/**
|
|
177
160
|
* The multi-factor related user settings.
|
|
178
161
|
*/
|
|
179
|
-
|
|
162
|
+
class MultiFactorSettings {
|
|
180
163
|
/**
|
|
181
164
|
* Initializes the MultiFactor object using the server side or JWT format response.
|
|
182
165
|
*
|
|
@@ -184,14 +167,14 @@ var MultiFactorSettings = /** @class */ (function () {
|
|
|
184
167
|
* @constructor
|
|
185
168
|
* @internal
|
|
186
169
|
*/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (!validator_1.isNonNullObject(response)) {
|
|
170
|
+
constructor(response) {
|
|
171
|
+
const parsedEnrolledFactors = [];
|
|
172
|
+
if (!(0, validator_1.isNonNullObject)(response)) {
|
|
190
173
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid multi-factor response');
|
|
191
174
|
}
|
|
192
175
|
else if (response.mfaInfo) {
|
|
193
|
-
response.mfaInfo.forEach(
|
|
194
|
-
|
|
176
|
+
response.mfaInfo.forEach((factorResponse) => {
|
|
177
|
+
const multiFactorInfo = MultiFactorInfo.initMultiFactorInfo(factorResponse);
|
|
195
178
|
if (multiFactorInfo) {
|
|
196
179
|
parsedEnrolledFactors.push(multiFactorInfo);
|
|
197
180
|
}
|
|
@@ -205,32 +188,31 @@ var MultiFactorSettings = /** @class */ (function () {
|
|
|
205
188
|
*
|
|
206
189
|
* @returns A JSON-serializable representation of this multi-factor object.
|
|
207
190
|
*/
|
|
208
|
-
|
|
191
|
+
toJSON() {
|
|
209
192
|
return {
|
|
210
|
-
enrolledFactors: this.enrolledFactors.map(
|
|
193
|
+
enrolledFactors: this.enrolledFactors.map((info) => info.toJSON()),
|
|
211
194
|
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
}());
|
|
195
|
+
}
|
|
196
|
+
}
|
|
215
197
|
exports.MultiFactorSettings = MultiFactorSettings;
|
|
216
198
|
/**
|
|
217
199
|
* Represents a user's metadata.
|
|
218
200
|
*/
|
|
219
|
-
|
|
201
|
+
class UserMetadata {
|
|
220
202
|
/**
|
|
221
203
|
* @param response - The server side response returned from the getAccountInfo
|
|
222
204
|
* endpoint.
|
|
223
205
|
* @constructor
|
|
224
206
|
* @internal
|
|
225
207
|
*/
|
|
226
|
-
|
|
208
|
+
constructor(response) {
|
|
227
209
|
// Creation date should always be available but due to some backend bugs there
|
|
228
210
|
// were cases in the past where users did not have creation date properly set.
|
|
229
211
|
// This included legacy Firebase migrating project users and some anonymous users.
|
|
230
212
|
// These bugs have already been addressed since then.
|
|
231
213
|
utils.addReadonlyGetter(this, 'creationTime', parseDate(response.createdAt));
|
|
232
214
|
utils.addReadonlyGetter(this, 'lastSignInTime', parseDate(response.lastLoginAt));
|
|
233
|
-
|
|
215
|
+
const lastRefreshAt = response.lastRefreshAt ? new Date(response.lastRefreshAt).toUTCString() : null;
|
|
234
216
|
utils.addReadonlyGetter(this, 'lastRefreshTime', lastRefreshAt);
|
|
235
217
|
}
|
|
236
218
|
/**
|
|
@@ -238,27 +220,26 @@ var UserMetadata = /** @class */ (function () {
|
|
|
238
220
|
*
|
|
239
221
|
* @returns A JSON-serializable representation of this object.
|
|
240
222
|
*/
|
|
241
|
-
|
|
223
|
+
toJSON() {
|
|
242
224
|
return {
|
|
243
225
|
lastSignInTime: this.lastSignInTime,
|
|
244
226
|
creationTime: this.creationTime,
|
|
245
227
|
};
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
}());
|
|
228
|
+
}
|
|
229
|
+
}
|
|
249
230
|
exports.UserMetadata = UserMetadata;
|
|
250
231
|
/**
|
|
251
232
|
* Represents a user's info from a third-party identity provider
|
|
252
233
|
* such as Google or Facebook.
|
|
253
234
|
*/
|
|
254
|
-
|
|
235
|
+
class UserInfo {
|
|
255
236
|
/**
|
|
256
237
|
* @param response - The server side response returned from the `getAccountInfo`
|
|
257
238
|
* endpoint.
|
|
258
239
|
* @constructor
|
|
259
240
|
* @internal
|
|
260
241
|
*/
|
|
261
|
-
|
|
242
|
+
constructor(response) {
|
|
262
243
|
// Provider user id and provider id are required.
|
|
263
244
|
if (!response.rawId || !response.providerId) {
|
|
264
245
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid user info response');
|
|
@@ -275,7 +256,7 @@ var UserInfo = /** @class */ (function () {
|
|
|
275
256
|
*
|
|
276
257
|
* @returns A JSON-serializable representation of this object.
|
|
277
258
|
*/
|
|
278
|
-
|
|
259
|
+
toJSON() {
|
|
279
260
|
return {
|
|
280
261
|
uid: this.uid,
|
|
281
262
|
displayName: this.displayName,
|
|
@@ -284,21 +265,20 @@ var UserInfo = /** @class */ (function () {
|
|
|
284
265
|
providerId: this.providerId,
|
|
285
266
|
phoneNumber: this.phoneNumber,
|
|
286
267
|
};
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
}());
|
|
268
|
+
}
|
|
269
|
+
}
|
|
290
270
|
exports.UserInfo = UserInfo;
|
|
291
271
|
/**
|
|
292
272
|
* Represents a user.
|
|
293
273
|
*/
|
|
294
|
-
|
|
274
|
+
class UserRecord {
|
|
295
275
|
/**
|
|
296
276
|
* @param response - The server side response returned from the getAccountInfo
|
|
297
277
|
* endpoint.
|
|
298
278
|
* @constructor
|
|
299
279
|
* @internal
|
|
300
280
|
*/
|
|
301
|
-
|
|
281
|
+
constructor(response) {
|
|
302
282
|
// The Firebase user id is required.
|
|
303
283
|
if (!response.localId) {
|
|
304
284
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid user response');
|
|
@@ -312,9 +292,8 @@ var UserRecord = /** @class */ (function () {
|
|
|
312
292
|
// If disabled is not provided, the account is enabled by default.
|
|
313
293
|
utils.addReadonlyGetter(this, 'disabled', response.disabled || false);
|
|
314
294
|
utils.addReadonlyGetter(this, 'metadata', new UserMetadata(response));
|
|
315
|
-
|
|
316
|
-
for (
|
|
317
|
-
var entry = _a[_i];
|
|
295
|
+
const providerData = [];
|
|
296
|
+
for (const entry of (response.providerUserInfo || [])) {
|
|
318
297
|
providerData.push(new UserInfo(entry));
|
|
319
298
|
}
|
|
320
299
|
utils.addReadonlyGetter(this, 'providerData', providerData);
|
|
@@ -331,14 +310,14 @@ var UserRecord = /** @class */ (function () {
|
|
|
331
310
|
if (response.customAttributes) {
|
|
332
311
|
utils.addReadonlyGetter(this, 'customClaims', JSON.parse(response.customAttributes));
|
|
333
312
|
}
|
|
334
|
-
|
|
313
|
+
let validAfterTime = null;
|
|
335
314
|
// Convert validSince first to UTC milliseconds and then to UTC date string.
|
|
336
315
|
if (typeof response.validSince !== 'undefined') {
|
|
337
316
|
validAfterTime = parseDate(parseInt(response.validSince, 10) * 1000);
|
|
338
317
|
}
|
|
339
318
|
utils.addReadonlyGetter(this, 'tokensValidAfterTime', validAfterTime || undefined);
|
|
340
319
|
utils.addReadonlyGetter(this, 'tenantId', response.tenantId);
|
|
341
|
-
|
|
320
|
+
const multiFactor = new MultiFactorSettings(response);
|
|
342
321
|
if (multiFactor.enrolledFactors.length > 0) {
|
|
343
322
|
utils.addReadonlyGetter(this, 'multiFactor', multiFactor);
|
|
344
323
|
}
|
|
@@ -348,8 +327,8 @@ var UserRecord = /** @class */ (function () {
|
|
|
348
327
|
*
|
|
349
328
|
* @returns A JSON-serializable representation of this object.
|
|
350
329
|
*/
|
|
351
|
-
|
|
352
|
-
|
|
330
|
+
toJSON() {
|
|
331
|
+
const json = {
|
|
353
332
|
uid: this.uid,
|
|
354
333
|
email: this.email,
|
|
355
334
|
emailVerified: this.emailVerified,
|
|
@@ -361,7 +340,7 @@ var UserRecord = /** @class */ (function () {
|
|
|
361
340
|
metadata: this.metadata.toJSON(),
|
|
362
341
|
passwordHash: this.passwordHash,
|
|
363
342
|
passwordSalt: this.passwordSalt,
|
|
364
|
-
customClaims: deep_copy_1.deepCopy(this.customClaims),
|
|
343
|
+
customClaims: (0, deep_copy_1.deepCopy)(this.customClaims),
|
|
365
344
|
tokensValidAfterTime: this.tokensValidAfterTime,
|
|
366
345
|
tenantId: this.tenantId,
|
|
367
346
|
};
|
|
@@ -369,13 +348,11 @@ var UserRecord = /** @class */ (function () {
|
|
|
369
348
|
json.multiFactor = this.multiFactor.toJSON();
|
|
370
349
|
}
|
|
371
350
|
json.providerData = [];
|
|
372
|
-
for (
|
|
373
|
-
var entry = _a[_i];
|
|
351
|
+
for (const entry of this.providerData) {
|
|
374
352
|
// Convert each provider data to json.
|
|
375
353
|
json.providerData.push(entry.toJSON());
|
|
376
354
|
}
|
|
377
355
|
return json;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
}());
|
|
356
|
+
}
|
|
357
|
+
}
|
|
381
358
|
exports.UserRecord = UserRecord;
|
package/lib/credential/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v11.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2020 Google Inc.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.credential = void 0;
|
|
20
|
-
|
|
20
|
+
const index_1 = require("../app/index");
|
|
21
21
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
22
22
|
var credential;
|
|
23
23
|
(function (credential) {
|