firebase-admin 13.10.0 → 14.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 -2
- package/lib/app/core.d.ts +2 -38
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +1 -1
- package/lib/app/credential-internal.d.ts +1 -1
- package/lib/app/credential-internal.js +45 -14
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/error.d.ts +47 -0
- package/lib/app/error.js +57 -0
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +28 -12
- package/lib/app/index.d.ts +4 -3
- package/lib/app/index.js +6 -4
- package/lib/app/lifecycle.d.ts +2 -2
- package/lib/app/lifecycle.js +46 -21
- package/lib/app-check/app-check-api-client-internal.d.ts +2 -16
- package/lib/app-check/app-check-api-client-internal.js +57 -48
- 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.d.ts +1 -1
- package/lib/app-check/app-check.js +6 -2
- package/lib/app-check/error.d.ts +47 -0
- package/lib/app-check/error.js +65 -0
- package/lib/app-check/index.d.ts +2 -1
- package/lib/app-check/index.js +5 -2
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +43 -13
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +39 -11
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +16 -16
- package/lib/auth/auth-api-request.d.ts +6 -4
- package/lib/auth/auth-api-request.js +277 -166
- package/lib/auth/auth-config.d.ts +31 -2
- package/lib/auth/auth-config.js +103 -103
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +1 -1
- package/lib/auth/base-auth.d.ts +2 -1
- package/lib/auth/base-auth.js +29 -27
- package/lib/auth/error.d.ts +137 -0
- package/lib/auth/error.js +690 -0
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +2 -2
- package/lib/auth/index.js +4 -4
- package/lib/auth/project-config-manager.d.ts +1 -1
- package/lib/auth/project-config-manager.js +1 -1
- package/lib/auth/project-config.d.ts +1 -1
- package/lib/auth/project-config.js +4 -4
- package/lib/auth/tenant-manager.d.ts +2 -1
- package/lib/auth/tenant-manager.js +13 -10
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +7 -7
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +13 -13
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +22 -22
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +22 -22
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +6 -6
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +1 -1
- package/lib/data-connect/data-connect-api-client-internal.d.ts +1 -16
- package/lib/data-connect/data-connect-api-client-internal.js +122 -65
- package/lib/data-connect/data-connect-api.d.ts +1 -1
- package/lib/data-connect/data-connect-api.js +1 -1
- package/lib/data-connect/data-connect.d.ts +1 -1
- package/lib/data-connect/data-connect.js +1 -1
- package/lib/data-connect/error.d.ts +47 -0
- package/lib/data-connect/error.js +66 -0
- package/lib/data-connect/index.d.ts +2 -1
- package/lib/data-connect/index.js +5 -2
- package/lib/data-connect/validate-admin-args.d.ts +1 -1
- package/lib/data-connect/validate-admin-args.js +6 -3
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +11 -6
- package/lib/database/error.d.ts +39 -0
- package/lib/database/error.js +49 -0
- package/lib/database/index.d.ts +2 -2
- package/lib/database/index.js +4 -3
- package/lib/esm/app/index.js +2 -1
- package/lib/esm/app-check/index.js +2 -0
- package/lib/esm/auth/index.js +1 -1
- package/lib/esm/data-connect/index.js +2 -0
- package/lib/esm/database/index.js +1 -0
- package/lib/esm/eventarc/index.js +2 -0
- package/lib/esm/extensions/index.js +2 -0
- package/lib/esm/firebase-admin/index.js +13 -0
- package/lib/esm/firestore/index.js +1 -0
- package/lib/esm/functions/index.js +2 -0
- package/lib/esm/installations/index.js +1 -1
- package/lib/esm/machine-learning/index.js +2 -0
- package/lib/esm/messaging/index.js +1 -1
- package/lib/esm/phone-number-verification/index.js +2 -0
- package/lib/esm/project-management/index.js +1 -0
- package/lib/esm/remote-config/index.js +2 -0
- package/lib/esm/security-rules/index.js +2 -0
- package/lib/esm/storage/index.js +2 -0
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/error.d.ts +38 -0
- package/lib/eventarc/error.js +47 -0
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +24 -9
- package/lib/eventarc/eventarc-utils.d.ts +1 -13
- package/lib/eventarc/eventarc-utils.js +34 -24
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +18 -6
- package/lib/eventarc/index.d.ts +2 -1
- package/lib/eventarc/index.js +5 -2
- package/lib/extensions/error.d.ts +41 -0
- package/lib/extensions/error.js +50 -0
- package/lib/extensions/extensions-api-client-internal.d.ts +1 -13
- package/lib/extensions/extensions-api-client-internal.js +40 -28
- package/lib/extensions/extensions-api.d.ts +1 -1
- package/lib/extensions/extensions-api.js +1 -1
- package/lib/extensions/extensions.d.ts +1 -1
- package/lib/extensions/extensions.js +18 -5
- package/lib/extensions/index.d.ts +2 -1
- package/lib/extensions/index.js +5 -2
- package/lib/firestore/error.d.ts +41 -0
- package/lib/firestore/error.js +51 -0
- package/lib/firestore/firestore-internal.d.ts +2 -1
- package/lib/firestore/firestore-internal.js +6 -6
- package/lib/firestore/index.d.ts +2 -2
- package/lib/firestore/index.js +7 -7
- package/lib/functions/error.d.ts +48 -0
- package/lib/functions/error.js +67 -0
- package/lib/functions/functions-api-client-internal.d.ts +1 -16
- package/lib/functions/functions-api-client-internal.js +111 -71
- package/lib/functions/functions-api.d.ts +1 -1
- package/lib/functions/functions-api.js +1 -1
- package/lib/functions/functions.d.ts +1 -1
- package/lib/functions/functions.js +14 -4
- package/lib/functions/index.d.ts +2 -1
- package/lib/functions/index.js +5 -2
- package/lib/index.d.ts +13 -8
- package/lib/index.js +19 -3
- package/lib/installations/error.d.ts +48 -0
- package/lib/installations/error.js +73 -0
- package/lib/installations/index.d.ts +2 -2
- package/lib/installations/index.js +4 -4
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +11 -5
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +3 -3
- package/lib/machine-learning/error.d.ts +53 -0
- package/lib/machine-learning/error.js +84 -0
- package/lib/machine-learning/index.d.ts +2 -1
- package/lib/machine-learning/index.js +5 -2
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +61 -24
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +21 -9
- package/lib/messaging/error.d.ts +63 -0
- package/lib/messaging/error.js +286 -0
- package/lib/messaging/index.d.ts +3 -3
- package/lib/messaging/index.js +4 -4
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +1 -1
- package/lib/messaging/messaging-api.d.ts +1 -280
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +2 -2
- package/lib/messaging/messaging-errors-internal.js +11 -8
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +48 -48
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +47 -50
- package/lib/phone-number-verification/error.d.ts +43 -0
- package/lib/phone-number-verification/error.js +48 -0
- package/lib/phone-number-verification/index.d.ts +2 -1
- package/lib/phone-number-verification/index.js +5 -2
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.d.ts +1 -18
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.js +2 -26
- package/lib/phone-number-verification/phone-number-verification-api.d.ts +2 -2
- package/lib/phone-number-verification/phone-number-verification-api.js +5 -4
- package/lib/phone-number-verification/phone-number-verification.d.ts +1 -1
- package/lib/phone-number-verification/phone-number-verification.js +1 -1
- package/lib/phone-number-verification/token-verifier.d.ts +1 -1
- package/lib/phone-number-verification/token-verifier.js +68 -20
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +15 -6
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/error.d.ts +45 -0
- package/lib/project-management/error.js +55 -0
- package/lib/project-management/index.d.ts +2 -2
- package/lib/project-management/index.js +4 -3
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +6 -3
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +18 -6
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +13 -7
- package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
- package/lib/remote-config/condition-evaluator-internal.js +2 -2
- package/lib/remote-config/error.d.ts +49 -0
- package/lib/remote-config/error.js +70 -0
- package/lib/remote-config/index.d.ts +2 -1
- package/lib/remote-config/index.js +5 -2
- package/lib/remote-config/internal/value-impl.d.ts +1 -1
- package/lib/remote-config/internal/value-impl.js +1 -1
- package/lib/remote-config/remote-config-api-client-internal.d.ts +2 -13
- package/lib/remote-config/remote-config-api-client-internal.js +80 -52
- 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.d.ts +1 -1
- package/lib/remote-config/remote-config.js +92 -23
- package/lib/security-rules/error.d.ts +45 -0
- package/lib/security-rules/error.js +54 -0
- package/lib/security-rules/index.d.ts +2 -1
- package/lib/security-rules/index.js +5 -2
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +50 -18
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +32 -11
- package/lib/storage/error.d.ts +41 -0
- package/lib/storage/error.js +50 -0
- package/lib/storage/index.d.ts +2 -1
- package/lib/storage/index.js +8 -5
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +12 -12
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +1 -1
- package/lib/utils/api-request.d.ts +12 -12
- package/lib/utils/api-request.js +97 -55
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +2 -7
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +1 -1
- package/lib/utils/error.d.ts +75 -570
- package/lib/utils/error.js +53 -1047
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +2 -2
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +1 -2
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +24 -29
- package/lib/app/firebase-namespace.d.ts +0 -163
- package/lib/app/firebase-namespace.js +0 -335
- package/lib/app-check/app-check-namespace.d.ts +0 -72
- package/lib/app-check/app-check-namespace.js +0 -18
- package/lib/auth/auth-namespace.d.ts +0 -257
- package/lib/auth/auth-namespace.js +0 -18
- package/lib/database/database-namespace.d.ts +0 -95
- package/lib/database/database-namespace.js +0 -23
- package/lib/default-namespace.d.ts +0 -24
- package/lib/default-namespace.js +0 -30
- package/lib/esm/instance-id/index.js +0 -6
- package/lib/firebase-namespace-api.d.ts +0 -91
- package/lib/firebase-namespace-api.js +0 -58
- package/lib/firestore/firestore-namespace.d.ts +0 -71
- package/lib/firestore/firestore-namespace.js +0 -52
- package/lib/installations/installations-namespace.d.ts +0 -55
- package/lib/installations/installations-namespace.js +0 -18
- package/lib/instance-id/index.d.ts +0 -62
- package/lib/instance-id/index.js +0 -74
- package/lib/instance-id/instance-id-namespace.d.ts +0 -38
- package/lib/instance-id/instance-id-namespace.js +0 -3
- package/lib/instance-id/instance-id.d.ts +0 -47
- package/lib/instance-id/instance-id.js +0 -77
- package/lib/machine-learning/machine-learning-namespace.d.ts +0 -81
- package/lib/machine-learning/machine-learning-namespace.js +0 -18
- package/lib/machine-learning/machine-learning-utils.d.ts +0 -22
- package/lib/machine-learning/machine-learning-utils.js +0 -47
- package/lib/messaging/messaging-namespace.d.ts +0 -161
- package/lib/messaging/messaging-namespace.js +0 -18
- package/lib/project-management/project-management-namespace.d.ts +0 -82
- package/lib/project-management/project-management-namespace.js +0 -18
- package/lib/remote-config/remote-config-namespace.d.ts +0 -141
- package/lib/remote-config/remote-config-namespace.js +0 -18
- package/lib/security-rules/security-rules-internal.d.ts +0 -21
- package/lib/security-rules/security-rules-internal.js +0 -26
- package/lib/security-rules/security-rules-namespace.d.ts +0 -69
- package/lib/security-rules/security-rules-namespace.js +0 -18
- package/lib/storage/storage-namespace.d.ts +0 -45
- package/lib/storage/storage-namespace.js +0 -18
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
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 { FirebaseError, ErrorInfo } from '../utils/error';
|
|
18
|
+
/**
|
|
19
|
+
* The constant mapping for valid Storage client error codes.
|
|
20
|
+
*/
|
|
21
|
+
export declare const StorageErrorCode: {
|
|
22
|
+
readonly INVALID_ARGUMENT: "invalid-argument";
|
|
23
|
+
readonly INVALID_EMULATOR_HOST: "invalid-emulator-host";
|
|
24
|
+
readonly MISSING_DEPENDENCIES: "missing-dependencies";
|
|
25
|
+
readonly INVALID_CREDENTIAL: "invalid-credential";
|
|
26
|
+
readonly NO_DOWNLOAD_TOKEN: "no-download-token";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The type definition for valid Storage client error codes.
|
|
30
|
+
*/
|
|
31
|
+
export type StorageErrorCode = typeof StorageErrorCode[keyof typeof StorageErrorCode];
|
|
32
|
+
/**
|
|
33
|
+
* Firebase Storage error code structure. This extends `FirebaseError`.
|
|
34
|
+
*/
|
|
35
|
+
export declare class FirebaseStorageError extends FirebaseError {
|
|
36
|
+
/**
|
|
37
|
+
* @param info - The error code info.
|
|
38
|
+
* @param message - The error message. If provided, this will override the default message.
|
|
39
|
+
*/
|
|
40
|
+
constructor(info: ErrorInfo, message?: string);
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2026 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.FirebaseStorageError = exports.StorageErrorCode = void 0;
|
|
20
|
+
const error_1 = require("../utils/error");
|
|
21
|
+
/**
|
|
22
|
+
* The constant mapping for valid Storage client error codes.
|
|
23
|
+
*/
|
|
24
|
+
exports.StorageErrorCode = {
|
|
25
|
+
INVALID_ARGUMENT: 'invalid-argument',
|
|
26
|
+
INVALID_EMULATOR_HOST: 'invalid-emulator-host',
|
|
27
|
+
MISSING_DEPENDENCIES: 'missing-dependencies',
|
|
28
|
+
INVALID_CREDENTIAL: 'invalid-credential',
|
|
29
|
+
NO_DOWNLOAD_TOKEN: 'no-download-token',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Firebase Storage error code structure. This extends `FirebaseError`.
|
|
33
|
+
*/
|
|
34
|
+
class FirebaseStorageError extends error_1.FirebaseError {
|
|
35
|
+
/**
|
|
36
|
+
* @param info - The error code info.
|
|
37
|
+
* @param message - The error message. If provided, this will override the default message.
|
|
38
|
+
*/
|
|
39
|
+
constructor(info, message) {
|
|
40
|
+
super({
|
|
41
|
+
code: `storage/${info.code}`,
|
|
42
|
+
message: message || info.message,
|
|
43
|
+
httpResponse: info.httpResponse,
|
|
44
|
+
cause: info.cause,
|
|
45
|
+
});
|
|
46
|
+
/** @internal */
|
|
47
|
+
this.codePrefix = 'storage';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.FirebaseStorageError = FirebaseStorageError;
|
package/lib/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright 2020 Google LLC
|
|
4
4
|
*
|
|
@@ -55,3 +55,4 @@ export declare function getStorage(app?: App): Storage;
|
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
57
|
export declare function getDownloadURL(file: File): Promise<string>;
|
|
58
|
+
export { FirebaseStorageError, StorageErrorCode, } from './error';
|
package/lib/storage/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2020 Google LLC
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.Storage = void 0;
|
|
19
|
+
exports.StorageErrorCode = exports.FirebaseStorageError = exports.Storage = void 0;
|
|
20
20
|
exports.getStorage = getStorage;
|
|
21
21
|
exports.getDownloadURL = getDownloadURL;
|
|
22
22
|
const app_1 = require("../app");
|
|
23
23
|
const storage_1 = require("./storage");
|
|
24
|
-
const error_1 = require("
|
|
24
|
+
const error_1 = require("./error");
|
|
25
25
|
const utils_1 = require("./utils");
|
|
26
26
|
var storage_2 = require("./storage");
|
|
27
27
|
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return storage_2.Storage; } });
|
|
@@ -67,11 +67,14 @@ async function getDownloadURL(file) {
|
|
|
67
67
|
'https://firebasestorage.googleapis.com') + '/v0';
|
|
68
68
|
const { downloadTokens } = await (0, utils_1.getFirebaseMetadata)(endpoint, file);
|
|
69
69
|
if (!downloadTokens) {
|
|
70
|
-
throw new error_1.
|
|
71
|
-
code: '
|
|
70
|
+
throw new error_1.FirebaseStorageError({
|
|
71
|
+
code: 'no-download-token',
|
|
72
72
|
message: 'No download token available. Please create one in the Firebase Console.',
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
const [token] = downloadTokens.split(',');
|
|
76
76
|
return `${endpoint}/b/${file.bucket.name}/o/${encodeURIComponent(file.name)}?alt=media&token=${token}`;
|
|
77
77
|
}
|
|
78
|
+
var error_2 = require("./error");
|
|
79
|
+
Object.defineProperty(exports, "FirebaseStorageError", { enumerable: true, get: function () { return error_2.FirebaseStorageError; } });
|
|
80
|
+
Object.defineProperty(exports, "StorageErrorCode", { enumerable: true, get: function () { return error_2.StorageErrorCode; } });
|
package/lib/storage/storage.d.ts
CHANGED
package/lib/storage/storage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.Storage = void 0;
|
|
21
|
-
const error_1 = require("
|
|
21
|
+
const error_1 = require("./error");
|
|
22
22
|
const credential_internal_1 = require("../app/credential-internal");
|
|
23
23
|
const utils = require("../utils/index");
|
|
24
24
|
const validator = require("../utils/validator");
|
|
@@ -35,16 +35,16 @@ class Storage {
|
|
|
35
35
|
*/
|
|
36
36
|
constructor(app) {
|
|
37
37
|
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
|
38
|
-
throw new error_1.
|
|
39
|
-
code: '
|
|
38
|
+
throw new error_1.FirebaseStorageError({
|
|
39
|
+
code: 'invalid-argument',
|
|
40
40
|
message: 'First argument passed to admin.storage() must be a valid Firebase app instance.',
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
if (!process.env.STORAGE_EMULATOR_HOST && process.env.FIREBASE_STORAGE_EMULATOR_HOST) {
|
|
44
44
|
const firebaseStorageEmulatorHost = process.env.FIREBASE_STORAGE_EMULATOR_HOST;
|
|
45
45
|
if (firebaseStorageEmulatorHost.match(/https?:\/\//)) {
|
|
46
|
-
throw new error_1.
|
|
47
|
-
code: '
|
|
46
|
+
throw new error_1.FirebaseStorageError({
|
|
47
|
+
code: 'invalid-emulator-host',
|
|
48
48
|
message: 'FIREBASE_STORAGE_EMULATOR_HOST should not contain a protocol (http or https).',
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -55,8 +55,8 @@ class Storage {
|
|
|
55
55
|
storage = require('@google-cloud/storage').Storage;
|
|
56
56
|
}
|
|
57
57
|
catch (err) {
|
|
58
|
-
throw new error_1.
|
|
59
|
-
code: '
|
|
58
|
+
throw new error_1.FirebaseStorageError({
|
|
59
|
+
code: 'missing-dependencies',
|
|
60
60
|
message: 'Failed to import the Cloud Storage client library for Node.js. '
|
|
61
61
|
+ 'Make sure to install the "@google-cloud/storage" npm package. '
|
|
62
62
|
+ `Original error: ${err}`,
|
|
@@ -80,8 +80,8 @@ class Storage {
|
|
|
80
80
|
this.storageClient = new storage();
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
throw new error_1.
|
|
84
|
-
code: '
|
|
83
|
+
throw new error_1.FirebaseStorageError({
|
|
84
|
+
code: 'invalid-credential',
|
|
85
85
|
message: 'Failed to initialize Google Cloud Storage client with the available credential. ' +
|
|
86
86
|
'Must initialize the SDK with a certificate credential or application default credentials ' +
|
|
87
87
|
'to use Cloud Storage API.',
|
|
@@ -103,8 +103,8 @@ class Storage {
|
|
|
103
103
|
if (validator.isNonEmptyString(bucketName)) {
|
|
104
104
|
return this.storageClient.bucket(bucketName);
|
|
105
105
|
}
|
|
106
|
-
throw new error_1.
|
|
107
|
-
code: '
|
|
106
|
+
throw new error_1.FirebaseStorageError({
|
|
107
|
+
code: 'invalid-argument',
|
|
108
108
|
message: 'Bucket name not specified or invalid. Specify a valid bucket name via the ' +
|
|
109
109
|
'storageBucket option when initializing the app, or specify the bucket name ' +
|
|
110
110
|
'explicitly when calling the getBucket() method.',
|
package/lib/storage/utils.d.ts
CHANGED
package/lib/storage/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
@@ -21,8 +21,10 @@ import http2 = require('http2');
|
|
|
21
21
|
import { EventEmitter } from 'events';
|
|
22
22
|
/** Http method type definition. */
|
|
23
23
|
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';
|
|
24
|
-
/** API callback function type definition. */
|
|
25
|
-
export type
|
|
24
|
+
/** API request callback function type definition. */
|
|
25
|
+
export type ApiRequestCallback = (data: any) => void;
|
|
26
|
+
/** API response callback function type definition. */
|
|
27
|
+
export type ApiResponseCallback = (response: RequestResponse) => void;
|
|
26
28
|
/**
|
|
27
29
|
* Base configuration for constructing a new request.
|
|
28
30
|
*/
|
|
@@ -248,16 +250,16 @@ export declare class ApiSettings {
|
|
|
248
250
|
* @param requestValidator - The request validator.
|
|
249
251
|
* @returns The current API settings instance.
|
|
250
252
|
*/
|
|
251
|
-
setRequestValidator(requestValidator:
|
|
253
|
+
setRequestValidator(requestValidator: ApiRequestCallback | null): ApiSettings;
|
|
252
254
|
/** @returns The request validator. */
|
|
253
|
-
getRequestValidator():
|
|
255
|
+
getRequestValidator(): ApiRequestCallback;
|
|
254
256
|
/**
|
|
255
257
|
* @param responseValidator - The response validator.
|
|
256
258
|
* @returns The current API settings instance.
|
|
257
259
|
*/
|
|
258
|
-
setResponseValidator(responseValidator:
|
|
260
|
+
setResponseValidator(responseValidator: ApiResponseCallback | null): ApiSettings;
|
|
259
261
|
/** @returns The response validator. */
|
|
260
|
-
getResponseValidator():
|
|
262
|
+
getResponseValidator(): ApiResponseCallback;
|
|
261
263
|
}
|
|
262
264
|
/**
|
|
263
265
|
* Class used for polling an endpoint with exponential backoff.
|
|
@@ -311,14 +313,12 @@ export declare class ExponentialBackoffPoller<T> extends EventEmitter {
|
|
|
311
313
|
}
|
|
312
314
|
export declare class Http2SessionHandler {
|
|
313
315
|
private http2Session;
|
|
314
|
-
|
|
315
|
-
protected resolve: () => void;
|
|
316
|
-
protected reject: (_: any) => void;
|
|
316
|
+
private sessionErrors;
|
|
317
317
|
constructor(url: string);
|
|
318
318
|
createSession(url: string): http2.ClientHttp2Session;
|
|
319
|
-
|
|
319
|
+
getErrors(): Error[];
|
|
320
320
|
get session(): http2.ClientHttp2Session;
|
|
321
|
-
get
|
|
321
|
+
get isCurrentSessionClosed(): boolean;
|
|
322
322
|
close(): void;
|
|
323
323
|
}
|
|
324
324
|
export {};
|
package/lib/utils/api-request.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -21,11 +21,11 @@ exports.Http2SessionHandler = exports.ExponentialBackoffPoller = exports.ApiSett
|
|
|
21
21
|
exports.defaultRetryConfig = defaultRetryConfig;
|
|
22
22
|
exports.parseHttpResponse = parseHttpResponse;
|
|
23
23
|
const error_1 = require("./error");
|
|
24
|
+
const error_2 = require("../app/error");
|
|
24
25
|
const validator = require("./validator");
|
|
25
26
|
const http = require("http");
|
|
26
27
|
const https = require("https");
|
|
27
28
|
const http2 = require("http2");
|
|
28
|
-
const url = require("url");
|
|
29
29
|
const events_1 = require("events");
|
|
30
30
|
const credential_internal_1 = require("../app/credential-internal");
|
|
31
31
|
const index_1 = require("../utils/index");
|
|
@@ -39,7 +39,7 @@ class DefaultRequestResponse {
|
|
|
39
39
|
this.text = resp.data;
|
|
40
40
|
try {
|
|
41
41
|
if (!resp.data) {
|
|
42
|
-
throw new
|
|
42
|
+
throw new error_2.FirebaseAppError({ code: error_2.AppErrorCode.INTERNAL_ERROR, message: 'HTTP response missing data.' });
|
|
43
43
|
}
|
|
44
44
|
this.parsedData = JSON.parse(resp.data);
|
|
45
45
|
}
|
|
@@ -47,15 +47,17 @@ class DefaultRequestResponse {
|
|
|
47
47
|
this.parsedData = undefined;
|
|
48
48
|
this.parseError = err;
|
|
49
49
|
}
|
|
50
|
-
this.request = `${resp.config.method} ${resp.config.url}`;
|
|
51
50
|
}
|
|
52
51
|
get data() {
|
|
53
52
|
if (this.isJson()) {
|
|
54
53
|
return this.parsedData;
|
|
55
54
|
}
|
|
56
|
-
throw new
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
throw new error_2.FirebaseAppError({
|
|
56
|
+
code: error_2.AppErrorCode.UNABLE_TO_PARSE_RESPONSE,
|
|
57
|
+
message: 'Error while parsing response data',
|
|
58
|
+
cause: this.parseError,
|
|
59
|
+
httpResponse: (0, error_1.toHttpResponse)(this)
|
|
60
|
+
});
|
|
59
61
|
}
|
|
60
62
|
isJson() {
|
|
61
63
|
return typeof this.parsedData !== 'undefined';
|
|
@@ -72,10 +74,16 @@ class MultipartRequestResponse {
|
|
|
72
74
|
this.multipart = resp.multipart;
|
|
73
75
|
}
|
|
74
76
|
get text() {
|
|
75
|
-
throw new
|
|
77
|
+
throw new error_2.FirebaseAppError({
|
|
78
|
+
code: error_2.AppErrorCode.UNABLE_TO_PARSE_RESPONSE,
|
|
79
|
+
message: 'Unable to parse multipart payload as text'
|
|
80
|
+
});
|
|
76
81
|
}
|
|
77
82
|
get data() {
|
|
78
|
-
throw new
|
|
83
|
+
throw new error_2.FirebaseAppError({
|
|
84
|
+
code: error_2.AppErrorCode.UNABLE_TO_PARSE_RESPONSE,
|
|
85
|
+
message: 'Unable to parse multipart payload as JSON'
|
|
86
|
+
});
|
|
79
87
|
}
|
|
80
88
|
isJson() {
|
|
81
89
|
return false;
|
|
@@ -112,21 +120,30 @@ function defaultRetryConfig() {
|
|
|
112
120
|
*/
|
|
113
121
|
function validateRetryConfig(retry) {
|
|
114
122
|
if (!validator.isNumber(retry.maxRetries) || retry.maxRetries < 0) {
|
|
115
|
-
throw new
|
|
123
|
+
throw new error_2.FirebaseAppError({
|
|
124
|
+
code: error_2.AppErrorCode.INVALID_ARGUMENT,
|
|
125
|
+
message: 'maxRetries must be a non-negative integer'
|
|
126
|
+
});
|
|
116
127
|
}
|
|
117
128
|
if (typeof retry.backOffFactor !== 'undefined') {
|
|
118
129
|
if (!validator.isNumber(retry.backOffFactor) || retry.backOffFactor < 0) {
|
|
119
|
-
throw new
|
|
130
|
+
throw new error_2.FirebaseAppError({
|
|
131
|
+
code: error_2.AppErrorCode.INVALID_ARGUMENT,
|
|
132
|
+
message: 'backOffFactor must be a non-negative number'
|
|
133
|
+
});
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
136
|
if (!validator.isNumber(retry.maxDelayInMillis) || retry.maxDelayInMillis < 0) {
|
|
123
|
-
throw new
|
|
137
|
+
throw new error_2.FirebaseAppError({
|
|
138
|
+
code: error_2.AppErrorCode.INVALID_ARGUMENT,
|
|
139
|
+
message: 'maxDelayInMillis must be a non-negative integer'
|
|
140
|
+
});
|
|
124
141
|
}
|
|
125
142
|
if (typeof retry.statusCodes !== 'undefined' && !validator.isArray(retry.statusCodes)) {
|
|
126
|
-
throw new
|
|
143
|
+
throw new error_2.FirebaseAppError({ code: error_2.AppErrorCode.INVALID_ARGUMENT, message: 'statusCodes must be an array' });
|
|
127
144
|
}
|
|
128
145
|
if (typeof retry.ioErrorCodes !== 'undefined' && !validator.isArray(retry.ioErrorCodes)) {
|
|
129
|
-
throw new
|
|
146
|
+
throw new error_2.FirebaseAppError({ code: error_2.AppErrorCode.INVALID_ARGUMENT, message: 'ioErrorCodes must be an array' });
|
|
130
147
|
}
|
|
131
148
|
}
|
|
132
149
|
class RequestClient {
|
|
@@ -209,7 +226,7 @@ class RequestClient {
|
|
|
209
226
|
return 0;
|
|
210
227
|
}
|
|
211
228
|
if (!this.retry) {
|
|
212
|
-
throw new
|
|
229
|
+
throw new error_2.FirebaseAppError({ code: error_2.AppErrorCode.INTERNAL_ERROR, message: 'Expected this.retry to exist.' });
|
|
213
230
|
}
|
|
214
231
|
const backOffFactor = this.retry.backOffFactor || 0;
|
|
215
232
|
const delayInSeconds = (2 ** retryAttempts) * backOffFactor;
|
|
@@ -263,9 +280,17 @@ class HttpClient extends RequestClient {
|
|
|
263
280
|
throw new RequestResponseError(this.createRequestResponse(err.response));
|
|
264
281
|
}
|
|
265
282
|
if (err.code === 'ETIMEDOUT') {
|
|
266
|
-
throw new
|
|
283
|
+
throw new error_2.FirebaseAppError({
|
|
284
|
+
code: error_2.AppErrorCode.NETWORK_TIMEOUT,
|
|
285
|
+
message: `Error while making request: ${err.message}.`,
|
|
286
|
+
cause: err
|
|
287
|
+
});
|
|
267
288
|
}
|
|
268
|
-
throw new
|
|
289
|
+
throw new error_2.FirebaseAppError({
|
|
290
|
+
code: error_2.AppErrorCode.NETWORK_ERROR,
|
|
291
|
+
message: `Error while making request: ${err.message}. Error code: ${err.code}`,
|
|
292
|
+
cause: err
|
|
293
|
+
});
|
|
269
294
|
});
|
|
270
295
|
}
|
|
271
296
|
}
|
|
@@ -316,9 +341,17 @@ class Http2Client extends RequestClient {
|
|
|
316
341
|
throw new RequestResponseError(this.createRequestResponse(err.response));
|
|
317
342
|
}
|
|
318
343
|
if (err.code === 'ETIMEDOUT') {
|
|
319
|
-
throw new
|
|
344
|
+
throw new error_2.FirebaseAppError({
|
|
345
|
+
code: error_2.AppErrorCode.NETWORK_TIMEOUT,
|
|
346
|
+
message: `Error while making request: ${err.message}.`,
|
|
347
|
+
cause: err
|
|
348
|
+
});
|
|
320
349
|
}
|
|
321
|
-
throw new
|
|
350
|
+
throw new error_2.FirebaseAppError({
|
|
351
|
+
code: error_2.AppErrorCode.NETWORK_ERROR,
|
|
352
|
+
message: `Error while making request: ${err.message}. Error code: ${err.code}`,
|
|
353
|
+
cause: err
|
|
354
|
+
});
|
|
322
355
|
});
|
|
323
356
|
}
|
|
324
357
|
}
|
|
@@ -359,7 +392,7 @@ function parseHttpResponse(response, config) {
|
|
|
359
392
|
request: null,
|
|
360
393
|
};
|
|
361
394
|
if (!validator.isNumber(lowLevelResponse.status)) {
|
|
362
|
-
throw new
|
|
395
|
+
throw new error_2.FirebaseAppError({ code: error_2.AppErrorCode.INTERNAL_ERROR, message: 'Malformed HTTP status line.' });
|
|
363
396
|
}
|
|
364
397
|
return new DefaultRequestResponse(lowLevelResponse);
|
|
365
398
|
}
|
|
@@ -399,7 +432,7 @@ class AsyncRequestCall {
|
|
|
399
432
|
return headerParams.boundary;
|
|
400
433
|
}
|
|
401
434
|
handleMultipartResponse(response, respStream, boundary) {
|
|
402
|
-
const busboy = require('@fastify/busboy');
|
|
435
|
+
const busboy = require('@fastify/busboy');
|
|
403
436
|
const multipartParser = new busboy.Dicer({ boundary });
|
|
404
437
|
const responseBuffer = [];
|
|
405
438
|
multipartParser.on('part', (part) => {
|
|
@@ -533,7 +566,10 @@ class AsyncHttpCall extends AsyncRequestCall {
|
|
|
533
566
|
return;
|
|
534
567
|
}
|
|
535
568
|
if (!res.statusCode) {
|
|
536
|
-
throw new
|
|
569
|
+
throw new error_2.FirebaseAppError({
|
|
570
|
+
code: error_2.AppErrorCode.INTERNAL_ERROR,
|
|
571
|
+
message: 'Expected a statusCode on the response from a ClientRequest'
|
|
572
|
+
});
|
|
537
573
|
}
|
|
538
574
|
const response = {
|
|
539
575
|
status: res.statusCode,
|
|
@@ -557,7 +593,7 @@ class AsyncHttpCall extends AsyncRequestCall {
|
|
|
557
593
|
const encodings = ['gzip', 'compress', 'deflate'];
|
|
558
594
|
if (res.headers['content-encoding'] && encodings.indexOf(res.headers['content-encoding']) !== -1) {
|
|
559
595
|
// Add the unzipper to the body stream processing pipeline.
|
|
560
|
-
const zlib = require('zlib');
|
|
596
|
+
const zlib = require('zlib');
|
|
561
597
|
respStream = respStream.pipe(zlib.createUnzip());
|
|
562
598
|
// Remove the content-encoding in order to not confuse downstream operations.
|
|
563
599
|
delete res.headers['content-encoding'];
|
|
@@ -625,7 +661,10 @@ class AsyncHttp2Call extends AsyncRequestCall {
|
|
|
625
661
|
return;
|
|
626
662
|
}
|
|
627
663
|
if (!headers[':status']) {
|
|
628
|
-
throw new
|
|
664
|
+
throw new error_2.FirebaseAppError({
|
|
665
|
+
code: error_2.AppErrorCode.INTERNAL_ERROR,
|
|
666
|
+
message: 'Expected a statusCode on the response from a ClientRequest'
|
|
667
|
+
});
|
|
629
668
|
}
|
|
630
669
|
const response = {
|
|
631
670
|
status: headers[':status'],
|
|
@@ -649,7 +688,7 @@ class AsyncHttp2Call extends AsyncRequestCall {
|
|
|
649
688
|
const encodings = ['gzip', 'compress', 'deflate'];
|
|
650
689
|
if (headers['content-encoding'] && encodings.indexOf(headers['content-encoding']) !== -1) {
|
|
651
690
|
// Add the unzipper to the body stream processing pipeline.
|
|
652
|
-
const zlib = require('zlib');
|
|
691
|
+
const zlib = require('zlib');
|
|
653
692
|
respStream = respStream.pipe(zlib.createUnzip());
|
|
654
693
|
// Remove the content-encoding in order to not confuse downstream operations.
|
|
655
694
|
delete headers['content-encoding'];
|
|
@@ -706,21 +745,21 @@ class BaseRequestConfigImpl {
|
|
|
706
745
|
}
|
|
707
746
|
buildUrl() {
|
|
708
747
|
const fullUrl = this.urlWithProtocol();
|
|
748
|
+
const parsedUrl = new URL(fullUrl);
|
|
709
749
|
if (!this.hasEntity() || this.isEntityEnclosingRequest()) {
|
|
710
|
-
return
|
|
750
|
+
return parsedUrl;
|
|
711
751
|
}
|
|
712
752
|
if (!validator.isObject(this.data)) {
|
|
713
753
|
throw new Error(`${this.method} requests cannot have a body`);
|
|
714
754
|
}
|
|
715
|
-
//
|
|
716
|
-
const parsedUrl = new url.URL(fullUrl);
|
|
755
|
+
// Append data to query string.
|
|
717
756
|
const dataObj = this.data;
|
|
718
757
|
for (const key in dataObj) {
|
|
719
758
|
if (Object.prototype.hasOwnProperty.call(dataObj, key)) {
|
|
720
759
|
parsedUrl.searchParams.append(key, dataObj[key]);
|
|
721
760
|
}
|
|
722
761
|
}
|
|
723
|
-
return
|
|
762
|
+
return parsedUrl;
|
|
724
763
|
}
|
|
725
764
|
urlWithProtocol() {
|
|
726
765
|
const fullUrl = this.url;
|
|
@@ -760,7 +799,7 @@ class HttpRequestConfigImpl extends BaseRequestConfigImpl {
|
|
|
760
799
|
protocol,
|
|
761
800
|
hostname: parsed.hostname,
|
|
762
801
|
port,
|
|
763
|
-
path: parsed.
|
|
802
|
+
path: `${parsed.pathname}${parsed.search}`,
|
|
764
803
|
method: this.method,
|
|
765
804
|
agent: this.httpAgent,
|
|
766
805
|
headers: Object.assign({}, this.headers),
|
|
@@ -784,7 +823,7 @@ class Http2RequestConfigImpl extends BaseRequestConfigImpl {
|
|
|
784
823
|
const protocol = parsed.protocol;
|
|
785
824
|
return {
|
|
786
825
|
protocol,
|
|
787
|
-
path: parsed.
|
|
826
|
+
path: `${parsed.pathname}${parsed.search}`,
|
|
788
827
|
method: this.method,
|
|
789
828
|
headers: Object.assign({}, this.headers),
|
|
790
829
|
};
|
|
@@ -1006,53 +1045,56 @@ class ExponentialBackoffPoller extends events_1.EventEmitter {
|
|
|
1006
1045
|
exports.ExponentialBackoffPoller = ExponentialBackoffPoller;
|
|
1007
1046
|
class Http2SessionHandler {
|
|
1008
1047
|
constructor(url) {
|
|
1009
|
-
this.
|
|
1010
|
-
|
|
1011
|
-
this.reject = reject;
|
|
1012
|
-
this.http2Session = this.createSession(url);
|
|
1013
|
-
});
|
|
1048
|
+
this.sessionErrors = [];
|
|
1049
|
+
this.createSession(url);
|
|
1014
1050
|
}
|
|
1015
1051
|
createSession(url) {
|
|
1016
|
-
if (!this.http2Session || this.
|
|
1052
|
+
if (!this.http2Session || this.isCurrentSessionClosed) {
|
|
1053
|
+
this.sessionErrors = [];
|
|
1017
1054
|
const opts = {
|
|
1018
1055
|
// Set local max concurrent stream limit to respect backend limit
|
|
1019
1056
|
peerMaxConcurrentStreams: 100,
|
|
1020
1057
|
ALPNProtocols: ['h2']
|
|
1021
1058
|
};
|
|
1022
|
-
|
|
1023
|
-
http2Session.on('goaway', (errorCode, _, opaqueData) => {
|
|
1024
|
-
|
|
1059
|
+
this.http2Session = http2.connect(url, opts);
|
|
1060
|
+
this.http2Session.on('goaway', (errorCode, _, opaqueData) => {
|
|
1061
|
+
const error = new error_2.FirebaseAppError({
|
|
1062
|
+
code: error_2.AppErrorCode.NETWORK_ERROR,
|
|
1063
|
+
message: `Error while making requests: GOAWAY - ${opaqueData?.toString()}, Error code: ${errorCode}`
|
|
1064
|
+
});
|
|
1065
|
+
this.sessionErrors.push(error);
|
|
1025
1066
|
});
|
|
1026
|
-
http2Session.on('error', (error) => {
|
|
1067
|
+
this.http2Session.on('error', (error) => {
|
|
1068
|
+
const codePart = error?.code ? `${error.code} - ` : '';
|
|
1027
1069
|
let errorMessage;
|
|
1028
|
-
if (error
|
|
1029
|
-
errorMessage = `Session error while making requests: ${
|
|
1070
|
+
if ((error instanceof AggregateError || error?.name === 'AggregateError') && Array.isArray(error.errors)) {
|
|
1071
|
+
errorMessage = `Session error while making requests: ${codePart}${error.name}: ` +
|
|
1030
1072
|
`[${error.errors.map((e) => e.message).join(', ')}]`;
|
|
1031
1073
|
}
|
|
1032
1074
|
else {
|
|
1033
|
-
errorMessage = `Session error while making requests: ${
|
|
1075
|
+
errorMessage = `Session error while making requests: ${codePart}${error?.message || 'Unknown error'}`;
|
|
1034
1076
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1077
|
+
const appError = new error_2.FirebaseAppError({
|
|
1078
|
+
code: error_2.AppErrorCode.NETWORK_ERROR,
|
|
1079
|
+
message: errorMessage,
|
|
1080
|
+
cause: error,
|
|
1081
|
+
});
|
|
1082
|
+
this.sessionErrors.push(appError);
|
|
1040
1083
|
});
|
|
1041
|
-
return http2Session;
|
|
1042
1084
|
}
|
|
1043
1085
|
return this.http2Session;
|
|
1044
1086
|
}
|
|
1045
|
-
|
|
1046
|
-
return this.
|
|
1087
|
+
getErrors() {
|
|
1088
|
+
return this.sessionErrors;
|
|
1047
1089
|
}
|
|
1048
1090
|
get session() {
|
|
1049
1091
|
return this.http2Session;
|
|
1050
1092
|
}
|
|
1051
|
-
get
|
|
1052
|
-
return this.http2Session
|
|
1093
|
+
get isCurrentSessionClosed() {
|
|
1094
|
+
return !!this.http2Session?.closed;
|
|
1053
1095
|
}
|
|
1054
1096
|
close() {
|
|
1055
|
-
this.http2Session
|
|
1097
|
+
this.http2Session?.close();
|
|
1056
1098
|
}
|
|
1057
1099
|
}
|
|
1058
1100
|
exports.Http2SessionHandler = Http2SessionHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -48,7 +48,7 @@ class ServiceAccountSigner {
|
|
|
48
48
|
* @inheritDoc
|
|
49
49
|
*/
|
|
50
50
|
sign(buffer) {
|
|
51
|
-
const crypto = require('node:crypto');
|
|
51
|
+
const crypto = require('node:crypto');
|
|
52
52
|
const sign = crypto.createSign('RSA-SHA256');
|
|
53
53
|
sign.update(buffer);
|
|
54
54
|
return Promise.resolve(sign.sign(this.credential.privateKey));
|
|
@@ -178,11 +178,6 @@ class CryptoSignerError extends Error {
|
|
|
178
178
|
constructor(errorInfo) {
|
|
179
179
|
super(errorInfo.message);
|
|
180
180
|
this.errorInfo = errorInfo;
|
|
181
|
-
/* tslint:disable:max-line-length */
|
|
182
|
-
// Set the prototype explicitly. See the following link for more details:
|
|
183
|
-
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
184
|
-
/* tslint:enable:max-line-length */
|
|
185
|
-
this.__proto__ = CryptoSignerError.prototype;
|
|
186
181
|
}
|
|
187
182
|
/** @returns The error code. */
|
|
188
183
|
get code() {
|