@firebase/storage 0.8.4 → 0.8.5-2021102231614
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/CHANGELOG.md +11 -0
- package/dist/index.browser.cjs.js +184 -255
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.esm2017.js +164 -187
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +184 -255
- package/dist/index.esm5.js.map +1 -1
- package/dist/{index.cjs.js → index.node.cjs.js} +152 -178
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/node-esm/index.node.esm.js +3351 -0
- package/dist/node-esm/index.node.esm.js.map +1 -0
- package/dist/node-esm/package.json +1 -0
- package/dist/node-esm/src/api.browser.d.ts +17 -0
- package/dist/node-esm/src/api.d.ts +184 -0
- package/dist/node-esm/src/api.node.d.ts +17 -0
- package/dist/node-esm/src/constants.d.ts +20 -0
- package/dist/{src/implementation/connectionPool.d.ts → node-esm/src/implementation/async.d.ts} +4 -8
- package/dist/node-esm/src/implementation/backoff.d.ts +37 -0
- package/dist/node-esm/src/implementation/blob.d.ts +34 -0
- package/dist/node-esm/src/implementation/connection.d.ts +47 -0
- package/dist/node-esm/src/implementation/constants.d.ts +44 -0
- package/dist/node-esm/src/implementation/error.d.ts +105 -0
- package/dist/node-esm/src/implementation/failrequest.d.ts +29 -0
- package/dist/node-esm/src/implementation/fs.d.ts +17 -0
- package/dist/node-esm/src/implementation/json.d.ts +7 -0
- package/dist/node-esm/src/implementation/list.d.ts +19 -0
- package/dist/node-esm/src/implementation/location.d.ts +32 -0
- package/dist/node-esm/src/implementation/metadata.d.ts +40 -0
- package/dist/node-esm/src/implementation/observer.d.ts +47 -0
- package/dist/node-esm/src/implementation/path.d.ts +31 -0
- package/dist/node-esm/src/implementation/request.d.ts +47 -0
- package/dist/node-esm/src/implementation/requestinfo.d.ts +65 -0
- package/dist/node-esm/src/implementation/requests.d.ts +83 -0
- package/dist/node-esm/src/implementation/string.d.ts +73 -0
- package/dist/node-esm/src/implementation/taskenums.d.ts +77 -0
- package/dist/node-esm/src/implementation/type.d.ts +23 -0
- package/dist/{src/implementation/requestmaker.d.ts → node-esm/src/implementation/url.d.ts} +6 -5
- package/dist/node-esm/src/index.d.ts +7 -0
- package/dist/node-esm/src/index.node.d.ts +7 -0
- package/dist/node-esm/src/list.d.ts +41 -0
- package/dist/node-esm/src/metadata.d.ts +27 -0
- package/dist/node-esm/src/platform/base64.d.ts +20 -0
- package/dist/node-esm/src/platform/browser/base64.d.ts +19 -0
- package/dist/node-esm/src/platform/browser/connection.d.ts +39 -0
- package/dist/node-esm/src/platform/connection.d.ts +19 -0
- package/dist/node-esm/src/platform/node/base64.d.ts +19 -0
- package/dist/node-esm/src/platform/node/connection.d.ts +45 -0
- package/dist/node-esm/src/public-types.d.ts +433 -0
- package/dist/node-esm/src/reference.d.ts +196 -0
- package/dist/node-esm/src/service.d.ts +130 -0
- package/dist/node-esm/src/task.d.ts +143 -0
- package/dist/node-esm/test/browser/blob.test.d.ts +17 -0
- package/dist/node-esm/test/browser/connection.test.d.ts +17 -0
- package/dist/node-esm/test/integration/integration.test.d.ts +20 -0
- package/dist/node-esm/test/unit/connection.d.ts +46 -0
- package/dist/node-esm/test/unit/connection.test.d.ts +17 -0
- package/dist/node-esm/test/unit/index.test.d.ts +4 -0
- package/dist/node-esm/test/unit/location.test.d.ts +1 -0
- package/dist/node-esm/test/unit/reference.test.d.ts +1 -0
- package/dist/node-esm/test/unit/request.test.d.ts +1 -0
- package/dist/node-esm/test/unit/requests.test.d.ts +1 -0
- package/dist/node-esm/test/unit/service.test.d.ts +1 -0
- package/dist/node-esm/test/unit/string.test.d.ts +1 -0
- package/dist/node-esm/test/unit/task.test.d.ts +1 -0
- package/dist/node-esm/test/unit/testshared.d.ts +47 -0
- package/dist/src/api.browser.d.ts +17 -0
- package/dist/src/api.d.ts +1 -1
- package/dist/src/api.node.d.ts +17 -0
- package/dist/src/implementation/request.d.ts +1 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.node.d.ts +7 -0
- package/dist/src/platform/browser/connection.d.ts +1 -0
- package/dist/src/platform/connection.d.ts +1 -0
- package/dist/src/platform/node/connection.d.ts +1 -0
- package/dist/src/service.d.ts +4 -5
- package/dist/storage.d.ts +3 -11
- package/dist/test/unit/connection.d.ts +1 -0
- package/dist/test/unit/testshared.d.ts +0 -3
- package/package.json +18 -8
- package/dist/index.cjs.js.map +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 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 { Location } from './implementation/location';
|
|
18
|
+
import { Request } from './implementation/request';
|
|
19
|
+
import { RequestInfo } from './implementation/requestinfo';
|
|
20
|
+
import { Reference } from './reference';
|
|
21
|
+
import { Provider } from '@firebase/component';
|
|
22
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
23
|
+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
24
|
+
import { FirebaseApp } from '@firebase/app';
|
|
25
|
+
import { FirebaseStorage } from './public-types';
|
|
26
|
+
import { EmulatorMockTokenOptions } from '@firebase/util';
|
|
27
|
+
import { Connection } from './implementation/connection';
|
|
28
|
+
export declare function isUrl(path?: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a storage Reference for the given url.
|
|
31
|
+
* @param storage - `Storage` instance.
|
|
32
|
+
* @param url - URL. If empty, returns root reference.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare function ref(storage: FirebaseStorageImpl, url?: string): Reference;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a storage Reference for the given path in the
|
|
38
|
+
* default bucket.
|
|
39
|
+
* @param storageOrRef - `Storage` service or storage `Reference`.
|
|
40
|
+
* @param pathOrUrlStorage - path. If empty, returns root reference (if Storage
|
|
41
|
+
* instance provided) or returns same reference (if Reference provided).
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function ref(storageOrRef: FirebaseStorageImpl | Reference, path?: string): Reference;
|
|
45
|
+
export declare function connectStorageEmulator(storage: FirebaseStorageImpl, host: string, port: number, options?: {
|
|
46
|
+
mockUserToken?: EmulatorMockTokenOptions | string;
|
|
47
|
+
}): void;
|
|
48
|
+
/**
|
|
49
|
+
* A service that provides Firebase Storage Reference instances.
|
|
50
|
+
* @param opt_url - gs:// url to a custom Storage Bucket
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export declare class FirebaseStorageImpl implements FirebaseStorage {
|
|
55
|
+
/**
|
|
56
|
+
* FirebaseApp associated with this StorageService instance.
|
|
57
|
+
*/
|
|
58
|
+
readonly app: FirebaseApp;
|
|
59
|
+
readonly _authProvider: Provider<FirebaseAuthInternalName>;
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
readonly _appCheckProvider: Provider<AppCheckInternalComponentName>;
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
readonly _url?: string | undefined;
|
|
68
|
+
readonly _firebaseVersion?: string | undefined;
|
|
69
|
+
_bucket: Location | null;
|
|
70
|
+
/**
|
|
71
|
+
* This string can be in the formats:
|
|
72
|
+
* - host
|
|
73
|
+
* - host:port
|
|
74
|
+
*/
|
|
75
|
+
private _host;
|
|
76
|
+
_protocol: string;
|
|
77
|
+
protected readonly _appId: string | null;
|
|
78
|
+
private readonly _requests;
|
|
79
|
+
private _deleted;
|
|
80
|
+
private _maxOperationRetryTime;
|
|
81
|
+
private _maxUploadRetryTime;
|
|
82
|
+
_overrideAuthToken?: string;
|
|
83
|
+
constructor(
|
|
84
|
+
/**
|
|
85
|
+
* FirebaseApp associated with this StorageService instance.
|
|
86
|
+
*/
|
|
87
|
+
app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>,
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
_appCheckProvider: Provider<AppCheckInternalComponentName>,
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
_url?: string | undefined, _firebaseVersion?: string | undefined);
|
|
96
|
+
/**
|
|
97
|
+
* The host string for this service, in the form of `host` or
|
|
98
|
+
* `host:port`.
|
|
99
|
+
*/
|
|
100
|
+
get host(): string;
|
|
101
|
+
set host(host: string);
|
|
102
|
+
/**
|
|
103
|
+
* The maximum time to retry uploads in milliseconds.
|
|
104
|
+
*/
|
|
105
|
+
get maxUploadRetryTime(): number;
|
|
106
|
+
set maxUploadRetryTime(time: number);
|
|
107
|
+
/**
|
|
108
|
+
* The maximum time to retry operations other than uploads or downloads in
|
|
109
|
+
* milliseconds.
|
|
110
|
+
*/
|
|
111
|
+
get maxOperationRetryTime(): number;
|
|
112
|
+
set maxOperationRetryTime(time: number);
|
|
113
|
+
_getAuthToken(): Promise<string | null>;
|
|
114
|
+
_getAppCheckToken(): Promise<string | null>;
|
|
115
|
+
/**
|
|
116
|
+
* Stop running requests and prevent more from being created.
|
|
117
|
+
*/
|
|
118
|
+
_delete(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Returns a new firebaseStorage.Reference object referencing this StorageService
|
|
121
|
+
* at the given Location.
|
|
122
|
+
*/
|
|
123
|
+
_makeStorageReference(loc: Location): Reference;
|
|
124
|
+
/**
|
|
125
|
+
* @param requestInfo - HTTP RequestInfo object
|
|
126
|
+
* @param authToken - Firebase auth token
|
|
127
|
+
*/
|
|
128
|
+
_makeRequest<T>(requestInfo: RequestInfo<T>, requestFactory: () => Connection, authToken: string | null, appCheckToken: string | null): Request<T>;
|
|
129
|
+
makeRequestWithTokens<T>(requestInfo: RequestInfo<T>, requestFactory: () => Connection): Promise<T>;
|
|
130
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 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
|
+
* @fileoverview Defines types for interacting with blob transfer tasks.
|
|
19
|
+
*/
|
|
20
|
+
import { FbsBlob } from './implementation/blob';
|
|
21
|
+
import { StorageError } from './implementation/error';
|
|
22
|
+
import { InternalTaskState, TaskEvent } from './implementation/taskenums';
|
|
23
|
+
import { Metadata } from './metadata';
|
|
24
|
+
import { Subscribe, Unsubscribe } from './implementation/observer';
|
|
25
|
+
import { UploadTaskSnapshot, StorageObserver } from './public-types';
|
|
26
|
+
import { Reference } from './reference';
|
|
27
|
+
/**
|
|
28
|
+
* Represents a blob being uploaded. Can be used to pause/resume/cancel the
|
|
29
|
+
* upload and manage callbacks for various events.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare class UploadTask {
|
|
33
|
+
private _ref;
|
|
34
|
+
/**
|
|
35
|
+
* The data to be uploaded.
|
|
36
|
+
*/
|
|
37
|
+
_blob: FbsBlob;
|
|
38
|
+
/**
|
|
39
|
+
* Metadata related to the upload.
|
|
40
|
+
*/
|
|
41
|
+
_metadata: Metadata | null;
|
|
42
|
+
private _mappings;
|
|
43
|
+
/**
|
|
44
|
+
* Number of bytes transferred so far.
|
|
45
|
+
*/
|
|
46
|
+
_transferred: number;
|
|
47
|
+
private _needToFetchStatus;
|
|
48
|
+
private _needToFetchMetadata;
|
|
49
|
+
private _observers;
|
|
50
|
+
private _resumable;
|
|
51
|
+
/**
|
|
52
|
+
* Upload state.
|
|
53
|
+
*/
|
|
54
|
+
_state: InternalTaskState;
|
|
55
|
+
private _error?;
|
|
56
|
+
private _uploadUrl?;
|
|
57
|
+
private _request?;
|
|
58
|
+
private _chunkMultiplier;
|
|
59
|
+
private _errorHandler;
|
|
60
|
+
private _metadataErrorHandler;
|
|
61
|
+
private _resolve?;
|
|
62
|
+
private _reject?;
|
|
63
|
+
private _promise;
|
|
64
|
+
/**
|
|
65
|
+
* @param ref - The firebaseStorage.Reference object this task came
|
|
66
|
+
* from, untyped to avoid cyclic dependencies.
|
|
67
|
+
* @param blob - The blob to upload.
|
|
68
|
+
*/
|
|
69
|
+
constructor(ref: Reference, blob: FbsBlob, metadata?: Metadata | null);
|
|
70
|
+
private _makeProgressCallback;
|
|
71
|
+
private _shouldDoResumable;
|
|
72
|
+
private _start;
|
|
73
|
+
private _resolveToken;
|
|
74
|
+
private _createResumable;
|
|
75
|
+
private _fetchStatus;
|
|
76
|
+
private _continueUpload;
|
|
77
|
+
private _increaseMultiplier;
|
|
78
|
+
private _fetchMetadata;
|
|
79
|
+
private _oneShotUpload;
|
|
80
|
+
private _updateProgress;
|
|
81
|
+
private _transition;
|
|
82
|
+
private completeTransitions_;
|
|
83
|
+
/**
|
|
84
|
+
* A snapshot of the current task state.
|
|
85
|
+
*/
|
|
86
|
+
get snapshot(): UploadTaskSnapshot;
|
|
87
|
+
/**
|
|
88
|
+
* Adds a callback for an event.
|
|
89
|
+
* @param type - The type of event to listen for.
|
|
90
|
+
* @param nextOrObserver -
|
|
91
|
+
* The `next` function, which gets called for each item in
|
|
92
|
+
* the event stream, or an observer object with some or all of these three
|
|
93
|
+
* properties (`next`, `error`, `complete`).
|
|
94
|
+
* @param error - A function that gets called with a `StorageError`
|
|
95
|
+
* if the event stream ends due to an error.
|
|
96
|
+
* @param completed - A function that gets called if the
|
|
97
|
+
* event stream ends normally.
|
|
98
|
+
* @returns
|
|
99
|
+
* If only the event argument is passed, returns a function you can use to
|
|
100
|
+
* add callbacks (see the examples above). If more than just the event
|
|
101
|
+
* argument is passed, returns a function you can call to unregister the
|
|
102
|
+
* callbacks.
|
|
103
|
+
*/
|
|
104
|
+
on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
|
|
105
|
+
/**
|
|
106
|
+
* This object behaves like a Promise, and resolves with its snapshot data
|
|
107
|
+
* when the upload completes.
|
|
108
|
+
* @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
|
|
109
|
+
* @param onRejected - The rejection callback.
|
|
110
|
+
*/
|
|
111
|
+
then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>;
|
|
112
|
+
/**
|
|
113
|
+
* Equivalent to calling `then(null, onRejected)`.
|
|
114
|
+
*/
|
|
115
|
+
catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>;
|
|
116
|
+
/**
|
|
117
|
+
* Adds the given observer.
|
|
118
|
+
*/
|
|
119
|
+
private _addObserver;
|
|
120
|
+
/**
|
|
121
|
+
* Removes the given observer.
|
|
122
|
+
*/
|
|
123
|
+
private _removeObserver;
|
|
124
|
+
private _notifyObservers;
|
|
125
|
+
private _finishPromise;
|
|
126
|
+
private _notifyObserver;
|
|
127
|
+
/**
|
|
128
|
+
* Resumes a paused task. Has no effect on a currently running or failed task.
|
|
129
|
+
* @returns True if the operation took effect, false if ignored.
|
|
130
|
+
*/
|
|
131
|
+
resume(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Pauses a currently running task. Has no effect on a paused or failed task.
|
|
134
|
+
* @returns True if the operation took effect, false if ignored.
|
|
135
|
+
*/
|
|
136
|
+
pause(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Cancels a currently running or paused task. Has no effect on a complete or
|
|
139
|
+
* failed task.
|
|
140
|
+
* @returns True if the operation took effect, false if ignored.
|
|
141
|
+
*/
|
|
142
|
+
cancel(): boolean;
|
|
143
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 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,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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,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 PROJECT_ID: any;
|
|
18
|
+
export declare const STORAGE_BUCKET: any;
|
|
19
|
+
export declare const API_KEY: any;
|
|
20
|
+
export declare const AUTH_DOMAIN: any;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 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 { ErrorCode, Headers, Connection } from '../../src/implementation/connection';
|
|
18
|
+
export declare type SendHook = (connection: TestingConnection, url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => void;
|
|
19
|
+
export declare enum State {
|
|
20
|
+
START = 0,
|
|
21
|
+
SENT = 1,
|
|
22
|
+
DONE = 2
|
|
23
|
+
}
|
|
24
|
+
export declare class TestingConnection implements Connection {
|
|
25
|
+
private state;
|
|
26
|
+
private sendPromise;
|
|
27
|
+
private resolve;
|
|
28
|
+
private sendHook;
|
|
29
|
+
private status;
|
|
30
|
+
private responseText;
|
|
31
|
+
private headers;
|
|
32
|
+
private errorCode;
|
|
33
|
+
constructor(sendHook: SendHook | null);
|
|
34
|
+
send(url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>;
|
|
35
|
+
simulateResponse(status: number, body: string, headers: {
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
}): void;
|
|
38
|
+
getErrorCode(): ErrorCode;
|
|
39
|
+
getStatus(): number;
|
|
40
|
+
getResponseText(): string;
|
|
41
|
+
abort(): void;
|
|
42
|
+
getResponseHeader(header: string): string | null;
|
|
43
|
+
addUploadProgressListener(): void;
|
|
44
|
+
removeUploadProgressListener(): void;
|
|
45
|
+
}
|
|
46
|
+
export declare function newTestConnection(sendHook?: SendHook | null): Connection;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FirebaseApp } from '@firebase/app-types';
|
|
2
|
+
import { StorageError } from '../../src/implementation/error';
|
|
3
|
+
import { Headers, Connection } from '../../src/implementation/connection';
|
|
4
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
5
|
+
import { Provider } from '@firebase/component';
|
|
6
|
+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
7
|
+
import { FirebaseStorageImpl } from '../../src/service';
|
|
8
|
+
import { Metadata } from '../../src/metadata';
|
|
9
|
+
export declare const authToken = "totally-legit-auth-token";
|
|
10
|
+
export declare const appCheckToken = "totally-shady-token";
|
|
11
|
+
export declare const bucket = "mybucket";
|
|
12
|
+
export declare const fakeApp: FirebaseApp;
|
|
13
|
+
export declare const fakeAuthProvider: Provider<"auth-internal">;
|
|
14
|
+
export declare const emptyAuthProvider: Provider<"auth-internal">;
|
|
15
|
+
export declare const fakeAppCheckTokenProvider: Provider<"app-check-internal">;
|
|
16
|
+
export declare function makeFakeApp(bucketArg?: string): FirebaseApp;
|
|
17
|
+
export declare function makeFakeAuthProvider(token: {
|
|
18
|
+
accessToken: string;
|
|
19
|
+
}): Provider<FirebaseAuthInternalName>;
|
|
20
|
+
export declare function makeFakeAppCheckProvider(tokenResult: {
|
|
21
|
+
token: string;
|
|
22
|
+
}): Provider<AppCheckInternalComponentName>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns something that looks like an fbs.XhrIo with the given headers
|
|
25
|
+
* and status.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fakeXhrIo(headers: Headers, status?: number): Connection;
|
|
28
|
+
/**
|
|
29
|
+
* Binds ignoring types. Used to test calls involving improper arguments.
|
|
30
|
+
*/
|
|
31
|
+
export declare function bind(f: Function, ctx: any, ...args: any[]): () => void;
|
|
32
|
+
export declare function assertThrows(f: () => void, code: string): StorageError;
|
|
33
|
+
export declare function assertUint8ArrayEquals(arr1: Uint8Array, arr2: Uint8Array): void;
|
|
34
|
+
export declare function assertObjectIncludes(included: {
|
|
35
|
+
[name: string]: any;
|
|
36
|
+
}, obj: {
|
|
37
|
+
[name: string]: any;
|
|
38
|
+
}): void;
|
|
39
|
+
interface Response {
|
|
40
|
+
status: number;
|
|
41
|
+
body: string;
|
|
42
|
+
headers: Headers;
|
|
43
|
+
}
|
|
44
|
+
declare type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response;
|
|
45
|
+
export declare function storageServiceWithHandler(handler: RequestHandler): FirebaseStorageImpl;
|
|
46
|
+
export declare function fakeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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 {};
|
package/dist/src/api.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { FbsBlob as _FbsBlob } from './implementation/blob';
|
|
|
32
32
|
export { dataFromString as _dataFromString } from './implementation/string';
|
|
33
33
|
export { invalidRootOperation as _invalidRootOperation, invalidArgument as _invalidArgument } from './implementation/error';
|
|
34
34
|
export { TaskEvent as _TaskEvent, TaskState as _TaskState } from './implementation/taskenums';
|
|
35
|
+
export { StringFormat };
|
|
35
36
|
/**
|
|
36
37
|
* Uploads data to this object's location.
|
|
37
38
|
* The upload is not resumable.
|
|
@@ -159,7 +160,6 @@ export declare function ref(storageOrRef: FirebaseStorage | StorageReference, pa
|
|
|
159
160
|
* @internal
|
|
160
161
|
*/
|
|
161
162
|
export declare function _getChild(ref: StorageReference, childPath: string): Reference;
|
|
162
|
-
export { StringFormat } from './implementation/string';
|
|
163
163
|
/**
|
|
164
164
|
* Gets a {@link FirebaseStorage} instance for the given Firebase app.
|
|
165
165
|
* @public
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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 {};
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { RequestInfo } from './requestinfo';
|
|
18
18
|
import { Headers, Connection } from './connection';
|
|
19
|
-
import { ConnectionPool } from './connectionPool';
|
|
20
19
|
export interface Request<T> {
|
|
21
20
|
getPromise(): Promise<T>;
|
|
22
21
|
/**
|
|
@@ -45,4 +44,4 @@ export declare function addAuthHeader_(headers: Headers, authToken: string | nul
|
|
|
45
44
|
export declare function addVersionHeader_(headers: Headers, firebaseVersion?: string): void;
|
|
46
45
|
export declare function addGmpidHeader_(headers: Headers, appId: string | null): void;
|
|
47
46
|
export declare function addAppCheckHeader_(headers: Headers, appCheckToken: string | null): void;
|
|
48
|
-
export declare function makeRequest<T>(requestInfo: RequestInfo<T>, appId: string | null, authToken: string | null, appCheckToken: string | null,
|
|
47
|
+
export declare function makeRequest<T>(requestInfo: RequestInfo<T>, appId: string | null, authToken: string | null, appCheckToken: string | null, requestFactory: () => Connection, firebaseVersion?: string): Request<T>;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -36,3 +36,4 @@ export declare class XhrConnection implements Connection {
|
|
|
36
36
|
removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
37
37
|
}
|
|
38
38
|
export declare function newConnection(): Connection;
|
|
39
|
+
export declare function injectTestConnection(factory: (() => Connection) | null): void;
|
|
@@ -42,3 +42,4 @@ export declare class FetchConnection implements Connection {
|
|
|
42
42
|
removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
43
43
|
}
|
|
44
44
|
export declare function newConnection(): Connection;
|
|
45
|
+
export declare function injectTestConnection(factory: (() => Connection) | null): void;
|
package/dist/src/service.d.ts
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
import { Location } from './implementation/location';
|
|
18
18
|
import { Request } from './implementation/request';
|
|
19
19
|
import { RequestInfo } from './implementation/requestinfo';
|
|
20
|
-
import { ConnectionPool } from './implementation/connectionPool';
|
|
21
20
|
import { Reference } from './reference';
|
|
22
21
|
import { Provider } from '@firebase/component';
|
|
23
22
|
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
@@ -25,6 +24,7 @@ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types
|
|
|
25
24
|
import { FirebaseApp } from '@firebase/app';
|
|
26
25
|
import { FirebaseStorage } from './public-types';
|
|
27
26
|
import { EmulatorMockTokenOptions } from '@firebase/util';
|
|
27
|
+
import { Connection } from './implementation/connection';
|
|
28
28
|
export declare function isUrl(path?: string): boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Returns a storage Reference for the given url.
|
|
@@ -64,7 +64,6 @@ export declare class FirebaseStorageImpl implements FirebaseStorage {
|
|
|
64
64
|
/**
|
|
65
65
|
* @internal
|
|
66
66
|
*/
|
|
67
|
-
readonly _pool: ConnectionPool;
|
|
68
67
|
readonly _url?: string | undefined;
|
|
69
68
|
readonly _firebaseVersion?: string | undefined;
|
|
70
69
|
_bucket: Location | null;
|
|
@@ -93,7 +92,7 @@ export declare class FirebaseStorageImpl implements FirebaseStorage {
|
|
|
93
92
|
/**
|
|
94
93
|
* @internal
|
|
95
94
|
*/
|
|
96
|
-
|
|
95
|
+
_url?: string | undefined, _firebaseVersion?: string | undefined);
|
|
97
96
|
/**
|
|
98
97
|
* The host string for this service, in the form of `host` or
|
|
99
98
|
* `host:port`.
|
|
@@ -126,6 +125,6 @@ export declare class FirebaseStorageImpl implements FirebaseStorage {
|
|
|
126
125
|
* @param requestInfo - HTTP RequestInfo object
|
|
127
126
|
* @param authToken - Firebase auth token
|
|
128
127
|
*/
|
|
129
|
-
_makeRequest<T>(requestInfo: RequestInfo<T>, authToken: string | null, appCheckToken: string | null): Request<T>;
|
|
130
|
-
makeRequestWithTokens<T>(requestInfo: RequestInfo<T
|
|
128
|
+
_makeRequest<T>(requestInfo: RequestInfo<T>, requestFactory: () => Connection, authToken: string | null, appCheckToken: string | null): Request<T>;
|
|
129
|
+
makeRequestWithTokens<T>(requestInfo: RequestInfo<T>, requestFactory: () => Connection): Promise<T>;
|
|
131
130
|
}
|
package/dist/storage.d.ts
CHANGED
|
@@ -43,13 +43,6 @@ declare interface Connection {
|
|
|
43
43
|
removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/**
|
|
47
|
-
* Factory-like class for creating XhrIo instances.
|
|
48
|
-
*/
|
|
49
|
-
declare class ConnectionPool {
|
|
50
|
-
createConnection(): Connection;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
46
|
/**
|
|
54
47
|
* Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.
|
|
55
48
|
*
|
|
@@ -167,7 +160,6 @@ export declare class _FirebaseStorageImpl implements FirebaseStorage {
|
|
|
167
160
|
/**
|
|
168
161
|
* @internal
|
|
169
162
|
*/
|
|
170
|
-
readonly _pool: ConnectionPool;
|
|
171
163
|
readonly _url?: string | undefined;
|
|
172
164
|
readonly _firebaseVersion?: string | undefined;
|
|
173
165
|
_bucket: _Location | null;
|
|
@@ -196,7 +188,7 @@ export declare class _FirebaseStorageImpl implements FirebaseStorage {
|
|
|
196
188
|
/**
|
|
197
189
|
* @internal
|
|
198
190
|
*/
|
|
199
|
-
|
|
191
|
+
_url?: string | undefined, _firebaseVersion?: string | undefined);
|
|
200
192
|
/**
|
|
201
193
|
* The host string for this service, in the form of `host` or
|
|
202
194
|
* `host:port`.
|
|
@@ -229,8 +221,8 @@ export declare class _FirebaseStorageImpl implements FirebaseStorage {
|
|
|
229
221
|
* @param requestInfo - HTTP RequestInfo object
|
|
230
222
|
* @param authToken - Firebase auth token
|
|
231
223
|
*/
|
|
232
|
-
_makeRequest<T>(requestInfo: RequestInfo_2<T>, authToken: string | null, appCheckToken: string | null): Request_2<T>;
|
|
233
|
-
makeRequestWithTokens<T>(requestInfo: RequestInfo_2<T
|
|
224
|
+
_makeRequest<T>(requestInfo: RequestInfo_2<T>, requestFactory: () => Connection, authToken: string | null, appCheckToken: string | null): Request_2<T>;
|
|
225
|
+
makeRequestWithTokens<T>(requestInfo: RequestInfo_2<T>, requestFactory: () => Connection): Promise<T>;
|
|
234
226
|
}
|
|
235
227
|
|
|
236
228
|
/**
|