firebase-admin 10.0.2 → 10.3.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.
Files changed (194) hide show
  1. package/README.md +2 -1
  2. package/lib/app/core.d.ts +1 -1
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +1 -1
  5. package/lib/app/credential-factory.js +1 -1
  6. package/lib/app/credential-internal.d.ts +3 -1
  7. package/lib/app/credential-internal.js +18 -1
  8. package/lib/app/credential.d.ts +1 -1
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +1 -1
  11. package/lib/app/firebase-app.js +1 -1
  12. package/lib/app/firebase-namespace.d.ts +1 -1
  13. package/lib/app/firebase-namespace.js +1 -1
  14. package/lib/app/index.d.ts +1 -1
  15. package/lib/app/index.js +1 -1
  16. package/lib/app/lifecycle.d.ts +1 -1
  17. package/lib/app/lifecycle.js +1 -1
  18. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  19. package/lib/app-check/app-check-api-client-internal.js +3 -3
  20. package/lib/app-check/app-check-api.d.ts +1 -1
  21. package/lib/app-check/app-check-api.js +1 -1
  22. package/lib/app-check/app-check-namespace.d.ts +1 -1
  23. package/lib/app-check/app-check-namespace.js +1 -1
  24. package/lib/app-check/app-check.d.ts +1 -1
  25. package/lib/app-check/app-check.js +1 -1
  26. package/lib/app-check/index.d.ts +1 -1
  27. package/lib/app-check/index.js +1 -1
  28. package/lib/app-check/token-generator.d.ts +1 -1
  29. package/lib/app-check/token-generator.js +2 -2
  30. package/lib/app-check/token-verifier.d.ts +1 -1
  31. package/lib/app-check/token-verifier.js +2 -2
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +1 -1
  34. package/lib/auth/auth-api-request.d.ts +1 -1
  35. package/lib/auth/auth-api-request.js +24 -4
  36. package/lib/auth/auth-config.d.ts +1 -1
  37. package/lib/auth/auth-config.js +1 -1
  38. package/lib/auth/auth-namespace.d.ts +4 -2
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +1 -1
  41. package/lib/auth/auth.js +1 -1
  42. package/lib/auth/base-auth.d.ts +29 -2
  43. package/lib/auth/base-auth.js +38 -1
  44. package/lib/auth/identifier.d.ts +1 -1
  45. package/lib/auth/identifier.js +1 -1
  46. package/lib/auth/index.d.ts +2 -2
  47. package/lib/auth/index.js +1 -1
  48. package/lib/auth/tenant-manager.d.ts +1 -1
  49. package/lib/auth/tenant-manager.js +1 -1
  50. package/lib/auth/tenant.d.ts +1 -1
  51. package/lib/auth/tenant.js +1 -1
  52. package/lib/auth/token-generator.d.ts +1 -1
  53. package/lib/auth/token-generator.js +1 -1
  54. package/lib/auth/token-verifier.d.ts +70 -1
  55. package/lib/auth/token-verifier.js +54 -7
  56. package/lib/auth/user-import-builder.d.ts +1 -1
  57. package/lib/auth/user-import-builder.js +1 -1
  58. package/lib/auth/user-record.d.ts +1 -1
  59. package/lib/auth/user-record.js +1 -1
  60. package/lib/credential/index.d.ts +1 -1
  61. package/lib/credential/index.js +1 -1
  62. package/lib/database/database-namespace.d.ts +1 -1
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +1 -1
  65. package/lib/database/database.js +1 -1
  66. package/lib/database/index.d.ts +1 -1
  67. package/lib/database/index.js +1 -1
  68. package/lib/default-namespace.d.ts +1 -1
  69. package/lib/default-namespace.js +1 -1
  70. package/lib/esm/eventarc/index.js +5 -0
  71. package/lib/esm/functions/index.js +5 -0
  72. package/lib/eventarc/cloudevent.d.ts +84 -0
  73. package/lib/eventarc/cloudevent.js +19 -0
  74. package/lib/eventarc/eventarc-client-internal.d.ts +18 -0
  75. package/lib/eventarc/eventarc-client-internal.js +205 -0
  76. package/lib/eventarc/eventarc-utils.d.ts +31 -0
  77. package/lib/eventarc/eventarc-utils.js +141 -0
  78. package/lib/eventarc/eventarc.d.ts +107 -0
  79. package/lib/eventarc/eventarc.js +139 -0
  80. package/lib/eventarc/index.d.ts +53 -0
  81. package/lib/eventarc/index.js +64 -0
  82. package/lib/firebase-namespace-api.d.ts +1 -1
  83. package/lib/firebase-namespace-api.js +1 -1
  84. package/lib/firestore/firestore-internal.d.ts +1 -1
  85. package/lib/firestore/firestore-internal.js +1 -1
  86. package/lib/firestore/firestore-namespace.d.ts +1 -1
  87. package/lib/firestore/firestore-namespace.js +1 -1
  88. package/lib/firestore/index.d.ts +1 -1
  89. package/lib/firestore/index.js +1 -1
  90. package/lib/functions/functions-api-client-internal.d.ts +32 -0
  91. package/lib/functions/functions-api-client-internal.js +279 -0
  92. package/lib/functions/functions-api.d.ts +67 -0
  93. package/lib/functions/functions-api.js +19 -0
  94. package/lib/functions/functions.d.ts +63 -0
  95. package/lib/functions/functions.js +99 -0
  96. package/lib/functions/index.d.ts +53 -0
  97. package/lib/functions/index.js +64 -0
  98. package/lib/index.d.ts +1 -1
  99. package/lib/index.js +1 -1
  100. package/lib/installations/index.d.ts +1 -1
  101. package/lib/installations/index.js +1 -1
  102. package/lib/installations/installations-namespace.d.ts +1 -1
  103. package/lib/installations/installations-namespace.js +1 -1
  104. package/lib/installations/installations-request-handler.d.ts +1 -1
  105. package/lib/installations/installations-request-handler.js +1 -1
  106. package/lib/installations/installations.d.ts +1 -1
  107. package/lib/installations/installations.js +1 -1
  108. package/lib/instance-id/index.d.ts +1 -1
  109. package/lib/instance-id/index.js +1 -1
  110. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  111. package/lib/instance-id/instance-id-namespace.js +1 -1
  112. package/lib/instance-id/instance-id.d.ts +1 -1
  113. package/lib/instance-id/instance-id.js +1 -1
  114. package/lib/machine-learning/index.d.ts +1 -1
  115. package/lib/machine-learning/index.js +1 -1
  116. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  117. package/lib/machine-learning/machine-learning-api-client.js +1 -1
  118. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  119. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  120. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  121. package/lib/machine-learning/machine-learning-utils.js +1 -1
  122. package/lib/machine-learning/machine-learning.d.ts +1 -1
  123. package/lib/machine-learning/machine-learning.js +1 -1
  124. package/lib/messaging/batch-request-internal.d.ts +1 -1
  125. package/lib/messaging/batch-request-internal.js +1 -1
  126. package/lib/messaging/index.d.ts +1 -1
  127. package/lib/messaging/index.js +1 -1
  128. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  129. package/lib/messaging/messaging-api-request-internal.js +1 -1
  130. package/lib/messaging/messaging-api.d.ts +1 -1
  131. package/lib/messaging/messaging-api.js +1 -1
  132. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  133. package/lib/messaging/messaging-errors-internal.js +1 -1
  134. package/lib/messaging/messaging-internal.d.ts +1 -1
  135. package/lib/messaging/messaging-internal.js +1 -1
  136. package/lib/messaging/messaging-namespace.d.ts +1 -1
  137. package/lib/messaging/messaging-namespace.js +1 -1
  138. package/lib/messaging/messaging.d.ts +1 -1
  139. package/lib/messaging/messaging.js +1 -1
  140. package/lib/project-management/android-app.d.ts +1 -1
  141. package/lib/project-management/android-app.js +1 -1
  142. package/lib/project-management/app-metadata.d.ts +1 -1
  143. package/lib/project-management/app-metadata.js +1 -1
  144. package/lib/project-management/index.d.ts +1 -1
  145. package/lib/project-management/index.js +1 -1
  146. package/lib/project-management/ios-app.d.ts +1 -1
  147. package/lib/project-management/ios-app.js +1 -1
  148. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  149. package/lib/project-management/project-management-api-request-internal.js +1 -1
  150. package/lib/project-management/project-management-namespace.d.ts +1 -1
  151. package/lib/project-management/project-management-namespace.js +1 -1
  152. package/lib/project-management/project-management.d.ts +1 -1
  153. package/lib/project-management/project-management.js +1 -1
  154. package/lib/remote-config/index.d.ts +1 -1
  155. package/lib/remote-config/index.js +1 -1
  156. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  157. package/lib/remote-config/remote-config-api-client-internal.js +1 -1
  158. package/lib/remote-config/remote-config-api.d.ts +1 -1
  159. package/lib/remote-config/remote-config-api.js +1 -1
  160. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  161. package/lib/remote-config/remote-config-namespace.js +1 -1
  162. package/lib/remote-config/remote-config.d.ts +1 -1
  163. package/lib/remote-config/remote-config.js +1 -1
  164. package/lib/security-rules/index.d.ts +1 -1
  165. package/lib/security-rules/index.js +1 -1
  166. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  167. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  168. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  169. package/lib/security-rules/security-rules-internal.js +1 -1
  170. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  171. package/lib/security-rules/security-rules-namespace.js +1 -1
  172. package/lib/security-rules/security-rules.d.ts +1 -1
  173. package/lib/security-rules/security-rules.js +1 -1
  174. package/lib/storage/index.d.ts +1 -1
  175. package/lib/storage/index.js +1 -1
  176. package/lib/storage/storage-namespace.d.ts +1 -1
  177. package/lib/storage/storage-namespace.js +1 -1
  178. package/lib/storage/storage.d.ts +1 -1
  179. package/lib/storage/storage.js +1 -1
  180. package/lib/utils/api-request.d.ts +1 -1
  181. package/lib/utils/api-request.js +3 -3
  182. package/lib/utils/crypto-signer.d.ts +1 -1
  183. package/lib/utils/crypto-signer.js +1 -1
  184. package/lib/utils/deep-copy.d.ts +1 -1
  185. package/lib/utils/deep-copy.js +1 -1
  186. package/lib/utils/error.d.ts +9 -1
  187. package/lib/utils/error.js +11 -1
  188. package/lib/utils/index.d.ts +43 -1
  189. package/lib/utils/index.js +72 -2
  190. package/lib/utils/jwt.d.ts +1 -1
  191. package/lib/utils/jwt.js +1 -1
  192. package/lib/utils/validator.d.ts +1 -1
  193. package/lib/utils/validator.js +1 -1
  194. package/package.json +44 -12
