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
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { isLocalRedirectPath, parseProviderSession } from './auth/provider-session.js';
|
|
2
|
+
import { resolveProviderId, providerCredentialFromResponse, FIREBASE_PROVIDER_IDS } from './auth/provider-credential.js';
|
|
1
3
|
import { FirebaseAdminAuth } from './auth/firebase-admin-auth.js';
|
|
4
|
+
import { Identity } from './auth/identity.js';
|
|
5
|
+
import { Firestore } from './db/firestore.js';
|
|
6
|
+
import { AppCheck } from './app-check/app-check.js';
|
|
7
|
+
import { Storage } from './storage/storage.js';
|
|
2
8
|
import { FirebaseAuth } from './auth/firebase-auth.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { exchangeCodeForGoogleIdToken } from './auth/google-oauth.js';
|
|
6
|
-
import { createGitHubOAuthLoginUrl, createGoogleOAuthLoginUrl } from './auth/oauth.js';
|
|
7
|
-
import { FirebaseEdgeError } from './auth/errors.js';
|
|
9
|
+
import { resolveAuthEmulatorHost } from './auth/auth-emulator.js';
|
|
10
|
+
import { FirebaseEdgeError, ensureError } from './auth/errors.js';
|
|
8
11
|
import { FirebaseEdgeServerErrorInfo } from './firebase-edge-errors.js';
|
|
12
|
+
import { createEmailLinkState, readEmailLinkState, parseEmailActionLink, parseEmailSignInLink } from './auth/email-link.js';
|
|
13
|
+
import { buildEmailActionRequest } from './auth/email-action-request.js';
|
|
9
14
|
const COOKIE_LIFETIME_SECONDS = 60 * 60 * 24 * 5; // 5 days
|
|
10
15
|
const COOKIE_OPTIONS = {
|
|
11
16
|
httpOnly: true,
|
|
@@ -14,26 +19,13 @@ const COOKIE_OPTIONS = {
|
|
|
14
19
|
path: '/',
|
|
15
20
|
maxAge: COOKIE_LIFETIME_SECONDS
|
|
16
21
|
};
|
|
17
|
-
|
|
18
|
-
* Official Firebase OAuth providers
|
|
19
|
-
*/
|
|
20
|
-
export const OFFICIAL_FIREBASE_OAUTH_PROVIDERS = [
|
|
21
|
-
'google',
|
|
22
|
-
'facebook',
|
|
23
|
-
'apple',
|
|
24
|
-
'twitter',
|
|
25
|
-
'github',
|
|
26
|
-
'microsoft',
|
|
27
|
-
'yahoo',
|
|
28
|
-
'playgames'
|
|
29
|
-
];
|
|
22
|
+
export const OFFICIAL_FIREBASE_OAUTH_PROVIDERS = Object.keys(FIREBASE_PROVIDER_IDS);
|
|
30
23
|
/**
|
|
31
24
|
* Creates a Firebase Edge Server for authentication and session management in edge environments.
|
|
32
25
|
*
|
|
33
26
|
* @param config Configuration object
|
|
34
27
|
* @param config.serviceAccount Firebase service account for admin operations
|
|
35
28
|
* @param config.firebaseConfig Firebase client configuration
|
|
36
|
-
* @param config.providers OAuth provider configurations (Google, GitHub, etc.)
|
|
37
29
|
* @param config.cookies Cookie management functions (getSession, saveSession)
|
|
38
30
|
* @param config.redirectUri OAuth callback redirect URI
|
|
39
31
|
* @param config.cache Optional cache implementation for token caching
|
|
@@ -43,9 +35,10 @@ export const OFFICIAL_FIREBASE_OAUTH_PROVIDERS = [
|
|
|
43
35
|
* @param config.tenantId Optional Firebase Auth tenant ID for multi-tenancy
|
|
44
36
|
* @param config.autoLinkProviders Optional flag to automatically link accounts with same email
|
|
45
37
|
* @param config.fetch Optional custom fetch implementation
|
|
46
|
-
* @
|
|
38
|
+
* @param config.authEmulatorHost Auth emulator host:port; null forces production, undefined reads the environment.
|
|
39
|
+
* @returns Object with auth, adminAuth, firestore, and session management methods
|
|
47
40
|
*/
|
|
48
|
-
export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig,
|
|
41
|
+
export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig, cookies, cookieName, cookieOptions, cache, cacheName, tenantId, redirectUri, autoLinkProviders, fetch, authEmulatorHost }) {
|
|
49
42
|
// Cookies
|
|
50
43
|
const _cookieName = cookieName || '__session';
|
|
51
44
|
const { getSession, saveSession } = cookies;
|
|
@@ -54,8 +47,399 @@ export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig, provi
|
|
|
54
47
|
const fetchImpl = fetch ?? globalThis.fetch;
|
|
55
48
|
const cacheImpl = cache ?? undefined;
|
|
56
49
|
// Auth instances
|
|
57
|
-
const
|
|
58
|
-
|
|
50
|
+
const authOptions = {
|
|
51
|
+
emulatorHost: resolveAuthEmulatorHost(authEmulatorHost)
|
|
52
|
+
};
|
|
53
|
+
const auth = new FirebaseAuth(firebaseConfig, redirectUri, {
|
|
54
|
+
tenantId,
|
|
55
|
+
fetch: fetchImpl,
|
|
56
|
+
...authOptions
|
|
57
|
+
});
|
|
58
|
+
const adminAuth = new FirebaseAdminAuth(serviceAccount, {
|
|
59
|
+
tenantId,
|
|
60
|
+
fetch: fetchImpl,
|
|
61
|
+
cache: cacheImpl,
|
|
62
|
+
cacheName,
|
|
63
|
+
...authOptions
|
|
64
|
+
});
|
|
65
|
+
const firestore = new Firestore(serviceAccount, {
|
|
66
|
+
fetch: fetchImpl,
|
|
67
|
+
cache: cacheImpl,
|
|
68
|
+
cacheName
|
|
69
|
+
});
|
|
70
|
+
const identity = new Identity(serviceAccount, {
|
|
71
|
+
tenantId,
|
|
72
|
+
fetch: fetchImpl,
|
|
73
|
+
cache: cacheImpl,
|
|
74
|
+
cacheName,
|
|
75
|
+
...authOptions
|
|
76
|
+
});
|
|
77
|
+
const appCheck = new AppCheck(serviceAccount, {
|
|
78
|
+
fetch: fetchImpl,
|
|
79
|
+
cache: cacheImpl,
|
|
80
|
+
cacheName
|
|
81
|
+
});
|
|
82
|
+
const storage = new Storage(serviceAccount, {
|
|
83
|
+
bucketName: firebaseConfig.storageBucket,
|
|
84
|
+
fetch: fetchImpl,
|
|
85
|
+
cache: cacheImpl,
|
|
86
|
+
cacheName
|
|
87
|
+
});
|
|
88
|
+
/** Describe the confirmation form to render, without exchanging or consuming any code. */
|
|
89
|
+
function getCallbackAction(url) {
|
|
90
|
+
try {
|
|
91
|
+
const action = parseEmailActionLink(url, firebaseConfig.apiKey, tenantId);
|
|
92
|
+
if (!action)
|
|
93
|
+
return { data: null, error: null };
|
|
94
|
+
return {
|
|
95
|
+
data: {
|
|
96
|
+
hasLink: action.hasLink,
|
|
97
|
+
actionMode: action.actionMode
|
|
98
|
+
},
|
|
99
|
+
error: null
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (cause) {
|
|
103
|
+
return { data: null, error: ensureError(cause) };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Complete any supported callback after the framework has obtained user confirmation. */
|
|
107
|
+
async function handleCallback(url, options = {}) {
|
|
108
|
+
try {
|
|
109
|
+
const action = parseEmailActionLink(url, firebaseConfig.apiKey, tenantId);
|
|
110
|
+
if (!action || action.actionMode === 'signIn') {
|
|
111
|
+
const { error, data } = await signInWithCallback(url, options);
|
|
112
|
+
if (error)
|
|
113
|
+
return { data: null, error };
|
|
114
|
+
return {
|
|
115
|
+
data: { type: 'redirect', url: data },
|
|
116
|
+
error: null
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (!action.hasLink || !action.code)
|
|
120
|
+
return {
|
|
121
|
+
data: null,
|
|
122
|
+
error: new FirebaseEdgeError({
|
|
123
|
+
code: 'auth/invalid-action-code',
|
|
124
|
+
message: 'An email action code is required.'
|
|
125
|
+
})
|
|
126
|
+
};
|
|
127
|
+
if (action.actionMode === 'resetPassword' &&
|
|
128
|
+
options.confirmPassword !== undefined &&
|
|
129
|
+
options.newPassword !== options.confirmPassword)
|
|
130
|
+
return {
|
|
131
|
+
data: null,
|
|
132
|
+
error: new FirebaseEdgeError({
|
|
133
|
+
code: 'auth/password-mismatch',
|
|
134
|
+
message: 'Passwords do not match.'
|
|
135
|
+
})
|
|
136
|
+
};
|
|
137
|
+
const { error } = action.actionMode === 'resetPassword'
|
|
138
|
+
? await confirmPasswordReset(action.code, options.newPassword ?? '')
|
|
139
|
+
: await applyActionCode(action.code);
|
|
140
|
+
if (error)
|
|
141
|
+
return { data: null, error };
|
|
142
|
+
return {
|
|
143
|
+
data: {
|
|
144
|
+
type: 'complete',
|
|
145
|
+
message: action.actionMode === 'resetPassword'
|
|
146
|
+
? 'Your password has been reset. You can sign in again.'
|
|
147
|
+
: 'Your email has been updated or verified. Please sign in again.'
|
|
148
|
+
},
|
|
149
|
+
error: null
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
catch (cause) {
|
|
153
|
+
return { data: null, error: ensureError(cause) };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Send Firebase's password reset email using the configured callback. */
|
|
157
|
+
async function sendPasswordResetEmail(email, locale) {
|
|
158
|
+
return auth.sendPasswordResetEmail(email, redirectUri, locale);
|
|
159
|
+
}
|
|
160
|
+
/** Reset a password and clear the local session after success. */
|
|
161
|
+
async function confirmPasswordReset(oobCode, newPassword) {
|
|
162
|
+
const { error, data } = await auth.confirmPasswordReset(oobCode, newPassword);
|
|
163
|
+
if (error)
|
|
164
|
+
return { error, data };
|
|
165
|
+
signOut();
|
|
166
|
+
return { error, data };
|
|
167
|
+
}
|
|
168
|
+
/** Verify a new email before changing the currently signed-in account. */
|
|
169
|
+
async function verifyBeforeUpdateEmail(newEmail, locale) {
|
|
170
|
+
const { error: userError, data: userData } = await getUser(true);
|
|
171
|
+
if (userError)
|
|
172
|
+
return { data: null, error: userError };
|
|
173
|
+
if (!userData)
|
|
174
|
+
return {
|
|
175
|
+
data: null,
|
|
176
|
+
error: new FirebaseEdgeError({
|
|
177
|
+
code: 'auth/unauthenticated',
|
|
178
|
+
message: 'Sign in before changing your email.'
|
|
179
|
+
})
|
|
180
|
+
};
|
|
181
|
+
// getToken exchanges a custom token, so enforce recency on the original session first.
|
|
182
|
+
const age = Date.now() / 1000 - userData.auth_time;
|
|
183
|
+
if (!Number.isFinite(age) || age < 0 || age > 300)
|
|
184
|
+
return {
|
|
185
|
+
data: null,
|
|
186
|
+
error: new FirebaseEdgeError({
|
|
187
|
+
code: 'auth/requires-recent-login',
|
|
188
|
+
message: 'Sign out and sign in again before changing your email.'
|
|
189
|
+
})
|
|
190
|
+
};
|
|
191
|
+
const { error: tokenError, data: tokenData } = await getToken();
|
|
192
|
+
if (tokenError)
|
|
193
|
+
return { data: null, error: tokenError };
|
|
194
|
+
if (!tokenData?.idToken)
|
|
195
|
+
return {
|
|
196
|
+
data: null,
|
|
197
|
+
error: new FirebaseEdgeError({
|
|
198
|
+
code: 'auth/unauthenticated',
|
|
199
|
+
message: 'Sign in before changing your email.'
|
|
200
|
+
})
|
|
201
|
+
};
|
|
202
|
+
return auth.verifyBeforeUpdateEmail(tokenData.idToken, newEmail, redirectUri, locale);
|
|
203
|
+
}
|
|
204
|
+
/** Apply an email action and discard stale local session claims on success. */
|
|
205
|
+
async function applyActionCode(oobCode) {
|
|
206
|
+
const { error, data } = await auth.applyActionCode(oobCode);
|
|
207
|
+
if (error)
|
|
208
|
+
return { error, data };
|
|
209
|
+
signOut();
|
|
210
|
+
return { error, data };
|
|
211
|
+
}
|
|
212
|
+
/** Persist a successful Firebase login as the configured session cookie. */
|
|
213
|
+
async function saveSignInSession(signInData, next, expiresIn_ms) {
|
|
214
|
+
const { idToken } = signInData;
|
|
215
|
+
if (!idToken) {
|
|
216
|
+
return {
|
|
217
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_ID_TOKEN)
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const { data: sessionCookie, error: sessionError } = await adminAuth.createSessionCookie(idToken, {
|
|
221
|
+
expiresIn: expiresIn_ms
|
|
222
|
+
});
|
|
223
|
+
if (sessionError) {
|
|
224
|
+
return {
|
|
225
|
+
error: sessionError
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (!sessionCookie) {
|
|
229
|
+
return {
|
|
230
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_SESSION_COOKIE)
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
await saveSession(_cookieName, sessionCookie, _cookieOptions);
|
|
234
|
+
return {
|
|
235
|
+
data: next,
|
|
236
|
+
error: null
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/** Send a magic link with an optional email inside encrypted continuation state. */
|
|
240
|
+
async function sendSignInLinkToEmail(email, next = '/', options = {}) {
|
|
241
|
+
if (!isLocalRedirectPath(next))
|
|
242
|
+
return {
|
|
243
|
+
error: new FirebaseEdgeError({
|
|
244
|
+
code: 'auth/invalid-continue-uri',
|
|
245
|
+
message: 'The next path must be a local absolute path.'
|
|
246
|
+
})
|
|
247
|
+
};
|
|
248
|
+
const callbackUrl = options.callbackUrl ?? redirectUri;
|
|
249
|
+
const { error: validatedError } = buildEmailActionRequest('EMAIL_SIGNIN', email, {
|
|
250
|
+
url: callbackUrl,
|
|
251
|
+
handleCodeInApp: true
|
|
252
|
+
});
|
|
253
|
+
if (validatedError)
|
|
254
|
+
return { error: validatedError };
|
|
255
|
+
try {
|
|
256
|
+
const state = await createEmailLinkState({ next, ...(options.includeEmailInLink && { email }) }, serviceAccount.private_key, firebaseConfig.projectId, tenantId);
|
|
257
|
+
const continuation = new URL(callbackUrl);
|
|
258
|
+
continuation.searchParams.set('emailLinkState', state);
|
|
259
|
+
const { error } = await auth.sendSignInLinkToEmail(email, continuation.toString(), options.locale);
|
|
260
|
+
if (error)
|
|
261
|
+
return { error };
|
|
262
|
+
return { data: { sent: true }, error: null };
|
|
263
|
+
}
|
|
264
|
+
catch (cause) {
|
|
265
|
+
return { error: ensureError(cause) };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/** Complete a magic link with explicit email or email carried in encrypted state. */
|
|
269
|
+
async function signInWithEmailLink(url, options = {}) {
|
|
270
|
+
try {
|
|
271
|
+
const link = parseEmailSignInLink(url, firebaseConfig.apiKey, tenantId);
|
|
272
|
+
const state = await readEmailLinkState(link.state, serviceAccount.private_key, firebaseConfig.projectId, tenantId);
|
|
273
|
+
const email = options.email ?? state.email;
|
|
274
|
+
if (!email)
|
|
275
|
+
return {
|
|
276
|
+
error: new FirebaseEdgeError({
|
|
277
|
+
code: 'auth/missing-email',
|
|
278
|
+
message: 'Enter the email address this sign-in link was sent to.'
|
|
279
|
+
})
|
|
280
|
+
};
|
|
281
|
+
if (state.email && options.email && state.email !== options.email)
|
|
282
|
+
return {
|
|
283
|
+
error: new FirebaseEdgeError({
|
|
284
|
+
code: 'auth/invalid-email',
|
|
285
|
+
message: 'The email does not match this sign-in link.'
|
|
286
|
+
})
|
|
287
|
+
};
|
|
288
|
+
const { error, data } = await auth.signInWithEmailLink(email, link.code);
|
|
289
|
+
if (error)
|
|
290
|
+
return { error };
|
|
291
|
+
return await saveSignInSession(data ?? {}, state.next, options.expiresInMs ?? COOKIE_LIFETIME_SECONDS * 1000);
|
|
292
|
+
}
|
|
293
|
+
catch (cause) {
|
|
294
|
+
return { error: ensureError(cause) };
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/** Begin a provider flow using the provider configuration in Firebase Console. */
|
|
298
|
+
async function startProviderAuthorization(provider, next, intent, options) {
|
|
299
|
+
const providerId = resolveProviderId(provider);
|
|
300
|
+
if (providerId === 'playgames.google.com')
|
|
301
|
+
throw new FirebaseEdgeError({
|
|
302
|
+
code: 'auth/operation-not-supported-in-this-environment',
|
|
303
|
+
message: 'Use a native Play Games server authorization code with signInWithProviderToken.'
|
|
304
|
+
});
|
|
305
|
+
if (!isLocalRedirectPath(next))
|
|
306
|
+
throw new FirebaseEdgeError({
|
|
307
|
+
code: 'auth/invalid-continue-uri',
|
|
308
|
+
message: 'The next path must be a local absolute path.'
|
|
309
|
+
});
|
|
310
|
+
if (intent === 'link') {
|
|
311
|
+
const { error: userError, data: userData } = await getUser();
|
|
312
|
+
if (userError)
|
|
313
|
+
throw userError;
|
|
314
|
+
if (!userData)
|
|
315
|
+
throw new FirebaseEdgeError({
|
|
316
|
+
code: 'auth/user-not-found',
|
|
317
|
+
message: 'Sign in before linking a provider.'
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
const { error, data } = await auth.createProviderAuthorization(providerId, options);
|
|
321
|
+
if (error)
|
|
322
|
+
throw error;
|
|
323
|
+
if (!data?.authUri || !data.sessionId)
|
|
324
|
+
throw new FirebaseEdgeError({
|
|
325
|
+
code: 'auth/internal-error',
|
|
326
|
+
message: 'Firebase returned an incomplete authorization response.'
|
|
327
|
+
});
|
|
328
|
+
await saveSession(_cookieName + '_oauth', JSON.stringify({ sessionId: data.sessionId, next, intent }), {
|
|
329
|
+
..._cookieOptions,
|
|
330
|
+
httpOnly: true,
|
|
331
|
+
secure: true,
|
|
332
|
+
sameSite: 'none',
|
|
333
|
+
maxAge: 600
|
|
334
|
+
});
|
|
335
|
+
if (intent === 'signin')
|
|
336
|
+
deleteSession();
|
|
337
|
+
return data.authUri;
|
|
338
|
+
}
|
|
339
|
+
async function getProviderLoginURL(provider, next, options) {
|
|
340
|
+
return startProviderAuthorization(provider, next, 'signin', options);
|
|
341
|
+
}
|
|
342
|
+
async function getProviderLinkURL(provider, next, options) {
|
|
343
|
+
return startProviderAuthorization(provider, next, 'link', options);
|
|
344
|
+
}
|
|
345
|
+
/** Complete GET or form POST callbacks from Firebase-managed provider authorization. */
|
|
346
|
+
async function signInWithProviderCallback(url, postBody, expiresIn_ms = COOKIE_LIFETIME_SECONDS * 1000) {
|
|
347
|
+
const stored = await getSession(_cookieName + '_oauth');
|
|
348
|
+
if (!stored)
|
|
349
|
+
return {
|
|
350
|
+
error: new FirebaseEdgeError({
|
|
351
|
+
code: 'auth/invalid-credential',
|
|
352
|
+
message: 'The provider authorization session is missing or expired.'
|
|
353
|
+
})
|
|
354
|
+
};
|
|
355
|
+
await saveSession(_cookieName + '_oauth', '', {
|
|
356
|
+
..._cookieOptions,
|
|
357
|
+
maxAge: 0
|
|
358
|
+
});
|
|
359
|
+
const flow = parseProviderSession(stored);
|
|
360
|
+
if (!flow)
|
|
361
|
+
return {
|
|
362
|
+
error: new FirebaseEdgeError({
|
|
363
|
+
code: 'auth/invalid-credential',
|
|
364
|
+
message: 'Invalid provider authorization session.'
|
|
365
|
+
})
|
|
366
|
+
};
|
|
367
|
+
let idToken;
|
|
368
|
+
if (flow.intent === 'link') {
|
|
369
|
+
const { error: tokenError, data: tokenData } = await getToken();
|
|
370
|
+
if (tokenError)
|
|
371
|
+
return { error: tokenError };
|
|
372
|
+
if (!tokenData?.idToken)
|
|
373
|
+
return {
|
|
374
|
+
error: new FirebaseEdgeError({
|
|
375
|
+
code: 'auth/user-not-found',
|
|
376
|
+
message: 'Sign in before linking a provider.'
|
|
377
|
+
})
|
|
378
|
+
};
|
|
379
|
+
idToken = tokenData.idToken;
|
|
380
|
+
}
|
|
381
|
+
const { error, data } = await auth.signInWithProviderCallback({ requestUri: url.toString(), sessionId: flow.sessionId, postBody }, idToken);
|
|
382
|
+
if (error)
|
|
383
|
+
return { error };
|
|
384
|
+
if (!data)
|
|
385
|
+
return {
|
|
386
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_SIGN_IN_DATA)
|
|
387
|
+
};
|
|
388
|
+
const signInData = data;
|
|
389
|
+
const { error: completedError, data: completedData } = flow.intent === 'link'
|
|
390
|
+
? { error, data }
|
|
391
|
+
: await completeProviderSignIn(signInData, async (existingIdToken) => {
|
|
392
|
+
if (signInData.pendingToken)
|
|
393
|
+
return auth.signInWithProviderCallback({
|
|
394
|
+
requestUri: url.toString(),
|
|
395
|
+
pendingToken: signInData.pendingToken
|
|
396
|
+
}, existingIdToken);
|
|
397
|
+
try {
|
|
398
|
+
const { providerId, credential } = providerCredentialFromResponse(signInData);
|
|
399
|
+
return await auth.linkWithCredential(existingIdToken, credential, providerId);
|
|
400
|
+
}
|
|
401
|
+
catch (cause) {
|
|
402
|
+
return { error: ensureError(cause) };
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
if (completedError)
|
|
406
|
+
return { error: completedError };
|
|
407
|
+
if (!completedData?.idToken)
|
|
408
|
+
return {
|
|
409
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_ID_TOKEN)
|
|
410
|
+
};
|
|
411
|
+
return saveSignInSession(completedData, flow.next, expiresIn_ms);
|
|
412
|
+
}
|
|
413
|
+
async function getFacebookLoginURL(next, options) {
|
|
414
|
+
return getProviderLoginURL('facebook', next, options);
|
|
415
|
+
}
|
|
416
|
+
async function getFacebookLinkURL(next, options) {
|
|
417
|
+
return getProviderLinkURL('facebook', next, options);
|
|
418
|
+
}
|
|
419
|
+
async function getAppleLoginURL(next, options) {
|
|
420
|
+
return getProviderLoginURL('apple', next, options);
|
|
421
|
+
}
|
|
422
|
+
async function getAppleLinkURL(next, options) {
|
|
423
|
+
return getProviderLinkURL('apple', next, options);
|
|
424
|
+
}
|
|
425
|
+
async function getTwitterLoginURL(next, options) {
|
|
426
|
+
return getProviderLoginURL('twitter', next, options);
|
|
427
|
+
}
|
|
428
|
+
async function getTwitterLinkURL(next, options) {
|
|
429
|
+
return getProviderLinkURL('twitter', next, options);
|
|
430
|
+
}
|
|
431
|
+
async function getMicrosoftLoginURL(next, options) {
|
|
432
|
+
return getProviderLoginURL('microsoft', next, options);
|
|
433
|
+
}
|
|
434
|
+
async function getMicrosoftLinkURL(next, options) {
|
|
435
|
+
return getProviderLinkURL('microsoft', next, options);
|
|
436
|
+
}
|
|
437
|
+
async function getYahooLoginURL(next, options) {
|
|
438
|
+
return getProviderLoginURL('yahoo', next, options);
|
|
439
|
+
}
|
|
440
|
+
async function getYahooLinkURL(next, options) {
|
|
441
|
+
return getProviderLinkURL('yahoo', next, options);
|
|
442
|
+
}
|
|
59
443
|
/**
|
|
60
444
|
* Clears the session cookie by setting its maxAge to 0.
|
|
61
445
|
*/
|
|
@@ -109,53 +493,29 @@ export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig, provi
|
|
|
109
493
|
error: null
|
|
110
494
|
};
|
|
111
495
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Generates a Google OAuth login URL and clears any existing session.
|
|
114
|
-
*
|
|
115
|
-
* @param next State parameter for the OAuth flow (typically the redirect path after login)
|
|
116
|
-
* @param options Optional configuration object
|
|
117
|
-
* @param options.languageCode ISO 639-1 language code (e.g., 'en', 'es', 'fr')
|
|
118
|
-
* @param options.customParameters Custom OAuth parameters (e.g., { login_hint: 'user@example.com', hd: 'example.com' })
|
|
119
|
-
* @param options.addScopes Additional OAuth scopes (e.g., ['https://www.googleapis.com/auth/calendar.readonly'])
|
|
120
|
-
* @returns Promise resolving to Google OAuth login URL string
|
|
121
|
-
* @throws {FirebaseEdgeError} If Google provider is not configured
|
|
122
|
-
*/
|
|
496
|
+
/** Begin Google sign-in using the provider configured in Firebase Console. */
|
|
123
497
|
async function getGoogleLoginURL(next, options) {
|
|
124
|
-
|
|
125
|
-
if (!providers.google) {
|
|
126
|
-
throw new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_GOOGLE_PROVIDER_NOT_CONFIGURED);
|
|
127
|
-
}
|
|
128
|
-
const { client_id } = providers.google;
|
|
129
|
-
return createGoogleOAuthLoginUrl(redirectUri, next, client_id, 'signin', options?.languageCode, options?.customParameters, options?.addScopes);
|
|
498
|
+
return getProviderLoginURL('google', next, options);
|
|
130
499
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Generates a GitHub OAuth login URL and clears any existing session.
|
|
133
|
-
* Note: GitHub doesn't support language parameters - language is determined by user's browser/account settings.
|
|
134
|
-
*
|
|
135
|
-
* @param next State parameter for the OAuth flow (typically the redirect path after login)
|
|
136
|
-
* @param options Optional configuration object
|
|
137
|
-
* @param options.customParameters Custom OAuth parameters (e.g., { login: 'username', allow_signup: 'false' })
|
|
138
|
-
* @param options.addScopes Additional OAuth scopes (e.g., ['repo', 'gist'])
|
|
139
|
-
* @returns Promise resolving to GitHub OAuth login URL string
|
|
140
|
-
* @throws {FirebaseEdgeError} If GitHub provider is not configured
|
|
141
|
-
*/
|
|
500
|
+
/** Begin GitHub sign-in using the provider configured in Firebase Console. */
|
|
142
501
|
async function getGitHubLoginURL(next, options) {
|
|
143
|
-
|
|
144
|
-
if (!providers.github) {
|
|
145
|
-
throw new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_GITHUB_PROVIDER_NOT_CONFIGURED);
|
|
146
|
-
}
|
|
147
|
-
const { client_id } = providers.github;
|
|
148
|
-
return createGitHubOAuthLoginUrl(redirectUri, next, client_id, 'link', options?.customParameters, options?.addScopes);
|
|
502
|
+
return getProviderLoginURL('github', next, options);
|
|
149
503
|
}
|
|
150
504
|
/**
|
|
151
505
|
* Signs a user in using an already-obtained provider token.
|
|
152
506
|
*
|
|
153
|
-
* @param provider
|
|
507
|
+
* @param provider Firebase provider slug or ID
|
|
154
508
|
* @param oauthToken Provider token (Google `id_token` or GitHub `access_token`)
|
|
155
509
|
* @returns Promise resolving to an object containing sign-in data and/or an error
|
|
156
510
|
*/
|
|
157
511
|
async function signInWithProviderToken(provider, oauthToken) {
|
|
158
|
-
|
|
512
|
+
let providerId;
|
|
513
|
+
try {
|
|
514
|
+
providerId = resolveProviderId(provider);
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
return { data: null, error: error };
|
|
518
|
+
}
|
|
159
519
|
const { data: signInData, error: signInError } = await auth.signInWithProvider(oauthToken, providerId);
|
|
160
520
|
if (signInError) {
|
|
161
521
|
return {
|
|
@@ -167,197 +527,77 @@ export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig, provi
|
|
|
167
527
|
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_SIGN_IN_DATA)
|
|
168
528
|
};
|
|
169
529
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (!signInData.email) {
|
|
178
|
-
return {
|
|
179
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_EMAIL_FOR_AUTO_LINKING)
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
const { data, error: getEmailError } = await adminAuth.getUserByEmail(signInData.email);
|
|
183
|
-
if (getEmailError) {
|
|
184
|
-
return {
|
|
185
|
-
error: getEmailError
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
if (!data?.localId) {
|
|
189
|
-
return {
|
|
190
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_USER_RECORD)
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
const { data: customTokenData, error: tokenError } = await adminAuth.createCustomToken(data.localId);
|
|
194
|
-
if (tokenError) {
|
|
195
|
-
return {
|
|
196
|
-
data: null,
|
|
197
|
-
error: tokenError
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
const { data: customSignInData, error: customSignInError } = await auth.signInWithCustomToken(customTokenData);
|
|
201
|
-
if (customSignInError) {
|
|
202
|
-
return {
|
|
203
|
-
data: null,
|
|
204
|
-
error: customSignInError
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
if (!customSignInData?.idToken) {
|
|
208
|
-
return {
|
|
209
|
-
data: null,
|
|
210
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_ID_TOKEN)
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
const { data: linkData, error: linkError } = await auth.linkWithCredential(customSignInData.idToken, oauthToken, providerId);
|
|
214
|
-
if (linkError) {
|
|
215
|
-
return {
|
|
216
|
-
data: null,
|
|
217
|
-
error: linkError
|
|
218
|
-
};
|
|
219
|
-
}
|
|
530
|
+
return completeProviderSignIn(signInData, (idToken) => auth.linkWithCredential(idToken, oauthToken, providerId));
|
|
531
|
+
}
|
|
532
|
+
/** Resolve same-email collisions consistently for credential and managed flows. */
|
|
533
|
+
async function completeProviderSignIn(signInData, linkCredential) {
|
|
534
|
+
if (!signInData.needConfirmation)
|
|
535
|
+
return { data: signInData, error: null };
|
|
536
|
+
if (!autoLinkProviders) {
|
|
220
537
|
return {
|
|
221
|
-
|
|
222
|
-
error: null
|
|
538
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_ACCOUNT_EXISTS_DIFFERENT_METHOD)
|
|
223
539
|
};
|
|
224
540
|
}
|
|
225
|
-
|
|
226
|
-
data: signInData,
|
|
227
|
-
error: signInError
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Completes OAuth flow by exchanging authorization code for a session.
|
|
232
|
-
*
|
|
233
|
-
* @param url URL containing authorization code and state from OAuth callback
|
|
234
|
-
* @param expiresIn_ms Session cookie expiration time in milliseconds (defaults to 5 days)
|
|
235
|
-
* @returns Promise resolving to object with next redirect path and error if any
|
|
236
|
-
*/
|
|
237
|
-
async function signInWithCallback(url, expiresIn_ms = COOKIE_LIFETIME_SECONDS * 1000) {
|
|
238
|
-
const code = url.searchParams.get('code');
|
|
239
|
-
const state = url.searchParams.get('state');
|
|
240
|
-
if (!code) {
|
|
541
|
+
if (!signInData.email) {
|
|
241
542
|
return {
|
|
242
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.
|
|
543
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_EMAIL_FOR_AUTO_LINKING)
|
|
243
544
|
};
|
|
244
545
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
let intent = null;
|
|
248
|
-
try {
|
|
249
|
-
const parsed = state && JSON.parse(state);
|
|
250
|
-
next = parsed?.next ?? '/';
|
|
251
|
-
provider = parsed?.provider ?? null;
|
|
252
|
-
intent = parsed?.intent ?? null;
|
|
253
|
-
}
|
|
254
|
-
catch { }
|
|
255
|
-
if (!provider) {
|
|
546
|
+
const { data, error: getEmailError } = await adminAuth.getUserByEmail(signInData.email);
|
|
547
|
+
if (getEmailError) {
|
|
256
548
|
return {
|
|
257
|
-
error:
|
|
549
|
+
error: getEmailError
|
|
258
550
|
};
|
|
259
551
|
}
|
|
260
|
-
|
|
261
|
-
if (providers.google && provider === 'google') {
|
|
262
|
-
const { client_id, client_secret } = providers.google;
|
|
263
|
-
const { data: googleData, error: exchangeError } = await exchangeCodeForGoogleIdToken(code, redirectUri, client_id, client_secret, fetchImpl);
|
|
264
|
-
if (exchangeError) {
|
|
265
|
-
return {
|
|
266
|
-
error: exchangeError
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
if (!googleData) {
|
|
270
|
-
return {
|
|
271
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_EXCHANGE_DATA)
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
oauthToken = googleData.id_token;
|
|
275
|
-
}
|
|
276
|
-
else if (providers.github && provider === 'github') {
|
|
277
|
-
const { client_id, client_secret } = providers.github;
|
|
278
|
-
const { data: githubData, error: exchangeError } = await exchangeCodeForGitHubIdToken(code, redirectUri, client_id, client_secret, fetchImpl);
|
|
279
|
-
if (exchangeError) {
|
|
280
|
-
return {
|
|
281
|
-
error: exchangeError
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
if (!githubData) {
|
|
285
|
-
return {
|
|
286
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_EXCHANGE_DATA)
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
oauthToken = githubData.access_token;
|
|
290
|
-
}
|
|
291
|
-
if (!oauthToken) {
|
|
552
|
+
if (!data?.localId) {
|
|
292
553
|
return {
|
|
293
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.
|
|
554
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_USER_RECORD)
|
|
294
555
|
};
|
|
295
556
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const { error: linkError } = await linkProvider(oauthToken, providerId);
|
|
299
|
-
if (linkError) {
|
|
300
|
-
return {
|
|
301
|
-
error: linkError
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
const { data: userData, error: userError } = await getUser();
|
|
305
|
-
if (userError) {
|
|
306
|
-
return {
|
|
307
|
-
error: userError
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
if (!userData?.user_id) {
|
|
311
|
-
return {
|
|
312
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_USER_FOR_LINKING)
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
const { error: revokeError } = await adminAuth.revokeRefreshTokens(userData.user_id);
|
|
316
|
-
if (revokeError) {
|
|
317
|
-
return {
|
|
318
|
-
error: revokeError
|
|
319
|
-
};
|
|
320
|
-
}
|
|
557
|
+
const { data: customTokenData, error: tokenError } = await adminAuth.createCustomToken(data.localId);
|
|
558
|
+
if (tokenError) {
|
|
321
559
|
return {
|
|
322
|
-
data:
|
|
323
|
-
error:
|
|
560
|
+
data: null,
|
|
561
|
+
error: tokenError
|
|
324
562
|
};
|
|
325
563
|
}
|
|
326
|
-
|
|
327
|
-
if (signInError) {
|
|
564
|
+
if (!customTokenData)
|
|
328
565
|
return {
|
|
329
|
-
error:
|
|
566
|
+
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_CUSTOM_TOKEN_SIGNED)
|
|
330
567
|
};
|
|
331
|
-
}
|
|
332
|
-
if (
|
|
568
|
+
const { data: customSignInData, error: customSignInError } = await auth.signInWithCustomToken(customTokenData);
|
|
569
|
+
if (customSignInError) {
|
|
333
570
|
return {
|
|
334
|
-
|
|
571
|
+
data: null,
|
|
572
|
+
error: customSignInError
|
|
335
573
|
};
|
|
336
574
|
}
|
|
337
|
-
|
|
338
|
-
if (!idToken) {
|
|
575
|
+
if (!customSignInData?.idToken) {
|
|
339
576
|
return {
|
|
577
|
+
data: null,
|
|
340
578
|
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_ID_TOKEN)
|
|
341
579
|
};
|
|
342
580
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
581
|
+
return linkCredential(customSignInData.idToken);
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Completes provider or magic-link sign-in and saves a session.
|
|
585
|
+
*
|
|
586
|
+
* @param url Full provider callback or email action URL
|
|
587
|
+
* @param options Callback options, or a legacy numeric session duration in milliseconds
|
|
588
|
+
* @returns Promise resolving to object with next redirect path and error if any
|
|
589
|
+
*/
|
|
590
|
+
async function signInWithCallback(url, options = {}) {
|
|
591
|
+
const settings = typeof options === 'number' ? { expiresInMs: options } : options;
|
|
592
|
+
try {
|
|
593
|
+
const action = parseEmailActionLink(url, firebaseConfig.apiKey, tenantId);
|
|
594
|
+
if (action)
|
|
595
|
+
return signInWithEmailLink(url, settings);
|
|
350
596
|
}
|
|
351
|
-
|
|
352
|
-
return {
|
|
353
|
-
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_SESSION_COOKIE)
|
|
354
|
-
};
|
|
597
|
+
catch (cause) {
|
|
598
|
+
return { error: ensureError(cause) };
|
|
355
599
|
}
|
|
356
|
-
|
|
357
|
-
return {
|
|
358
|
-
data: next,
|
|
359
|
-
error: null
|
|
360
|
-
};
|
|
600
|
+
return signInWithProviderCallback(url, settings.postBody, settings.expiresInMs);
|
|
361
601
|
}
|
|
362
602
|
/**
|
|
363
603
|
* Generates fresh Firebase client tokens for the authenticated user.
|
|
@@ -379,8 +619,7 @@ export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig, provi
|
|
|
379
619
|
error: null
|
|
380
620
|
};
|
|
381
621
|
}
|
|
382
|
-
const
|
|
383
|
-
const { data: signJWTData, error: signJWTError } = await signJWTCustomToken(verifiedToken.sub, serviceAccount, claims);
|
|
622
|
+
const { data: signJWTData, error: signJWTError } = await adminAuth.createCustomToken(verifiedToken.sub);
|
|
384
623
|
if (signJWTError) {
|
|
385
624
|
return {
|
|
386
625
|
data: null,
|
|
@@ -463,46 +702,19 @@ export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig, provi
|
|
|
463
702
|
error: new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_NO_SESSION_COOKIE)
|
|
464
703
|
};
|
|
465
704
|
}
|
|
466
|
-
saveSession(_cookieName, sessionCookie, _cookieOptions);
|
|
705
|
+
await saveSession(_cookieName, sessionCookie, _cookieOptions);
|
|
467
706
|
return {
|
|
468
707
|
data: unlinkData,
|
|
469
708
|
error: null
|
|
470
709
|
};
|
|
471
710
|
}
|
|
472
|
-
/**
|
|
473
|
-
* Generates a Google OAuth URL for linking an additional provider to the current user.
|
|
474
|
-
*
|
|
475
|
-
* @param next State parameter for the OAuth flow (typically the redirect path after linking)
|
|
476
|
-
* @param options Optional configuration object
|
|
477
|
-
* @param options.languageCode ISO 639-1 language code (e.g., 'en', 'es', 'fr')
|
|
478
|
-
* @param options.customParameters Custom OAuth parameters (e.g., { login_hint: 'user@example.com' })
|
|
479
|
-
* @param options.addScopes Additional OAuth scopes (e.g., ['https://www.googleapis.com/auth/calendar.readonly'])
|
|
480
|
-
* @returns Promise resolving to Google OAuth link URL string
|
|
481
|
-
* @throws {FirebaseEdgeError} If Google provider is not configured
|
|
482
|
-
*/
|
|
711
|
+
/** Begin Google linking for the currently authenticated user. */
|
|
483
712
|
async function getGoogleLinkURL(next, options) {
|
|
484
|
-
|
|
485
|
-
throw new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_GOOGLE_PROVIDER_NOT_CONFIGURED);
|
|
486
|
-
}
|
|
487
|
-
const { client_id } = providers.google;
|
|
488
|
-
return createGoogleOAuthLoginUrl(redirectUri, next, client_id, 'link', options?.languageCode, options?.customParameters, options?.addScopes);
|
|
713
|
+
return getProviderLinkURL('google', next, options);
|
|
489
714
|
}
|
|
490
|
-
/**
|
|
491
|
-
* Generates a GitHub OAuth URL for linking an additional provider to the current user.
|
|
492
|
-
*
|
|
493
|
-
* @param next State parameter for the OAuth flow (typically the redirect path after linking)
|
|
494
|
-
* @param options Optional configuration object
|
|
495
|
-
* @param options.customParameters Custom OAuth parameters (e.g., { login: 'username', allow_signup: 'false' })
|
|
496
|
-
* @param options.addScopes Additional OAuth scopes (e.g., ['repo', 'gist'])
|
|
497
|
-
* @returns Promise resolving to GitHub OAuth link URL string
|
|
498
|
-
* @throws {FirebaseEdgeError} If GitHub provider is not configured
|
|
499
|
-
*/
|
|
715
|
+
/** Begin GitHub linking for the currently authenticated user. */
|
|
500
716
|
async function getGitHubLinkURL(next, options) {
|
|
501
|
-
|
|
502
|
-
throw new FirebaseEdgeError(FirebaseEdgeServerErrorInfo.EDGE_GITHUB_PROVIDER_NOT_CONFIGURED);
|
|
503
|
-
}
|
|
504
|
-
const { client_id } = providers.github;
|
|
505
|
-
return createGitHubOAuthLoginUrl(redirectUri, next, client_id, 'signin', options?.customParameters, options?.addScopes);
|
|
717
|
+
return getProviderLinkURL('github', next, options);
|
|
506
718
|
}
|
|
507
719
|
/**
|
|
508
720
|
* Links an OAuth provider to the currently authenticated user.
|
|
@@ -540,8 +752,33 @@ export function createFirebaseEdgeServer({ serviceAccount, firebaseConfig, provi
|
|
|
540
752
|
return {
|
|
541
753
|
auth,
|
|
542
754
|
adminAuth,
|
|
755
|
+
firestore,
|
|
756
|
+
identity,
|
|
757
|
+
appCheck,
|
|
758
|
+
storage,
|
|
759
|
+
sendSignInLinkToEmail,
|
|
760
|
+
getCallbackAction,
|
|
761
|
+
handleCallback,
|
|
762
|
+
sendPasswordResetEmail,
|
|
763
|
+
confirmPasswordReset,
|
|
764
|
+
verifyBeforeUpdateEmail,
|
|
765
|
+
applyActionCode,
|
|
543
766
|
signOut,
|
|
544
767
|
getUser,
|
|
768
|
+
getProviderLoginURL,
|
|
769
|
+
getProviderLinkURL,
|
|
770
|
+
signInWithProviderCallback,
|
|
771
|
+
signInWithProviderToken,
|
|
772
|
+
getFacebookLoginURL,
|
|
773
|
+
getFacebookLinkURL,
|
|
774
|
+
getAppleLoginURL,
|
|
775
|
+
getAppleLinkURL,
|
|
776
|
+
getTwitterLoginURL,
|
|
777
|
+
getTwitterLinkURL,
|
|
778
|
+
getMicrosoftLoginURL,
|
|
779
|
+
getMicrosoftLinkURL,
|
|
780
|
+
getYahooLoginURL,
|
|
781
|
+
getYahooLinkURL,
|
|
545
782
|
getGoogleLoginURL,
|
|
546
783
|
getGitHubLoginURL,
|
|
547
784
|
getGoogleLinkURL,
|