firebase-admin 9.100.0-alpha.0 → 10.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/lib/app/core.d.ts +15 -22
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +17 -33
- package/lib/app/credential-factory.js +17 -33
- package/lib/app/credential-internal.d.ts +10 -9
- package/lib/app/credential-internal.js +15 -13
- package/lib/app/credential.d.ts +3 -9
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +6 -30
- package/lib/app/firebase-app.js +72 -216
- package/lib/app/firebase-namespace.d.ts +28 -34
- package/lib/app/firebase-namespace.js +119 -99
- package/lib/app/index.d.ts +6 -1
- package/lib/app/index.js +1 -1
- package/lib/app/lifecycle.d.ts +24 -3
- package/lib/app/lifecycle.js +119 -25
- package/lib/app-check/app-check-api-client-internal.d.ts +32 -0
- package/lib/app-check/app-check-api-client-internal.js +197 -0
- package/lib/app-check/app-check-api.d.ts +95 -0
- package/lib/app-check/app-check-api.js +19 -0
- package/lib/app-check/app-check-namespace.d.ts +65 -0
- package/lib/app-check/app-check-namespace.js +18 -0
- package/lib/app-check/app-check.d.ts +49 -0
- package/lib/app-check/app-check.js +82 -0
- package/lib/app-check/index.d.ts +53 -0
- package/lib/app-check/index.js +63 -0
- package/lib/app-check/token-generator.d.ts +25 -0
- package/lib/app-check/token-generator.js +159 -0
- package/lib/app-check/token-verifier.d.ts +17 -0
- package/lib/app-check/token-verifier.js +151 -0
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +2 -2
- package/lib/auth/auth-api-request.d.ts +28 -32
- package/lib/auth/auth-api-request.js +167 -125
- package/lib/auth/auth-config.d.ts +123 -21
- package/lib/auth/auth-config.js +85 -34
- package/lib/auth/auth-namespace.d.ts +157 -4
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +5 -3
- package/lib/auth/auth.js +6 -4
- package/lib/auth/base-auth.d.ts +134 -116
- package/lib/auth/base-auth.js +213 -143
- package/lib/auth/identifier.d.ts +5 -5
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +10 -5
- package/lib/auth/index.js +9 -4
- package/lib/auth/tenant-manager.d.ts +19 -19
- package/lib/auth/tenant-manager.js +21 -25
- package/lib/auth/tenant.d.ts +14 -5
- package/lib/auth/tenant.js +19 -11
- package/lib/auth/token-generator.d.ts +7 -108
- package/lib/auth/token-generator.js +52 -145
- package/lib/auth/token-verifier.d.ts +3 -4
- package/lib/auth/token-verifier.js +96 -145
- package/lib/auth/user-import-builder.d.ts +11 -11
- package/lib/auth/user-import-builder.js +9 -9
- package/lib/auth/user-record.d.ts +23 -15
- package/lib/auth/user-record.js +30 -20
- package/lib/credential/index.d.ts +18 -35
- package/lib/credential/index.js +17 -33
- package/lib/database/database-namespace.d.ts +39 -10
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +16 -6
- package/lib/database/database.js +61 -6
- package/lib/database/index.d.ts +19 -18
- package/lib/database/index.js +21 -23
- package/lib/default-namespace.d.ts +7 -1
- package/lib/default-namespace.js +4 -4
- package/lib/esm/app/index.js +10 -0
- package/lib/esm/app-check/index.js +4 -0
- package/lib/esm/auth/index.js +14 -0
- package/lib/esm/database/index.js +6 -0
- package/lib/esm/firestore/index.js +24 -0
- package/lib/esm/installations/index.js +4 -0
- package/lib/esm/instance-id/index.js +4 -0
- package/lib/esm/machine-learning/index.js +5 -0
- package/lib/esm/messaging/index.js +4 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/project-management/index.js +8 -0
- package/lib/esm/remote-config/index.js +4 -0
- package/lib/esm/security-rules/index.js +6 -0
- package/lib/esm/storage/index.js +4 -0
- package/lib/firebase-namespace-api.d.ts +12 -6
- package/lib/firebase-namespace-api.js +5 -1
- package/lib/firestore/firestore-internal.d.ts +2 -2
- package/lib/firestore/firestore-internal.js +2 -2
- package/lib/firestore/firestore-namespace.d.ts +6 -1
- package/lib/firestore/firestore-namespace.js +2 -1
- package/lib/firestore/index.d.ts +36 -4
- package/lib/firestore/index.js +29 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +52 -0
- package/lib/installations/index.js +62 -0
- package/lib/installations/installations-namespace.d.ts +55 -0
- package/lib/installations/installations-namespace.js +18 -0
- package/lib/{instance-id/instance-id-request-internal.d.ts → installations/installations-request-handler.d.ts} +8 -8
- package/lib/{instance-id/instance-id-request-internal.js → installations/installations-request-handler.js} +23 -23
- package/lib/installations/installations.d.ts +38 -0
- package/lib/installations/installations.js +63 -0
- package/lib/instance-id/index.d.ts +20 -9
- package/lib/instance-id/index.js +20 -9
- package/lib/instance-id/instance-id-namespace.d.ts +9 -8
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +8 -6
- package/lib/instance-id/instance-id.js +20 -11
- package/lib/machine-learning/index.d.ts +29 -27
- package/lib/machine-learning/index.js +29 -27
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +4 -4
- package/lib/machine-learning/machine-learning-namespace.d.ts +33 -8
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.d.ts +19 -19
- package/lib/machine-learning/machine-learning.js +20 -20
- package/lib/messaging/batch-request-internal.d.ts +3 -3
- package/lib/messaging/batch-request-internal.js +9 -9
- package/lib/messaging/index.d.ts +11 -9
- package/lib/messaging/index.js +11 -9
- package/lib/messaging/messaging-api-request-internal.d.ts +8 -8
- package/lib/messaging/messaging-api-request-internal.js +8 -8
- package/lib/messaging/messaging-api.d.ts +79 -75
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +5 -5
- package/lib/messaging/messaging-errors-internal.js +7 -7
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +6 -31
- package/lib/messaging/messaging-namespace.d.ts +105 -8
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +70 -86
- package/lib/messaging/messaging.js +76 -89
- package/lib/project-management/android-app.d.ts +11 -12
- package/lib/project-management/android-app.js +13 -14
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +11 -9
- package/lib/project-management/index.js +11 -9
- package/lib/project-management/ios-app.d.ts +6 -7
- package/lib/project-management/ios-app.js +6 -7
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -80
- package/lib/project-management/project-management-api-request-internal.js +14 -14
- package/lib/project-management/project-management-namespace.d.ts +31 -9
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +18 -21
- package/lib/project-management/project-management.js +19 -22
- package/lib/remote-config/index.d.ts +12 -10
- package/lib/remote-config/index.js +11 -9
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +2 -2
- package/lib/remote-config/remote-config-api.d.ts +12 -2
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +50 -9
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +19 -21
- package/lib/remote-config/remote-config.js +25 -25
- package/lib/security-rules/index.d.ts +12 -10
- package/lib/security-rules/index.js +12 -10
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +43 -28
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +39 -42
- package/lib/security-rules/security-rules.js +38 -39
- package/lib/storage/index.d.ts +9 -7
- package/lib/storage/index.js +9 -7
- package/lib/storage/storage-namespace.d.ts +7 -6
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +3 -3
- package/lib/storage/storage.js +14 -4
- package/lib/utils/api-request.d.ts +24 -24
- package/lib/utils/api-request.js +25 -25
- package/lib/utils/crypto-signer.d.ts +128 -0
- package/lib/utils/crypto-signer.js +237 -0
- package/lib/utils/deep-copy.d.ts +6 -6
- package/lib/utils/deep-copy.js +6 -6
- package/lib/utils/error.d.ts +69 -36
- package/lib/utils/error.js +98 -43
- package/lib/utils/index.d.ts +30 -19
- package/lib/utils/index.js +47 -20
- package/lib/utils/jwt.d.ts +131 -0
- package/lib/utils/jwt.js +355 -0
- package/lib/utils/validator.d.ts +37 -37
- package/lib/utils/validator.js +37 -37
- package/package.json +126 -53
package/README.md
CHANGED
|
@@ -36,13 +36,17 @@ $ npm install --save firebase-admin
|
|
|
36
36
|
To use the module in your application, `require` it from any JavaScript file:
|
|
37
37
|
|
|
38
38
|
```js
|
|
39
|
-
|
|
39
|
+
const { initializeApp } = require("firebase-admin/app");
|
|
40
|
+
|
|
41
|
+
initializeApp();
|
|
40
42
|
```
|
|
41
43
|
|
|
42
44
|
If you are using ES2015, you can `import` the module instead:
|
|
43
45
|
|
|
44
46
|
```js
|
|
45
|
-
import
|
|
47
|
+
import { initializeApp } from "firebase-admin/app";
|
|
48
|
+
|
|
49
|
+
initializeApp();
|
|
46
50
|
```
|
|
47
51
|
|
|
48
52
|
|
|
@@ -55,7 +59,7 @@ requests, code review feedback, and also pull requests.
|
|
|
55
59
|
|
|
56
60
|
## Supported Environments
|
|
57
61
|
|
|
58
|
-
We support Node.js
|
|
62
|
+
We support Node.js 12 and higher.
|
|
59
63
|
|
|
60
64
|
Please also note that the Admin SDK should only
|
|
61
65
|
be used in server-side/back-end environments controlled by the app developer.
|
package/lib/app/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google Inc.
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
import { Agent } from 'http';
|
|
20
20
|
import { Credential } from './credential';
|
|
21
21
|
/**
|
|
22
|
-
* Available options to pass to
|
|
22
|
+
* Available options to pass to {@link firebase-admin.app#initializeApp}.
|
|
23
23
|
*/
|
|
24
24
|
export interface AppOptions {
|
|
25
25
|
/**
|
|
26
|
-
* A {@link Credential
|
|
26
|
+
* A {@link firebase-admin.app#Credential} object used to
|
|
27
27
|
* authenticate the Admin SDK.
|
|
28
28
|
*
|
|
29
|
-
* See
|
|
30
|
-
* documentation and code samples.
|
|
29
|
+
* See {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
|
30
|
+
* for detailed documentation and code samples.
|
|
31
31
|
*/
|
|
32
32
|
credential?: Credential;
|
|
33
33
|
/**
|
|
34
|
-
* The object to use as the
|
|
34
|
+
* The object to use as the {@link https://firebase.google.com/docs/reference/security/database/#auth | auth}
|
|
35
35
|
* variable in your Realtime Database Rules when the Admin SDK reads from or
|
|
36
36
|
* writes to the Realtime Database. This allows you to downscope the Admin SDK
|
|
37
37
|
* from its default full read and write privileges.
|
|
@@ -39,7 +39,8 @@ export interface AppOptions {
|
|
|
39
39
|
* You can pass `null` to act as an unauthenticated client.
|
|
40
40
|
*
|
|
41
41
|
* See
|
|
42
|
-
*
|
|
42
|
+
* {@link https://firebase.google.com/docs/database/admin/start#authenticate-with-limited-privileges |
|
|
43
|
+
* Authenticate with limited privileges}
|
|
43
44
|
* for detailed documentation and code samples.
|
|
44
45
|
*/
|
|
45
46
|
databaseAuthVariableOverride?: object | null;
|
|
@@ -63,7 +64,7 @@ export interface AppOptions {
|
|
|
63
64
|
*/
|
|
64
65
|
projectId?: string;
|
|
65
66
|
/**
|
|
66
|
-
* An
|
|
67
|
+
* An {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
|
67
68
|
* to be used when making outgoing HTTP calls. This Agent instance is used
|
|
68
69
|
* by all services that make REST calls (e.g. `auth`, `messaging`,
|
|
69
70
|
* `projectManagement`).
|
|
@@ -78,12 +79,6 @@ export interface AppOptions {
|
|
|
78
79
|
/**
|
|
79
80
|
* A Firebase app holds the initialization information for a collection of
|
|
80
81
|
* services.
|
|
81
|
-
*
|
|
82
|
-
* Do not call this constructor directly. Instead, use
|
|
83
|
-
* {@link
|
|
84
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
85
|
-
* `admin.initializeApp()`}
|
|
86
|
-
* to create an app.
|
|
87
82
|
*/
|
|
88
83
|
export interface App {
|
|
89
84
|
/**
|
|
@@ -108,10 +103,7 @@ export interface App {
|
|
|
108
103
|
name: string;
|
|
109
104
|
/**
|
|
110
105
|
* The (read-only) configuration options for this app. These are the original
|
|
111
|
-
* parameters given in
|
|
112
|
-
* {@link
|
|
113
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
114
|
-
* `admin.initializeApp()`}.
|
|
106
|
+
* parameters given in {@link firebase-admin.app#initializeApp}.
|
|
115
107
|
*
|
|
116
108
|
* @example
|
|
117
109
|
* ```javascript
|
|
@@ -148,13 +140,14 @@ export interface FirebaseError {
|
|
|
148
140
|
* A string value containing the execution backtrace when the error originally
|
|
149
141
|
* occurred.
|
|
150
142
|
*
|
|
151
|
-
* This information can be useful
|
|
152
|
-
* {@link https://firebase.google.com/support
|
|
153
|
-
* explain the cause of an error.
|
|
143
|
+
* This information can be useful for troubleshooting the cause of the error with
|
|
144
|
+
* {@link https://firebase.google.com/support | Firebase Support}.
|
|
154
145
|
*/
|
|
155
146
|
stack?: string;
|
|
156
147
|
/**
|
|
157
|
-
*
|
|
148
|
+
* Returns a JSON-serializable object representation of this error.
|
|
149
|
+
*
|
|
150
|
+
* @returns A JSON-serializable representation of this object.
|
|
158
151
|
*/
|
|
159
152
|
toJSON(): object;
|
|
160
153
|
}
|
package/lib/app/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google Inc.
|
|
@@ -20,22 +20,16 @@ import { Agent } from 'http';
|
|
|
20
20
|
import { Credential, ServiceAccount } from './credential';
|
|
21
21
|
/**
|
|
22
22
|
* Returns a credential created from the
|
|
23
|
-
* {@link
|
|
24
|
-
*
|
|
25
|
-
* Google Application Default Credentials}
|
|
23
|
+
* {@link https://developers.google.com/identity/protocols/application-default-credentials |
|
|
24
|
+
* Google Application Default Credentials}
|
|
26
25
|
* that grants admin access to Firebase services. This credential can be used
|
|
27
|
-
* in the call to
|
|
28
|
-
* {@link
|
|
29
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
30
|
-
* `admin.initializeApp()`}.
|
|
26
|
+
* in the call to {@link firebase-admin.app#initializeApp}.
|
|
31
27
|
*
|
|
32
28
|
* Google Application Default Credentials are available on any Google
|
|
33
29
|
* infrastructure, such as Google App Engine and Google Compute Engine.
|
|
34
30
|
*
|
|
35
31
|
* See
|
|
36
|
-
* {@link
|
|
37
|
-
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
38
|
-
* Initialize the SDK}
|
|
32
|
+
* {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
|
39
33
|
* for more details.
|
|
40
34
|
*
|
|
41
35
|
* @example
|
|
@@ -46,25 +40,20 @@ import { Credential, ServiceAccount } from './credential';
|
|
|
46
40
|
* });
|
|
47
41
|
* ```
|
|
48
42
|
*
|
|
49
|
-
* @param httpAgent Optional
|
|
43
|
+
* @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
|
50
44
|
* to be used when retrieving access tokens from Google token servers.
|
|
51
45
|
*
|
|
52
|
-
* @
|
|
46
|
+
* @returns A credential authenticated via Google
|
|
53
47
|
* Application Default Credentials that can be used to initialize an app.
|
|
54
48
|
*/
|
|
55
49
|
export declare function applicationDefault(httpAgent?: Agent): Credential;
|
|
56
50
|
/**
|
|
57
51
|
* Returns a credential created from the provided service account that grants
|
|
58
52
|
* admin access to Firebase services. This credential can be used in the call
|
|
59
|
-
* to
|
|
60
|
-
* {@link
|
|
61
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
62
|
-
* `admin.initializeApp()`}.
|
|
53
|
+
* to {@link firebase-admin.app#initializeApp}.
|
|
63
54
|
*
|
|
64
55
|
* See
|
|
65
|
-
* {@link
|
|
66
|
-
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
67
|
-
* Initialize the SDK}
|
|
56
|
+
* {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
|
68
57
|
* for more details.
|
|
69
58
|
*
|
|
70
59
|
* @example
|
|
@@ -90,27 +79,22 @@ export declare function applicationDefault(httpAgent?: Agent): Credential;
|
|
|
90
79
|
* });
|
|
91
80
|
* ```
|
|
92
81
|
*
|
|
93
|
-
* @param serviceAccountPathOrObject The path to a service
|
|
82
|
+
* @param serviceAccountPathOrObject - The path to a service
|
|
94
83
|
* account key JSON file or an object representing a service account key.
|
|
95
|
-
* @param httpAgent Optional
|
|
84
|
+
* @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
|
96
85
|
* to be used when retrieving access tokens from Google token servers.
|
|
97
86
|
*
|
|
98
|
-
* @
|
|
87
|
+
* @returns A credential authenticated via the
|
|
99
88
|
* provided service account that can be used to initialize an app.
|
|
100
89
|
*/
|
|
101
90
|
export declare function cert(serviceAccountPathOrObject: string | ServiceAccount, httpAgent?: Agent): Credential;
|
|
102
91
|
/**
|
|
103
92
|
* Returns a credential created from the provided refresh token that grants
|
|
104
93
|
* admin access to Firebase services. This credential can be used in the call
|
|
105
|
-
* to
|
|
106
|
-
* {@link
|
|
107
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
108
|
-
* `admin.initializeApp()`}.
|
|
94
|
+
* to {@link firebase-admin.app#initializeApp}.
|
|
109
95
|
*
|
|
110
96
|
* See
|
|
111
|
-
* {@link
|
|
112
|
-
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
113
|
-
* Initialize the SDK}
|
|
97
|
+
* {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
|
114
98
|
* for more details.
|
|
115
99
|
*
|
|
116
100
|
* @example
|
|
@@ -123,13 +107,13 @@ export declare function cert(serviceAccountPathOrObject: string | ServiceAccount
|
|
|
123
107
|
* });
|
|
124
108
|
* ```
|
|
125
109
|
*
|
|
126
|
-
* @param refreshTokenPathOrObject The path to a Google
|
|
110
|
+
* @param refreshTokenPathOrObject - The path to a Google
|
|
127
111
|
* OAuth2 refresh token JSON file or an object representing a Google OAuth2
|
|
128
112
|
* refresh token.
|
|
129
|
-
* @param httpAgent Optional
|
|
113
|
+
* @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
|
130
114
|
* to be used when retrieving access tokens from Google token servers.
|
|
131
115
|
*
|
|
132
|
-
* @
|
|
116
|
+
* @returns A credential authenticated via the
|
|
133
117
|
* provided service account that can be used to initialize an app.
|
|
134
118
|
*/
|
|
135
119
|
export declare function refreshToken(refreshTokenPathOrObject: string | object, httpAgent?: Agent): Credential;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -24,22 +24,16 @@ var globalCertCreds = {};
|
|
|
24
24
|
var globalRefreshTokenCreds = {};
|
|
25
25
|
/**
|
|
26
26
|
* Returns a credential created from the
|
|
27
|
-
* {@link
|
|
28
|
-
*
|
|
29
|
-
* Google Application Default Credentials}
|
|
27
|
+
* {@link https://developers.google.com/identity/protocols/application-default-credentials |
|
|
28
|
+
* Google Application Default Credentials}
|
|
30
29
|
* that grants admin access to Firebase services. This credential can be used
|
|
31
|
-
* in the call to
|
|
32
|
-
* {@link
|
|
33
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
34
|
-
* `admin.initializeApp()`}.
|
|
30
|
+
* in the call to {@link firebase-admin.app#initializeApp}.
|
|
35
31
|
*
|
|
36
32
|
* Google Application Default Credentials are available on any Google
|
|
37
33
|
* infrastructure, such as Google App Engine and Google Compute Engine.
|
|
38
34
|
*
|
|
39
35
|
* See
|
|
40
|
-
* {@link
|
|
41
|
-
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
42
|
-
* Initialize the SDK}
|
|
36
|
+
* {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
|
43
37
|
* for more details.
|
|
44
38
|
*
|
|
45
39
|
* @example
|
|
@@ -50,10 +44,10 @@ var globalRefreshTokenCreds = {};
|
|
|
50
44
|
* });
|
|
51
45
|
* ```
|
|
52
46
|
*
|
|
53
|
-
* @param httpAgent Optional
|
|
47
|
+
* @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
|
54
48
|
* to be used when retrieving access tokens from Google token servers.
|
|
55
49
|
*
|
|
56
|
-
* @
|
|
50
|
+
* @returns A credential authenticated via Google
|
|
57
51
|
* Application Default Credentials that can be used to initialize an app.
|
|
58
52
|
*/
|
|
59
53
|
function applicationDefault(httpAgent) {
|
|
@@ -66,15 +60,10 @@ exports.applicationDefault = applicationDefault;
|
|
|
66
60
|
/**
|
|
67
61
|
* Returns a credential created from the provided service account that grants
|
|
68
62
|
* admin access to Firebase services. This credential can be used in the call
|
|
69
|
-
* to
|
|
70
|
-
* {@link
|
|
71
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
72
|
-
* `admin.initializeApp()`}.
|
|
63
|
+
* to {@link firebase-admin.app#initializeApp}.
|
|
73
64
|
*
|
|
74
65
|
* See
|
|
75
|
-
* {@link
|
|
76
|
-
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
77
|
-
* Initialize the SDK}
|
|
66
|
+
* {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
|
78
67
|
* for more details.
|
|
79
68
|
*
|
|
80
69
|
* @example
|
|
@@ -100,12 +89,12 @@ exports.applicationDefault = applicationDefault;
|
|
|
100
89
|
* });
|
|
101
90
|
* ```
|
|
102
91
|
*
|
|
103
|
-
* @param serviceAccountPathOrObject The path to a service
|
|
92
|
+
* @param serviceAccountPathOrObject - The path to a service
|
|
104
93
|
* account key JSON file or an object representing a service account key.
|
|
105
|
-
* @param httpAgent Optional
|
|
94
|
+
* @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
|
106
95
|
* to be used when retrieving access tokens from Google token servers.
|
|
107
96
|
*
|
|
108
|
-
* @
|
|
97
|
+
* @returns A credential authenticated via the
|
|
109
98
|
* provided service account that can be used to initialize an app.
|
|
110
99
|
*/
|
|
111
100
|
function cert(serviceAccountPathOrObject, httpAgent) {
|
|
@@ -119,15 +108,10 @@ exports.cert = cert;
|
|
|
119
108
|
/**
|
|
120
109
|
* Returns a credential created from the provided refresh token that grants
|
|
121
110
|
* admin access to Firebase services. This credential can be used in the call
|
|
122
|
-
* to
|
|
123
|
-
* {@link
|
|
124
|
-
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
125
|
-
* `admin.initializeApp()`}.
|
|
111
|
+
* to {@link firebase-admin.app#initializeApp}.
|
|
126
112
|
*
|
|
127
113
|
* See
|
|
128
|
-
* {@link
|
|
129
|
-
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
130
|
-
* Initialize the SDK}
|
|
114
|
+
* {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
|
131
115
|
* for more details.
|
|
132
116
|
*
|
|
133
117
|
* @example
|
|
@@ -140,13 +124,13 @@ exports.cert = cert;
|
|
|
140
124
|
* });
|
|
141
125
|
* ```
|
|
142
126
|
*
|
|
143
|
-
* @param refreshTokenPathOrObject The path to a Google
|
|
127
|
+
* @param refreshTokenPathOrObject - The path to a Google
|
|
144
128
|
* OAuth2 refresh token JSON file or an object representing a Google OAuth2
|
|
145
129
|
* refresh token.
|
|
146
|
-
* @param httpAgent Optional
|
|
130
|
+
* @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
|
147
131
|
* to be used when retrieving access tokens from Google token servers.
|
|
148
132
|
*
|
|
149
|
-
* @
|
|
133
|
+
* @returns A credential authenticated via the
|
|
150
134
|
* provided service account that can be used to initialize an app.
|
|
151
135
|
*/
|
|
152
136
|
function refreshToken(refreshTokenPathOrObject, httpAgent) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google Inc.
|
|
@@ -31,9 +31,9 @@ export declare class ServiceAccountCredential implements Credential {
|
|
|
31
31
|
/**
|
|
32
32
|
* Creates a new ServiceAccountCredential from the given parameters.
|
|
33
33
|
*
|
|
34
|
-
* @param serviceAccountPathOrObject Service account json object or path to a service account json file.
|
|
35
|
-
* @param httpAgent Optional http.Agent to use when calling the remote token server.
|
|
36
|
-
* @param implicit An optinal boolean indicating whether this credential was implicitly discovered from the
|
|
34
|
+
* @param serviceAccountPathOrObject - Service account json object or path to a service account json file.
|
|
35
|
+
* @param httpAgent - Optional http.Agent to use when calling the remote token server.
|
|
36
|
+
* @param implicit - An optinal boolean indicating whether this credential was implicitly discovered from the
|
|
37
37
|
* environment, as opposed to being explicitly specified by the developer.
|
|
38
38
|
*
|
|
39
39
|
* @constructor
|
|
@@ -67,10 +67,11 @@ export declare class RefreshTokenCredential implements Credential {
|
|
|
67
67
|
/**
|
|
68
68
|
* Creates a new RefreshTokenCredential from the given parameters.
|
|
69
69
|
*
|
|
70
|
-
* @param refreshTokenPathOrObject Refresh token json object or path to a refresh token
|
|
71
|
-
*
|
|
72
|
-
* @param
|
|
73
|
-
*
|
|
70
|
+
* @param refreshTokenPathOrObject - Refresh token json object or path to a refresh token
|
|
71
|
+
* (user credentials) json file.
|
|
72
|
+
* @param httpAgent - Optional http.Agent to use when calling the remote token server.
|
|
73
|
+
* @param implicit - An optinal boolean indicating whether this credential was implicitly
|
|
74
|
+
* discovered from the environment, as opposed to being explicitly specified by the developer.
|
|
74
75
|
*
|
|
75
76
|
* @constructor
|
|
76
77
|
*/
|
|
@@ -83,7 +84,7 @@ export declare class RefreshTokenCredential implements Credential {
|
|
|
83
84
|
* instances that were loaded from well-known files or environment variables, rather than being explicitly
|
|
84
85
|
* instantiated.
|
|
85
86
|
*
|
|
86
|
-
* @param credential The credential instance to check.
|
|
87
|
+
* @param credential - The credential instance to check.
|
|
87
88
|
*/
|
|
88
89
|
export declare function isApplicationDefault(credential?: Credential): boolean;
|
|
89
90
|
export declare function getApplicationDefault(httpAgent?: Agent): Credential;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -53,9 +53,9 @@ var ServiceAccountCredential = /** @class */ (function () {
|
|
|
53
53
|
/**
|
|
54
54
|
* Creates a new ServiceAccountCredential from the given parameters.
|
|
55
55
|
*
|
|
56
|
-
* @param serviceAccountPathOrObject Service account json object or path to a service account json file.
|
|
57
|
-
* @param httpAgent Optional http.Agent to use when calling the remote token server.
|
|
58
|
-
* @param implicit An optinal boolean indicating whether this credential was implicitly discovered from the
|
|
56
|
+
* @param serviceAccountPathOrObject - Service account json object or path to a service account json file.
|
|
57
|
+
* @param httpAgent - Optional http.Agent to use when calling the remote token server.
|
|
58
|
+
* @param implicit - An optinal boolean indicating whether this credential was implicitly discovered from the
|
|
59
59
|
* environment, as opposed to being explicitly specified by the developer.
|
|
60
60
|
*
|
|
61
61
|
* @constructor
|
|
@@ -87,6 +87,7 @@ var ServiceAccountCredential = /** @class */ (function () {
|
|
|
87
87
|
};
|
|
88
88
|
return requestAccessToken(this.httpClient, request);
|
|
89
89
|
};
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
90
91
|
ServiceAccountCredential.prototype.createAuthJwt_ = function () {
|
|
91
92
|
var claims = {
|
|
92
93
|
scope: [
|
|
@@ -204,10 +205,11 @@ var RefreshTokenCredential = /** @class */ (function () {
|
|
|
204
205
|
/**
|
|
205
206
|
* Creates a new RefreshTokenCredential from the given parameters.
|
|
206
207
|
*
|
|
207
|
-
* @param refreshTokenPathOrObject Refresh token json object or path to a refresh token
|
|
208
|
-
*
|
|
209
|
-
* @param
|
|
210
|
-
*
|
|
208
|
+
* @param refreshTokenPathOrObject - Refresh token json object or path to a refresh token
|
|
209
|
+
* (user credentials) json file.
|
|
210
|
+
* @param httpAgent - Optional http.Agent to use when calling the remote token server.
|
|
211
|
+
* @param implicit - An optinal boolean indicating whether this credential was implicitly
|
|
212
|
+
* discovered from the environment, as opposed to being explicitly specified by the developer.
|
|
211
213
|
*
|
|
212
214
|
* @constructor
|
|
213
215
|
*/
|
|
@@ -283,7 +285,7 @@ var RefreshToken = /** @class */ (function () {
|
|
|
283
285
|
* instances that were loaded from well-known files or environment variables, rather than being explicitly
|
|
284
286
|
* instantiated.
|
|
285
287
|
*
|
|
286
|
-
* @param credential The credential instance to check.
|
|
288
|
+
* @param credential - The credential instance to check.
|
|
287
289
|
*/
|
|
288
290
|
function isApplicationDefault(credential) {
|
|
289
291
|
return credential instanceof ComputeEngineCredential ||
|
|
@@ -311,10 +313,10 @@ exports.getApplicationDefault = getApplicationDefault;
|
|
|
311
313
|
* If no property exists by the given "key", looks for a property identified by "alt", and copies it instead.
|
|
312
314
|
* This can be used to implement behaviors such as "copy property myKey or my_key".
|
|
313
315
|
*
|
|
314
|
-
* @param to Target object to copy the property into.
|
|
315
|
-
* @param from Source object to copy the property from.
|
|
316
|
-
* @param key Name of the property to copy.
|
|
317
|
-
* @param alt Alternative name of the property to copy.
|
|
316
|
+
* @param to - Target object to copy the property into.
|
|
317
|
+
* @param from - Source object to copy the property from.
|
|
318
|
+
* @param key - Name of the property to copy.
|
|
319
|
+
* @param alt - Alternative name of the property to copy.
|
|
318
320
|
*/
|
|
319
321
|
function copyAttr(to, from, key, alt) {
|
|
320
322
|
var tmp = from[key] || from[alt];
|
package/lib/app/credential.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google Inc.
|
|
@@ -32,20 +32,14 @@ export interface GoogleOAuthAccessToken {
|
|
|
32
32
|
* with Firebase services.
|
|
33
33
|
*
|
|
34
34
|
* In most cases, you will not need to implement this yourself and can instead
|
|
35
|
-
* use the default implementations provided by
|
|
36
|
-
* {@link credential `admin.credential`}.
|
|
35
|
+
* use the default implementations provided by the `firebase-admin/app` module.
|
|
37
36
|
*/
|
|
38
37
|
export interface Credential {
|
|
39
38
|
/**
|
|
40
39
|
* Returns a Google OAuth2 access token object used to authenticate with
|
|
41
40
|
* Firebase services.
|
|
42
41
|
*
|
|
43
|
-
*
|
|
44
|
-
* * `access_token` (`string`): The actual Google OAuth2 access token.
|
|
45
|
-
* * `expires_in` (`number`): The number of seconds from when the token was
|
|
46
|
-
* issued that it expires.
|
|
47
|
-
*
|
|
48
|
-
* @return A Google OAuth2 access token object.
|
|
42
|
+
* @returns A Google OAuth2 access token object.
|
|
49
43
|
*/
|
|
50
44
|
getAccessToken(): Promise<GoogleOAuthAccessToken>;
|
|
51
45
|
}
|
package/lib/app/credential.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google Inc.
|
|
@@ -15,12 +15,7 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { app } from '../firebase-namespace-api';
|
|
19
18
|
import { Credential } from './credential';
|
|
20
|
-
/**
|
|
21
|
-
* Type representing a callback which is called every time an app lifecycle event occurs.
|
|
22
|
-
*/
|
|
23
|
-
export declare type AppHook = (event: string, app: app.App) => void;
|
|
24
19
|
/**
|
|
25
20
|
* Type representing a Firebase OAuth access token (derived from a Google OAuth2 access token) which
|
|
26
21
|
* can be used to authenticate to Firebase services such as the Realtime Database and Auth.
|
|
@@ -34,42 +29,23 @@ export interface FirebaseAccessToken {
|
|
|
34
29
|
*/
|
|
35
30
|
export declare class FirebaseAppInternals {
|
|
36
31
|
private credential_;
|
|
37
|
-
private isDeleted_;
|
|
38
32
|
private cachedToken_;
|
|
39
|
-
private cachedTokenPromise_;
|
|
40
33
|
private tokenListeners_;
|
|
41
|
-
private tokenRefreshTimeout_;
|
|
42
34
|
constructor(credential_: Credential);
|
|
43
|
-
/**
|
|
44
|
-
* Gets an auth token for the associated app.
|
|
45
|
-
*
|
|
46
|
-
* @param {boolean} forceRefresh Whether or not to force a token refresh.
|
|
47
|
-
* @return {Promise<FirebaseAccessToken>} A Promise that will be fulfilled with the current or
|
|
48
|
-
* new token.
|
|
49
|
-
*/
|
|
50
35
|
getToken(forceRefresh?: boolean): Promise<FirebaseAccessToken>;
|
|
36
|
+
getCachedToken(): FirebaseAccessToken | null;
|
|
37
|
+
private refreshToken;
|
|
38
|
+
private shouldRefresh;
|
|
51
39
|
/**
|
|
52
40
|
* Adds a listener that is called each time a token changes.
|
|
53
41
|
*
|
|
54
|
-
* @param
|
|
42
|
+
* @param listener - The listener that will be called with each new token.
|
|
55
43
|
*/
|
|
56
44
|
addAuthTokenListener(listener: (token: string) => void): void;
|
|
57
45
|
/**
|
|
58
46
|
* Removes a token listener.
|
|
59
47
|
*
|
|
60
|
-
* @param
|
|
48
|
+
* @param listener - The listener to remove.
|
|
61
49
|
*/
|
|
62
50
|
removeAuthTokenListener(listener: (token: string) => void): void;
|
|
63
|
-
/**
|
|
64
|
-
* Deletes the FirebaseAppInternals instance.
|
|
65
|
-
*/
|
|
66
|
-
delete(): void;
|
|
67
|
-
/**
|
|
68
|
-
* Establishes timeout to refresh the Google OAuth2 access token used by the SDK.
|
|
69
|
-
*
|
|
70
|
-
* @param {number} delayInMilliseconds The delay to use for the timeout.
|
|
71
|
-
* @param {number} numRetries The number of times to retry fetching a new token if the prior fetch
|
|
72
|
-
* failed.
|
|
73
|
-
*/
|
|
74
|
-
private setTokenRefreshTimeout;
|
|
75
51
|
}
|