@depup/firebase__remote-config 0.8.1-depup.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 +31 -0
- package/changes.json +10 -0
- package/dist/esm/index.esm.js +2199 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/src/abt/experiment.d.ts +13 -0
- package/dist/esm/src/api.d.ts +144 -0
- package/dist/esm/src/api2.d.ts +40 -0
- package/dist/esm/src/client/caching_client.d.ts +46 -0
- package/dist/esm/src/client/eventEmitter.d.ts +39 -0
- package/dist/esm/src/client/realtime_handler.d.ts +141 -0
- package/dist/esm/src/client/remote_config_fetch_client.d.ts +104 -0
- package/dist/esm/src/client/rest_client.d.ts +41 -0
- package/dist/esm/src/client/retrying_client.d.ts +50 -0
- package/dist/esm/src/client/visibility_monitor.d.ts +23 -0
- package/dist/esm/src/constants.d.ts +20 -0
- package/dist/esm/src/errors.d.ts +87 -0
- package/dist/esm/src/index.d.ts +14 -0
- package/dist/esm/src/language.d.ts +26 -0
- package/dist/esm/src/public_types.d.ts +274 -0
- package/dist/esm/src/register.d.ts +2 -0
- package/dist/esm/src/remote_config.d.ts +98 -0
- package/dist/esm/src/storage/storage.d.ts +118 -0
- package/dist/esm/src/storage/storage_cache.d.ts +51 -0
- package/dist/esm/src/value.d.ts +26 -0
- package/dist/esm/test/setup.d.ts +17 -0
- package/dist/index.cjs.js +2216 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/remote-config-public.d.ts +441 -0
- package/dist/remote-config.d.ts +441 -0
- package/dist/src/abt/experiment.d.ts +13 -0
- package/dist/src/api.d.ts +144 -0
- package/dist/src/api2.d.ts +40 -0
- package/dist/src/client/caching_client.d.ts +46 -0
- package/dist/src/client/eventEmitter.d.ts +39 -0
- package/dist/src/client/realtime_handler.d.ts +141 -0
- package/dist/src/client/remote_config_fetch_client.d.ts +104 -0
- package/dist/src/client/rest_client.d.ts +41 -0
- package/dist/src/client/retrying_client.d.ts +50 -0
- package/dist/src/client/visibility_monitor.d.ts +23 -0
- package/dist/src/constants.d.ts +20 -0
- package/dist/src/errors.d.ts +87 -0
- package/dist/src/global_index.d.ts +674 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/language.d.ts +26 -0
- package/dist/src/public_types.d.ts +274 -0
- package/dist/src/register.d.ts +2 -0
- package/dist/src/remote_config.d.ts +98 -0
- package/dist/src/storage/storage.d.ts +118 -0
- package/dist/src/storage/storage_cache.d.ts +51 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/value.d.ts +26 -0
- package/dist/test/setup.d.ts +17 -0
- package/package.json +93 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 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 { StorageCache } from '../storage/storage_cache';
|
|
18
|
+
import { FetchResponse } from '../public_types';
|
|
19
|
+
import { RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
|
|
20
|
+
import { Storage } from '../storage/storage';
|
|
21
|
+
import { Logger } from '@firebase/logger';
|
|
22
|
+
/**
|
|
23
|
+
* Implements the {@link RemoteConfigClient} abstraction with success response caching.
|
|
24
|
+
*
|
|
25
|
+
* <p>Comparable to the browser's Cache API for responses, but the Cache API requires a Service
|
|
26
|
+
* Worker, which requires HTTPS, which would significantly complicate SDK installation. Also, the
|
|
27
|
+
* Cache API doesn't support matching entries by time.
|
|
28
|
+
*/
|
|
29
|
+
export declare class CachingClient implements RemoteConfigFetchClient {
|
|
30
|
+
private readonly client;
|
|
31
|
+
private readonly storage;
|
|
32
|
+
private readonly storageCache;
|
|
33
|
+
private readonly logger;
|
|
34
|
+
constructor(client: RemoteConfigFetchClient, storage: Storage, storageCache: StorageCache, logger: Logger);
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if the age of the cached fetched configs is less than or equal to
|
|
37
|
+
* {@link Settings#minimumFetchIntervalInSeconds}.
|
|
38
|
+
*
|
|
39
|
+
* <p>This is comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the
|
|
40
|
+
* native Fetch API.
|
|
41
|
+
*
|
|
42
|
+
* <p>Visible for testing.
|
|
43
|
+
*/
|
|
44
|
+
isCachedDataFresh(cacheMaxAgeMillis: number, lastSuccessfulFetchTimestampMillis: number | undefined): boolean;
|
|
45
|
+
fetch(request: FetchRequest): Promise<FetchResponse>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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
|
+
/**
|
|
18
|
+
* Base class to be used if you want to emit events. Call the constructor with
|
|
19
|
+
* the set of allowed event names.
|
|
20
|
+
*/
|
|
21
|
+
export declare abstract class EventEmitter {
|
|
22
|
+
private allowedEvents_;
|
|
23
|
+
private listeners_;
|
|
24
|
+
constructor(allowedEvents_: string[]);
|
|
25
|
+
/**
|
|
26
|
+
* To be overridden by derived classes in order to fire an initial event when
|
|
27
|
+
* somebody subscribes for data.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Array.<*>} Array of parameters to trigger initial event with.
|
|
30
|
+
*/
|
|
31
|
+
abstract getInitialEvent(eventType: string): unknown[];
|
|
32
|
+
/**
|
|
33
|
+
* To be called by derived classes to trigger events.
|
|
34
|
+
*/
|
|
35
|
+
protected trigger(eventType: string, ...varArgs: unknown[]): void;
|
|
36
|
+
on(eventType: string, callback: (a: unknown) => void, context: unknown): void;
|
|
37
|
+
off(eventType: string, callback: (a: unknown) => void, context: unknown): void;
|
|
38
|
+
private validateEventType_;
|
|
39
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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 { _FirebaseInstallationsInternal } from '@firebase/installations';
|
|
18
|
+
import { Logger } from '@firebase/logger';
|
|
19
|
+
import { ConfigUpdateObserver } from '../public_types';
|
|
20
|
+
import { Storage } from '../storage/storage';
|
|
21
|
+
import { StorageCache } from '../storage/storage_cache';
|
|
22
|
+
import { CachingClient } from './caching_client';
|
|
23
|
+
export declare class RealtimeHandler {
|
|
24
|
+
private readonly firebaseInstallations;
|
|
25
|
+
private readonly storage;
|
|
26
|
+
private readonly sdkVersion;
|
|
27
|
+
private readonly namespace;
|
|
28
|
+
private readonly projectId;
|
|
29
|
+
private readonly apiKey;
|
|
30
|
+
private readonly appId;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
private readonly storageCache;
|
|
33
|
+
private readonly cachingClient;
|
|
34
|
+
constructor(firebaseInstallations: _FirebaseInstallationsInternal, storage: Storage, sdkVersion: string, namespace: string, projectId: string, apiKey: string, appId: string, logger: Logger, storageCache: StorageCache, cachingClient: CachingClient);
|
|
35
|
+
private observers;
|
|
36
|
+
private isConnectionActive;
|
|
37
|
+
private isRealtimeDisabled;
|
|
38
|
+
private controller?;
|
|
39
|
+
private reader;
|
|
40
|
+
private httpRetriesRemaining;
|
|
41
|
+
private isInBackground;
|
|
42
|
+
private readonly decoder;
|
|
43
|
+
private isClosingConnection;
|
|
44
|
+
private setRetriesRemaining;
|
|
45
|
+
private propagateError;
|
|
46
|
+
/**
|
|
47
|
+
* Increment the number of failed stream attempts, increase the backoff duration, set the backoff
|
|
48
|
+
* end time to "backoff duration" after `lastFailedStreamTime` and persist the new
|
|
49
|
+
* values to storage metadata.
|
|
50
|
+
*/
|
|
51
|
+
private updateBackoffMetadataWithLastFailedStreamConnectionTime;
|
|
52
|
+
/**
|
|
53
|
+
* Increase the backoff duration with a new end time based on Retry Interval.
|
|
54
|
+
*/
|
|
55
|
+
private updateBackoffMetadataWithRetryInterval;
|
|
56
|
+
/**
|
|
57
|
+
* HTTP status code that the Realtime client should retry on.
|
|
58
|
+
*/
|
|
59
|
+
private isStatusCodeRetryable;
|
|
60
|
+
/**
|
|
61
|
+
* Closes the realtime HTTP connection.
|
|
62
|
+
* Note: This method is designed to be called only once at a time.
|
|
63
|
+
* If a call is already in progress, subsequent calls will be ignored.
|
|
64
|
+
*/
|
|
65
|
+
private closeRealtimeHttpConnection;
|
|
66
|
+
private resetRealtimeBackoff;
|
|
67
|
+
private resetRetryCount;
|
|
68
|
+
/**
|
|
69
|
+
* Assembles the request headers and body and executes the fetch request to
|
|
70
|
+
* establish the real-time streaming connection. This is the "worker" method
|
|
71
|
+
* that performs the actual network communication.
|
|
72
|
+
*/
|
|
73
|
+
private establishRealtimeConnection;
|
|
74
|
+
private getRealtimeUrl;
|
|
75
|
+
private createRealtimeConnection;
|
|
76
|
+
/**
|
|
77
|
+
* Retries HTTP stream connection asyncly in random time intervals.
|
|
78
|
+
*/
|
|
79
|
+
private retryHttpConnectionWhenBackoffEnds;
|
|
80
|
+
private setIsHttpConnectionRunning;
|
|
81
|
+
/**
|
|
82
|
+
* Combines the check and set operations to prevent multiple asynchronous
|
|
83
|
+
* calls from redundantly starting an HTTP connection. This ensures that
|
|
84
|
+
* only one attempt is made at a time.
|
|
85
|
+
*/
|
|
86
|
+
private checkAndSetHttpConnectionFlagIfNotRunning;
|
|
87
|
+
private fetchResponseIsUpToDate;
|
|
88
|
+
private parseAndValidateConfigUpdateMessage;
|
|
89
|
+
private isEventListenersEmpty;
|
|
90
|
+
private getRandomInt;
|
|
91
|
+
private executeAllListenerCallbacks;
|
|
92
|
+
/**
|
|
93
|
+
* Compares two configuration objects and returns a set of keys that have changed.
|
|
94
|
+
* A key is considered changed if it's new, removed, or has a different value.
|
|
95
|
+
*/
|
|
96
|
+
private getChangedParams;
|
|
97
|
+
private fetchLatestConfig;
|
|
98
|
+
private autoFetch;
|
|
99
|
+
/**
|
|
100
|
+
* Processes a stream of real-time messages for configuration updates.
|
|
101
|
+
* This method reassembles fragmented messages, validates and parses the JSON,
|
|
102
|
+
* and automatically fetches a new config if a newer template version is available.
|
|
103
|
+
* It also handles server-specified retry intervals and propagates errors for
|
|
104
|
+
* invalid messages or when real-time updates are disabled.
|
|
105
|
+
*/
|
|
106
|
+
private handleNotifications;
|
|
107
|
+
private listenForNotifications;
|
|
108
|
+
/**
|
|
109
|
+
* Open the real-time connection, begin listening for updates, and auto-fetch when an update is
|
|
110
|
+
* received.
|
|
111
|
+
*
|
|
112
|
+
* If the connection is successful, this method will block on its thread while it reads the
|
|
113
|
+
* chunk-encoded HTTP body. When the connection closes, it attempts to reestablish the stream.
|
|
114
|
+
*/
|
|
115
|
+
private prepareAndBeginRealtimeHttpStream;
|
|
116
|
+
/**
|
|
117
|
+
* Checks whether connection can be made or not based on some conditions
|
|
118
|
+
* @returns booelean
|
|
119
|
+
*/
|
|
120
|
+
private canEstablishStreamConnection;
|
|
121
|
+
private makeRealtimeHttpConnection;
|
|
122
|
+
private beginRealtime;
|
|
123
|
+
/**
|
|
124
|
+
* Adds an observer to the realtime updates.
|
|
125
|
+
* @param observer The observer to add.
|
|
126
|
+
*/
|
|
127
|
+
addObserver(observer: ConfigUpdateObserver): void;
|
|
128
|
+
/**
|
|
129
|
+
* Removes an observer from the realtime updates.
|
|
130
|
+
* @param observer The observer to remove.
|
|
131
|
+
*/
|
|
132
|
+
removeObserver(observer: ConfigUpdateObserver): void;
|
|
133
|
+
/**
|
|
134
|
+
* Handles changes to the application's visibility state, managing the real-time connection.
|
|
135
|
+
*
|
|
136
|
+
* When the application is moved to the background, this method closes the existing
|
|
137
|
+
* real-time connection to save resources. When the application returns to the
|
|
138
|
+
* foreground, it attempts to re-establish the connection.
|
|
139
|
+
*/
|
|
140
|
+
private onVisibilityChange;
|
|
141
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 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 { CustomSignals, FetchResponse, FetchType } from '../public_types';
|
|
18
|
+
/**
|
|
19
|
+
* Defines a client, as in https://en.wikipedia.org/wiki/Client%E2%80%93server_model, for the
|
|
20
|
+
* Remote Config server (https://firebase.google.com/docs/reference/remote-config/rest).
|
|
21
|
+
*
|
|
22
|
+
* <p>Abstracts throttle, response cache and network implementation details.
|
|
23
|
+
*
|
|
24
|
+
* <p>Modeled after the native {@link GlobalFetch} interface, which is relatively modern and
|
|
25
|
+
* convenient, but simplified for Remote Config's use case.
|
|
26
|
+
*
|
|
27
|
+
* Disambiguation: {@link GlobalFetch} interface and the Remote Config service define "fetch"
|
|
28
|
+
* methods. The RestClient uses the former to make HTTP calls. This interface abstracts the latter.
|
|
29
|
+
*/
|
|
30
|
+
export interface RemoteConfigFetchClient {
|
|
31
|
+
/**
|
|
32
|
+
* @throws if response status is not 200 or 304.
|
|
33
|
+
*/
|
|
34
|
+
fetch(request: FetchRequest): Promise<FetchResponse>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Shims a minimal AbortSignal.
|
|
38
|
+
*
|
|
39
|
+
* <p>AbortController's AbortSignal conveniently decouples fetch timeout logic from other aspects
|
|
40
|
+
* of networking, such as retries. Firebase doesn't use AbortController enough to justify a
|
|
41
|
+
* polyfill recommendation, like we do with the Fetch API, but this minimal shim can easily be
|
|
42
|
+
* swapped out if/when we do.
|
|
43
|
+
*/
|
|
44
|
+
export declare class RemoteConfigAbortSignal {
|
|
45
|
+
listeners: Array<() => void>;
|
|
46
|
+
addEventListener(listener: () => void): void;
|
|
47
|
+
abort(): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Defines per-request inputs for the Remote Config fetch request.
|
|
51
|
+
*
|
|
52
|
+
* <p>Modeled after the native {@link Request} interface, but simplified for Remote Config's
|
|
53
|
+
* use case.
|
|
54
|
+
*/
|
|
55
|
+
export interface FetchRequest {
|
|
56
|
+
/**
|
|
57
|
+
* Uses cached config if it is younger than this age.
|
|
58
|
+
*
|
|
59
|
+
* <p>Required because it's defined by settings, which always have a value.
|
|
60
|
+
*
|
|
61
|
+
* <p>Comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the native
|
|
62
|
+
* Fetch API.
|
|
63
|
+
*/
|
|
64
|
+
cacheMaxAgeMillis: number;
|
|
65
|
+
/**
|
|
66
|
+
* An event bus for the signal to abort a request.
|
|
67
|
+
*
|
|
68
|
+
* <p>Required because all requests should be abortable.
|
|
69
|
+
*
|
|
70
|
+
* <p>Comparable to the native
|
|
71
|
+
* Fetch API's "signal" field on its request configuration object
|
|
72
|
+
* https://fetch.spec.whatwg.org/#dom-requestinit-signal.
|
|
73
|
+
*
|
|
74
|
+
* <p>Disambiguation: Remote Config commonly refers to API inputs as
|
|
75
|
+
* "signals". See the private ConfigFetchRequestBody interface for those:
|
|
76
|
+
* http://google3/firebase/remote_config/web/src/core/rest_client.ts?l=14&rcl=255515243.
|
|
77
|
+
*/
|
|
78
|
+
signal: RemoteConfigAbortSignal;
|
|
79
|
+
/**
|
|
80
|
+
* The ETag header value from the last response.
|
|
81
|
+
*
|
|
82
|
+
* <p>Optional in case this is the first request.
|
|
83
|
+
*
|
|
84
|
+
* <p>Comparable to passing `headers = { 'If-None-Match': <eTag> }` to the native Fetch API.
|
|
85
|
+
*/
|
|
86
|
+
eTag?: string;
|
|
87
|
+
/** The custom signals stored for the app instance.
|
|
88
|
+
*
|
|
89
|
+
* <p>Optional in case no custom signals are set for the instance.
|
|
90
|
+
*/
|
|
91
|
+
customSignals?: CustomSignals;
|
|
92
|
+
/**
|
|
93
|
+
* The type of fetch to perform, such as a regular fetch or a real-time fetch.
|
|
94
|
+
*
|
|
95
|
+
* Optional as not all fetch requests need to be distinguished.
|
|
96
|
+
*/
|
|
97
|
+
fetchType?: FetchType;
|
|
98
|
+
/**
|
|
99
|
+
* The number of fetch attempts made so far for this request.
|
|
100
|
+
*
|
|
101
|
+
* Optional as not all fetch requests are part of a retry series.
|
|
102
|
+
*/
|
|
103
|
+
fetchAttempt?: number;
|
|
104
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 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 { FetchResponse } from '../public_types';
|
|
18
|
+
import { RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
|
|
19
|
+
import { _FirebaseInstallationsInternal } from '@firebase/installations';
|
|
20
|
+
/**
|
|
21
|
+
* Implements the Client abstraction for the Remote Config REST API.
|
|
22
|
+
*/
|
|
23
|
+
export declare class RestClient implements RemoteConfigFetchClient {
|
|
24
|
+
private readonly firebaseInstallations;
|
|
25
|
+
private readonly sdkVersion;
|
|
26
|
+
private readonly namespace;
|
|
27
|
+
private readonly projectId;
|
|
28
|
+
private readonly apiKey;
|
|
29
|
+
private readonly appId;
|
|
30
|
+
constructor(firebaseInstallations: _FirebaseInstallationsInternal, sdkVersion: string, namespace: string, projectId: string, apiKey: string, appId: string);
|
|
31
|
+
/**
|
|
32
|
+
* Fetches from the Remote Config REST API.
|
|
33
|
+
*
|
|
34
|
+
* @throws a {@link ErrorCode.FETCH_NETWORK} error if {@link GlobalFetch#fetch} can't
|
|
35
|
+
* connect to the network.
|
|
36
|
+
* @throws a {@link ErrorCode.FETCH_PARSE} error if {@link Response#json} can't parse the
|
|
37
|
+
* fetch response.
|
|
38
|
+
* @throws a {@link ErrorCode.FETCH_STATUS} error if the service returns an HTTP error status.
|
|
39
|
+
*/
|
|
40
|
+
fetch(request: FetchRequest): Promise<FetchResponse>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 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 { FetchResponse } from '../public_types';
|
|
18
|
+
import { RemoteConfigAbortSignal, RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
|
|
19
|
+
import { ThrottleMetadata, Storage } from '../storage/storage';
|
|
20
|
+
/**
|
|
21
|
+
* Supports waiting on a backoff by:
|
|
22
|
+
*
|
|
23
|
+
* <ul>
|
|
24
|
+
* <li>Promisifying setTimeout, so we can set a timeout in our Promise chain</li>
|
|
25
|
+
* <li>Listening on a signal bus for abort events, just like the Fetch API</li>
|
|
26
|
+
* <li>Failing in the same way the Fetch API fails, so timing out a live request and a throttled
|
|
27
|
+
* request appear the same.</li>
|
|
28
|
+
* </ul>
|
|
29
|
+
*
|
|
30
|
+
* <p>Visible for testing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function setAbortableTimeout(signal: RemoteConfigAbortSignal, throttleEndTimeMillis: number): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Decorates a Client with retry logic.
|
|
35
|
+
*
|
|
36
|
+
* <p>Comparable to CachingClient, but uses backoff logic instead of cache max age and doesn't cache
|
|
37
|
+
* responses (because the SDK has no use for error responses).
|
|
38
|
+
*/
|
|
39
|
+
export declare class RetryingClient implements RemoteConfigFetchClient {
|
|
40
|
+
private readonly client;
|
|
41
|
+
private readonly storage;
|
|
42
|
+
constructor(client: RemoteConfigFetchClient, storage: Storage);
|
|
43
|
+
fetch(request: FetchRequest): Promise<FetchResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* A recursive helper for attempting a fetch request repeatedly.
|
|
46
|
+
*
|
|
47
|
+
* @throws any non-retriable errors.
|
|
48
|
+
*/
|
|
49
|
+
attemptFetch(request: FetchRequest, { throttleEndTimeMillis, backoffCount }: ThrottleMetadata): Promise<FetchResponse>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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 { EventEmitter } from './eventEmitter';
|
|
18
|
+
export declare class VisibilityMonitor extends EventEmitter {
|
|
19
|
+
private visible_;
|
|
20
|
+
static getInstance(): VisibilityMonitor;
|
|
21
|
+
constructor();
|
|
22
|
+
getInitialEvent(eventType: string): boolean[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 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
|
+
export declare const RC_COMPONENT_NAME = "remote-config";
|
|
18
|
+
export declare const RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = 100;
|
|
19
|
+
export declare const RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH = 250;
|
|
20
|
+
export declare const RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH = 500;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 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 { ErrorFactory } from '@firebase/util';
|
|
18
|
+
export declare const enum ErrorCode {
|
|
19
|
+
ALREADY_INITIALIZED = "already-initialized",
|
|
20
|
+
REGISTRATION_WINDOW = "registration-window",
|
|
21
|
+
REGISTRATION_PROJECT_ID = "registration-project-id",
|
|
22
|
+
REGISTRATION_API_KEY = "registration-api-key",
|
|
23
|
+
REGISTRATION_APP_ID = "registration-app-id",
|
|
24
|
+
STORAGE_OPEN = "storage-open",
|
|
25
|
+
STORAGE_GET = "storage-get",
|
|
26
|
+
STORAGE_SET = "storage-set",
|
|
27
|
+
STORAGE_DELETE = "storage-delete",
|
|
28
|
+
FETCH_NETWORK = "fetch-client-network",
|
|
29
|
+
FETCH_TIMEOUT = "fetch-timeout",
|
|
30
|
+
FETCH_THROTTLE = "fetch-throttle",
|
|
31
|
+
FETCH_PARSE = "fetch-client-parse",
|
|
32
|
+
FETCH_STATUS = "fetch-status",
|
|
33
|
+
INDEXED_DB_UNAVAILABLE = "indexed-db-unavailable",
|
|
34
|
+
CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = "custom-signal-max-allowed-signals",
|
|
35
|
+
CONFIG_UPDATE_STREAM_ERROR = "stream-error",
|
|
36
|
+
CONFIG_UPDATE_UNAVAILABLE = "realtime-unavailable",
|
|
37
|
+
CONFIG_UPDATE_MESSAGE_INVALID = "update-message-invalid",
|
|
38
|
+
CONFIG_UPDATE_NOT_FETCHED = "update-not-fetched",
|
|
39
|
+
ANALYTICS_UNAVAILABLE = "analytics-unavailable"
|
|
40
|
+
}
|
|
41
|
+
interface ErrorParams {
|
|
42
|
+
[ErrorCode.STORAGE_OPEN]: {
|
|
43
|
+
originalErrorMessage: string | undefined;
|
|
44
|
+
};
|
|
45
|
+
[ErrorCode.STORAGE_GET]: {
|
|
46
|
+
originalErrorMessage: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
[ErrorCode.STORAGE_SET]: {
|
|
49
|
+
originalErrorMessage: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
[ErrorCode.STORAGE_DELETE]: {
|
|
52
|
+
originalErrorMessage: string | undefined;
|
|
53
|
+
};
|
|
54
|
+
[ErrorCode.FETCH_NETWORK]: {
|
|
55
|
+
originalErrorMessage: string;
|
|
56
|
+
};
|
|
57
|
+
[ErrorCode.FETCH_THROTTLE]: {
|
|
58
|
+
throttleEndTimeMillis: number;
|
|
59
|
+
};
|
|
60
|
+
[ErrorCode.FETCH_PARSE]: {
|
|
61
|
+
originalErrorMessage: string;
|
|
62
|
+
};
|
|
63
|
+
[ErrorCode.FETCH_STATUS]: {
|
|
64
|
+
httpStatus: number;
|
|
65
|
+
};
|
|
66
|
+
[ErrorCode.CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS]: {
|
|
67
|
+
maxSignals: number;
|
|
68
|
+
};
|
|
69
|
+
[ErrorCode.CONFIG_UPDATE_STREAM_ERROR]: {
|
|
70
|
+
originalErrorMessage: string;
|
|
71
|
+
};
|
|
72
|
+
[ErrorCode.CONFIG_UPDATE_UNAVAILABLE]: {
|
|
73
|
+
originalErrorMessage: string;
|
|
74
|
+
};
|
|
75
|
+
[ErrorCode.CONFIG_UPDATE_MESSAGE_INVALID]: {
|
|
76
|
+
originalErrorMessage: string;
|
|
77
|
+
};
|
|
78
|
+
[ErrorCode.CONFIG_UPDATE_NOT_FETCHED]: {
|
|
79
|
+
originalErrorMessage: string;
|
|
80
|
+
};
|
|
81
|
+
[ErrorCode.ANALYTICS_UNAVAILABLE]: {
|
|
82
|
+
originalErrorMessage: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
|
|
86
|
+
export declare function hasErrorCode(e: Error, errorCode: ErrorCode): boolean;
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Firebase Remote Config Web SDK.
|
|
3
|
+
* This SDK does not work in a Node.js environment.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
FIREBASE_REMOTE_CONFIG_URL_BASE: string;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export * from './api';
|
|
13
|
+
export * from './api2';
|
|
14
|
+
export * from './public_types';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 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
|
+
/**
|
|
18
|
+
* Attempts to get the most accurate browser language setting.
|
|
19
|
+
*
|
|
20
|
+
* <p>Adapted from getUserLanguage in packages/auth/src/utils.js for TypeScript.
|
|
21
|
+
*
|
|
22
|
+
* <p>Defers default language specification to server logic for consistency.
|
|
23
|
+
*
|
|
24
|
+
* @param navigatorLanguage Enables tests to override read-only {@link NavigatorLanguage}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getUserLanguage(navigatorLanguage?: NavigatorLanguage): string;
|