firebase-admin-edge 1.1.1 → 3.0.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 +103 -260
- package/dist/app-check/app-check-endpoints.d.ts +31 -0
- package/dist/app-check/app-check-endpoints.d.ts.map +1 -0
- package/dist/app-check/app-check-endpoints.js +75 -0
- package/dist/app-check/app-check-endpoints.js.map +1 -0
- package/dist/app-check/app-check-jwt.d.ts +16 -0
- package/dist/app-check/app-check-jwt.d.ts.map +1 -0
- package/dist/app-check/app-check-jwt.js +59 -0
- package/dist/app-check/app-check-jwt.js.map +1 -0
- package/dist/app-check/app-check.d.ts +48 -0
- package/dist/app-check/app-check.d.ts.map +1 -0
- package/dist/app-check/app-check.js +142 -0
- package/dist/app-check/app-check.js.map +1 -0
- package/dist/auth/auth-blocking-types.d.ts +44 -0
- package/dist/auth/auth-blocking-types.d.ts.map +1 -0
- package/dist/auth/auth-blocking-types.js +2 -0
- package/dist/auth/auth-blocking-types.js.map +1 -0
- package/dist/auth/auth-config-types.d.ts +146 -0
- package/dist/auth/auth-config-types.d.ts.map +1 -0
- package/dist/auth/auth-config-types.js +2 -0
- package/dist/auth/auth-config-types.js.map +1 -0
- package/dist/auth/auth-config.d.ts +15 -0
- package/dist/auth/auth-config.d.ts.map +1 -0
- package/dist/auth/auth-config.js +413 -0
- package/dist/auth/auth-config.js.map +1 -0
- package/dist/auth/auth-emulator.d.ts +7 -0
- package/dist/auth/auth-emulator.d.ts.map +1 -0
- package/dist/auth/auth-emulator.js +24 -0
- package/dist/auth/auth-emulator.js.map +1 -0
- package/dist/auth/auth-endpoint-errors.d.ts +2 -0
- package/dist/auth/auth-endpoint-errors.d.ts.map +1 -1
- package/dist/auth/auth-endpoint-errors.js +20 -1
- package/dist/auth/auth-endpoint-errors.js.map +1 -1
- package/dist/auth/email-link.d.ts +24 -0
- package/dist/auth/email-link.d.ts.map +1 -0
- package/dist/auth/email-link.js +103 -0
- package/dist/auth/email-link.js.map +1 -0
- package/dist/auth/firebase-admin-auth.d.ts +56 -8
- package/dist/auth/firebase-admin-auth.d.ts.map +1 -1
- package/dist/auth/firebase-admin-auth.js +323 -63
- package/dist/auth/firebase-admin-auth.js.map +1 -1
- package/dist/auth/firebase-auth-endpoints.d.ts +93 -5
- package/dist/auth/firebase-auth-endpoints.d.ts.map +1 -1
- package/dist/auth/firebase-auth-endpoints.js +342 -73
- package/dist/auth/firebase-auth-endpoints.js.map +1 -1
- package/dist/auth/firebase-auth.d.ts +82 -6
- package/dist/auth/firebase-auth.d.ts.map +1 -1
- package/dist/auth/firebase-auth.js +103 -10
- package/dist/auth/firebase-auth.js.map +1 -1
- package/dist/auth/firebase-jwt.d.ts +19 -10
- package/dist/auth/firebase-jwt.d.ts.map +1 -1
- package/dist/auth/firebase-jwt.js +176 -39
- package/dist/auth/firebase-jwt.js.map +1 -1
- package/dist/auth/firebase-types.d.ts +3 -0
- package/dist/auth/firebase-types.d.ts.map +1 -1
- package/dist/auth/google-oauth.d.ts +0 -1
- package/dist/auth/google-oauth.d.ts.map +1 -1
- package/dist/auth/google-oauth.js +16 -86
- package/dist/auth/google-oauth.js.map +1 -1
- package/dist/auth/identity-builder-types.d.ts +36 -0
- package/dist/auth/identity-builder-types.d.ts.map +1 -0
- package/dist/auth/identity-builder-types.js +2 -0
- package/dist/auth/identity-builder-types.js.map +1 -0
- package/dist/auth/identity-count-query.d.ts +17 -0
- package/dist/auth/identity-count-query.d.ts.map +1 -0
- package/dist/auth/identity-count-query.js +51 -0
- package/dist/auth/identity-count-query.js.map +1 -0
- package/dist/auth/identity-filter.d.ts +9 -0
- package/dist/auth/identity-filter.d.ts.map +1 -0
- package/dist/auth/identity-filter.js +129 -0
- package/dist/auth/identity-filter.js.map +1 -0
- package/dist/auth/identity-query.d.ts +11 -0
- package/dist/auth/identity-query.d.ts.map +1 -0
- package/dist/auth/identity-query.js +122 -0
- package/dist/auth/identity-query.js.map +1 -0
- package/dist/auth/identity-reference.d.ts +131 -0
- package/dist/auth/identity-reference.d.ts.map +1 -0
- package/dist/auth/identity-reference.js +293 -0
- package/dist/auth/identity-reference.js.map +1 -0
- package/dist/auth/identity-types.d.ts +44 -0
- package/dist/auth/identity-types.d.ts.map +1 -0
- package/dist/auth/identity-types.js +2 -0
- package/dist/auth/identity-types.js.map +1 -0
- package/dist/auth/identity-write.d.ts +41 -0
- package/dist/auth/identity-write.d.ts.map +1 -0
- package/dist/auth/identity-write.js +146 -0
- package/dist/auth/identity-write.js.map +1 -0
- package/dist/auth/identity.d.ts +84 -0
- package/dist/auth/identity.d.ts.map +1 -0
- package/dist/auth/identity.js +319 -0
- package/dist/auth/identity.js.map +1 -0
- package/dist/auth/project-config-manager.d.ts +10 -0
- package/dist/auth/project-config-manager.d.ts.map +1 -0
- package/dist/auth/project-config-manager.js +22 -0
- package/dist/auth/project-config-manager.js.map +1 -0
- package/dist/auth/provider-credential.d.ts +43 -0
- package/dist/auth/provider-credential.d.ts.map +1 -0
- package/dist/auth/provider-credential.js +107 -0
- package/dist/auth/provider-credential.js.map +1 -0
- package/dist/auth/provider-session.d.ts +10 -0
- package/dist/auth/provider-session.d.ts.map +1 -0
- package/dist/auth/provider-session.js +28 -0
- package/dist/auth/provider-session.js.map +1 -0
- package/dist/auth/tenant-manager.d.ts +17 -0
- package/dist/auth/tenant-manager.d.ts.map +1 -0
- package/dist/auth/tenant-manager.js +59 -0
- package/dist/auth/tenant-manager.js.map +1 -0
- package/dist/auth/user-import.d.ts +7 -1
- package/dist/auth/user-import.d.ts.map +1 -1
- package/dist/auth/user-import.js +53 -15
- package/dist/auth/user-import.js.map +1 -1
- package/dist/auth/user-record.d.ts +1 -0
- package/dist/auth/user-record.d.ts.map +1 -1
- package/dist/auth/user-record.js +5 -0
- package/dist/auth/user-record.js.map +1 -1
- package/dist/auth/user-request.d.ts +4 -1
- package/dist/auth/user-request.d.ts.map +1 -1
- package/dist/auth/user-request.js +7 -4
- package/dist/auth/user-request.js.map +1 -1
- package/dist/db/aggregate.d.ts +49 -0
- package/dist/db/aggregate.d.ts.map +1 -0
- package/dist/db/aggregate.js +115 -0
- package/dist/db/aggregate.js.map +1 -0
- package/dist/db/bulk-writer.d.ts +55 -0
- package/dist/db/bulk-writer.d.ts.map +1 -0
- package/dist/db/bulk-writer.js +257 -0
- package/dist/db/bulk-writer.js.map +1 -0
- package/dist/db/bundle-builder.d.ts +17 -0
- package/dist/db/bundle-builder.d.ts.map +1 -0
- package/dist/db/bundle-builder.js +118 -0
- package/dist/db/bundle-builder.js.map +1 -0
- package/dist/db/bytes.d.ts +12 -0
- package/dist/db/bytes.d.ts.map +1 -0
- package/dist/db/bytes.js +49 -0
- package/dist/db/bytes.js.map +1 -0
- package/dist/db/collection-group.d.ts +14 -0
- package/dist/db/collection-group.d.ts.map +1 -0
- package/dist/db/collection-group.js +43 -0
- package/dist/db/collection-group.js.map +1 -0
- package/dist/db/collection-reference.d.ts +21 -0
- package/dist/db/collection-reference.d.ts.map +1 -0
- package/dist/db/collection-reference.js +46 -0
- package/dist/db/collection-reference.js.map +1 -0
- package/dist/db/document-reference.d.ts +41 -0
- package/dist/db/document-reference.d.ts.map +1 -0
- package/dist/db/document-reference.js +125 -0
- package/dist/db/document-reference.js.map +1 -0
- package/dist/db/document-snapshot.d.ts +31 -0
- package/dist/db/document-snapshot.d.ts.map +1 -0
- package/dist/db/document-snapshot.js +103 -0
- package/dist/db/document-snapshot.js.map +1 -0
- package/dist/db/explain.d.ts +28 -0
- package/dist/db/explain.d.ts.map +1 -0
- package/dist/db/explain.js +61 -0
- package/dist/db/explain.js.map +1 -0
- package/dist/db/field-path.d.ts +10 -0
- package/dist/db/field-path.d.ts.map +1 -0
- package/dist/db/field-path.js +65 -0
- package/dist/db/field-path.js.map +1 -0
- package/dist/db/field-value.d.ts +17 -0
- package/dist/db/field-value.d.ts.map +1 -0
- package/dist/db/field-value.js +57 -0
- package/dist/db/field-value.js.map +1 -0
- package/dist/db/filter.d.ts +20 -0
- package/dist/db/filter.d.ts.map +1 -0
- package/dist/db/filter.js +48 -0
- package/dist/db/filter.js.map +1 -0
- package/dist/db/firestore-converter.d.ts +11 -0
- package/dist/db/firestore-converter.d.ts.map +1 -0
- package/dist/db/firestore-converter.js +14 -0
- package/dist/db/firestore-converter.js.map +1 -0
- package/dist/db/firestore-document.d.ts +62 -0
- package/dist/db/firestore-document.d.ts.map +1 -0
- package/dist/db/firestore-document.js +238 -0
- package/dist/db/firestore-document.js.map +1 -0
- package/dist/db/firestore-endpoints.d.ts +41 -0
- package/dist/db/firestore-endpoints.d.ts.map +1 -0
- package/dist/db/firestore-endpoints.js +735 -0
- package/dist/db/firestore-endpoints.js.map +1 -0
- package/dist/db/firestore-error-codes.d.ts +24 -0
- package/dist/db/firestore-error-codes.d.ts.map +1 -0
- package/dist/db/firestore-error-codes.js +24 -0
- package/dist/db/firestore-error-codes.js.map +1 -0
- package/dist/db/firestore-logging.d.ts +23 -0
- package/dist/db/firestore-logging.d.ts.map +1 -0
- package/dist/db/firestore-logging.js +41 -0
- package/dist/db/firestore-logging.js.map +1 -0
- package/dist/db/firestore-path.d.ts +4 -0
- package/dist/db/firestore-path.d.ts.map +1 -0
- package/dist/db/firestore-path.js +37 -0
- package/dist/db/firestore-path.js.map +1 -0
- package/dist/db/firestore-results.d.ts +12 -0
- package/dist/db/firestore-results.d.ts.map +1 -0
- package/dist/db/firestore-results.js +19 -0
- package/dist/db/firestore-results.js.map +1 -0
- package/dist/db/firestore-settings.d.ts +22 -0
- package/dist/db/firestore-settings.d.ts.map +1 -0
- package/dist/db/firestore-settings.js +83 -0
- package/dist/db/firestore-settings.js.map +1 -0
- package/dist/db/firestore-telemetry.d.ts +21 -0
- package/dist/db/firestore-telemetry.d.ts.map +1 -0
- package/dist/db/firestore-telemetry.js +84 -0
- package/dist/db/firestore-telemetry.js.map +1 -0
- package/dist/db/firestore-types.d.ts +25 -0
- package/dist/db/firestore-types.d.ts.map +1 -0
- package/dist/db/firestore-types.js +2 -0
- package/dist/db/firestore-types.js.map +1 -0
- package/dist/db/firestore.d.ts +157 -0
- package/dist/db/firestore.d.ts.map +1 -0
- package/dist/db/firestore.js +513 -0
- package/dist/db/firestore.js.map +1 -0
- package/dist/db/geo-point.d.ts +11 -0
- package/dist/db/geo-point.d.ts.map +1 -0
- package/dist/db/geo-point.js +29 -0
- package/dist/db/geo-point.js.map +1 -0
- package/dist/db/json-stream.d.ts +3 -0
- package/dist/db/json-stream.d.ts.map +1 -0
- package/dist/db/json-stream.js +117 -0
- package/dist/db/json-stream.js.map +1 -0
- package/dist/db/pipeline-expression.d.ts +293 -0
- package/dist/db/pipeline-expression.d.ts.map +1 -0
- package/dist/db/pipeline-expression.js +1436 -0
- package/dist/db/pipeline-expression.js.map +1 -0
- package/dist/db/pipeline-query.d.ts +6 -0
- package/dist/db/pipeline-query.d.ts.map +1 -0
- package/dist/db/pipeline-query.js +91 -0
- package/dist/db/pipeline-query.js.map +1 -0
- package/dist/db/pipeline.d.ts +120 -0
- package/dist/db/pipeline.d.ts.map +1 -0
- package/dist/db/pipeline.js +396 -0
- package/dist/db/pipeline.js.map +1 -0
- package/dist/db/query-document-snapshot.d.ts +2 -0
- package/dist/db/query-document-snapshot.d.ts.map +1 -0
- package/dist/db/query-document-snapshot.js +2 -0
- package/dist/db/query-document-snapshot.js.map +1 -0
- package/dist/db/query-partition.d.ts +14 -0
- package/dist/db/query-partition.d.ts.map +1 -0
- package/dist/db/query-partition.js +32 -0
- package/dist/db/query-partition.js.map +1 -0
- package/dist/db/query-request.d.ts +96 -0
- package/dist/db/query-request.d.ts.map +1 -0
- package/dist/db/query-request.js +283 -0
- package/dist/db/query-request.js.map +1 -0
- package/dist/db/query.d.ts +129 -0
- package/dist/db/query.d.ts.map +1 -0
- package/dist/db/query.js +468 -0
- package/dist/db/query.js.map +1 -0
- package/dist/db/recursive-delete.d.ts +6 -0
- package/dist/db/recursive-delete.d.ts.map +1 -0
- package/dist/db/recursive-delete.js +38 -0
- package/dist/db/recursive-delete.js.map +1 -0
- package/dist/db/snapshot-listener.d.ts +10 -0
- package/dist/db/snapshot-listener.d.ts.map +1 -0
- package/dist/db/snapshot-listener.js +71 -0
- package/dist/db/snapshot-listener.js.map +1 -0
- package/dist/db/timestamp.d.ts +29 -0
- package/dist/db/timestamp.d.ts.map +1 -0
- package/dist/db/timestamp.js +98 -0
- package/dist/db/timestamp.js.map +1 -0
- package/dist/db/transaction.d.ts +44 -0
- package/dist/db/transaction.d.ts.map +1 -0
- package/dist/db/transaction.js +177 -0
- package/dist/db/transaction.js.map +1 -0
- package/dist/db/value-equality.d.ts +3 -0
- package/dist/db/value-equality.d.ts.map +1 -0
- package/dist/db/value-equality.js +29 -0
- package/dist/db/value-equality.js.map +1 -0
- package/dist/db/vector-query.d.ts +38 -0
- package/dist/db/vector-query.d.ts.map +1 -0
- package/dist/db/vector-query.js +110 -0
- package/dist/db/vector-query.js.map +1 -0
- package/dist/db/vector-value.d.ts +8 -0
- package/dist/db/vector-value.d.ts.map +1 -0
- package/dist/db/vector-value.js +25 -0
- package/dist/db/vector-value.js.map +1 -0
- package/dist/db/write-batch.d.ts +25 -0
- package/dist/db/write-batch.d.ts.map +1 -0
- package/dist/db/write-batch.js +72 -0
- package/dist/db/write-batch.js.map +1 -0
- package/dist/db/write-request.d.ts +36 -0
- package/dist/db/write-request.d.ts.map +1 -0
- package/dist/db/write-request.js +257 -0
- package/dist/db/write-request.js.map +1 -0
- package/dist/firebase-edge-server.d.ts +145 -36
- package/dist/firebase-edge-server.d.ts.map +1 -1
- package/dist/firebase-edge-server.js +495 -258
- package/dist/firebase-edge-server.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/rest-fetch.d.ts +1 -1
- package/dist/rest-fetch.d.ts.map +1 -1
- package/dist/storage/storage-acl.d.ts +48 -0
- package/dist/storage/storage-acl.d.ts.map +1 -0
- package/dist/storage/storage-acl.js +101 -0
- package/dist/storage/storage-acl.js.map +1 -0
- package/dist/storage/storage-bucket-endpoints.d.ts +10 -0
- package/dist/storage/storage-bucket-endpoints.d.ts.map +1 -0
- package/dist/storage/storage-bucket-endpoints.js +514 -0
- package/dist/storage/storage-bucket-endpoints.js.map +1 -0
- package/dist/storage/storage-bucket-types.d.ts +183 -0
- package/dist/storage/storage-bucket-types.d.ts.map +1 -0
- package/dist/storage/storage-bucket-types.js +2 -0
- package/dist/storage/storage-bucket-types.js.map +1 -0
- package/dist/storage/storage-bucket.d.ts +122 -0
- package/dist/storage/storage-bucket.d.ts.map +1 -0
- package/dist/storage/storage-bucket.js +544 -0
- package/dist/storage/storage-bucket.js.map +1 -0
- package/dist/storage/storage-channel.d.ts +10 -0
- package/dist/storage/storage-channel.d.ts.map +1 -0
- package/dist/storage/storage-channel.js +15 -0
- package/dist/storage/storage-channel.js.map +1 -0
- package/dist/storage/storage-checksum.d.ts +35 -0
- package/dist/storage/storage-checksum.d.ts.map +1 -0
- package/dist/storage/storage-checksum.js +312 -0
- package/dist/storage/storage-checksum.js.map +1 -0
- package/dist/storage/storage-endpoints.d.ts +14 -0
- package/dist/storage/storage-endpoints.d.ts.map +1 -0
- package/dist/storage/storage-endpoints.js +721 -0
- package/dist/storage/storage-endpoints.js.map +1 -0
- package/dist/storage/storage-file.d.ts +126 -0
- package/dist/storage/storage-file.d.ts.map +1 -0
- package/dist/storage/storage-file.js +604 -0
- package/dist/storage/storage-file.js.map +1 -0
- package/dist/storage/storage-hmac-key.d.ts +26 -0
- package/dist/storage/storage-hmac-key.d.ts.map +1 -0
- package/dist/storage/storage-hmac-key.js +45 -0
- package/dist/storage/storage-hmac-key.js.map +1 -0
- package/dist/storage/storage-iam.d.ts +20 -0
- package/dist/storage/storage-iam.d.ts.map +1 -0
- package/dist/storage/storage-iam.js +43 -0
- package/dist/storage/storage-iam.js.map +1 -0
- package/dist/storage/storage-md5.d.ts +11 -0
- package/dist/storage/storage-md5.d.ts.map +1 -0
- package/dist/storage/storage-md5.js +96 -0
- package/dist/storage/storage-md5.js.map +1 -0
- package/dist/storage/storage-notification.d.ts +24 -0
- package/dist/storage/storage-notification.d.ts.map +1 -0
- package/dist/storage/storage-notification.js +40 -0
- package/dist/storage/storage-notification.js.map +1 -0
- package/dist/storage/storage-progress.d.ts +4 -0
- package/dist/storage/storage-progress.d.ts.map +1 -0
- package/dist/storage/storage-progress.js +17 -0
- package/dist/storage/storage-progress.js.map +1 -0
- package/dist/storage/storage-reference-endpoints.d.ts +63 -0
- package/dist/storage/storage-reference-endpoints.d.ts.map +1 -0
- package/dist/storage/storage-reference-endpoints.js +276 -0
- package/dist/storage/storage-reference-endpoints.js.map +1 -0
- package/dist/storage/storage-reference-helpers.d.ts +12 -0
- package/dist/storage/storage-reference-helpers.d.ts.map +1 -0
- package/dist/storage/storage-reference-helpers.js +72 -0
- package/dist/storage/storage-reference-helpers.js.map +1 -0
- package/dist/storage/storage-reference-signing.d.ts +40 -0
- package/dist/storage/storage-reference-signing.d.ts.map +1 -0
- package/dist/storage/storage-reference-signing.js +289 -0
- package/dist/storage/storage-reference-signing.js.map +1 -0
- package/dist/storage/storage-reference-types.d.ts +76 -0
- package/dist/storage/storage-reference-types.d.ts.map +1 -0
- package/dist/storage/storage-reference-types.js +2 -0
- package/dist/storage/storage-reference-types.js.map +1 -0
- package/dist/storage/storage-results.d.ts +8 -0
- package/dist/storage/storage-results.d.ts.map +1 -0
- package/dist/storage/storage-results.js +32 -0
- package/dist/storage/storage-results.js.map +1 -0
- package/dist/storage/storage-resumable.d.ts +18 -0
- package/dist/storage/storage-resumable.d.ts.map +1 -0
- package/dist/storage/storage-resumable.js +166 -0
- package/dist/storage/storage-resumable.js.map +1 -0
- package/dist/storage/storage-retry.d.ts +9 -0
- package/dist/storage/storage-retry.d.ts.map +1 -0
- package/dist/storage/storage-retry.js +104 -0
- package/dist/storage/storage-retry.js.map +1 -0
- package/dist/storage/storage-signed-url.d.ts +9 -0
- package/dist/storage/storage-signed-url.d.ts.map +1 -0
- package/dist/storage/storage-signed-url.js +96 -0
- package/dist/storage/storage-signed-url.js.map +1 -0
- package/dist/storage/storage-special-endpoints.d.ts +10 -0
- package/dist/storage/storage-special-endpoints.d.ts.map +1 -0
- package/dist/storage/storage-special-endpoints.js +394 -0
- package/dist/storage/storage-special-endpoints.js.map +1 -0
- package/dist/storage/storage-special-types.d.ts +154 -0
- package/dist/storage/storage-special-types.d.ts.map +1 -0
- package/dist/storage/storage-special-types.js +2 -0
- package/dist/storage/storage-special-types.js.map +1 -0
- package/dist/storage/storage-types.d.ts +251 -0
- package/dist/storage/storage-types.d.ts.map +1 -0
- package/dist/storage/storage-types.js +2 -0
- package/dist/storage/storage-types.js.map +1 -0
- package/dist/storage/storage-upload-stream.d.ts +41 -0
- package/dist/storage/storage-upload-stream.d.ts.map +1 -0
- package/dist/storage/storage-upload-stream.js +335 -0
- package/dist/storage/storage-upload-stream.js.map +1 -0
- package/dist/storage/storage-xml-signing.d.ts +17 -0
- package/dist/storage/storage-xml-signing.d.ts.map +1 -0
- package/dist/storage/storage-xml-signing.js +144 -0
- package/dist/storage/storage-xml-signing.js.map +1 -0
- package/dist/storage/storage.d.ts +159 -0
- package/dist/storage/storage.d.ts.map +1 -0
- package/dist/storage/storage.js +545 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/utils/token-cache.d.ts.map +1 -1
- package/dist/utils/token-cache.js +3 -2
- package/dist/utils/token-cache.js.map +1 -1
- package/package.json +24 -8
- package/dist/auth/auth-endpoint-errors.test.d.ts +0 -2
- package/dist/auth/auth-endpoint-errors.test.d.ts.map +0 -1
- package/dist/auth/auth-endpoint-errors.test.js +0 -411
- package/dist/auth/auth-endpoint-errors.test.js.map +0 -1
- package/dist/auth/email-action-request.test.d.ts +0 -2
- package/dist/auth/email-action-request.test.d.ts.map +0 -1
- package/dist/auth/email-action-request.test.js +0 -128
- package/dist/auth/email-action-request.test.js.map +0 -1
- package/dist/auth/errors.test.d.ts +0 -2
- package/dist/auth/errors.test.d.ts.map +0 -1
- package/dist/auth/errors.test.js +0 -123
- package/dist/auth/errors.test.js.map +0 -1
- package/dist/auth/firebase-admin-auth.test.d.ts +0 -2
- package/dist/auth/firebase-admin-auth.test.d.ts.map +0 -1
- package/dist/auth/firebase-admin-auth.test.js +0 -1542
- package/dist/auth/firebase-admin-auth.test.js.map +0 -1
- package/dist/auth/firebase-auth-endpoints.test.d.ts +0 -2
- package/dist/auth/firebase-auth-endpoints.test.d.ts.map +0 -1
- package/dist/auth/firebase-auth-endpoints.test.js +0 -1082
- package/dist/auth/firebase-auth-endpoints.test.js.map +0 -1
- package/dist/auth/firebase-auth.test.d.ts +0 -2
- package/dist/auth/firebase-auth.test.d.ts.map +0 -1
- package/dist/auth/firebase-auth.test.js +0 -167
- package/dist/auth/firebase-auth.test.js.map +0 -1
- package/dist/auth/firebase-jwt.test.d.ts +0 -2
- package/dist/auth/firebase-jwt.test.d.ts.map +0 -1
- package/dist/auth/firebase-jwt.test.js +0 -164
- package/dist/auth/firebase-jwt.test.js.map +0 -1
- package/dist/auth/github-oauth.d.ts +0 -19
- package/dist/auth/github-oauth.d.ts.map +0 -1
- package/dist/auth/github-oauth.js +0 -145
- package/dist/auth/github-oauth.js.map +0 -1
- package/dist/auth/github-oauth.test.d.ts +0 -2
- package/dist/auth/github-oauth.test.d.ts.map +0 -1
- package/dist/auth/github-oauth.test.js +0 -202
- package/dist/auth/github-oauth.test.js.map +0 -1
- package/dist/auth/google-oauth.test.d.ts +0 -2
- package/dist/auth/google-oauth.test.d.ts.map +0 -1
- package/dist/auth/google-oauth.test.js +0 -200
- package/dist/auth/google-oauth.test.js.map +0 -1
- package/dist/auth/oauth.d.ts +0 -3
- package/dist/auth/oauth.d.ts.map +0 -1
- package/dist/auth/oauth.js +0 -48
- package/dist/auth/oauth.js.map +0 -1
- package/dist/auth/oauth.test.d.ts +0 -2
- package/dist/auth/oauth.test.d.ts.map +0 -1
- package/dist/auth/oauth.test.js +0 -109
- package/dist/auth/oauth.test.js.map +0 -1
- package/dist/auth/user-batch.test.d.ts +0 -2
- package/dist/auth/user-batch.test.d.ts.map +0 -1
- package/dist/auth/user-batch.test.js +0 -73
- package/dist/auth/user-batch.test.js.map +0 -1
- package/dist/auth/user-import.test.d.ts +0 -2
- package/dist/auth/user-import.test.d.ts.map +0 -1
- package/dist/auth/user-import.test.js +0 -217
- package/dist/auth/user-import.test.js.map +0 -1
- package/dist/auth/user-record.test.d.ts +0 -2
- package/dist/auth/user-record.test.d.ts.map +0 -1
- package/dist/auth/user-record.test.js +0 -198
- package/dist/auth/user-record.test.js.map +0 -1
- package/dist/auth/user-request.test.d.ts +0 -2
- package/dist/auth/user-request.test.d.ts.map +0 -1
- package/dist/auth/user-request.test.js +0 -327
- package/dist/auth/user-request.test.js.map +0 -1
- package/dist/firebase-edge-errors.test.d.ts +0 -2
- package/dist/firebase-edge-errors.test.d.ts.map +0 -1
- package/dist/firebase-edge-errors.test.js +0 -72
- package/dist/firebase-edge-errors.test.js.map +0 -1
- package/dist/firebase-edge-server.test.d.ts +0 -2
- package/dist/firebase-edge-server.test.d.ts.map +0 -1
- package/dist/firebase-edge-server.test.js +0 -293
- package/dist/firebase-edge-server.test.js.map +0 -1
- package/dist/rest-fetch.test.d.ts +0 -2
- package/dist/rest-fetch.test.d.ts.map +0 -1
- package/dist/rest-fetch.test.js +0 -164
- package/dist/rest-fetch.test.js.map +0 -1
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
import { FirebaseEdgeError } from '../auth/errors.js';
|
|
2
|
+
import { calculateStorageCrc32c, calculateStorageMd5, validateStorageMd5, validateStorageCrc32c, verifyStorageDownload, verifyStorageStream, verifyStorageUpload, storageUploadBlob } from './storage-checksum.js';
|
|
3
|
+
import { reportStorageProgress } from './storage-progress.js';
|
|
4
|
+
import { storageEncryptionHeaders } from './storage-reference-endpoints.js';
|
|
5
|
+
/** @internal Validate before requesting credentials. */
|
|
6
|
+
export function validateStorageOperation(bucket, operation) {
|
|
7
|
+
if (typeof bucket !== 'string' ||
|
|
8
|
+
!bucket ||
|
|
9
|
+
/[\s/\\?#]/.test(bucket) ||
|
|
10
|
+
bucket === '.' ||
|
|
11
|
+
bucket === '..') {
|
|
12
|
+
throw new FirebaseEdgeError({
|
|
13
|
+
code: 'storage/invalid-argument',
|
|
14
|
+
message: 'Configure a storage bucket name without a URL or gs:// prefix.'
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if ('name' in operation &&
|
|
18
|
+
(typeof operation.name !== 'string' ||
|
|
19
|
+
!operation.name ||
|
|
20
|
+
/[\r\n]/.test(operation.name) ||
|
|
21
|
+
operation.name === '.' ||
|
|
22
|
+
operation.name === '..')) {
|
|
23
|
+
throw new FirebaseEdgeError({
|
|
24
|
+
code: 'storage/invalid-argument',
|
|
25
|
+
message: 'A valid object name is required.'
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if ('options' in operation &&
|
|
29
|
+
!(operation.options === undefined &&
|
|
30
|
+
['download', 'stream', 'metadata'].includes(operation.kind)) &&
|
|
31
|
+
(!operation.options ||
|
|
32
|
+
typeof operation.options !== 'object' ||
|
|
33
|
+
Array.isArray(operation.options))) {
|
|
34
|
+
throw new FirebaseEdgeError({
|
|
35
|
+
code: 'storage/invalid-argument',
|
|
36
|
+
message: 'Storage options must be an object.'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (operation.kind === 'upload') {
|
|
40
|
+
if (operation.options.md5Hash !== undefined &&
|
|
41
|
+
operation.options.md5Hash !== 'auto') {
|
|
42
|
+
validateStorageMd5(operation.options.md5Hash);
|
|
43
|
+
}
|
|
44
|
+
if (operation.options.metadata !== undefined) {
|
|
45
|
+
validateMetadataUpdate(operation.options.metadata);
|
|
46
|
+
}
|
|
47
|
+
if (operation.options.crc32c !== undefined &&
|
|
48
|
+
operation.options.crc32c !== 'auto') {
|
|
49
|
+
validateStorageCrc32c(operation.options.crc32c);
|
|
50
|
+
}
|
|
51
|
+
if (operation.options.onProgress !== undefined &&
|
|
52
|
+
typeof operation.options.onProgress !== 'function') {
|
|
53
|
+
throw new FirebaseEdgeError({
|
|
54
|
+
code: 'storage/invalid-argument',
|
|
55
|
+
message: 'onProgress must be a function.'
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (typeof operation.body !== 'string' &&
|
|
59
|
+
!(operation.body instanceof Blob) &&
|
|
60
|
+
!(operation.body instanceof ArrayBuffer) &&
|
|
61
|
+
!(operation.body instanceof Uint8Array)) {
|
|
62
|
+
throw new FirebaseEdgeError({
|
|
63
|
+
code: 'storage/invalid-argument',
|
|
64
|
+
message: 'Upload data must be a string, Blob, ArrayBuffer, or Uint8Array.'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const { contentType } = operation.options;
|
|
68
|
+
if (contentType !== undefined &&
|
|
69
|
+
(typeof contentType !== 'string' ||
|
|
70
|
+
!contentType.trim() ||
|
|
71
|
+
/[\r\n]/.test(contentType))) {
|
|
72
|
+
throw new FirebaseEdgeError({
|
|
73
|
+
code: 'storage/invalid-argument',
|
|
74
|
+
message: 'contentType must be a nonempty HTTP header value.'
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if ('options' in operation && operation.options) {
|
|
79
|
+
const query = operation.options;
|
|
80
|
+
if (query.overrideUnlockedRetention !== undefined &&
|
|
81
|
+
typeof query.overrideUnlockedRetention !== 'boolean') {
|
|
82
|
+
throw new FirebaseEdgeError({
|
|
83
|
+
code: 'storage/invalid-argument',
|
|
84
|
+
message: 'overrideUnlockedRetention must be a boolean.'
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
for (const key of [
|
|
88
|
+
'userProject',
|
|
89
|
+
'fields',
|
|
90
|
+
'kmsKeyName',
|
|
91
|
+
'predefinedAcl',
|
|
92
|
+
'origin'
|
|
93
|
+
]) {
|
|
94
|
+
const value = query[key];
|
|
95
|
+
if (value !== undefined &&
|
|
96
|
+
(typeof value !== 'string' ||
|
|
97
|
+
!value.trim() ||
|
|
98
|
+
/[\r\n]/.test(value))) {
|
|
99
|
+
throw new FirebaseEdgeError({
|
|
100
|
+
code: 'storage/invalid-argument',
|
|
101
|
+
message: `${key} must be a nonempty string.`
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (query.checksumAlgorithm !== undefined &&
|
|
106
|
+
!['crc32c', 'md5'].includes(String(query.checksumAlgorithm))) {
|
|
107
|
+
throw new FirebaseEdgeError({
|
|
108
|
+
code: 'storage/invalid-argument',
|
|
109
|
+
message: 'Unknown checksum algorithm.'
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
for (const key of [
|
|
113
|
+
'ifGenerationMatch',
|
|
114
|
+
'ifGenerationNotMatch',
|
|
115
|
+
'ifMetagenerationMatch',
|
|
116
|
+
'ifMetagenerationNotMatch',
|
|
117
|
+
'ifSourceGenerationMatch',
|
|
118
|
+
'ifSourceMetagenerationMatch',
|
|
119
|
+
'generation',
|
|
120
|
+
'sourceGeneration'
|
|
121
|
+
]) {
|
|
122
|
+
const value = operation.options[key];
|
|
123
|
+
if (value !== undefined &&
|
|
124
|
+
(typeof value !== 'string' || !/^\d+$/.test(value))) {
|
|
125
|
+
throw new FirebaseEdgeError({
|
|
126
|
+
code: 'storage/invalid-argument',
|
|
127
|
+
message: `${key} must be a nonnegative integer string.`
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if ((operation.kind === 'download' || operation.kind === 'stream') &&
|
|
133
|
+
operation.options) {
|
|
134
|
+
const { start, end } = operation.options;
|
|
135
|
+
if (operation.options.verifyChecksum !== undefined &&
|
|
136
|
+
typeof operation.options.verifyChecksum !== 'boolean') {
|
|
137
|
+
throw new FirebaseEdgeError({
|
|
138
|
+
code: 'storage/invalid-argument',
|
|
139
|
+
message: 'verifyChecksum must be a boolean.'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (operation.options.verifyChecksum &&
|
|
143
|
+
(start !== undefined || end !== undefined)) {
|
|
144
|
+
throw new FirebaseEdgeError({
|
|
145
|
+
code: 'storage/invalid-argument',
|
|
146
|
+
message: 'Checksum verification requires a complete download without a byte range.'
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if ((start !== undefined &&
|
|
150
|
+
(!Number.isSafeInteger(start) || start < 0)) ||
|
|
151
|
+
(end !== undefined &&
|
|
152
|
+
(!Number.isSafeInteger(end) ||
|
|
153
|
+
(end < 0 ? start !== undefined : end < (start ?? 0))))) {
|
|
154
|
+
throw new FirebaseEdgeError({
|
|
155
|
+
code: 'storage/invalid-argument',
|
|
156
|
+
message: 'Use a nonnegative start/end range or a negative end alone for a suffix range.'
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (operation.kind === 'resumable') {
|
|
161
|
+
if (operation.options.md5Hash !== undefined) {
|
|
162
|
+
validateStorageMd5(operation.options.md5Hash);
|
|
163
|
+
}
|
|
164
|
+
if (operation.options.crc32c !== undefined) {
|
|
165
|
+
validateStorageCrc32c(operation.options.crc32c);
|
|
166
|
+
}
|
|
167
|
+
const { size, contentType, metadata } = operation.options;
|
|
168
|
+
if (size !== undefined && (!Number.isSafeInteger(size) || size < 0)) {
|
|
169
|
+
throw new FirebaseEdgeError({
|
|
170
|
+
code: 'storage/invalid-argument',
|
|
171
|
+
message: 'Upload size must be a nonnegative safe integer.'
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (contentType !== undefined &&
|
|
175
|
+
(typeof contentType !== 'string' ||
|
|
176
|
+
!contentType.trim() ||
|
|
177
|
+
/[\r\n]/.test(contentType))) {
|
|
178
|
+
throw new FirebaseEdgeError({
|
|
179
|
+
code: 'storage/invalid-argument',
|
|
180
|
+
message: 'Invalid upload content type.'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (metadata !== undefined) {
|
|
184
|
+
validateMetadataUpdate(metadata);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (operation.kind === 'restore' &&
|
|
188
|
+
(!operation.options.generation ||
|
|
189
|
+
(operation.options.projection !== undefined &&
|
|
190
|
+
!['full', 'noAcl'].includes(operation.options.projection)) ||
|
|
191
|
+
(operation.options.restoreToken !== undefined &&
|
|
192
|
+
typeof operation.options.restoreToken !== 'string') ||
|
|
193
|
+
(operation.options.copySourceAcl !== undefined &&
|
|
194
|
+
typeof operation.options.copySourceAcl !== 'boolean'))) {
|
|
195
|
+
throw new FirebaseEdgeError({
|
|
196
|
+
code: 'storage/invalid-argument',
|
|
197
|
+
message: 'Restore requires a generation and valid restore options.'
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (operation.kind === 'compose') {
|
|
201
|
+
if (!Array.isArray(operation.sources) ||
|
|
202
|
+
operation.sources.length < 1 ||
|
|
203
|
+
operation.sources.length > 32) {
|
|
204
|
+
throw new FirebaseEdgeError({
|
|
205
|
+
code: 'storage/invalid-argument',
|
|
206
|
+
message: 'Compose requires 1 to 32 source objects.'
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
for (const source of operation.sources) {
|
|
210
|
+
if (!source || typeof source !== 'object') {
|
|
211
|
+
throw new FirebaseEdgeError({
|
|
212
|
+
code: 'storage/invalid-argument',
|
|
213
|
+
message: 'Invalid compose source.'
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
validateStorageOperation(bucket, {
|
|
217
|
+
kind: 'metadata',
|
|
218
|
+
name: source.name,
|
|
219
|
+
options: {
|
|
220
|
+
generation: source.generation,
|
|
221
|
+
ifGenerationMatch: source.objectPreconditions?.ifGenerationMatch
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (operation.options.metadata !== undefined) {
|
|
226
|
+
validateMetadataUpdate(operation.options.metadata);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (operation.kind === 'updateMetadata') {
|
|
230
|
+
validateMetadataUpdate(operation.metadata);
|
|
231
|
+
}
|
|
232
|
+
if (operation.kind === 'copy') {
|
|
233
|
+
const destinationBucket = operation.options.destinationBucket === undefined
|
|
234
|
+
? bucket
|
|
235
|
+
: operation.options.destinationBucket;
|
|
236
|
+
validateStorageOperation(destinationBucket, {
|
|
237
|
+
kind: 'metadata',
|
|
238
|
+
name: operation.destination
|
|
239
|
+
});
|
|
240
|
+
if (destinationBucket === bucket &&
|
|
241
|
+
operation.destination === operation.name &&
|
|
242
|
+
operation.options.sourceGeneration === undefined &&
|
|
243
|
+
!operation.options.metadata &&
|
|
244
|
+
!operation.options.destinationEncryptionKey &&
|
|
245
|
+
!operation.options.destinationKmsKeyName) {
|
|
246
|
+
throw new FirebaseEdgeError({
|
|
247
|
+
code: 'storage/invalid-argument',
|
|
248
|
+
message: 'Source and destination must be different objects.'
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (operation.kind !== 'list') {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const { maxResults, prefix, delimiter, pageToken, versions, softDeleted, startOffset, endOffset, matchGlob } = operation.options;
|
|
256
|
+
if ([
|
|
257
|
+
versions,
|
|
258
|
+
softDeleted,
|
|
259
|
+
operation.options.includeFoldersAsPrefixes,
|
|
260
|
+
operation.options.includeTrailingDelimiter
|
|
261
|
+
].some((value) => value !== undefined && typeof value !== 'boolean') ||
|
|
262
|
+
(versions && softDeleted)) {
|
|
263
|
+
throw new FirebaseEdgeError({
|
|
264
|
+
code: 'storage/invalid-argument',
|
|
265
|
+
message: 'versions and softDeleted must be booleans and cannot both be true.'
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (maxResults !== undefined &&
|
|
269
|
+
(!Number.isInteger(maxResults) || maxResults < 1 || maxResults > 1000)) {
|
|
270
|
+
throw new FirebaseEdgeError({
|
|
271
|
+
code: 'storage/invalid-argument',
|
|
272
|
+
message: 'maxResults must be an integer between 1 and 1000.'
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if ([prefix, delimiter, pageToken, startOffset, endOffset, matchGlob].some((value) => value !== undefined && typeof value !== 'string')) {
|
|
276
|
+
throw new FirebaseEdgeError({
|
|
277
|
+
code: 'storage/invalid-argument',
|
|
278
|
+
message: 'List filters and pageToken must be strings.'
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/** @internal Storage needs raw media bodies and binary responses rather than restFetch's JSON/text conversion. */
|
|
283
|
+
export async function storageRequest(bucket, accessToken, request, fetch) {
|
|
284
|
+
const operation = request;
|
|
285
|
+
validateStorageOperation(bucket, operation);
|
|
286
|
+
if (operation.kind === 'copy') {
|
|
287
|
+
const copied = await copyStorageObject(bucket, accessToken, operation, fetch);
|
|
288
|
+
return copied;
|
|
289
|
+
}
|
|
290
|
+
const upload = operation.kind === 'upload' || operation.kind === 'resumable';
|
|
291
|
+
const base = upload ? 'upload/storage/v1' : 'storage/v1';
|
|
292
|
+
const objectPath = 'name' in operation && !upload
|
|
293
|
+
? `/${encodeURIComponent(operation.name)}`
|
|
294
|
+
: '';
|
|
295
|
+
const suffix = operation.kind === 'compose'
|
|
296
|
+
? '/compose'
|
|
297
|
+
: operation.kind === 'restore'
|
|
298
|
+
? '/restore'
|
|
299
|
+
: '';
|
|
300
|
+
const url = new URL(`https://storage.googleapis.com/${base}/b/${encodeURIComponent(bucket)}/o${objectPath}${suffix}`);
|
|
301
|
+
const headers = {
|
|
302
|
+
Authorization: `Bearer ${accessToken}`
|
|
303
|
+
};
|
|
304
|
+
let uploadBody = operation.kind === 'upload' ? operation.body : undefined;
|
|
305
|
+
let uploadChecksum;
|
|
306
|
+
let uploadMd5;
|
|
307
|
+
if (operation.kind === 'upload') {
|
|
308
|
+
url.searchParams.set('uploadType', 'media');
|
|
309
|
+
url.searchParams.set('name', operation.name);
|
|
310
|
+
headers['Content-Type'] =
|
|
311
|
+
operation.options.contentType ||
|
|
312
|
+
(operation.body instanceof Blob && operation.body.type) ||
|
|
313
|
+
'application/octet-stream';
|
|
314
|
+
if (operation.options.crc32c !== undefined ||
|
|
315
|
+
operation.options.metadata !== undefined ||
|
|
316
|
+
operation.options.md5Hash !== undefined) {
|
|
317
|
+
uploadChecksum =
|
|
318
|
+
operation.options.crc32c === 'auto'
|
|
319
|
+
? await calculateStorageCrc32c(operation.body, operation.options.crc32cGenerator)
|
|
320
|
+
: operation.options.crc32c;
|
|
321
|
+
const boundary = `storage-${crypto.randomUUID()}`;
|
|
322
|
+
uploadMd5 =
|
|
323
|
+
operation.options.md5Hash === 'auto'
|
|
324
|
+
? await calculateStorageMd5(operation.body)
|
|
325
|
+
: operation.options.md5Hash;
|
|
326
|
+
uploadBody = createChecksumUploadBody(operation.body, headers['Content-Type'], uploadChecksum, boundary, {
|
|
327
|
+
...operation.options.metadata,
|
|
328
|
+
...(uploadMd5 !== undefined && { md5Hash: uploadMd5 })
|
|
329
|
+
});
|
|
330
|
+
url.searchParams.set('uploadType', 'multipart');
|
|
331
|
+
headers['Content-Type'] = `multipart/related; boundary=${boundary}`;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (operation.kind === 'resumable') {
|
|
335
|
+
url.searchParams.set('uploadType', 'resumable');
|
|
336
|
+
if (operation.options.origin !== undefined) {
|
|
337
|
+
headers.Origin = operation.options.origin;
|
|
338
|
+
}
|
|
339
|
+
url.searchParams.set('name', operation.name);
|
|
340
|
+
headers['Content-Type'] = 'application/json';
|
|
341
|
+
if (operation.options.contentType !== undefined) {
|
|
342
|
+
headers['X-Upload-Content-Type'] = operation.options.contentType;
|
|
343
|
+
}
|
|
344
|
+
if (operation.options.size !== undefined) {
|
|
345
|
+
headers['X-Upload-Content-Length'] = String(operation.options.size);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (operation.kind === 'download' || operation.kind === 'stream') {
|
|
349
|
+
url.searchParams.set('alt', 'media');
|
|
350
|
+
const { start, end } = operation.options ?? {};
|
|
351
|
+
if (start !== undefined || end !== undefined) {
|
|
352
|
+
headers.Range =
|
|
353
|
+
end !== undefined && end < 0
|
|
354
|
+
? `bytes=${end}`
|
|
355
|
+
: `bytes=${start ?? 0}-${end ?? ''}`;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (operation.kind === 'updateMetadata' || operation.kind === 'compose') {
|
|
359
|
+
headers['Content-Type'] = 'application/json';
|
|
360
|
+
}
|
|
361
|
+
if ('options' in operation && operation.options) {
|
|
362
|
+
for (const [key, value] of Object.entries(operation.options)) {
|
|
363
|
+
if (value !== undefined &&
|
|
364
|
+
[
|
|
365
|
+
'prefix',
|
|
366
|
+
'delimiter',
|
|
367
|
+
'maxResults',
|
|
368
|
+
'pageToken',
|
|
369
|
+
'versions',
|
|
370
|
+
'softDeleted',
|
|
371
|
+
'startOffset',
|
|
372
|
+
'endOffset',
|
|
373
|
+
'matchGlob',
|
|
374
|
+
'userProject',
|
|
375
|
+
'fields',
|
|
376
|
+
'includeFoldersAsPrefixes',
|
|
377
|
+
'includeTrailingDelimiter',
|
|
378
|
+
'projection',
|
|
379
|
+
'predefinedAcl',
|
|
380
|
+
'destinationPredefinedAcl',
|
|
381
|
+
'kmsKeyName',
|
|
382
|
+
'generation',
|
|
383
|
+
'restoreToken',
|
|
384
|
+
'overrideUnlockedRetention',
|
|
385
|
+
'copySourceAcl',
|
|
386
|
+
'ifGenerationMatch',
|
|
387
|
+
'ifGenerationNotMatch',
|
|
388
|
+
'ifMetagenerationMatch',
|
|
389
|
+
'ifMetagenerationNotMatch'
|
|
390
|
+
].includes(key)) {
|
|
391
|
+
url.searchParams.set(key, String(value));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (operation.kind === 'list' && operation.options.fields) {
|
|
396
|
+
url.searchParams.set('fields', `items(name,bucket,generation,size),prefixes,nextPageToken,${operation.options.fields}`);
|
|
397
|
+
}
|
|
398
|
+
const response = await storageFetch(url.toString(), {
|
|
399
|
+
method: upload ||
|
|
400
|
+
operation.kind === 'compose' ||
|
|
401
|
+
operation.kind === 'restore'
|
|
402
|
+
? 'POST'
|
|
403
|
+
: operation.kind === 'delete'
|
|
404
|
+
? 'DELETE'
|
|
405
|
+
: operation.kind === 'updateMetadata'
|
|
406
|
+
? 'PATCH'
|
|
407
|
+
: 'GET',
|
|
408
|
+
headers,
|
|
409
|
+
...(operation.kind === 'upload' && { body: uploadBody }),
|
|
410
|
+
...(operation.kind === 'updateMetadata' && {
|
|
411
|
+
body: JSON.stringify(storageWritableMetadata(operation.metadata))
|
|
412
|
+
}),
|
|
413
|
+
...(operation.kind === 'resumable' && {
|
|
414
|
+
body: JSON.stringify({
|
|
415
|
+
...storageWritableMetadata(operation.options.metadata),
|
|
416
|
+
...(operation.options.md5Hash !== undefined && {
|
|
417
|
+
md5Hash: operation.options.md5Hash
|
|
418
|
+
}),
|
|
419
|
+
...(operation.options.crc32c !== undefined && {
|
|
420
|
+
crc32c: operation.options.crc32c
|
|
421
|
+
}),
|
|
422
|
+
...(operation.options.contentType !== undefined && {
|
|
423
|
+
contentType: operation.options.contentType
|
|
424
|
+
})
|
|
425
|
+
})
|
|
426
|
+
}),
|
|
427
|
+
...(operation.kind === 'compose' && {
|
|
428
|
+
body: JSON.stringify({
|
|
429
|
+
sourceObjects: operation.sources,
|
|
430
|
+
destination: storageWritableMetadata(operation.options.metadata)
|
|
431
|
+
})
|
|
432
|
+
})
|
|
433
|
+
}, fetch);
|
|
434
|
+
if (operation.kind === 'resumable') {
|
|
435
|
+
const location = response.headers.get('location');
|
|
436
|
+
if (!location) {
|
|
437
|
+
throw new FirebaseEdgeError({
|
|
438
|
+
code: 'storage/internal-error',
|
|
439
|
+
message: 'Missing resumable upload session URI.'
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
return location;
|
|
443
|
+
}
|
|
444
|
+
if (operation.kind === 'stream') {
|
|
445
|
+
return (operation.options?.verifyChecksum
|
|
446
|
+
? verifyStorageStream(response, operation.options.checksumAlgorithm, operation.options.crc32cGenerator)
|
|
447
|
+
: response);
|
|
448
|
+
}
|
|
449
|
+
if (operation.kind === 'delete') {
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
if (operation.kind === 'download') {
|
|
453
|
+
const bytes = await response.arrayBuffer();
|
|
454
|
+
const data = new Uint8Array(bytes);
|
|
455
|
+
if (operation.options?.verifyChecksum) {
|
|
456
|
+
await verifyStorageDownload(data, response, operation.options.checksumAlgorithm, operation.options.crc32cGenerator);
|
|
457
|
+
}
|
|
458
|
+
return data;
|
|
459
|
+
}
|
|
460
|
+
const data = await readStorageObject(response);
|
|
461
|
+
if (operation.kind === 'list') {
|
|
462
|
+
if ((data.items !== undefined && !Array.isArray(data.items)) ||
|
|
463
|
+
(data.prefixes !== undefined &&
|
|
464
|
+
(!Array.isArray(data.prefixes) ||
|
|
465
|
+
data.prefixes.some((prefix) => typeof prefix !== 'string'))) ||
|
|
466
|
+
(data.nextPageToken !== undefined &&
|
|
467
|
+
typeof data.nextPageToken !== 'string')) {
|
|
468
|
+
throw new FirebaseEdgeError({
|
|
469
|
+
code: 'storage/internal-error',
|
|
470
|
+
message: 'Invalid Storage list response.'
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
return {
|
|
474
|
+
files: (data.items ?? []).map(parseStorageMetadata),
|
|
475
|
+
prefixes: data.prefixes ?? [],
|
|
476
|
+
...(data.nextPageToken !== undefined && {
|
|
477
|
+
nextPageToken: data.nextPageToken
|
|
478
|
+
})
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
const metadata = parseStorageMetadata(data);
|
|
482
|
+
if (operation.kind === 'upload') {
|
|
483
|
+
verifyStorageUpload(uploadChecksum, metadata, uploadMd5);
|
|
484
|
+
const totalBytes = storageUploadBlob(operation.body).size;
|
|
485
|
+
await reportStorageProgress(operation.options.onProgress, {
|
|
486
|
+
bytesTransferred: totalBytes,
|
|
487
|
+
totalBytes,
|
|
488
|
+
complete: true
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return metadata;
|
|
492
|
+
}
|
|
493
|
+
/** @internal Use metadata checksums so validation is enforced before the object is committed. */
|
|
494
|
+
function createChecksumUploadBody(body, contentType, crc32c, boundary, metadata) {
|
|
495
|
+
return new Blob([
|
|
496
|
+
`--${boundary}\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n`,
|
|
497
|
+
JSON.stringify({
|
|
498
|
+
...storageWritableMetadata(metadata),
|
|
499
|
+
crc32c,
|
|
500
|
+
contentType
|
|
501
|
+
}),
|
|
502
|
+
`\r\n--${boundary}\r\nContent-Type: ${contentType}\r\n\r\n`,
|
|
503
|
+
body,
|
|
504
|
+
`\r\n--${boundary}--\r\n`
|
|
505
|
+
]);
|
|
506
|
+
}
|
|
507
|
+
/** @internal Shared media/JSON transport and error mapping. */
|
|
508
|
+
export async function storageFetch(url, init, fetch, acceptedStatuses = [], notFoundCode = 'object-not-found') {
|
|
509
|
+
const response = await fetch(url, init);
|
|
510
|
+
if (!response.ok && !acceptedStatuses.includes(response.status)) {
|
|
511
|
+
const text = await response.text();
|
|
512
|
+
let message = text || `Storage request failed (${response.status}).`;
|
|
513
|
+
try {
|
|
514
|
+
const parsed = JSON.parse(text);
|
|
515
|
+
if (typeof parsed?.error?.message === 'string') {
|
|
516
|
+
message = parsed.error.message;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
catch {
|
|
520
|
+
/* Preserve non-JSON error bodies. */
|
|
521
|
+
}
|
|
522
|
+
const codes = {
|
|
523
|
+
400: 'invalid-argument',
|
|
524
|
+
401: 'unauthenticated',
|
|
525
|
+
403: 'permission-denied',
|
|
526
|
+
404: notFoundCode,
|
|
527
|
+
409: 'conflict',
|
|
528
|
+
412: 'precondition-failed',
|
|
529
|
+
416: 'invalid-range',
|
|
530
|
+
429: 'quota-exceeded'
|
|
531
|
+
};
|
|
532
|
+
throw new FirebaseEdgeError({
|
|
533
|
+
code: `storage/${codes[response.status] ?? 'unknown-error'}`,
|
|
534
|
+
message
|
|
535
|
+
}, { context: { status: response.status } });
|
|
536
|
+
}
|
|
537
|
+
return response;
|
|
538
|
+
}
|
|
539
|
+
/** @internal Validate the JSON envelope before interpreting it. */
|
|
540
|
+
export async function readStorageObject(response) {
|
|
541
|
+
const responseData = await response.json();
|
|
542
|
+
if (!responseData ||
|
|
543
|
+
typeof responseData !== 'object' ||
|
|
544
|
+
Array.isArray(responseData)) {
|
|
545
|
+
throw new FirebaseEdgeError({
|
|
546
|
+
code: 'storage/internal-error',
|
|
547
|
+
message: 'Invalid Storage response.'
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
return responseData;
|
|
551
|
+
}
|
|
552
|
+
/** @internal Complete multi-request server-side copies without buffering media. */
|
|
553
|
+
async function copyStorageObject(bucket, accessToken, operation, fetch) {
|
|
554
|
+
const { destinationBucket = bucket, ifGenerationMatch, ifSourceGenerationMatch } = operation.options;
|
|
555
|
+
const url = new URL(`https://storage.googleapis.com/storage/v1/b/${encodeURIComponent(bucket)}/o/${encodeURIComponent(operation.name)}/rewriteTo/b/${encodeURIComponent(destinationBucket)}/o/${encodeURIComponent(operation.destination)}`);
|
|
556
|
+
if (ifGenerationMatch !== undefined) {
|
|
557
|
+
url.searchParams.set('ifGenerationMatch', ifGenerationMatch);
|
|
558
|
+
}
|
|
559
|
+
if (ifSourceGenerationMatch !== undefined) {
|
|
560
|
+
url.searchParams.set('ifSourceGenerationMatch', ifSourceGenerationMatch);
|
|
561
|
+
}
|
|
562
|
+
for (const key of [
|
|
563
|
+
'sourceGeneration',
|
|
564
|
+
'ifGenerationNotMatch',
|
|
565
|
+
'ifMetagenerationMatch',
|
|
566
|
+
'ifMetagenerationNotMatch',
|
|
567
|
+
'ifSourceMetagenerationMatch'
|
|
568
|
+
]) {
|
|
569
|
+
const value = operation.options[key];
|
|
570
|
+
if (value !== undefined) {
|
|
571
|
+
url.searchParams.set(key, value);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (operation.options.destinationKmsKeyName) {
|
|
575
|
+
url.searchParams.set('destinationKmsKeyName', operation.options.destinationKmsKeyName);
|
|
576
|
+
}
|
|
577
|
+
if (operation.options.predefinedAcl) {
|
|
578
|
+
url.searchParams.set('destinationPredefinedAcl', operation.options.predefinedAcl);
|
|
579
|
+
}
|
|
580
|
+
if (operation.options.token) {
|
|
581
|
+
url.searchParams.set('rewriteToken', operation.options.token);
|
|
582
|
+
}
|
|
583
|
+
if (operation.options.userProject) {
|
|
584
|
+
url.searchParams.set('userProject', operation.options.userProject);
|
|
585
|
+
}
|
|
586
|
+
const encryptionHeaders = operation.options.destinationEncryptionKey === undefined
|
|
587
|
+
? {}
|
|
588
|
+
: await storageEncryptionHeaders(operation.options.destinationEncryptionKey);
|
|
589
|
+
for (;;) {
|
|
590
|
+
const response = await storageFetch(url.toString(), {
|
|
591
|
+
method: 'POST',
|
|
592
|
+
headers: {
|
|
593
|
+
...encryptionHeaders,
|
|
594
|
+
Authorization: `Bearer ${accessToken}`,
|
|
595
|
+
...(operation.options.metadata && {
|
|
596
|
+
'Content-Type': 'application/json'
|
|
597
|
+
})
|
|
598
|
+
},
|
|
599
|
+
...(operation.options.metadata && {
|
|
600
|
+
body: JSON.stringify(storageWritableMetadata(operation.options.metadata))
|
|
601
|
+
})
|
|
602
|
+
}, fetch);
|
|
603
|
+
const data = await readStorageObject(response);
|
|
604
|
+
if (data.done === true) {
|
|
605
|
+
return parseStorageMetadata(data.resource);
|
|
606
|
+
}
|
|
607
|
+
if (data.done !== false ||
|
|
608
|
+
typeof data.rewriteToken !== 'string' ||
|
|
609
|
+
!data.rewriteToken) {
|
|
610
|
+
throw new FirebaseEdgeError({
|
|
611
|
+
code: 'storage/internal-error',
|
|
612
|
+
message: 'Invalid Storage rewrite response.'
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
url.searchParams.set('rewriteToken', data.rewriteToken);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
/** @internal Only permit writable metadata, including explicit removals. */
|
|
619
|
+
function validateMetadataUpdate(metadata) {
|
|
620
|
+
if (!metadata ||
|
|
621
|
+
typeof metadata !== 'object' ||
|
|
622
|
+
Array.isArray(metadata) ||
|
|
623
|
+
Object.keys(metadata).length === 0) {
|
|
624
|
+
throw new FirebaseEdgeError({
|
|
625
|
+
code: 'storage/invalid-argument',
|
|
626
|
+
message: 'A nonempty metadata update is required.'
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
const fields = [
|
|
630
|
+
'storageClass',
|
|
631
|
+
'customTime',
|
|
632
|
+
'contentType',
|
|
633
|
+
'cacheControl',
|
|
634
|
+
'contentDisposition',
|
|
635
|
+
'contentEncoding',
|
|
636
|
+
'contentLanguage'
|
|
637
|
+
];
|
|
638
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
639
|
+
if (key === 'retention' &&
|
|
640
|
+
(value === null ||
|
|
641
|
+
(value &&
|
|
642
|
+
typeof value === 'object' &&
|
|
643
|
+
'mode' in value &&
|
|
644
|
+
['Locked', 'Unlocked'].includes(String(value.mode)) &&
|
|
645
|
+
'retainUntilTime' in value &&
|
|
646
|
+
typeof value.retainUntilTime === 'string' &&
|
|
647
|
+
Number.isFinite(Date.parse(value.retainUntilTime))))) {
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
if (key === 'acl' &&
|
|
651
|
+
(value === null ||
|
|
652
|
+
(Array.isArray(value) &&
|
|
653
|
+
value.every((entry) => entry &&
|
|
654
|
+
typeof entry.entity === 'string' &&
|
|
655
|
+
entry.entity.trim() &&
|
|
656
|
+
['OWNER', 'READER', 'WRITER'].includes(entry.role))))) {
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (['temporaryHold', 'eventBasedHold'].includes(key) &&
|
|
660
|
+
typeof value === 'boolean') {
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
if (key === 'metadata') {
|
|
664
|
+
if (value === null ||
|
|
665
|
+
(typeof value === 'object' &&
|
|
666
|
+
value !== null &&
|
|
667
|
+
!Array.isArray(value) &&
|
|
668
|
+
Object.values(value).every((item) => item === null ||
|
|
669
|
+
typeof item === 'string' ||
|
|
670
|
+
typeof item === 'boolean' ||
|
|
671
|
+
(typeof item === 'number' && Number.isFinite(item))))) {
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
throw new FirebaseEdgeError({
|
|
675
|
+
code: 'storage/invalid-argument',
|
|
676
|
+
message: 'Custom metadata must contain strings or null values.'
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
if (!fields.includes(key) ||
|
|
680
|
+
(value !== null &&
|
|
681
|
+
(typeof value !== 'string' || /[\r\n]/.test(value)))) {
|
|
682
|
+
throw new FirebaseEdgeError({
|
|
683
|
+
code: 'storage/invalid-argument',
|
|
684
|
+
message: `Invalid writable metadata field: ${key}.`
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
/** @internal Admin accepts primitive custom metadata; the REST API stores strings. */
|
|
690
|
+
function storageWritableMetadata(metadata = {}) {
|
|
691
|
+
if (!metadata.metadata) {
|
|
692
|
+
return metadata;
|
|
693
|
+
}
|
|
694
|
+
return {
|
|
695
|
+
...metadata,
|
|
696
|
+
metadata: Object.fromEntries(Object.entries(metadata.metadata).map(([key, value]) => [
|
|
697
|
+
key,
|
|
698
|
+
value === null ? null : String(value)
|
|
699
|
+
]))
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
/** @internal Preserve API integer strings and additional metadata fields. */
|
|
703
|
+
export function parseStorageMetadata(data) {
|
|
704
|
+
if (!data ||
|
|
705
|
+
typeof data !== 'object' ||
|
|
706
|
+
!('name' in data) ||
|
|
707
|
+
typeof data.name !== 'string' ||
|
|
708
|
+
!('bucket' in data) ||
|
|
709
|
+
typeof data.bucket !== 'string' ||
|
|
710
|
+
!('generation' in data) ||
|
|
711
|
+
typeof data.generation !== 'string' ||
|
|
712
|
+
!('size' in data) ||
|
|
713
|
+
typeof data.size !== 'string') {
|
|
714
|
+
throw new FirebaseEdgeError({
|
|
715
|
+
code: 'storage/internal-error',
|
|
716
|
+
message: 'Invalid Storage object metadata.'
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
return data;
|
|
720
|
+
}
|
|
721
|
+
//# sourceMappingURL=storage-endpoints.js.map
|