@@ -0,0 +1,31 @@
1
+ /*! firebase-admin v10.3.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2022 Google Inc.
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
+ import { PrefixedFirebaseError } from '../utils/error';
19
+ import { CloudEvent } from './cloudevent';
20
+ export declare type EventarcErrorCode = 'unknown-error' | 'invalid-argument';
21
+ /**
22
+ * Firebase Eventarc error code structure. This extends PrefixedFirebaseError.
23
+ *
24
+ * @param code - The error code.
25
+ * @param message - The error message.
26
+ * @constructor
27
+ */
28
+ export declare class FirebaseEventarcError extends PrefixedFirebaseError {
29
+ constructor(code: EventarcErrorCode, message: string);
30
+ }
31
+ export declare function toCloudEventProtoFormat(ce: CloudEvent): any;
@@ -0,0 +1,141 @@
1
+ /*! firebase-admin v10.3.0 */
2
+ "use strict";
3
+ /*!
4
+ * @license
5
+ * Copyright 2022 Google Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ var __extends = (this && this.__extends) || (function () {
20
+ var extendStatics = function (d, b) {
21
+ extendStatics = Object.setPrototypeOf ||
22
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24
+ return extendStatics(d, b);
25
+ };
26
+ return function (d, b) {
27
+ extendStatics(d, b);
28
+ function __() { this.constructor = d; }
29
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
+ };
31
+ })();
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.toCloudEventProtoFormat = exports.FirebaseEventarcError = void 0;
34
+ var error_1 = require("../utils/error");
35
+ var uuid_1 = require("uuid");
36
+ var validator = require("../utils/validator");
37
+ // List of CloudEvent properties that are handled "by hand" and should be skipped by
38
+ // automatic attribute copy.
39
+ var TOP_LEVEL_CE_ATTRS = ['id', 'type', 'specversion', 'source', 'data', 'time', 'datacontenttype', 'subject'];
40
+ /**
41
+ * Firebase Eventarc error code structure. This extends PrefixedFirebaseError.
42
+ *
43
+ * @param code - The error code.
44
+ * @param message - The error message.
45
+ * @constructor
46
+ */
47
+ var FirebaseEventarcError = /** @class */ (function (_super) {
48
+ __extends(FirebaseEventarcError, _super);
49
+ function FirebaseEventarcError(code, message) {
50
+ return _super.call(this, 'eventarc', code, message) || this;
51
+ }
52
+ return FirebaseEventarcError;
53
+ }(error_1.PrefixedFirebaseError));
54
+ exports.FirebaseEventarcError = FirebaseEventarcError;
55
+ function toCloudEventProtoFormat(ce) {
56
+ var _a, _b, _c;
57
+ var source = (_a = ce.source) !== null && _a !== void 0 ? _a : process.env.EVENTARC_CLOUD_EVENT_SOURCE;
58
+ if (typeof source === 'undefined' || !validator.isNonEmptyString(source)) {
59
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent 'source' is required.");
60
+ }
61
+ if (!validator.isNonEmptyString(ce.type)) {
62
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent 'type' is required.");
63
+ }
64
+ var out = {
65
+ '@type': 'type.googleapis.com/io.cloudevents.v1.CloudEvent',
66
+ 'id': (_b = ce.id) !== null && _b !== void 0 ? _b : uuid_1.v4(),
67
+ 'type': ce.type,
68
+ 'specVersion': (_c = ce.specversion) !== null && _c !== void 0 ? _c : '1.0',
69
+ 'source': source
70
+ };
71
+ if (typeof ce.time !== 'undefined') {
72
+ if (!validator.isISODateString(ce.time)) {
73
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent 'tyme' must be in ISO date format.");
74
+ }
75
+ setAttribute(out, 'time', {
76
+ 'ceTimestamp': ce.time
77
+ });
78
+ }
79
+ else {
80
+ setAttribute(out, 'time', {
81
+ 'ceTimestamp': new Date().toISOString()
82
+ });
83
+ }
84
+ if (typeof ce.datacontenttype !== 'undefined') {
85
+ if (!validator.isNonEmptyString(ce.datacontenttype)) {
86
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent 'datacontenttype' if specified must be non-empty string.");
87
+ }
88
+ setAttribute(out, 'datacontenttype', {
89
+ 'ceString': ce.datacontenttype
90
+ });
91
+ }
92
+ if (ce.subject) {
93
+ if (!validator.isNonEmptyString(ce.subject)) {
94
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent 'subject' if specified must be non-empty string.");
95
+ }
96
+ setAttribute(out, 'subject', {
97
+ 'ceString': ce.subject
98
+ });
99
+ }
100
+ if (typeof ce.data === 'undefined') {
101
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent 'data' is required.");
102
+ }
103
+ if (validator.isObject(ce.data)) {
104
+ out['textData'] = JSON.stringify(ce.data);
105
+ if (!ce.datacontenttype) {
106
+ setAttribute(out, 'datacontenttype', {
107
+ 'ceString': 'application/json'
108
+ });
109
+ }
110
+ }
111
+ else if (validator.isNonEmptyString(ce.data)) {
112
+ out['textData'] = ce.data;
113
+ if (!ce.datacontenttype) {
114
+ setAttribute(out, 'datacontenttype', {
115
+ 'ceString': 'text/plain'
116
+ });
117
+ }
118
+ }
119
+ else {
120
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent 'data' must be string or an object (which are converted to JSON), got '" + typeof ce.data + "'.");
121
+ }
122
+ for (var attr in ce) {
123
+ if (TOP_LEVEL_CE_ATTRS.includes(attr)) {
124
+ continue;
125
+ }
126
+ if (!validator.isNonEmptyString(ce[attr])) {
127
+ throw new FirebaseEventarcError('invalid-argument', "CloudEvent extension attributes ('" + attr + "') must be string.");
128
+ }
129
+ setAttribute(out, attr, {
130
+ 'ceString': ce[attr]
131
+ });
132
+ }
133
+ return out;
134
+ }
135
+ exports.toCloudEventProtoFormat = toCloudEventProtoFormat;
136
+ function setAttribute(event, attr, value) {
137
+ if (!Object.prototype.hasOwnProperty.call(event, 'attributes')) {
138
+ event.attributes = {};
139
+ }
140
+ event['attributes'][attr] = value;
141
+ }
@@ -0,0 +1,107 @@
1
+ /*! firebase-admin v10.3.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2022 Google Inc.
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
+ import { App } from '../app';
19
+ import { CloudEvent } from './cloudevent';
20
+ /**
21
+ * Channel options interface.
22
+ */
23
+ export interface ChannelOptions {
24
+ /**
25
+ * An array of allowed event types. If specified, publishing events of
26
+ * unknown types is a no op. When not provided, no event filtering is
27
+ * performed.
28
+ */
29
+ allowedEventTypes?: string[] | string | undefined;
30
+ }
31
+ /**
32
+ * Eventarc service bound to the provided app.
33
+ */
34
+ export declare class Eventarc {
35
+ private readonly appInternal;
36
+ /**
37
+ * The {@link firebase-admin.app#App} associated with the current Eventarc service
38
+ * instance.
39
+ *
40
+ * @example
41
+ * ```javascript
42
+ * var app = eventarc.app;
43
+ * ```
44
+ */
45
+ get app(): App;
46
+ /**
47
+ * Creates a reference to the Eventarc channel using the provided channel resource name.
48
+ * The channel resource name can be either:
49
+ *
50
+ * - A fully qualified channel resource name:
51
+ * `projects/{project}/locations/{location}/channels/{channel-id}`
52
+ *
53
+ * - A partial resource name with location and channel ID, in which case
54
+ * the runtime project ID of the function is used:
55
+ * `locations/{location}/channels/{channel-id}`
56
+ *
57
+ * - A partial channel ID, in which case the runtime project ID of the
58
+ * function and `us-central1` as location is used:
59
+ * `{channel-id}`
60
+ *
61
+ * @param name - Channel resource name.
62
+ * @param options - (optional) additional channel options
63
+ * @returns An Eventarc channel reference for publishing events.
64
+ */
65
+ channel(name: string, options?: ChannelOptions): Channel;
66
+ /**
67
+ * Create a reference to the default Firebase channel:
68
+ * `locations/us-central1/channels/firebase`
69
+ *
70
+ * @param options - (optional) additional channel options
71
+ * @returns Eventarc channel reference for publishing events.
72
+ */
73
+ channel(options?: ChannelOptions): Channel;
74
+ }
75
+ /**
76
+ * Eventarc Channel.
77
+ */
78
+ export declare class Channel {
79
+ private readonly eventarcInternal;
80
+ private nameInternal;
81
+ /**
82
+ * List of event types allowed by this channel for publishing. Other event types are ignored.
83
+ */
84
+ readonly allowedEventTypes?: string[];
85
+ private readonly client;
86
+ /**
87
+ * The {@link firebase-admin.eventarc#Eventarc} service instance associated with the current `Channel`.
88
+ *
89
+ * @example
90
+ * ```javascript
91
+ * var app = channel.eventarc;
92
+ * ```
93
+ */
94
+ get eventarc(): Eventarc;
95
+ /**
96
+ * The channel name as provided during channel creation. If it was not specifed, the default channel name is returned
97
+ * ('locations/us-central1/channels/firebase').
98
+ */
99
+ get name(): string;
100
+ /**
101
+ * Publishes provided events to this channel. If channel was created with `allowedEventTypes` and event type is not
102
+ * on that list, the event is ignored.
103
+ *
104
+ * @param events - CloudEvent to publish to the channel.
105
+ */
106
+ publish(events: CloudEvent | CloudEvent[]): Promise<void>;
107
+ }
@@ -0,0 +1,139 @@
1
+ /*! firebase-admin v10.3.0 */
2
+ "use strict";
3
+ /*!
4
+ * @license
5
+ * Copyright 2022 Google Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Channel = exports.Eventarc = void 0;
21
+ var validator = require("../utils/validator");
22
+ var eventarc_utils_1 = require("./eventarc-utils");
23
+ var eventarc_client_internal_1 = require("./eventarc-client-internal");
24
+ /**
25
+ * Eventarc service bound to the provided app.
26
+ */
27
+ var Eventarc = /** @class */ (function () {
28
+ /**
29
+ * @internal
30
+ */
31
+ function Eventarc(app) {
32
+ if (!validator.isNonNullObject(app) || !('options' in app)) {
33
+ throw new eventarc_utils_1.FirebaseEventarcError('invalid-argument', 'First argument passed to Eventarc() must be a valid Firebase app instance.');
34
+ }
35
+ this.appInternal = app;
36
+ }
37
+ Object.defineProperty(Eventarc.prototype, "app", {
38
+ /**
39
+ * The {@link firebase-admin.app#App} associated with the current Eventarc service
40
+ * instance.
41
+ *
42
+ * @example
43
+ * ```javascript
44
+ * var app = eventarc.app;
45
+ * ```
46
+ */
47
+ get: function () {
48
+ return this.appInternal;
49
+ },
50
+ enumerable: false,
51
+ configurable: true
52
+ });
53
+ Eventarc.prototype.channel = function (nameOrOptions, options) {
54
+ var channel;
55
+ var opts;
56
+ if (validator.isNonEmptyString(nameOrOptions)) {
57
+ channel = nameOrOptions;
58
+ }
59
+ else {
60
+ channel = 'locations/us-central1/channels/firebase';
61
+ }
62
+ if (validator.isNonNullObject(nameOrOptions)) {
63
+ opts = nameOrOptions;
64
+ }
65
+ else {
66
+ opts = options;
67
+ }
68
+ var allowedEventTypes = undefined;
69
+ if (typeof (opts === null || opts === void 0 ? void 0 : opts.allowedEventTypes) === 'string') {
70
+ allowedEventTypes = opts.allowedEventTypes.split(',');
71
+ }
72
+ else if (validator.isArray(opts === null || opts === void 0 ? void 0 : opts.allowedEventTypes)) {
73
+ allowedEventTypes = opts === null || opts === void 0 ? void 0 : opts.allowedEventTypes;
74
+ }
75
+ else if (typeof (opts === null || opts === void 0 ? void 0 : opts.allowedEventTypes) !== 'undefined') {
76
+ throw new eventarc_utils_1.FirebaseEventarcError('invalid-argument', 'AllowedEventTypes must be either an array of strings or a comma separated string.');
77
+ }
78
+ return new Channel(this, channel, allowedEventTypes);
79
+ };
80
+ return Eventarc;
81
+ }());
82
+ exports.Eventarc = Eventarc;
83
+ /**
84
+ * Eventarc Channel.
85
+ */
86
+ var Channel = /** @class */ (function () {
87
+ /**
88
+ * @internal
89
+ */
90
+ function Channel(eventarc, name, allowedEventTypes) {
91
+ if (!validator.isNonNullObject(eventarc)) {
92
+ throw new eventarc_utils_1.FirebaseEventarcError('invalid-argument', 'First argument passed to Channel() must be a valid Eventarc service instance.');
93
+ }
94
+ if (!validator.isNonEmptyString(name)) {
95
+ throw new eventarc_utils_1.FirebaseEventarcError('invalid-argument', 'name is required.');
96
+ }
97
+ this.nameInternal = name;
98
+ this.eventarcInternal = eventarc;
99
+ this.allowedEventTypes = allowedEventTypes;
100
+ this.client = new eventarc_client_internal_1.EventarcApiClient(eventarc.app, this);
101
+ }
102
+ Object.defineProperty(Channel.prototype, "eventarc", {
103
+ /**
104
+ * The {@link firebase-admin.eventarc#Eventarc} service instance associated with the current `Channel`.
105
+ *
106
+ * @example
107
+ * ```javascript
108
+ * var app = channel.eventarc;
109
+ * ```
110
+ */
111
+ get: function () {
112
+ return this.eventarcInternal;
113
+ },
114
+ enumerable: false,
115
+ configurable: true
116
+ });
117
+ Object.defineProperty(Channel.prototype, "name", {
118
+ /**
119
+ * The channel name as provided during channel creation. If it was not specifed, the default channel name is returned
120
+ * ('locations/us-central1/channels/firebase').
121
+ */
122
+ get: function () {
123
+ return this.nameInternal;
124
+ },
125
+ enumerable: false,
126
+ configurable: true
127
+ });
128
+ /**
129
+ * Publishes provided events to this channel. If channel was created with `allowedEventTypes` and event type is not
130
+ * on that list, the event is ignored.
131
+ *
132
+ * @param events - CloudEvent to publish to the channel.
133
+ */
134
+ Channel.prototype.publish = function (events) {
135
+ return this.client.publish(events);
136
+ };
137
+ return Channel;
138
+ }());
139
+ exports.Channel = Channel;
@@ -0,0 +1,53 @@
1
+ /*! firebase-admin v10.3.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2022 Google Inc.
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
+ /**
19
+ * Firebase Eventarc.
20
+ *
21
+ * @packageDocumentation
22
+ */
23
+ import { App } from '../app';
24
+ import { Eventarc } from './eventarc';
25
+ export { CloudEvent, CloudEventVersion } from './cloudevent';
26
+ export { Eventarc, Channel, ChannelOptions } from './eventarc';
27
+ /**
28
+ * Gets the {@link Eventarc} service for the default app or a given app.
29
+ *
30
+ * `getEventarc()` can be called with no arguments to access the default
31
+ * app's `Eventarc` service or as `getEventarc(app)` to access the
32
+ * `Eventarc` service associated with specific app.
33
+ *
34
+ * @example
35
+ * ```javascript
36
+ * // Get the Eventarc service for the default app
37
+ * const defaultEventarc = getEventarc();
38
+ * ```
39
+ *
40
+ * @example
41
+ * ```javascript
42
+ * // Get the Eventarc service for a given app
43
+ * const otherEventarc = getEventarc(otherApp);
44
+ * ```
45
+ *
46
+ * @param app - Optional app whose `Eventarc` service will be returned.
47
+ * If not provided, the default `Eventarc` service will be returned.
48
+ *
49
+ * @returns The default `Eventarc` service if no
50
+ * app is provided or the `Eventarc` service associated with the provided
51
+ * app.
52
+ */
53
+ export declare function getEventarc(app?: App): Eventarc;
@@ -0,0 +1,64 @@
1
+ /*! firebase-admin v10.3.0 */
2
+ "use strict";
3
+ /*!
4
+ * @license
5
+ * Copyright 2022 Google Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getEventarc = void 0;
21
+ /**
22
+ * Firebase Eventarc.
23
+ *
24
+ * @packageDocumentation
25
+ */
26
+ var app_1 = require("../app");
27
+ var eventarc_1 = require("./eventarc");
28
+ var eventarc_2 = require("./eventarc");
29
+ Object.defineProperty(exports, "Eventarc", { enumerable: true, get: function () { return eventarc_2.Eventarc; } });
30
+ Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return eventarc_2.Channel; } });
31
+ /**
32
+ * Gets the {@link Eventarc} service for the default app or a given app.
33
+ *
34
+ * `getEventarc()` can be called with no arguments to access the default
35
+ * app's `Eventarc` service or as `getEventarc(app)` to access the
36
+ * `Eventarc` service associated with specific app.
37
+ *
38
+ * @example
39
+ * ```javascript
40
+ * // Get the Eventarc service for the default app
41
+ * const defaultEventarc = getEventarc();
42
+ * ```
43
+ *
44
+ * @example
45
+ * ```javascript
46
+ * // Get the Eventarc service for a given app
47
+ * const otherEventarc = getEventarc(otherApp);
48
+ * ```
49
+ *
50
+ * @param app - Optional app whose `Eventarc` service will be returned.
51
+ * If not provided, the default `Eventarc` service will be returned.
52
+ *
53
+ * @returns The default `Eventarc` service if no
54
+ * app is provided or the `Eventarc` service associated with the provided
55
+ * app.
56
+ */
57
+ function getEventarc(app) {
58
+ if (typeof app === 'undefined') {
59
+ app = app_1.getApp();
60
+ }
61
+ var firebaseApp = app;
62
+ return firebaseApp.getOrInitService('eventarc', function (app) { return new eventarc_1.Eventarc(app); });
63
+ }
64
+ exports.getEventarc = getEventarc;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.0.2 */
1
+ /*! firebase-admin v10.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -0,0 +1,32 @@
1
+ /*! firebase-admin v10.3.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2021 Google Inc.
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
+ import { PrefixedFirebaseError } from '../utils/error';
19
+ export declare const FUNCTIONS_ERROR_CODE_MAPPING: {
20
+ [key: string]: FunctionsErrorCode;
21
+ };
22
+ export declare type FunctionsErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'failed-precondition' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'unknown-error';
23
+ /**
24
+ * Firebase Functions 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 FirebaseFunctionsError extends PrefixedFirebaseError {
31
+ constructor(code: FunctionsErrorCode, message: string);
32
+ }