@firebase/installations 0.5.1 → 0.5.2-canary.2322b6023

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 (58) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{index.esm.js → esm/index.esm.js} +4 -2
  3. package/dist/esm/index.esm.js.map +1 -0
  4. package/dist/{index.esm2017.js → esm/index.esm2017.js} +4 -2
  5. package/dist/esm/index.esm2017.js.map +1 -0
  6. package/dist/esm/package.json +1 -0
  7. package/dist/esm/src/api/delete-installations.d.ts +24 -0
  8. package/dist/esm/src/api/delete-installations.test.d.ts +17 -0
  9. package/dist/esm/src/api/get-id.d.ts +25 -0
  10. package/dist/esm/src/api/get-id.test.d.ts +17 -0
  11. package/dist/esm/src/api/get-installations.d.ts +26 -0
  12. package/dist/esm/src/api/get-token.d.ts +26 -0
  13. package/dist/esm/src/api/get-token.test.d.ts +17 -0
  14. package/dist/esm/src/api/index.d.ts +21 -0
  15. package/dist/esm/src/api/on-id-change.d.ts +39 -0
  16. package/dist/esm/src/api/on-id-change.test.d.ts +17 -0
  17. package/dist/esm/src/functions/common.d.ts +38 -0
  18. package/dist/esm/src/functions/common.test.d.ts +17 -0
  19. package/dist/esm/src/functions/config.d.ts +17 -0
  20. package/dist/esm/src/functions/create-installation-request.d.ts +19 -0
  21. package/dist/esm/src/functions/create-installation-request.test.d.ts +17 -0
  22. package/dist/esm/src/functions/delete-installation-request.d.ts +19 -0
  23. package/dist/esm/src/functions/delete-installation-request.test.d.ts +17 -0
  24. package/dist/esm/src/functions/generate-auth-token-request.d.ts +19 -0
  25. package/dist/esm/src/functions/generate-auth-token-request.test.d.ts +17 -0
  26. package/dist/esm/src/helpers/buffer-to-base64-url-safe.d.ts +17 -0
  27. package/dist/esm/src/helpers/buffer-to-base64-url-safe.test.d.ts +17 -0
  28. package/dist/esm/src/helpers/extract-app-config.d.ts +19 -0
  29. package/dist/esm/src/helpers/extract-app-config.test.d.ts +17 -0
  30. package/dist/esm/src/helpers/fid-changed.d.ts +25 -0
  31. package/dist/esm/src/helpers/fid-changed.test.d.ts +17 -0
  32. package/dist/esm/src/helpers/generate-fid.d.ts +23 -0
  33. package/dist/esm/src/helpers/generate-fid.test.d.ts +17 -0
  34. package/dist/esm/src/helpers/get-installation-entry.d.ts +28 -0
  35. package/dist/esm/src/helpers/get-installation-entry.test.d.ts +17 -0
  36. package/dist/esm/src/helpers/idb-manager.d.ts +32 -0
  37. package/dist/esm/src/helpers/idb-manager.test.d.ts +17 -0
  38. package/dist/esm/src/helpers/refresh-auth-token.d.ts +25 -0
  39. package/dist/esm/src/helpers/refresh-auth-token.test.d.ts +17 -0
  40. package/dist/esm/src/index.d.ts +7 -0
  41. package/dist/esm/src/interfaces/api-response.d.ts +31 -0
  42. package/dist/esm/src/interfaces/installation-entry.d.ts +85 -0
  43. package/dist/esm/src/interfaces/installation-impl.d.ts +29 -0
  44. package/dist/esm/src/interfaces/public-types.d.ts +50 -0
  45. package/dist/esm/src/testing/compare-headers.d.ts +21 -0
  46. package/dist/esm/src/testing/compare-headers.test.d.ts +17 -0
  47. package/dist/esm/src/testing/fake-generators.d.ts +21 -0
  48. package/dist/esm/src/testing/setup.d.ts +17 -0
  49. package/dist/esm/src/util/constants.d.ts +23 -0
  50. package/dist/esm/src/util/errors.d.ts +46 -0
  51. package/dist/esm/src/util/get-key.d.ts +19 -0
  52. package/dist/esm/src/util/sleep.d.ts +18 -0
  53. package/dist/esm/src/util/sleep.test.d.ts +17 -0
  54. package/dist/index.cjs.js +4 -2
  55. package/dist/index.cjs.js.map +1 -1
  56. package/package.json +19 -12
  57. package/dist/index.esm.js.map +0 -1
  58. package/dist/index.esm2017.js.map +0 -1
