firebase-admin-edge 1.1.0 → 2.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 +102 -405
- 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 +43 -0
- package/dist/app-check/app-check.d.ts.map +1 -0
- package/dist/app-check/app-check.js +141 -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/auth-error-codes.d.ts +12 -0
- package/dist/auth/auth-error-codes.d.ts.map +1 -1
- package/dist/auth/auth-error-codes.js +12 -0
- package/dist/auth/auth-error-codes.js.map +1 -1
- package/dist/auth/email-action-request.d.ts +40 -0
- package/dist/auth/email-action-request.d.ts.map +1 -0
- package/dist/auth/email-action-request.js +80 -0
- package/dist/auth/email-action-request.js.map +1 -0
- 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 +60 -12
- package/dist/auth/firebase-admin-auth.d.ts.map +1 -1
- package/dist/auth/firebase-admin-auth.js +455 -64
- package/dist/auth/firebase-admin-auth.js.map +1 -1
- package/dist/auth/firebase-auth-endpoints.d.ts +94 -4
- package/dist/auth/firebase-auth-endpoints.d.ts.map +1 -1
- package/dist/auth/firebase-auth-endpoints.js +304 -64
- package/dist/auth/firebase-auth-endpoints.js.map +1 -1
- package/dist/auth/firebase-auth.d.ts +78 -4
- package/dist/auth/firebase-auth.d.ts.map +1 -1
- package/dist/auth/firebase-auth.js +101 -8
- 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/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-batch.d.ts +21 -0
- package/dist/auth/user-batch.d.ts.map +1 -0
- package/dist/auth/user-batch.js +49 -0
- package/dist/auth/user-batch.js.map +1 -0
- package/dist/auth/user-import.d.ts +55 -0
- package/dist/auth/user-import.d.ts.map +1 -0
- package/dist/auth/user-import.js +208 -0
- package/dist/auth/user-import.js.map +1 -0
- package/dist/auth/user-request.d.ts +10 -0
- package/dist/auth/user-request.d.ts.map +1 -1
- package/dist/auth/user-request.js +56 -0
- 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 +151 -0
- package/dist/db/firestore.d.ts.map +1 -0
- package/dist/db/firestore.js +505 -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 +143 -36
- package/dist/firebase-edge-server.d.ts.map +1 -1
- package/dist/firebase-edge-server.js +466 -257
- package/dist/firebase-edge-server.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -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 +152 -0
- package/dist/storage/storage.d.ts.map +1 -0
- package/dist/storage/storage.js +532 -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 +22 -6
- 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/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 -923
- 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 -957
- 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-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 -269
- 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 -264
- 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
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { createAccountAdmin, updateAccountAdmin, deleteAccountAdmin, createSessionCookie, downloadAccount, getAccountInfo, getAccountsInfo, revokeRefreshTokens } from './firebase-auth-endpoints.js';
|
|
2
|
-
import {
|
|
1
|
+
import { createAuthEmulatorFetch, manageAuthConfig, generateEmailActionLink, deleteAccountsAdmin, importAccountsAdmin, createAccountAdmin, updateAccountAdmin, deleteAccountAdmin, createSessionCookie, downloadAccount, getAccountInfo, getAccountsInfo, revokeRefreshTokens } from './firebase-auth-endpoints.js';
|
|
2
|
+
import { resolveAuthEmulatorHost } from './auth-emulator.js';
|
|
3
|
+
import { buildAuthConfigRequest, validateTenantId } from './auth-config.js';
|
|
4
|
+
import { ProjectConfigManager } from './project-config-manager.js';
|
|
5
|
+
import { TenantManager } from './tenant-manager.js';
|
|
6
|
+
export { ProjectConfigManager } from './project-config-manager.js';
|
|
7
|
+
export { TenantManager } from './tenant-manager.js';
|
|
8
|
+
import { verifyAuthBlockingJWT, signJWTCustomToken, verifyJWT, verifySessionJWT } from './firebase-jwt.js';
|
|
3
9
|
import { getToken } from './google-oauth.js';
|
|
4
10
|
import { FirebaseEdgeError, FirebaseAdminAuthErrorInfo, ensureError } from './errors.js';
|
|
11
|
+
import { validateDeleteUsers, createBatchUserResult } from './user-batch.js';
|
|
12
|
+
import { prepareUserImport } from './user-import.js';
|
|
5
13
|
import { createUserRecord, createGetUsersResult } from './user-record.js';
|
|
6
|
-
import { buildUserRequest, buildUsersLookupRequest, validateUserUid } from './user-request.js';
|
|
14
|
+
import { buildUserRequest, buildCustomClaimsRequest, buildUsersLookupRequest, validateUserUid } from './user-request.js';
|
|
15
|
+
import { buildEmailActionRequest } from './email-action-request.js';
|
|
7
16
|
/**
|
|
8
17
|
* Firebase Admin Authentication handler for edge environments.
|
|
9
18
|
* Provides server-side authentication operations using service account credentials.
|
|
@@ -14,7 +23,98 @@ export class FirebaseAdminAuth {
|
|
|
14
23
|
fetch;
|
|
15
24
|
cache;
|
|
16
25
|
cacheName;
|
|
26
|
+
/** Verify a blocking-event JWT. Audience matching follows the SDK's substring convention. */
|
|
27
|
+
async _verifyAuthBlockingToken(token, audience) {
|
|
28
|
+
const result = await verifyAuthBlockingJWT(token, this.serviceAccountKey.project_id, audience, this.fetch, !!this.emulatorHost);
|
|
29
|
+
if (result.error)
|
|
30
|
+
return result;
|
|
31
|
+
if (this.tenantId && result.data.tenant_id !== this.tenantId)
|
|
32
|
+
return {
|
|
33
|
+
data: null,
|
|
34
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_TENANT_ID_INVALID)
|
|
35
|
+
};
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
emulatorHost;
|
|
17
39
|
_cacheName = '__cache';
|
|
40
|
+
projectManager;
|
|
41
|
+
tenants;
|
|
42
|
+
createProviderConfig(config) {
|
|
43
|
+
return this.executeConfig({
|
|
44
|
+
resource: 'provider',
|
|
45
|
+
action: 'create',
|
|
46
|
+
id: config?.providerId,
|
|
47
|
+
properties: config
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getProviderConfig(providerId) {
|
|
51
|
+
return this.executeConfig({
|
|
52
|
+
resource: 'provider',
|
|
53
|
+
action: 'get',
|
|
54
|
+
id: providerId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
updateProviderConfig(providerId, config) {
|
|
58
|
+
return this.executeConfig({
|
|
59
|
+
resource: 'provider',
|
|
60
|
+
action: 'update',
|
|
61
|
+
id: providerId,
|
|
62
|
+
properties: config
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
deleteProviderConfig(providerId) {
|
|
66
|
+
return this.executeConfig({
|
|
67
|
+
resource: 'provider',
|
|
68
|
+
action: 'delete',
|
|
69
|
+
id: providerId
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
listProviderConfigs(filter) {
|
|
73
|
+
return this.executeConfig({
|
|
74
|
+
resource: 'provider',
|
|
75
|
+
action: 'list',
|
|
76
|
+
type: filter?.type,
|
|
77
|
+
maxResults: filter?.maxResults,
|
|
78
|
+
pageToken: filter?.pageToken
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
projectConfigManager() {
|
|
82
|
+
if (this.projectManager)
|
|
83
|
+
return this.projectManager;
|
|
84
|
+
this.projectManager = new ProjectConfigManager(this.executeConfig.bind(this));
|
|
85
|
+
return this.projectManager;
|
|
86
|
+
}
|
|
87
|
+
tenantManager() {
|
|
88
|
+
if (this.tenants)
|
|
89
|
+
return this.tenants;
|
|
90
|
+
this.tenants = new TenantManager(this.executeConfig.bind(this), (tenantId) => new FirebaseAdminAuth(this.serviceAccountKey, tenantId, this.fetch, this.cache, this._cacheName, { emulatorHost: this.emulatorHost }));
|
|
91
|
+
return this.tenants;
|
|
92
|
+
}
|
|
93
|
+
async executeConfig(operation) {
|
|
94
|
+
try {
|
|
95
|
+
buildAuthConfigRequest(operation);
|
|
96
|
+
const { data: token, error } = await this.getCachedToken();
|
|
97
|
+
if (error)
|
|
98
|
+
return { data: null, error };
|
|
99
|
+
if (!token?.access_token)
|
|
100
|
+
return {
|
|
101
|
+
data: null,
|
|
102
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
103
|
+
};
|
|
104
|
+
return await manageAuthConfig(this.serviceAccountKey.project_id, operation, token.access_token, this.fetch, this.tenantId);
|
|
105
|
+
}
|
|
106
|
+
catch (cause) {
|
|
107
|
+
if (cause instanceof FirebaseEdgeError)
|
|
108
|
+
return { data: null, error: cause };
|
|
109
|
+
return {
|
|
110
|
+
data: null,
|
|
111
|
+
error: new FirebaseEdgeError({
|
|
112
|
+
code: 'auth/configuration-request-failed',
|
|
113
|
+
message: 'Authentication configuration request failed.'
|
|
114
|
+
}, { cause: ensureError(cause) })
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
18
118
|
/**
|
|
19
119
|
* Creates a new Firebase Admin Auth instance.
|
|
20
120
|
*
|
|
@@ -23,13 +123,19 @@ export class FirebaseAdminAuth {
|
|
|
23
123
|
* @param fetch Optional custom fetch implementation
|
|
24
124
|
* @param cache Optional cache implementation for token caching
|
|
25
125
|
* @param cacheName Optional cache key name (defaults to '__cache')
|
|
126
|
+
* @param options Auth emulator configuration; defaults to FIREBASE_AUTH_EMULATOR_HOST when set.
|
|
26
127
|
*/
|
|
27
|
-
constructor(serviceAccountKey, tenantId, fetch, cache, cacheName) {
|
|
128
|
+
constructor(serviceAccountKey, tenantId, fetch, cache, cacheName, options = {}) {
|
|
28
129
|
this.serviceAccountKey = serviceAccountKey;
|
|
29
130
|
this.tenantId = tenantId;
|
|
30
131
|
this.fetch = fetch;
|
|
31
132
|
this.cache = cache;
|
|
32
133
|
this.cacheName = cacheName;
|
|
134
|
+
if (tenantId !== undefined)
|
|
135
|
+
validateTenantId(tenantId);
|
|
136
|
+
this.emulatorHost = resolveAuthEmulatorHost(options.emulatorHost);
|
|
137
|
+
if (this.emulatorHost)
|
|
138
|
+
this.fetch = createAuthEmulatorFetch(this.emulatorHost, this.fetch);
|
|
33
139
|
this._cacheName = this.cacheName || this._cacheName;
|
|
34
140
|
}
|
|
35
141
|
/**
|
|
@@ -39,7 +145,20 @@ export class FirebaseAdminAuth {
|
|
|
39
145
|
* @returns Promise with token data and error
|
|
40
146
|
*/
|
|
41
147
|
async getCachedToken() {
|
|
42
|
-
|
|
148
|
+
if (this.emulatorHost) {
|
|
149
|
+
return {
|
|
150
|
+
data: {
|
|
151
|
+
access_token: 'owner',
|
|
152
|
+
expires_in: 3600,
|
|
153
|
+
token_type: 'Bearer',
|
|
154
|
+
scope: '',
|
|
155
|
+
id_token: ''
|
|
156
|
+
},
|
|
157
|
+
error: null
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const cacheKey = `${this._cacheName}:auth:${this.serviceAccountKey.client_email}`;
|
|
161
|
+
const cachedToken = await this.cache?.getCache(cacheKey);
|
|
43
162
|
if (cachedToken) {
|
|
44
163
|
return {
|
|
45
164
|
data: cachedToken,
|
|
@@ -48,8 +167,11 @@ export class FirebaseAdminAuth {
|
|
|
48
167
|
}
|
|
49
168
|
const { data: token, error: getTokenError } = await getToken(this.serviceAccountKey, this.fetch);
|
|
50
169
|
if (token && this.cache) {
|
|
51
|
-
//
|
|
52
|
-
|
|
170
|
+
// Cache adapters accept milliseconds. Expire before the OAuth token does.
|
|
171
|
+
const ttlMs = Math.max(0, (token.expires_in - 60) * 1000);
|
|
172
|
+
if (Number.isFinite(ttlMs) && ttlMs > 0) {
|
|
173
|
+
await this.cache.setCache(cacheKey, token, ttlMs);
|
|
174
|
+
}
|
|
53
175
|
}
|
|
54
176
|
if (getTokenError) {
|
|
55
177
|
return {
|
|
@@ -133,6 +255,43 @@ export class FirebaseAdminAuth {
|
|
|
133
255
|
};
|
|
134
256
|
}
|
|
135
257
|
}
|
|
258
|
+
/** Replace stored custom claims; pass null to clear all claims. */
|
|
259
|
+
async setCustomUserClaims(uid, claims) {
|
|
260
|
+
const uidError = validateUserUid(uid);
|
|
261
|
+
if (uidError)
|
|
262
|
+
return { data: null, error: uidError };
|
|
263
|
+
const request = buildCustomClaimsRequest(claims);
|
|
264
|
+
if (request.error)
|
|
265
|
+
return { data: null, error: request.error };
|
|
266
|
+
try {
|
|
267
|
+
const { data: token, error } = await this.getCachedToken();
|
|
268
|
+
if (error)
|
|
269
|
+
return { data: null, error };
|
|
270
|
+
if (!token?.access_token)
|
|
271
|
+
return {
|
|
272
|
+
data: null,
|
|
273
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
274
|
+
};
|
|
275
|
+
const result = await updateAccountAdmin(this.serviceAccountKey.project_id, uid, request.data, token.access_token, this.fetch, this.tenantId);
|
|
276
|
+
if (result.error)
|
|
277
|
+
return {
|
|
278
|
+
data: null,
|
|
279
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SET_CUSTOM_CLAIMS_FAILED, { cause: result.error })
|
|
280
|
+
};
|
|
281
|
+
if (!result.data?.localId)
|
|
282
|
+
return {
|
|
283
|
+
data: null,
|
|
284
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SET_CUSTOM_CLAIMS_FAILED)
|
|
285
|
+
};
|
|
286
|
+
return { data: undefined, error: null };
|
|
287
|
+
}
|
|
288
|
+
catch (cause) {
|
|
289
|
+
return {
|
|
290
|
+
data: null,
|
|
291
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SET_CUSTOM_CLAIMS_FAILED, { cause: ensureError(cause) })
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
136
295
|
/** Delete one user. A successful deletion returns undefined data. */
|
|
137
296
|
async deleteUser(uid) {
|
|
138
297
|
const uidError = validateUserUid(uid);
|
|
@@ -162,6 +321,88 @@ export class FirebaseAdminAuth {
|
|
|
162
321
|
};
|
|
163
322
|
}
|
|
164
323
|
}
|
|
324
|
+
/** Delete up to 1000 users, reporting failures by original input index. */
|
|
325
|
+
async deleteUsers(uids) {
|
|
326
|
+
const validationError = validateDeleteUsers(uids);
|
|
327
|
+
if (validationError)
|
|
328
|
+
return { data: null, error: validationError };
|
|
329
|
+
if (uids.length === 0)
|
|
330
|
+
return { data: createBatchUserResult([]), error: null };
|
|
331
|
+
try {
|
|
332
|
+
const { data: token, error } = await this.getCachedToken();
|
|
333
|
+
if (error)
|
|
334
|
+
return { data: null, error };
|
|
335
|
+
if (!token?.access_token)
|
|
336
|
+
return {
|
|
337
|
+
data: null,
|
|
338
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
339
|
+
};
|
|
340
|
+
const result = await deleteAccountsAdmin(this.serviceAccountKey.project_id, uids, token.access_token, this.fetch, this.tenantId);
|
|
341
|
+
if (result.error)
|
|
342
|
+
return {
|
|
343
|
+
data: null,
|
|
344
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_DELETE_USER_FAILED, { cause: result.error })
|
|
345
|
+
};
|
|
346
|
+
if (!result.data || typeof result.data !== 'object')
|
|
347
|
+
return {
|
|
348
|
+
data: null,
|
|
349
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_DELETE_USER_FAILED)
|
|
350
|
+
};
|
|
351
|
+
return {
|
|
352
|
+
data: createBatchUserResult(uids.map((_, index) => index), result.data.errors),
|
|
353
|
+
error: null
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
catch (cause) {
|
|
357
|
+
return {
|
|
358
|
+
data: null,
|
|
359
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_DELETE_USER_FAILED, { cause: ensureError(cause) })
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/** Import up to 1000 users, with local and API failures indexed to the original input. */
|
|
364
|
+
async importUsers(users, options) {
|
|
365
|
+
const prepared = prepareUserImport(users, options, this.tenantId);
|
|
366
|
+
if (prepared.error)
|
|
367
|
+
return { data: null, error: prepared.error };
|
|
368
|
+
const { body, indices, errors } = prepared.data;
|
|
369
|
+
if (indices.length === 0)
|
|
370
|
+
return {
|
|
371
|
+
data: createBatchUserResult([], [], errors, 'import'),
|
|
372
|
+
error: null
|
|
373
|
+
};
|
|
374
|
+
try {
|
|
375
|
+
const { data: token, error } = await this.getCachedToken();
|
|
376
|
+
if (error)
|
|
377
|
+
return { data: null, error };
|
|
378
|
+
if (!token?.access_token)
|
|
379
|
+
return {
|
|
380
|
+
data: null,
|
|
381
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
382
|
+
};
|
|
383
|
+
const result = await importAccountsAdmin(this.serviceAccountKey.project_id, body, token.access_token, this.fetch, this.tenantId);
|
|
384
|
+
if (result.error)
|
|
385
|
+
return {
|
|
386
|
+
data: null,
|
|
387
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_IMPORT_USERS_FAILED, { cause: result.error })
|
|
388
|
+
};
|
|
389
|
+
if (!result.data || typeof result.data !== 'object')
|
|
390
|
+
return {
|
|
391
|
+
data: null,
|
|
392
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_IMPORT_USERS_FAILED)
|
|
393
|
+
};
|
|
394
|
+
return {
|
|
395
|
+
data: createBatchUserResult(indices, result.data.error, errors, 'import'),
|
|
396
|
+
error: null
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
catch (cause) {
|
|
400
|
+
return {
|
|
401
|
+
data: null,
|
|
402
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_IMPORT_USERS_FAILED, { cause: ensureError(cause) })
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
}
|
|
165
406
|
/** Read back a complete record after a successful create or update. */
|
|
166
407
|
async getManagedUser(uid, token) {
|
|
167
408
|
const { data, error } = await getAccountInfo({ uid }, token, this.serviceAccountKey.project_id, this.tenantId, this.fetch);
|
|
@@ -220,24 +461,37 @@ export class FirebaseAdminAuth {
|
|
|
220
461
|
* @returns Promise with object containing user data or null, and error if any
|
|
221
462
|
*/
|
|
222
463
|
async getUser(uid) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
};
|
|
464
|
+
return this.lookupUser({ uid });
|
|
465
|
+
}
|
|
466
|
+
async lookupUser(identifier) {
|
|
467
|
+
const validation = buildUsersLookupRequest([identifier]);
|
|
468
|
+
if (validation.error)
|
|
469
|
+
return { data: null, error: validation.error };
|
|
470
|
+
try {
|
|
471
|
+
const { data: token, error: tokenError } = await this.getCachedToken();
|
|
472
|
+
if (tokenError)
|
|
473
|
+
return { data: null, error: tokenError };
|
|
474
|
+
if (!token?.access_token)
|
|
475
|
+
return {
|
|
476
|
+
data: null,
|
|
477
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
478
|
+
};
|
|
479
|
+
const result = await getAccountInfo(identifier, token.access_token, this.serviceAccountKey.project_id, this.tenantId, this.fetch);
|
|
480
|
+
if (result.error)
|
|
481
|
+
return { data: null, error: result.error };
|
|
482
|
+
if (!result.data)
|
|
483
|
+
return {
|
|
484
|
+
data: null,
|
|
485
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_USER_NOT_FOUND)
|
|
486
|
+
};
|
|
487
|
+
return { data: result.data, error: null };
|
|
229
488
|
}
|
|
230
|
-
|
|
231
|
-
if (error) {
|
|
489
|
+
catch (cause) {
|
|
232
490
|
return {
|
|
233
491
|
data: null,
|
|
234
|
-
error
|
|
492
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_USER_LOOKUP_FAILED, { cause: ensureError(cause) })
|
|
235
493
|
};
|
|
236
494
|
}
|
|
237
|
-
return {
|
|
238
|
-
data,
|
|
239
|
-
error: null
|
|
240
|
-
};
|
|
241
495
|
}
|
|
242
496
|
/**
|
|
243
497
|
* Lists one page of users, using Firebase Admin's page size and token contract.
|
|
@@ -313,24 +567,56 @@ export class FirebaseAdminAuth {
|
|
|
313
567
|
* @returns Promise with object containing user data or null, and error if any
|
|
314
568
|
*/
|
|
315
569
|
async getUserByEmail(email) {
|
|
316
|
-
|
|
317
|
-
|
|
570
|
+
return this.lookupUser({ email });
|
|
571
|
+
}
|
|
572
|
+
/** Look up a linked provider UID, or a primary email/phone identifier. */
|
|
573
|
+
async getUserByProviderUid(providerId, uid) {
|
|
574
|
+
const identifier = providerId === 'email'
|
|
575
|
+
? { email: uid }
|
|
576
|
+
: providerId === 'phone'
|
|
577
|
+
? { phoneNumber: uid }
|
|
578
|
+
: { providerId, providerUid: uid };
|
|
579
|
+
const result = await this.getUsers([identifier]);
|
|
580
|
+
if (result.error)
|
|
581
|
+
return { data: null, error: result.error };
|
|
582
|
+
const user = result.data.users[0];
|
|
583
|
+
if (!user)
|
|
318
584
|
return {
|
|
319
585
|
data: null,
|
|
320
|
-
error:
|
|
586
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_USER_NOT_FOUND)
|
|
321
587
|
};
|
|
588
|
+
return { data: user, error: null };
|
|
589
|
+
}
|
|
590
|
+
/** Look up a user by their primary international phone number. */
|
|
591
|
+
async getUserByPhoneNumber(phoneNumber) {
|
|
592
|
+
const validation = buildUsersLookupRequest([{ phoneNumber }]);
|
|
593
|
+
if (validation.error)
|
|
594
|
+
return { data: null, error: validation.error };
|
|
595
|
+
try {
|
|
596
|
+
const { data: token, error } = await this.getCachedToken();
|
|
597
|
+
if (error)
|
|
598
|
+
return { data: null, error };
|
|
599
|
+
if (!token?.access_token)
|
|
600
|
+
return {
|
|
601
|
+
data: null,
|
|
602
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
603
|
+
};
|
|
604
|
+
const result = await getAccountInfo({ phoneNumber }, token.access_token, this.serviceAccountKey.project_id, this.tenantId, this.fetch);
|
|
605
|
+
if (result.error)
|
|
606
|
+
return { data: null, error: result.error };
|
|
607
|
+
if (!result.data)
|
|
608
|
+
return {
|
|
609
|
+
data: null,
|
|
610
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_USER_NOT_FOUND)
|
|
611
|
+
};
|
|
612
|
+
return { data: createUserRecord(result.data), error: null };
|
|
322
613
|
}
|
|
323
|
-
|
|
324
|
-
if (error) {
|
|
614
|
+
catch (cause) {
|
|
325
615
|
return {
|
|
326
616
|
data: null,
|
|
327
|
-
error
|
|
617
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_USER_LOOKUP_FAILED, { cause: ensureError(cause) })
|
|
328
618
|
};
|
|
329
619
|
}
|
|
330
|
-
return {
|
|
331
|
-
data,
|
|
332
|
-
error: null
|
|
333
|
-
};
|
|
334
620
|
}
|
|
335
621
|
/**
|
|
336
622
|
* Verifies a Firebase ID token and returns the decoded payload.
|
|
@@ -341,7 +627,7 @@ export class FirebaseAdminAuth {
|
|
|
341
627
|
* @returns Promise with object containing decoded token payload or null, and error if any
|
|
342
628
|
*/
|
|
343
629
|
async verifyIdToken(idToken, checkRevoked = false) {
|
|
344
|
-
const { data: decodedIdToken, error: verifyError } = await verifyJWT(idToken, this.serviceAccountKey.project_id, this.fetch);
|
|
630
|
+
const { data: decodedIdToken, error: verifyError } = await verifyJWT(idToken, this.serviceAccountKey.project_id, this.fetch, !!this.emulatorHost);
|
|
345
631
|
if (verifyError) {
|
|
346
632
|
return {
|
|
347
633
|
data: null,
|
|
@@ -369,7 +655,7 @@ export class FirebaseAdminAuth {
|
|
|
369
655
|
};
|
|
370
656
|
}
|
|
371
657
|
}
|
|
372
|
-
if (!checkRevoked) {
|
|
658
|
+
if (!checkRevoked && !this.emulatorHost) {
|
|
373
659
|
return {
|
|
374
660
|
data: decodedIdToken,
|
|
375
661
|
error: null
|
|
@@ -379,7 +665,10 @@ export class FirebaseAdminAuth {
|
|
|
379
665
|
if (userError) {
|
|
380
666
|
return {
|
|
381
667
|
data: null,
|
|
382
|
-
error: new FirebaseEdgeError(
|
|
668
|
+
error: new FirebaseEdgeError(userError.code ===
|
|
669
|
+
FirebaseAdminAuthErrorInfo.ADMIN_USER_NOT_FOUND.code
|
|
670
|
+
? FirebaseAdminAuthErrorInfo.ADMIN_USER_RECORD_NOT_FOUND
|
|
671
|
+
: FirebaseAdminAuthErrorInfo.ADMIN_USER_LOOKUP_FAILED, { cause: ensureError(userError) })
|
|
383
672
|
};
|
|
384
673
|
}
|
|
385
674
|
if (!user) {
|
|
@@ -413,28 +702,105 @@ export class FirebaseAdminAuth {
|
|
|
413
702
|
* Creates a session cookie from a Firebase ID token.
|
|
414
703
|
*
|
|
415
704
|
* @param idToken Firebase ID token to convert to session cookie
|
|
416
|
-
* @param
|
|
705
|
+
* @param options Session cookie lifetime in milliseconds
|
|
417
706
|
* @returns Promise with object containing session cookie string or null, and error if any
|
|
418
707
|
*/
|
|
419
|
-
async createSessionCookie(idToken,
|
|
420
|
-
|
|
421
|
-
|
|
708
|
+
async createSessionCookie(idToken, options) {
|
|
709
|
+
if (typeof idToken !== 'string' || !idToken.length)
|
|
710
|
+
return {
|
|
711
|
+
data: null,
|
|
712
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_ID_TOKEN_INVALID)
|
|
713
|
+
};
|
|
714
|
+
if (!options ||
|
|
715
|
+
typeof options !== 'object' ||
|
|
716
|
+
!Number.isFinite(options.expiresIn) ||
|
|
717
|
+
options.expiresIn < 300000 ||
|
|
718
|
+
options.expiresIn > 1209600000)
|
|
719
|
+
return {
|
|
720
|
+
data: null,
|
|
721
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SESSION_COOKIE_DURATION_INVALID)
|
|
722
|
+
};
|
|
723
|
+
try {
|
|
724
|
+
const { data: token, error: getTokenError } = await this.getCachedToken();
|
|
725
|
+
if (getTokenError) {
|
|
726
|
+
return {
|
|
727
|
+
data: null,
|
|
728
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SERVICE_ACCOUNT_TOKEN_FAILED, { cause: getTokenError })
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
if (!token?.access_token)
|
|
732
|
+
return {
|
|
733
|
+
data: null,
|
|
734
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
735
|
+
};
|
|
736
|
+
const { data, error } = await createSessionCookie(idToken, token.access_token, this.serviceAccountKey.project_id, options.expiresIn, this.tenantId, this.fetch);
|
|
737
|
+
if (error || !data) {
|
|
738
|
+
return {
|
|
739
|
+
data: null,
|
|
740
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SESSION_COOKIE_CREATE_FAILED, {
|
|
741
|
+
cause: ensureError(error ??
|
|
742
|
+
new Error('Firebase returned no session cookie.'))
|
|
743
|
+
})
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
return {
|
|
747
|
+
data,
|
|
748
|
+
error: null
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
catch (cause) {
|
|
422
752
|
return {
|
|
423
753
|
data: null,
|
|
424
|
-
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.
|
|
754
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SESSION_COOKIE_CREATE_FAILED, { cause: ensureError(cause) })
|
|
425
755
|
};
|
|
426
756
|
}
|
|
427
|
-
|
|
428
|
-
|
|
757
|
+
}
|
|
758
|
+
/** Generate a password reset link to send through your own email service. */
|
|
759
|
+
async generatePasswordResetLink(email, settings) {
|
|
760
|
+
return this.generateActionLink('PASSWORD_RESET', email, settings);
|
|
761
|
+
}
|
|
762
|
+
/** Generate an email verification link without sending an email. */
|
|
763
|
+
async generateEmailVerificationLink(email, settings) {
|
|
764
|
+
return this.generateActionLink('VERIFY_EMAIL', email, settings);
|
|
765
|
+
}
|
|
766
|
+
/** Generate a link that verifies a new email before changing the account email. */
|
|
767
|
+
async generateVerifyAndChangeEmailLink(email, newEmail, settings) {
|
|
768
|
+
return this.generateActionLink('VERIFY_AND_CHANGE_EMAIL', email, settings, newEmail);
|
|
769
|
+
}
|
|
770
|
+
/** Generate an email sign-in link; action code settings are required. */
|
|
771
|
+
async generateSignInWithEmailLink(email, settings) {
|
|
772
|
+
return this.generateActionLink('EMAIL_SIGNIN', email, settings);
|
|
773
|
+
}
|
|
774
|
+
async generateActionLink(requestType, email, settings, newEmail) {
|
|
775
|
+
const request = buildEmailActionRequest(requestType, email, settings, newEmail);
|
|
776
|
+
if (request.error)
|
|
777
|
+
return request;
|
|
778
|
+
try {
|
|
779
|
+
const { data: token, error: tokenError } = await this.getCachedToken();
|
|
780
|
+
if (tokenError)
|
|
781
|
+
return {
|
|
782
|
+
data: null,
|
|
783
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SERVICE_ACCOUNT_TOKEN_FAILED, { cause: ensureError(tokenError) })
|
|
784
|
+
};
|
|
785
|
+
if (!token?.access_token)
|
|
786
|
+
return {
|
|
787
|
+
data: null,
|
|
788
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
789
|
+
};
|
|
790
|
+
const { data, error } = await generateEmailActionLink(this.serviceAccountKey.project_id, request.data, token.access_token, this.fetch, this.tenantId);
|
|
791
|
+
if (error)
|
|
792
|
+
return {
|
|
793
|
+
data: null,
|
|
794
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_EMAIL_ACTION_LINK_FAILED, { cause: ensureError(error) })
|
|
795
|
+
};
|
|
796
|
+
return { data, error: null };
|
|
797
|
+
}
|
|
798
|
+
catch (cause) {
|
|
429
799
|
return {
|
|
430
800
|
data: null,
|
|
431
|
-
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.
|
|
801
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_EMAIL_ACTION_LINK_FAILED, { cause: ensureError(cause) })
|
|
432
802
|
};
|
|
433
803
|
}
|
|
434
|
-
return {
|
|
435
|
-
data,
|
|
436
|
-
error: null
|
|
437
|
-
};
|
|
438
804
|
}
|
|
439
805
|
/**
|
|
440
806
|
* Verifies a Firebase session cookie and returns the decoded payload.
|
|
@@ -445,7 +811,7 @@ export class FirebaseAdminAuth {
|
|
|
445
811
|
* @returns Promise with object containing decoded session payload or null, and error if any
|
|
446
812
|
*/
|
|
447
813
|
async verifySessionCookie(sessionCookie, checkRevoked = false) {
|
|
448
|
-
const { data, error } = await verifySessionJWT(sessionCookie, this.serviceAccountKey.project_id, this.fetch);
|
|
814
|
+
const { data, error } = await verifySessionJWT(sessionCookie, this.serviceAccountKey.project_id, this.fetch, !!this.emulatorHost);
|
|
449
815
|
if (error) {
|
|
450
816
|
return {
|
|
451
817
|
data: null,
|
|
@@ -473,7 +839,7 @@ export class FirebaseAdminAuth {
|
|
|
473
839
|
};
|
|
474
840
|
}
|
|
475
841
|
}
|
|
476
|
-
if (!checkRevoked) {
|
|
842
|
+
if (!checkRevoked && !this.emulatorHost) {
|
|
477
843
|
return {
|
|
478
844
|
data,
|
|
479
845
|
error: null
|
|
@@ -483,7 +849,10 @@ export class FirebaseAdminAuth {
|
|
|
483
849
|
if (userError) {
|
|
484
850
|
return {
|
|
485
851
|
data: null,
|
|
486
|
-
error: new FirebaseEdgeError(
|
|
852
|
+
error: new FirebaseEdgeError(userError.code ===
|
|
853
|
+
FirebaseAdminAuthErrorInfo.ADMIN_USER_NOT_FOUND.code
|
|
854
|
+
? FirebaseAdminAuthErrorInfo.ADMIN_USER_RECORD_NOT_FOUND
|
|
855
|
+
: FirebaseAdminAuthErrorInfo.ADMIN_USER_LOOKUP_FAILED, { cause: ensureError(userError) })
|
|
487
856
|
};
|
|
488
857
|
}
|
|
489
858
|
if (!user) {
|
|
@@ -492,6 +861,16 @@ export class FirebaseAdminAuth {
|
|
|
492
861
|
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_USER_RECORD_NOT_FOUND)
|
|
493
862
|
};
|
|
494
863
|
}
|
|
864
|
+
if (user.disabled)
|
|
865
|
+
return {
|
|
866
|
+
data: null,
|
|
867
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_USER_DISABLED)
|
|
868
|
+
};
|
|
869
|
+
if (user.validSince && data.auth_time < Number(user.validSince))
|
|
870
|
+
return {
|
|
871
|
+
data: null,
|
|
872
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SESSION_COOKIE_REVOKED)
|
|
873
|
+
};
|
|
495
874
|
return {
|
|
496
875
|
data,
|
|
497
876
|
error: null
|
|
@@ -504,25 +883,40 @@ export class FirebaseAdminAuth {
|
|
|
504
883
|
* @returns Promise with object containing revoke response data or null, and error if any
|
|
505
884
|
*/
|
|
506
885
|
async revokeRefreshTokens(uid) {
|
|
507
|
-
const
|
|
508
|
-
if (
|
|
886
|
+
const uidError = validateUserUid(uid);
|
|
887
|
+
if (uidError)
|
|
888
|
+
return { data: null, error: uidError };
|
|
889
|
+
try {
|
|
890
|
+
const { data: token, error: getTokenError } = await this.getCachedToken();
|
|
891
|
+
if (getTokenError) {
|
|
892
|
+
return {
|
|
893
|
+
data: null,
|
|
894
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_SERVICE_ACCOUNT_TOKEN_FAILED, { cause: getTokenError })
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
if (!token?.access_token)
|
|
898
|
+
return {
|
|
899
|
+
data: null,
|
|
900
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_NO_TOKEN_RETURNED)
|
|
901
|
+
};
|
|
902
|
+
const { data: revokeData, error: revokeError } = await revokeRefreshTokens(this.serviceAccountKey.project_id, uid, token.access_token, this.fetch, this.tenantId);
|
|
903
|
+
if (revokeError || !revokeData) {
|
|
904
|
+
return {
|
|
905
|
+
data: null,
|
|
906
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_REVOKE_TOKENS_FAILED, { cause: ensureError(revokeError) })
|
|
907
|
+
};
|
|
908
|
+
}
|
|
509
909
|
return {
|
|
510
|
-
data:
|
|
511
|
-
error:
|
|
910
|
+
data: revokeData,
|
|
911
|
+
error: null
|
|
512
912
|
};
|
|
513
913
|
}
|
|
514
|
-
|
|
515
|
-
if (revokeError) {
|
|
516
|
-
console.error('Error revoking tokens:', revokeError);
|
|
914
|
+
catch (cause) {
|
|
517
915
|
return {
|
|
518
916
|
data: null,
|
|
519
|
-
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_REVOKE_TOKENS_FAILED, { cause: ensureError(
|
|
917
|
+
error: new FirebaseEdgeError(FirebaseAdminAuthErrorInfo.ADMIN_REVOKE_TOKENS_FAILED, { cause: ensureError(cause) })
|
|
520
918
|
};
|
|
521
919
|
}
|
|
522
|
-
return {
|
|
523
|
-
data: revokeData,
|
|
524
|
-
error: null
|
|
525
|
-
};
|
|
526
920
|
}
|
|
527
921
|
/**
|
|
528
922
|
* Creates a custom Firebase authentication token for a given user.
|
|
@@ -532,10 +926,7 @@ export class FirebaseAdminAuth {
|
|
|
532
926
|
* @returns Promise with object containing custom token string or null, and error if any
|
|
533
927
|
*/
|
|
534
928
|
async createCustomToken(uid, developerClaims = {}) {
|
|
535
|
-
const
|
|
536
|
-
? { ...developerClaims, tenant_id: this.tenantId }
|
|
537
|
-
: developerClaims;
|
|
538
|
-
const { data, error } = await signJWTCustomToken(uid, this.serviceAccountKey, claims);
|
|
929
|
+
const { data, error } = await signJWTCustomToken(uid, this.serviceAccountKey, developerClaims, this.tenantId, !!this.emulatorHost);
|
|
539
930
|
if (error) {
|
|
540
931
|
return {
|
|
541
932
|
data: null,
|