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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
@@ -15,18 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
export declare const APP_CHECK_ERROR_CODE_MAPPING: {
|
|
20
|
-
[key: string]: AppCheckErrorCode;
|
|
21
|
-
};
|
|
22
|
-
export type AppCheckErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'app-check-token-expired' | 'unknown-error';
|
|
23
|
-
/**
|
|
24
|
-
* Firebase App Check error code structure. This extends PrefixedFirebaseError.
|
|
25
|
-
*
|
|
26
|
-
* @param code - The error code.
|
|
27
|
-
* @param message - The error message.
|
|
28
|
-
* @constructor
|
|
29
|
-
*/
|
|
30
|
-
export declare class FirebaseAppCheckError extends PrefixedFirebaseError {
|
|
31
|
-
constructor(code: AppCheckErrorCode, message: string);
|
|
32
|
-
}
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.AppCheckApiClient = void 0;
|
|
21
21
|
const api_request_1 = require("../utils/api-request");
|
|
22
22
|
const error_1 = require("../utils/error");
|
|
23
|
+
const error_2 = require("./error");
|
|
23
24
|
const utils = require("../utils/index");
|
|
24
25
|
const validator = require("../utils/validator");
|
|
25
26
|
// App Check backend constants
|
|
@@ -37,7 +38,10 @@ class AppCheckApiClient {
|
|
|
37
38
|
constructor(app) {
|
|
38
39
|
this.app = app;
|
|
39
40
|
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
|
40
|
-
throw new FirebaseAppCheckError(
|
|
41
|
+
throw new error_2.FirebaseAppCheckError({
|
|
42
|
+
code: 'invalid-argument',
|
|
43
|
+
message: 'First argument passed to admin.appCheck() must be a valid Firebase app instance.'
|
|
44
|
+
});
|
|
41
45
|
}
|
|
42
46
|
this.httpClient = new api_request_1.AuthorizedHttpClient(app);
|
|
43
47
|
}
|
|
@@ -50,20 +54,35 @@ class AppCheckApiClient {
|
|
|
50
54
|
*/
|
|
51
55
|
exchangeToken(customToken, appId, options) {
|
|
52
56
|
if (!validator.isNonEmptyString(appId)) {
|
|
53
|
-
throw new FirebaseAppCheckError(
|
|
57
|
+
throw new error_2.FirebaseAppCheckError({
|
|
58
|
+
code: 'invalid-argument',
|
|
59
|
+
message: '`appId` must be a non-empty string.'
|
|
60
|
+
});
|
|
54
61
|
}
|
|
55
62
|
if (!validator.isNonEmptyString(customToken)) {
|
|
56
|
-
throw new FirebaseAppCheckError(
|
|
63
|
+
throw new error_2.FirebaseAppCheckError({
|
|
64
|
+
code: 'invalid-argument',
|
|
65
|
+
message: '`customToken` must be a non-empty string.'
|
|
66
|
+
});
|
|
57
67
|
}
|
|
58
68
|
if (typeof options?.limitedUse !== 'undefined' && !validator.isBoolean(options.limitedUse)) {
|
|
59
|
-
throw new FirebaseAppCheckError(
|
|
69
|
+
throw new error_2.FirebaseAppCheckError({
|
|
70
|
+
code: 'invalid-argument',
|
|
71
|
+
message: '`limitedUse` must be a boolean value.'
|
|
72
|
+
});
|
|
60
73
|
}
|
|
61
74
|
if (typeof options?.jti !== 'undefined') {
|
|
62
75
|
if (!validator.isString(options.jti)) {
|
|
63
|
-
throw new FirebaseAppCheckError(
|
|
76
|
+
throw new error_2.FirebaseAppCheckError({
|
|
77
|
+
code: 'invalid-argument',
|
|
78
|
+
message: '`jti` must be a string value.'
|
|
79
|
+
});
|
|
64
80
|
}
|
|
65
81
|
if (!options.limitedUse) {
|
|
66
|
-
throw new FirebaseAppCheckError(
|
|
82
|
+
throw new error_2.FirebaseAppCheckError({
|
|
83
|
+
code: 'invalid-argument',
|
|
84
|
+
message: '`jti` cannot be specified without setting `limitedUse` to `true`.'
|
|
85
|
+
});
|
|
67
86
|
}
|
|
68
87
|
}
|
|
69
88
|
return this.getUrl(appId)
|
|
@@ -89,7 +108,10 @@ class AppCheckApiClient {
|
|
|
89
108
|
}
|
|
90
109
|
verifyReplayProtection(token) {
|
|
91
110
|
if (!validator.isNonEmptyString(token)) {
|
|
92
|
-
throw new FirebaseAppCheckError(
|
|
111
|
+
throw new error_2.FirebaseAppCheckError({
|
|
112
|
+
code: 'invalid-argument',
|
|
113
|
+
message: '`token` must be a non-empty string.'
|
|
114
|
+
});
|
|
93
115
|
}
|
|
94
116
|
return this.getVerifyTokenUrl()
|
|
95
117
|
.then((url) => {
|
|
@@ -104,7 +126,11 @@ class AppCheckApiClient {
|
|
|
104
126
|
.then((resp) => {
|
|
105
127
|
if (typeof resp.data.alreadyConsumed !== 'undefined'
|
|
106
128
|
&& !validator.isBoolean(resp.data?.alreadyConsumed)) {
|
|
107
|
-
throw new FirebaseAppCheckError(
|
|
129
|
+
throw new error_2.FirebaseAppCheckError({
|
|
130
|
+
code: 'invalid-argument',
|
|
131
|
+
message: '`alreadyConsumed` must be a boolean value.',
|
|
132
|
+
httpResponse: (0, error_1.toHttpResponse)(resp)
|
|
133
|
+
});
|
|
108
134
|
}
|
|
109
135
|
return resp.data.alreadyConsumed || false;
|
|
110
136
|
})
|
|
@@ -140,29 +166,37 @@ class AppCheckApiClient {
|
|
|
140
166
|
return utils.findProjectId(this.app)
|
|
141
167
|
.then((projectId) => {
|
|
142
168
|
if (!validator.isNonEmptyString(projectId)) {
|
|
143
|
-
throw new FirebaseAppCheckError(
|
|
144
|
-
|
|
145
|
-
|
|
169
|
+
throw new error_2.FirebaseAppCheckError({
|
|
170
|
+
code: 'unknown-error',
|
|
171
|
+
message: 'Failed to determine project ID. Initialize the '
|
|
172
|
+
+ 'SDK with service account credentials or set project ID as an app option. '
|
|
173
|
+
+ 'Alternatively, set the GOOGLE_CLOUD_PROJECT environment variable.'
|
|
174
|
+
});
|
|
146
175
|
}
|
|
147
176
|
this.projectId = projectId;
|
|
148
177
|
return projectId;
|
|
149
178
|
});
|
|
150
179
|
}
|
|
151
180
|
toFirebaseError(err) {
|
|
152
|
-
if (err instanceof error_1.
|
|
181
|
+
if (err instanceof error_1.FirebaseError) {
|
|
153
182
|
return err;
|
|
154
183
|
}
|
|
155
184
|
const response = err.response;
|
|
156
185
|
if (!response.isJson()) {
|
|
157
|
-
return new FirebaseAppCheckError(
|
|
186
|
+
return new error_2.FirebaseAppCheckError({
|
|
187
|
+
code: 'unknown-error',
|
|
188
|
+
message: `Unexpected response with status: ${response.status} and body: ${response.text}`,
|
|
189
|
+
httpResponse: (0, error_1.toHttpResponse)(response),
|
|
190
|
+
cause: err
|
|
191
|
+
});
|
|
158
192
|
}
|
|
159
193
|
const error = response.data.error || {};
|
|
160
194
|
let code = 'unknown-error';
|
|
161
|
-
if (error.status && error.status in
|
|
162
|
-
code =
|
|
195
|
+
if (error.status && error.status in error_2.APP_CHECK_ERROR_CODE_MAPPING) {
|
|
196
|
+
code = error_2.APP_CHECK_ERROR_CODE_MAPPING[error.status];
|
|
163
197
|
}
|
|
164
|
-
const message = error.message ||
|
|
165
|
-
return new FirebaseAppCheckError(code, message);
|
|
198
|
+
const message = error.message || 'Unknown server error';
|
|
199
|
+
return new error_2.FirebaseAppCheckError({ code, message, httpResponse: (0, error_1.toHttpResponse)(response), cause: err });
|
|
166
200
|
}
|
|
167
201
|
/**
|
|
168
202
|
* Creates an AppCheckToken from the API response.
|
|
@@ -192,38 +226,13 @@ class AppCheckApiClient {
|
|
|
192
226
|
*/
|
|
193
227
|
stringToMilliseconds(duration) {
|
|
194
228
|
if (!validator.isNonEmptyString(duration) || !duration.endsWith('s')) {
|
|
195
|
-
throw new FirebaseAppCheckError(
|
|
229
|
+
throw new error_2.FirebaseAppCheckError({
|
|
230
|
+
code: 'invalid-argument',
|
|
231
|
+
message: '`ttl` must be a valid duration string with the suffix `s`.'
|
|
232
|
+
});
|
|
196
233
|
}
|
|
197
234
|
const seconds = duration.slice(0, -1);
|
|
198
235
|
return Math.floor(Number(seconds) * 1000);
|
|
199
236
|
}
|
|
200
237
|
}
|
|
201
238
|
exports.AppCheckApiClient = AppCheckApiClient;
|
|
202
|
-
exports.APP_CHECK_ERROR_CODE_MAPPING = {
|
|
203
|
-
ABORTED: 'aborted',
|
|
204
|
-
INVALID_ARGUMENT: 'invalid-argument',
|
|
205
|
-
INVALID_CREDENTIAL: 'invalid-credential',
|
|
206
|
-
INTERNAL: 'internal-error',
|
|
207
|
-
PERMISSION_DENIED: 'permission-denied',
|
|
208
|
-
UNAUTHENTICATED: 'unauthenticated',
|
|
209
|
-
NOT_FOUND: 'not-found',
|
|
210
|
-
UNKNOWN: 'unknown-error',
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Firebase App Check error code structure. This extends PrefixedFirebaseError.
|
|
214
|
-
*
|
|
215
|
-
* @param code - The error code.
|
|
216
|
-
* @param message - The error message.
|
|
217
|
-
* @constructor
|
|
218
|
-
*/
|
|
219
|
-
class FirebaseAppCheckError extends error_1.PrefixedFirebaseError {
|
|
220
|
-
constructor(code, message) {
|
|
221
|
-
super('app-check', code, message);
|
|
222
|
-
/* tslint:disable:max-line-length */
|
|
223
|
-
// Set the prototype explicitly. See the following link for more details:
|
|
224
|
-
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
225
|
-
/* tslint:enable:max-line-length */
|
|
226
|
-
this.__proto__ = FirebaseAppCheckError.prototype;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
exports.FirebaseAppCheckError = FirebaseAppCheckError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.AppCheck = void 0;
|
|
21
21
|
const validator = require("../utils/validator");
|
|
22
22
|
const app_check_api_client_internal_1 = require("./app-check-api-client-internal");
|
|
23
|
+
const error_1 = require("./error");
|
|
23
24
|
const token_generator_1 = require("./token-generator");
|
|
24
25
|
const token_verifier_1 = require("./token-verifier");
|
|
25
26
|
const crypto_signer_1 = require("../utils/crypto-signer");
|
|
@@ -94,7 +95,10 @@ class AppCheck {
|
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
if (!validator.isNonNullObject(options)) {
|
|
97
|
-
throw new
|
|
98
|
+
throw new error_1.FirebaseAppCheckError({
|
|
99
|
+
code: 'invalid-argument',
|
|
100
|
+
message: 'VerifyAppCheckTokenOptions must be a non-null object.'
|
|
101
|
+
});
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
/** @const {Record<string, AppCheckErrorCode>} App Check server to client error code mapping. */
|
|
19
|
+
export declare const APP_CHECK_ERROR_CODE_MAPPING: Record<string, AppCheckErrorCode>;
|
|
20
|
+
/**
|
|
21
|
+
* The constant mapping for valid App Check client error codes.
|
|
22
|
+
*/
|
|
23
|
+
export declare const AppCheckErrorCode: {
|
|
24
|
+
readonly ABORTED: "aborted";
|
|
25
|
+
readonly INVALID_ARGUMENT: "invalid-argument";
|
|
26
|
+
readonly INVALID_CREDENTIAL: "invalid-credential";
|
|
27
|
+
readonly INTERNAL: "internal-error";
|
|
28
|
+
readonly PERMISSION_DENIED: "permission-denied";
|
|
29
|
+
readonly UNAUTHENTICATED: "unauthenticated";
|
|
30
|
+
readonly NOT_FOUND: "not-found";
|
|
31
|
+
readonly APP_CHECK_TOKEN_EXPIRED: "app-check-token-expired";
|
|
32
|
+
readonly UNKNOWN: "unknown-error";
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The type definition for valid App Check client error codes.
|
|
36
|
+
*/
|
|
37
|
+
export type AppCheckErrorCode = typeof AppCheckErrorCode[keyof typeof AppCheckErrorCode];
|
|
38
|
+
/**
|
|
39
|
+
* Firebase App Check error code structure. This extends `FirebaseError`.
|
|
40
|
+
*/
|
|
41
|
+
export declare class FirebaseAppCheckError extends FirebaseError {
|
|
42
|
+
/**
|
|
43
|
+
* @param info - The error code info.
|
|
44
|
+
* @param message - The error message. If provided, this will override the default message.
|
|
45
|
+
*/
|
|
46
|
+
constructor(info: ErrorInfo, message?: string);
|
|
47
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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.FirebaseAppCheckError = exports.AppCheckErrorCode = exports.APP_CHECK_ERROR_CODE_MAPPING = void 0;
|
|
20
|
+
const error_1 = require("../utils/error");
|
|
21
|
+
/** @const {Record<string, AppCheckErrorCode>} App Check server to client error code mapping. */
|
|
22
|
+
exports.APP_CHECK_ERROR_CODE_MAPPING = {
|
|
23
|
+
ABORTED: 'aborted',
|
|
24
|
+
INVALID_ARGUMENT: 'invalid-argument',
|
|
25
|
+
INVALID_CREDENTIAL: 'invalid-credential',
|
|
26
|
+
INTERNAL: 'internal-error',
|
|
27
|
+
PERMISSION_DENIED: 'permission-denied',
|
|
28
|
+
UNAUTHENTICATED: 'unauthenticated',
|
|
29
|
+
NOT_FOUND: 'not-found',
|
|
30
|
+
UNKNOWN: 'unknown-error',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The constant mapping for valid App Check client error codes.
|
|
34
|
+
*/
|
|
35
|
+
exports.AppCheckErrorCode = {
|
|
36
|
+
ABORTED: 'aborted',
|
|
37
|
+
INVALID_ARGUMENT: 'invalid-argument',
|
|
38
|
+
INVALID_CREDENTIAL: 'invalid-credential',
|
|
39
|
+
INTERNAL: 'internal-error',
|
|
40
|
+
PERMISSION_DENIED: 'permission-denied',
|
|
41
|
+
UNAUTHENTICATED: 'unauthenticated',
|
|
42
|
+
NOT_FOUND: 'not-found',
|
|
43
|
+
APP_CHECK_TOKEN_EXPIRED: 'app-check-token-expired',
|
|
44
|
+
UNKNOWN: 'unknown-error',
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Firebase App Check error code structure. This extends `FirebaseError`.
|
|
48
|
+
*/
|
|
49
|
+
class FirebaseAppCheckError extends error_1.FirebaseError {
|
|
50
|
+
/**
|
|
51
|
+
* @param info - The error code info.
|
|
52
|
+
* @param message - The error message. If provided, this will override the default message.
|
|
53
|
+
*/
|
|
54
|
+
constructor(info, message) {
|
|
55
|
+
super({
|
|
56
|
+
code: `app-check/${info.code}`,
|
|
57
|
+
message: message || info.message,
|
|
58
|
+
httpResponse: info.httpResponse,
|
|
59
|
+
cause: info.cause,
|
|
60
|
+
});
|
|
61
|
+
/** @internal */
|
|
62
|
+
this.codePrefix = 'app-check';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.FirebaseAppCheckError = FirebaseAppCheckError;
|
package/lib/app-check/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
@@ -51,3 +51,4 @@ export { AppCheck } from './app-check';
|
|
|
51
51
|
* app.
|
|
52
52
|
*/
|
|
53
53
|
export declare function getAppCheck(app?: App): AppCheck;
|
|
54
|
+
export { FirebaseAppCheckError, AppCheckErrorCode } from './error';
|
package/lib/app-check/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.AppCheck = void 0;
|
|
20
|
+
exports.AppCheckErrorCode = exports.FirebaseAppCheckError = exports.AppCheck = void 0;
|
|
21
21
|
exports.getAppCheck = getAppCheck;
|
|
22
22
|
/**
|
|
23
23
|
* Firebase App Check.
|
|
@@ -61,3 +61,6 @@ function getAppCheck(app) {
|
|
|
61
61
|
const firebaseApp = app;
|
|
62
62
|
return firebaseApp.getOrInitService('appCheck', (app) => new app_check_1.AppCheck(app));
|
|
63
63
|
}
|
|
64
|
+
var error_1 = require("./error");
|
|
65
|
+
Object.defineProperty(exports, "FirebaseAppCheckError", { enumerable: true, get: function () { return error_1.FirebaseAppCheckError; } });
|
|
66
|
+
Object.defineProperty(exports, "AppCheckErrorCode", { enumerable: true, get: function () { return error_1.AppCheckErrorCode; } });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -22,7 +22,8 @@ exports.appCheckErrorFromCryptoSignerError = appCheckErrorFromCryptoSignerError;
|
|
|
22
22
|
const validator = require("../utils/validator");
|
|
23
23
|
const utils_1 = require("../utils");
|
|
24
24
|
const crypto_signer_1 = require("../utils/crypto-signer");
|
|
25
|
-
const
|
|
25
|
+
const error_1 = require("./error");
|
|
26
|
+
const error_2 = require("../utils/error");
|
|
26
27
|
const ONE_MINUTE_IN_SECONDS = 60;
|
|
27
28
|
const ONE_MINUTE_IN_MILLIS = ONE_MINUTE_IN_SECONDS * 1000;
|
|
28
29
|
const ONE_DAY_IN_MILLIS = 24 * 60 * 60 * 1000;
|
|
@@ -42,7 +43,10 @@ class AppCheckTokenGenerator {
|
|
|
42
43
|
*/
|
|
43
44
|
constructor(signer) {
|
|
44
45
|
if (!validator.isNonNullObject(signer)) {
|
|
45
|
-
throw new
|
|
46
|
+
throw new error_1.FirebaseAppCheckError({
|
|
47
|
+
code: 'invalid-argument',
|
|
48
|
+
message: 'INTERNAL ASSERT: Must provide a CryptoSigner to use AppCheckTokenGenerator.'
|
|
49
|
+
});
|
|
46
50
|
}
|
|
47
51
|
this.signer = signer;
|
|
48
52
|
}
|
|
@@ -56,7 +60,10 @@ class AppCheckTokenGenerator {
|
|
|
56
60
|
*/
|
|
57
61
|
createCustomToken(appId, options) {
|
|
58
62
|
if (!validator.isNonEmptyString(appId)) {
|
|
59
|
-
throw new
|
|
63
|
+
throw new error_1.FirebaseAppCheckError({
|
|
64
|
+
code: 'invalid-argument',
|
|
65
|
+
message: '`appId` must be a non-empty string.'
|
|
66
|
+
});
|
|
60
67
|
}
|
|
61
68
|
let customOptions = {};
|
|
62
69
|
if (typeof options !== 'undefined') {
|
|
@@ -99,15 +106,24 @@ class AppCheckTokenGenerator {
|
|
|
99
106
|
*/
|
|
100
107
|
validateTokenOptions(options) {
|
|
101
108
|
if (!validator.isNonNullObject(options)) {
|
|
102
|
-
throw new
|
|
109
|
+
throw new error_1.FirebaseAppCheckError({
|
|
110
|
+
code: 'invalid-argument',
|
|
111
|
+
message: 'AppCheckTokenOptions must be a non-null object.'
|
|
112
|
+
});
|
|
103
113
|
}
|
|
104
114
|
if (typeof options.ttlMillis !== 'undefined') {
|
|
105
115
|
if (!validator.isNumber(options.ttlMillis)) {
|
|
106
|
-
throw new
|
|
116
|
+
throw new error_1.FirebaseAppCheckError({
|
|
117
|
+
code: 'invalid-argument',
|
|
118
|
+
message: 'ttlMillis must be a duration in milliseconds.'
|
|
119
|
+
});
|
|
107
120
|
}
|
|
108
121
|
// ttlMillis must be between 30 minutes and 7 days (inclusive)
|
|
109
122
|
if (options.ttlMillis < (ONE_MINUTE_IN_MILLIS * 30) || options.ttlMillis > (ONE_DAY_IN_MILLIS * 7)) {
|
|
110
|
-
throw new
|
|
123
|
+
throw new error_1.FirebaseAppCheckError({
|
|
124
|
+
code: 'invalid-argument',
|
|
125
|
+
message: 'ttlMillis must be a duration in milliseconds between 30 minutes and 7 days (inclusive).'
|
|
126
|
+
});
|
|
111
127
|
}
|
|
112
128
|
return { ttl: (0, utils_1.transformMillisecondsToSecondsString)(options.ttlMillis) };
|
|
113
129
|
}
|
|
@@ -131,16 +147,30 @@ function appCheckErrorFromCryptoSignerError(err) {
|
|
|
131
147
|
const errorResponse = httpError.response.data;
|
|
132
148
|
if (errorResponse?.error) {
|
|
133
149
|
const status = errorResponse.error.status;
|
|
134
|
-
const description = errorResponse.error.message ||
|
|
150
|
+
const description = errorResponse.error.message || 'Unknown server error';
|
|
135
151
|
let code = 'unknown-error';
|
|
136
|
-
if (status && status in
|
|
137
|
-
code =
|
|
152
|
+
if (status && status in error_1.APP_CHECK_ERROR_CODE_MAPPING) {
|
|
153
|
+
code = error_1.APP_CHECK_ERROR_CODE_MAPPING[status];
|
|
138
154
|
}
|
|
139
|
-
return new
|
|
155
|
+
return new error_1.FirebaseAppCheckError({
|
|
156
|
+
code,
|
|
157
|
+
message: `Error returned from server while signing a custom token: ${description}`,
|
|
158
|
+
httpResponse: (0, error_2.toHttpResponse)(httpError.response),
|
|
159
|
+
cause: err
|
|
160
|
+
});
|
|
140
161
|
}
|
|
141
|
-
return new
|
|
162
|
+
return new error_1.FirebaseAppCheckError({
|
|
163
|
+
code: 'internal-error',
|
|
164
|
+
message: 'Error returned from server.',
|
|
165
|
+
httpResponse: (0, error_2.toHttpResponse)(httpError.response),
|
|
166
|
+
cause: err
|
|
167
|
+
});
|
|
142
168
|
}
|
|
143
|
-
return new
|
|
169
|
+
return new error_1.FirebaseAppCheckError({
|
|
170
|
+
code: mapToAppCheckErrorCode(err.code),
|
|
171
|
+
message: err.message,
|
|
172
|
+
cause: err
|
|
173
|
+
});
|
|
144
174
|
}
|
|
145
175
|
function mapToAppCheckErrorCode(code) {
|
|
146
176
|
switch (code) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.AppCheckTokenVerifier = void 0;
|
|
20
20
|
const validator = require("../utils/validator");
|
|
21
21
|
const util = require("../utils/index");
|
|
22
|
-
const
|
|
22
|
+
const error_1 = require("./error");
|
|
23
23
|
const jwt_1 = require("../utils/jwt");
|
|
24
24
|
const APP_CHECK_ISSUER = 'https://firebaseappcheck.googleapis.com/';
|
|
25
25
|
const JWKS_URL = 'https://firebaseappcheck.googleapis.com/v1/jwks';
|
|
@@ -41,7 +41,10 @@ class AppCheckTokenVerifier {
|
|
|
41
41
|
*/
|
|
42
42
|
verifyToken(token) {
|
|
43
43
|
if (!validator.isString(token)) {
|
|
44
|
-
throw new
|
|
44
|
+
throw new error_1.FirebaseAppCheckError({
|
|
45
|
+
code: 'invalid-argument',
|
|
46
|
+
message: 'App check token must be a non-null string.'
|
|
47
|
+
});
|
|
45
48
|
}
|
|
46
49
|
return this.ensureProjectId()
|
|
47
50
|
.then((projectId) => {
|
|
@@ -57,8 +60,11 @@ class AppCheckTokenVerifier {
|
|
|
57
60
|
return util.findProjectId(this.app)
|
|
58
61
|
.then((projectId) => {
|
|
59
62
|
if (!validator.isNonEmptyString(projectId)) {
|
|
60
|
-
throw new
|
|
61
|
-
|
|
63
|
+
throw new error_1.FirebaseAppCheckError({
|
|
64
|
+
code: 'invalid-credential',
|
|
65
|
+
message: 'Must initialize app with a cert credential or set your Firebase project ID as the ' +
|
|
66
|
+
'GOOGLE_CLOUD_PROJECT environment variable to verify an App Check token.'
|
|
67
|
+
});
|
|
62
68
|
}
|
|
63
69
|
return projectId;
|
|
64
70
|
});
|
|
@@ -76,7 +82,10 @@ class AppCheckTokenVerifier {
|
|
|
76
82
|
.catch(() => {
|
|
77
83
|
const errorMessage = 'Decoding App Check token failed. Make sure you passed ' +
|
|
78
84
|
'the entire string JWT which represents the Firebase App Check token.';
|
|
79
|
-
throw new
|
|
85
|
+
throw new error_1.FirebaseAppCheckError({
|
|
86
|
+
code: 'invalid-argument',
|
|
87
|
+
message: errorMessage
|
|
88
|
+
});
|
|
80
89
|
});
|
|
81
90
|
}
|
|
82
91
|
/**
|
|
@@ -110,7 +119,10 @@ class AppCheckTokenVerifier {
|
|
|
110
119
|
errorMessage = 'The provided App Check token has an empty string "sub" (subject) claim.';
|
|
111
120
|
}
|
|
112
121
|
if (errorMessage) {
|
|
113
|
-
throw new
|
|
122
|
+
throw new error_1.FirebaseAppCheckError({
|
|
123
|
+
code: 'invalid-argument',
|
|
124
|
+
message: errorMessage
|
|
125
|
+
});
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
verifySignature(jwtToken) {
|
|
@@ -129,19 +141,35 @@ class AppCheckTokenVerifier {
|
|
|
129
141
|
if (error.code === jwt_1.JwtErrorCode.TOKEN_EXPIRED) {
|
|
130
142
|
const errorMessage = 'The provided App Check token has expired. Get a fresh App Check token' +
|
|
131
143
|
' from your client app and try again.';
|
|
132
|
-
return new
|
|
144
|
+
return new error_1.FirebaseAppCheckError({
|
|
145
|
+
code: 'app-check-token-expired',
|
|
146
|
+
message: errorMessage,
|
|
147
|
+
cause: error
|
|
148
|
+
});
|
|
133
149
|
}
|
|
134
150
|
else if (error.code === jwt_1.JwtErrorCode.INVALID_SIGNATURE) {
|
|
135
151
|
const errorMessage = 'The provided App Check token has invalid signature.';
|
|
136
|
-
return new
|
|
152
|
+
return new error_1.FirebaseAppCheckError({
|
|
153
|
+
code: 'invalid-argument',
|
|
154
|
+
message: errorMessage,
|
|
155
|
+
cause: error
|
|
156
|
+
});
|
|
137
157
|
}
|
|
138
158
|
else if (error.code === jwt_1.JwtErrorCode.NO_MATCHING_KID) {
|
|
139
159
|
const errorMessage = 'The provided App Check token has "kid" claim which does not ' +
|
|
140
160
|
'correspond to a known public key. Most likely the provided App Check token ' +
|
|
141
161
|
'is expired, so get a fresh token from your client app and try again.';
|
|
142
|
-
return new
|
|
162
|
+
return new error_1.FirebaseAppCheckError({
|
|
163
|
+
code: 'invalid-argument',
|
|
164
|
+
message: errorMessage,
|
|
165
|
+
cause: error
|
|
166
|
+
});
|
|
143
167
|
}
|
|
144
|
-
return new
|
|
168
|
+
return new error_1.FirebaseAppCheckError({
|
|
169
|
+
code: 'invalid-argument',
|
|
170
|
+
message: error.message,
|
|
171
|
+
cause: error
|
|
172
|
+
});
|
|
145
173
|
}
|
|
146
174
|
}
|
|
147
175
|
exports.AppCheckTokenVerifier = AppCheckTokenVerifier;
|