@@ -0,0 +1,85 @@
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
+ /** Status of a server request. */
18
+ export declare const enum RequestStatus {
19
+ NOT_STARTED = 0,
20
+ IN_PROGRESS = 1,
21
+ COMPLETED = 2
22
+ }
23
+ export interface NotStartedAuthToken {
24
+ readonly requestStatus: RequestStatus.NOT_STARTED;
25
+ }
26
+ export interface InProgressAuthToken {
27
+ readonly requestStatus: RequestStatus.IN_PROGRESS;
28
+ /**
29
+ * Unix timestamp when the current generateAuthRequest was initiated.
30
+ * Used for figuring out how long the request status has been IN_PROGRESS.
31
+ */
32
+ readonly requestTime: number;
33
+ }
34
+ export interface CompletedAuthToken {
35
+ readonly requestStatus: RequestStatus.COMPLETED;
36
+ /**
37
+ * Firebase Installations Authentication Token.
38
+ * Only exists if requestStatus is COMPLETED.
39
+ */
40
+ readonly token: string;
41
+ /**
42
+ * Unix timestamp when Authentication Token was created.
43
+ * Only exists if requestStatus is COMPLETED.
44
+ */
45
+ readonly creationTime: number;
46
+ /**
47
+ * Authentication Token time to live duration in milliseconds.
48
+ * Only exists if requestStatus is COMPLETED.
49
+ */
50
+ readonly expiresIn: number;
51
+ }
52
+ export declare type AuthToken = NotStartedAuthToken | InProgressAuthToken | CompletedAuthToken;
53
+ export interface UnregisteredInstallationEntry {
54
+ /** Status of the Firebase Installation registration on the server. */
55
+ readonly registrationStatus: RequestStatus.NOT_STARTED;
56
+ /** Firebase Installation ID */
57
+ readonly fid: string;
58
+ }
59
+ export interface InProgressInstallationEntry {
60
+ /** Status of the Firebase Installation registration on the server. */
61
+ readonly registrationStatus: RequestStatus.IN_PROGRESS;
62
+ /**
63
+ * Unix timestamp that shows the time when the current createInstallation
64
+ * request was initiated.
65
+ * Used for figuring out how long the registration status has been PENDING.
66
+ */
67
+ readonly registrationTime: number;
68
+ /** Firebase Installation ID */
69
+ readonly fid: string;
70
+ }
71
+ export interface RegisteredInstallationEntry {
72
+ /** Status of the Firebase Installation registration on the server. */
73
+ readonly registrationStatus: RequestStatus.COMPLETED;
74
+ /** Firebase Installation ID */
75
+ readonly fid: string;
76
+ /**
77
+ * Refresh Token returned from the server.
78
+ * Used for authenticating generateAuthToken requests.
79
+ */
80
+ readonly refreshToken: string;
81
+ /** Firebase Installation Authentication Token. */
82
+ readonly authToken: AuthToken;
83
+ }
84
+ /** Firebase Installation ID and related data in the database. */
85
+ export declare type InstallationEntry = UnregisteredInstallationEntry | InProgressInstallationEntry | RegisteredInstallationEntry;
@@ -0,0 +1,29 @@
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
+ import { Provider } from '@firebase/component';
18
+ import { _FirebaseService } from '@firebase/app';
19
+ import { Installations } from '../interfaces/public-types';
20
+ export interface FirebaseInstallationsImpl extends Installations, _FirebaseService {
21
+ readonly appConfig: AppConfig;
22
+ readonly platformLoggerProvider: Provider<'platform-logger'>;
23
+ }
24
+ export interface AppConfig {
25
+ readonly appName: string;
26
+ readonly projectId: string;
27
+ readonly apiKey: string;
28
+ readonly appId: string;
29
+ }
@@ -0,0 +1,50 @@
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
+ import { FirebaseApp } from '@firebase/app';
18
+ /**
19
+ * Public interface of the Firebase Installations SDK.
20
+ *
21
+ * @public
22
+ */
23
+ export interface Installations {
24
+ /**
25
+ * The {@link @firebase/app#FirebaseApp} this `Installations` instance is associated with.
26
+ */
27
+ app: FirebaseApp;
28
+ }
29
+ /**
30
+ * An interface for Firebase internal SDKs use only.
31
+ *
32
+ * @internal
33
+ */
34
+ export interface _FirebaseInstallationsInternal {
35
+ /**
36
+ * Creates a Firebase Installation if there isn't one for the app and
37
+ * returns the Installation ID.
38
+ */
39
+ getId(): Promise<string>;
40
+ /**
41
+ * Returns an Authentication Token for the current Firebase Installation.
42
+ */
43
+ getToken(forceRefresh?: boolean): Promise<string>;
44
+ }
45
+ declare module '@firebase/component' {
46
+ interface NameServiceMapping {
47
+ 'installations': Installations;
48
+ 'installations-internal': _FirebaseInstallationsInternal;
49
+ }
50
+ }
@@ -0,0 +1,21 @@
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
+ declare class HeadersWithEntries extends Headers {
18
+ entries?(): Iterable<[string, string]>;
19
+ }
20
+ export declare function compareHeaders(expectedHeaders: HeadersWithEntries, actualHeaders: HeadersWithEntries): void;
21
+ export {};
@@ -0,0 +1,17 @@
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 '../testing/setup';
@@ -0,0 +1,21 @@
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 { FirebaseApp } from '@firebase/app';
18
+ import { FirebaseInstallationsImpl, AppConfig } from '../interfaces/installation-impl';
19
+ export declare function getFakeApp(): FirebaseApp;
20
+ export declare function getFakeAppConfig(customValues?: Partial<AppConfig>): AppConfig;
21
+ export declare function getFakeInstallations(): FirebaseInstallationsImpl;
@@ -0,0 +1,17 @@
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
+ export {};
@@ -0,0 +1,23 @@
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
+ export declare const PENDING_TIMEOUT_MS = 10000;
18
+ export declare const PACKAGE_VERSION: string;
19
+ export declare const INTERNAL_AUTH_VERSION = "FIS_v2";
20
+ export declare const INSTALLATIONS_API_URL = "https://firebaseinstallations.googleapis.com/v1";
21
+ export declare const TOKEN_EXPIRATION_BUFFER: number;
22
+ export declare const SERVICE = "installations";
23
+ export declare const SERVICE_NAME = "Installations";
@@ -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 { ErrorFactory, FirebaseError } from '@firebase/util';
18
+ export declare const enum ErrorCode {
19
+ MISSING_APP_CONFIG_VALUES = "missing-app-config-values",
20
+ NOT_REGISTERED = "not-registered",
21
+ INSTALLATION_NOT_FOUND = "installation-not-found",
22
+ REQUEST_FAILED = "request-failed",
23
+ APP_OFFLINE = "app-offline",
24
+ DELETE_PENDING_REGISTRATION = "delete-pending-registration"
25
+ }
26
+ interface ErrorParams {
27
+ [ErrorCode.MISSING_APP_CONFIG_VALUES]: {
28
+ valueName: string;
29
+ };
30
+ [ErrorCode.REQUEST_FAILED]: {
31
+ requestName: string;
32
+ [index: string]: string | number;
33
+ } & ServerErrorData;
34
+ }
35
+ export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
36
+ export interface ServerErrorData {
37
+ serverCode: number;
38
+ serverMessage: string;
39
+ serverStatus: string;
40
+ }
41
+ export declare type ServerError = FirebaseError & {
42
+ customData: ServerErrorData;
43
+ };
44
+ /** Returns true if error is a FirebaseError that is based on an error from the server. */
45
+ export declare function isServerError(error: unknown): error is ServerError;
46
+ export {};
@@ -0,0 +1,19 @@
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 { AppConfig } from '../interfaces/installation-impl';
18
+ /** Returns a string key that can be used to identify the app. */
19
+ export declare function getKey(appConfig: AppConfig): string;
@@ -0,0 +1,18 @@
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
+ /** Returns a promise that resolves after given time passes. */
18
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1,17 @@
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 '../testing/setup';
package/dist/index.cjs.js CHANGED
@@ -9,7 +9,7 @@ var util = require('@firebase/util');
9
9
  var idb = require('idb');
10
10
 
11
11
  var name = "@firebase/installations";
12
- var version = "0.5.1";
12
+ var version = "0.5.2-canary.2322b6023";
13
13
 
14
14
  /**
15
15
  * @license
@@ -1397,7 +1397,9 @@ function registerInstallations() {
1397
1397
  * @packageDocumentation
1398
1398
  */
1399
1399
  registerInstallations();
1400
- app.registerVersion(name, version);
1400
+ app.registerVersion(name, version);
1401
+ // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
1402
+ app.registerVersion(name, version, 'cjs5');
1401
1403
 
1402
1404
  exports.deleteInstallations = deleteInstallations;
1403
1405
  exports.getId = getId;