From 1452a031ee1b7904a361b23391af8533237eab82 Mon Sep 17 00:00:00 2001 From: KlutchDEV Date: Mon, 11 Jan 2021 05:19:57 -0500 Subject: [PATCH 001/170] Simple typo (#84) --- auth-next/email.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth-next/email.js b/auth-next/email.js index 368ad8a8..07a3cc3a 100644 --- a/auth-next/email.js +++ b/auth-next/email.js @@ -29,7 +29,7 @@ function signInWithEmailPassword() { // [END auth_signin_password] } -function signUpWithEmailPasswoerd() { +function signUpWithEmailPassword() { const email = "test@example.com"; const password = "hunter2"; From 6344eeb4d72df3bca3af1a7409110694aaa15573 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 15 Jan 2021 02:32:40 -0800 Subject: [PATCH 002/170] Auto-update dependencies. (#85) --- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/auth/package.json b/auth/package.json index 6af79a47..c814359e 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.2", + "firebase": "^8.2.3", "firebaseui": "^4.7.1" } } diff --git a/database/package.json b/database/package.json index 763ebb14..1063856e 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.2" + "firebase": "^8.2.3" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index f2483182..ab98eba2 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.2" + "firebase": "^8.2.3" } } diff --git a/firestore/package.json b/firestore/package.json index df5faf59..eada0581 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.2", + "firebase": "^8.2.3", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index aa09b8f3..6cf0d5cf 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.2" + "firebase": "^8.2.3" } } diff --git a/installations/package.json b/installations/package.json index 64ac9086..13361e6d 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.2" + "firebase": "^8.2.3" } } diff --git a/perf/package.json b/perf/package.json index 1c259bef..6689d178 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.2" + "firebase": "^8.2.3" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index db3c3182..94072b11 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.2" + "firebase": "^8.2.3" } } From 1f7e6e98a56964caa5854ddc1c659f245f139bd1 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 15 Jan 2021 12:30:03 +0000 Subject: [PATCH 003/170] Move quickstart-js snippets (#86) --- lerna.json | 4 ++- messaging/index.js | 70 +++++++++++++++++++++++++++++++++++++ messaging/package.json | 11 ++++++ messaging/service-worker.js | 53 ++++++++++++++++++++++++++++ storage/index.js | 33 +++++++++++++++++ storage/package.json | 11 ++++++ 6 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 messaging/index.js create mode 100644 messaging/package.json create mode 100644 messaging/service-worker.js create mode 100644 storage/index.js create mode 100644 storage/package.json diff --git a/lerna.json b/lerna.json index 6397cfbf..8080d78a 100644 --- a/lerna.json +++ b/lerna.json @@ -10,10 +10,12 @@ "functions", "functions-next", "installations", + "messaging", "perf", "perf-next", "remoteconfig", - "remoteconfig-next" + "remoteconfig-next", + "storage" ], "version": "1.0.0" } diff --git a/messaging/index.js b/messaging/index.js new file mode 100644 index 00000000..073d8c2a --- /dev/null +++ b/messaging/index.js @@ -0,0 +1,70 @@ +import firebase from "firebase/app"; +import "firebase/messaging"; + +function getMessagingObject() { + // [START messaging_get_messaging_object] + const messaging = firebase.messaging(); + // [END messaging_get_messaging_object] +} + +function receiveMessage() { + const messaging = firebase.messaging(); + // [START messaging_receive_message] + // Handle incoming messages. Called when: + // - a message is received while the app has focus + // - the user clicks on an app notification created by a service worker + // `messaging.onBackgroundMessage` handler. + messaging.onMessage((payload) => { + console.log('Message received. ', payload); + // ... + }); + // [END messaging_receive_message] +} + +function getToken() { + const messaging = firebase.messaging(); + // [START messaging_get_token] + // Get registration token. Initially this makes a network call, once retrieved + // subsequent calls to getToken will return from cache. + messaging.getToken({ vapidKey: '' }).then((currentToken) => { + if (currentToken) { + // Send the token to your server and update the UI if necessary + // ... + } else { + // Show permission request UI + console.log('No registration token available. Request permission to generate one.'); + // ... + } + }).catch((err) => { + console.log('An error occurred while retrieving token. ', err); + // ... + }); + // [END messaging_get_token] +} + +function requestPermission() { + // [START messaging_request_permission] + Notification.requestPermission().then((permission) => { + if (permission === 'granted') { + console.log('Notification permission granted.'); + // TODO(developer): Retrieve a registration token for use with FCM. + // ... + } else { + console.log('Unable to get permission to notify.'); + } + }); + // [END messaging_request_permission] +} + +function deleteToken() { + const messaging = firebase.messaging(); + + // [START messaging_delete_token] + messaging.deleteToken().then(() => { + console.log('Token deleted.'); + // ... + }).catch((err) => { + console.log('Unable to delete token. ', err); + }); + // [END messaging_delete_token] +} diff --git a/messaging/package.json b/messaging/package.json new file mode 100644 index 00000000..6ca0ae56 --- /dev/null +++ b/messaging/package.json @@ -0,0 +1,11 @@ +{ + "name": "messaging", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "^8.2.3" + } +} diff --git a/messaging/service-worker.js b/messaging/service-worker.js new file mode 100644 index 00000000..20179153 --- /dev/null +++ b/messaging/service-worker.js @@ -0,0 +1,53 @@ +import firebase from "firebase/app"; +import "firebase/messaging"; + +// See: https://github.com/microsoft/TypeScript/issues/14877 +/** @type {ServiceWorkerGlobalScope} */ +let self; + +function initInSw() { + // [START messaging_init_in_sw] + // Give the service worker access to Firebase Messaging. + // Note that you can only use Firebase Messaging here. Other Firebase libraries + // are not available in the service worker. + importScripts('https://www.gstatic.com/firebasejs/8.2.3/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.3/firebase-messaging.js'); + + // Initialize the Firebase app in the service worker by passing in + // your app's Firebase config object. + // https://firebase.google.com/docs/web/setup#config-object + firebase.initializeApp({ + apiKey: 'api-key', + authDomain: 'project-id.firebaseapp.com', + databaseURL: 'https://project-id.firebaseio.com', + projectId: 'project-id', + storageBucket: 'project-id.appspot.com', + messagingSenderId: 'sender-id', + appId: 'app-id', + measurementId: 'G-measurement-id', + }); + + // Retrieve an instance of Firebase Messaging so that it can handle background + // messages. + const messaging = firebase.messaging(); + // [END messaging_init_in_sw] +} + +function onBackgroundMessage() { + const messaging = firebase.messaging(); + + // [START messaging_on_background_message] + messaging.onBackgroundMessage((payload) => { + console.log('[firebase-messaging-sw.js] Received background message ', payload); + // Customize notification here + const notificationTitle = 'Background Message Title'; + const notificationOptions = { + body: 'Background Message body.', + icon: '/firebase-logo.png' + }; + + self.registration.showNotification(notificationTitle, + notificationOptions); + }); + // [END messaging_on_background_message] +} diff --git a/storage/index.js b/storage/index.js new file mode 100644 index 00000000..02598d88 --- /dev/null +++ b/storage/index.js @@ -0,0 +1,33 @@ +import firebase from "firebase/app"; +import "firebase/storage"; + +/** + * @param {File} file + */ +function storageOnComplete(file) { + // The file param would be a File object from a file selection event in the browser. + // See: + // - https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications + // - https://developer.mozilla.org/en-US/docs/Web/API/File + + const metadata = { + 'contentType': file.type + }; + + // [START storage_on_complete] + const storageRef = firebase.storage().ref(); + storageRef.child('images/' + file.name).put(file, metadata) + .then((snapshot) => { + console.log('Uploaded', snapshot.totalBytes, 'bytes.'); + console.log('File metadata:', snapshot.metadata); + // Let's get a download URL for the file. + snapshot.ref.getDownloadURL().then((url) => { + console.log('File available at', url); + // ... + }); + }).catch((error) => { + console.error('Upload failed', error); + // ... + }); + // [END storage_on_complete] +} diff --git a/storage/package.json b/storage/package.json new file mode 100644 index 00000000..655f1d3c --- /dev/null +++ b/storage/package.json @@ -0,0 +1,11 @@ +{ + "name": "storage", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "^8.2.3" + } +} From c0ca18d8abb53e338956fbbffe9731e14b9b7e4c Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 15 Jan 2021 05:20:06 -0800 Subject: [PATCH 004/170] Auto-update dependencies. (#87) --- firestore/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 54ff25bd..a02a895c 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + From 67bda8b68e1d202b0dd3eb464383a4eefb449170 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Wed, 20 Jan 2021 17:23:41 +0000 Subject: [PATCH 005/170] Add analytics snippets (#88) --- analytics/ecommerce.js | 248 +++++++++++++++++++++++++++++++++++++++++ analytics/index.js | 40 +++++++ analytics/package.json | 11 ++ lerna.json | 1 + 4 files changed, 300 insertions(+) create mode 100644 analytics/ecommerce.js create mode 100644 analytics/index.js create mode 100644 analytics/package.json diff --git a/analytics/ecommerce.js b/analytics/ecommerce.js new file mode 100644 index 00000000..6e5216bd --- /dev/null +++ b/analytics/ecommerce.js @@ -0,0 +1,248 @@ +import firebase from "firebase/app"; +import "firebase/analytics"; + +// [START analytics_ecommerce_items] +// A pair of jeggings +const item_jeggings = { + item_id: 'SKU_123', + item_name: 'jeggings', + item_category: 'pants', + item_variant: 'black', + item_brand: 'Google', + price: 9.99 +}; + +// A pair of boots +const item_boots = { + item_id: 'SKU_456', + item_name: 'boots', + item_category: 'shoes', + item_variant: 'brown', + item_brand: 'Google', + price: 24.99 +}; + +// A pair of socks +const item_socks = { + item_id: 'SKU_789', + item_name: 'ankle_socks', + item_category: 'socks', + item_variant: 'red', + item_brand: 'Google', + price: 5.99 +}; +// [END analytics_ecommerce_items] + +function ecommerceViewItemList() { + // [START analytics_ecommerce_view_item_list] + // Prepare ecommerce params + const params1 = { + item_list_id: 'L001', + item_list_name: 'Related products', + items: [item_jeggings, item_boots, item_socks] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_ITEM_LIST, params1); + // [END analytics_ecommerce_view_item_list] +} + +function ecommerceSelectItem() { + // [START analytics_ecommerce_select_item] + // Prepare ecommerce event params + const params2 = { + item_list_id: 'L001', + item_list_name: 'Related products', + items: [item_jeggings] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.SELECT_ITEM, params2); + // [END analytics_ecommerce_select_item] +} + +function ecommerceViewItemDetails() { + // [START analytics_ecommerce_view_item_details] + // Prepare ecommerce event params + const params3 = { + currency: 'USD', + value: 9.99, + items: [item_jeggings] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_ITEM, params3); + // [END analytics_ecommerce_view_item_details] +} + +function ecommerceAddCart() { + // [START analytics_ecommerce_add_cart] + // Specify order quantity + const item_jeggings_quantity = { + ...item_jeggings, + quantity: 2 + }; + + // Prepare ecommerce bundle + const params4 = { + currency: 'USD', + value: 19.98, + items: [item_jeggings_quantity] + }; + + // Log event when a product is added to a wishlist + firebase.analytics().logEvent(firebase.analytics.EventName.ADD_TO_WISHLIST, params4); + + // Log event when a product is added to the cart + firebase.analytics().logEvent(firebase.analytics.EventName.ADD_TO_CART, params4); + // [END analytics_ecommerce_add_cart] +} + +function ecommerceViewCart() { + // [START analytics_ecommerce_view_cart] + // Specify order quantity + const item_jeggings_quantity = { + ...item_jeggings, + quantity: 2 + }; + + const item_boots_quantity = { + ...item_boots, + quantity: 1 + }; + + // Prepare ecommerce params + const params5 = { + currency: 'USD', + value: 44.97, + items: [item_jeggings_quantity, item_boots_quantity] + }; + + // Log event when the cart is viewed + firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_CART, params5); + // [END analytics_ecommerce_view_cart] +} + +function ecommerceRemoveCart() { + // [START analytics_ecommerce_remove_cart] + // Prepare ecommerce params + const params6 = { + currency: 'USD', + value: 24.99, + items: [item_jeggings] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.REMOVE_FROM_CART, params6); + // [END analytics_ecommerce_remove_cart] +} + +function ecommerceCheckout() { + // [START analytics_ecommerce_checkout] + // Prepare ecommerce params + const params7 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + items: [item_jeggings] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.BEGIN_CHECKOUT, params7); + // [END analytics_ecommerce_checkout] +} + +function ecommerceShippingInfo() { + // [START analytics_ecommerce_shipping_info] + // Prepare ecommerce params + const params8 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + shipping_tier: 'Ground', + items: [item_jeggings] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.ADD_SHIPPING_INFO, params8); + // [END analytics_ecommerce_shipping_info] +} + +function ecommercePaymentInfo() { + // [START analytics_ecommerce_payment_info] + // Prepare ecommerce params + const params9 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + payment_type: 'Visa', + items: [item_jeggings] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.ADD_PAYMENT_INFO, params9); + // [END analytics_ecommerce_payment_info] +} + +function ecommercePurchase() { + // [START analytics_ecommerce_purchase] + // Prepare ecommerce bundle + const params10 = { + transaction_id: 'T12345', + affiliation: 'Google Store', + currency: 'USD', + value: 14.98, // Total Revenue + tax: 2.85, + shipping: 5.34, + coupon: 'SUMMER_FUN', + items: [item_jeggings] + }; + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.PURCHASE, params10); + // [END analytics_ecommerce_purchase] +} + +function ecommerceRefund() { + // [START analytics_ecommerce_refund] + // Prepare ecommerce params + const params11 = { + transaction_id: 'T12345', // Required + affiliation: 'Google Store', + currency: 'USD', + value: 9.99, + items: [] + }; + + // (Optional) For partial refunds, define the item_id and quantity of refunded items + const refundedProduct = { + item_id: 'SKU_123', // Required + quantity: 1 // Required + }; + + params11.items.push(refundedProduct); + + // Log event + firebase.analytics().logEvent(firebase.analytics.EventName.REFUND, params11); + // [END analytics_ecommerce_refund] +} + +function ecommercePromotions() { + // [START analytics_ecommerce_promotions] + // Prepare ecommerce params + const params12 = { + promotion_id: 'ABC123', + promotion_name: 'Summer Sale', + creative_name: 'summer2020_promo.jpg', + creative_slot: 'featured_app_1', + location_id: 'HERO_BANNER', + items: [item_jeggings] + }; + + // Log event when a promotion is displayed + firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_PROMOTION, params12); + + // Log event when a promotion is selected + firebase.analytics().logEvent(firebase.analytics.EventName.SELECT_PROMOTION, params12); + // [END analytics_ecommerce_promotions] +} diff --git a/analytics/index.js b/analytics/index.js new file mode 100644 index 00000000..f8a0e856 --- /dev/null +++ b/analytics/index.js @@ -0,0 +1,40 @@ +import firebase from "firebase/app"; +import "firebase/analytics"; + +function initialize() { + // [START analytics_initialize] + const analytics = firebase.analytics(); + // [END analytics_initialize] +} + +function logEvent() { + // [START analytics_log_event] + firebase.analytics().logEvent('notification_received'); + // [END analytics_log_event] +} + +function logEventParams() { + const analytics = firebase.analytics(); + + // [START analytics_log_event_params] + analytics.logEvent('select_content', { + content_type: 'image', + content_id: 'P12453', + items: [{ name: 'Kittens' }] + }); + // [END analytics_log_event_params] +} + +function logEventCustomParams() { + const analytics = firebase.analytics(); + + // [START analytics_log_event_custom_params] + analytics.logEvent('goal_completion', { name: 'lever_puzzle'}); + // [END analytics_log_event_custom_params] +} + +function setUserProperties() { + // [START analytics_set_user_properties] + firebase.analytics().setUserProperties({favorite_food: 'apples'}); + // [END analytics_set_user_properties] +} diff --git a/analytics/package.json b/analytics/package.json new file mode 100644 index 00000000..41bd45d7 --- /dev/null +++ b/analytics/package.json @@ -0,0 +1,11 @@ +{ + "name": "analytics", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "^8.2.3" + } +} diff --git a/lerna.json b/lerna.json index 8080d78a..ca43200d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,7 @@ { "lerna": "2.8.0", "packages": [ + "analytics", "auth", "auth-next", "database", From a808a4b54d06ba3a2f69a5d8fe75e4df7671b50d Mon Sep 17 00:00:00 2001 From: Frank van Puffelen Date: Thu, 21 Jan 2021 02:55:47 -0800 Subject: [PATCH 006/170] Update email.js (#89) Co-authored-by: Sam --- auth-next/custom.js | 3 ++- auth-next/email.js | 6 ++++-- auth/custom.js | 3 ++- auth/email.js | 8 +++++--- snippets/auth-next/custom/auth_sign_in_custom.js | 3 ++- snippets/auth-next/email/auth_signin_password.js | 3 ++- snippets/auth-next/email/auth_signup_password.js | 3 ++- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/auth-next/custom.js b/auth-next/custom.js index 6ecdbe18..8f4ac547 100644 --- a/auth-next/custom.js +++ b/auth-next/custom.js @@ -17,8 +17,9 @@ function signInCustom() { const auth = getAuth(firebaseApp); signInWithCustomToken(auth, token) - .then((user) => { + .then((userCredential) => { // Signed in + const user = userCredential.user; // ... }) .catch((error) => { diff --git a/auth-next/email.js b/auth-next/email.js index 07a3cc3a..7285185a 100644 --- a/auth-next/email.js +++ b/auth-next/email.js @@ -18,8 +18,9 @@ function signInWithEmailPassword() { const auth = getAuth(firebaseApp); signInWithEmailAndPassword(auth, email, password) - .then((user) => { + .then((userCredential) => { // Signed in + const user = userCredential.user; // ... }) .catch((error) => { @@ -38,8 +39,9 @@ function signUpWithEmailPassword() { const auth = getAuth(firebaseApp); createUserWithEmailAndPassword(auth, email, password) - .then((user) => { + .then((userCredential) => { // Signed in + const user = userCredential.user; // ... }) .catch((error) => { diff --git a/auth/custom.js b/auth/custom.js index dc02990e..97713714 100644 --- a/auth/custom.js +++ b/auth/custom.js @@ -8,8 +8,9 @@ function signInCustom() { var token = "token123"; // [START auth_sign_in_custom] firebase.auth().signInWithCustomToken(token) - .then((user) => { + .then((userCredential) => { // Signed in + var user = userCredential.user; // ... }) .catch((error) => { diff --git a/auth/email.js b/auth/email.js index ba919819..cdb4bde3 100644 --- a/auth/email.js +++ b/auth/email.js @@ -9,8 +9,9 @@ function signInWithEmailPassword() { var password = "hunter2"; // [START auth_signin_password] firebase.auth().signInWithEmailAndPassword(email, password) - .then((user) => { - // Signed in + .then((userCredential) => { + // Signed in + var user = userCredential.user; // ... }) .catch((error) => { @@ -25,8 +26,9 @@ function signUpWithEmailPasswoerd() { var password = "hunter2"; // [START auth_signup_password] firebase.auth().createUserWithEmailAndPassword(email, password) - .then((user) => { + .then((userCredential) => { // Signed in + var user = userCredential.user; // ... }) .catch((error) => { diff --git a/snippets/auth-next/custom/auth_sign_in_custom.js b/snippets/auth-next/custom/auth_sign_in_custom.js index c22ed725..018c8b07 100644 --- a/snippets/auth-next/custom/auth_sign_in_custom.js +++ b/snippets/auth-next/custom/auth_sign_in_custom.js @@ -8,8 +8,9 @@ import { getAuth, signInWithCustomToken } from "firebase/auth"; const auth = getAuth(firebaseApp); signInWithCustomToken(auth, token) - .then((user) => { + .then((userCredential) => { // Signed in + const user = userCredential.user; // ... }) .catch((error) => { diff --git a/snippets/auth-next/email/auth_signin_password.js b/snippets/auth-next/email/auth_signin_password.js index d04a492e..43817787 100644 --- a/snippets/auth-next/email/auth_signin_password.js +++ b/snippets/auth-next/email/auth_signin_password.js @@ -8,8 +8,9 @@ import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; const auth = getAuth(firebaseApp); signInWithEmailAndPassword(auth, email, password) - .then((user) => { + .then((userCredential) => { // Signed in + const user = userCredential.user; // ... }) .catch((error) => { diff --git a/snippets/auth-next/email/auth_signup_password.js b/snippets/auth-next/email/auth_signup_password.js index de1e38bb..3a20884c 100644 --- a/snippets/auth-next/email/auth_signup_password.js +++ b/snippets/auth-next/email/auth_signup_password.js @@ -8,8 +8,9 @@ import { getAuth, createUserWithEmailAndPassword } from "firebase/auth"; const auth = getAuth(firebaseApp); createUserWithEmailAndPassword(auth, email, password) - .then((user) => { + .then((userCredential) => { // Signed in + const user = userCredential.user; // ... }) .catch((error) => { From d5f652de67fbaaf5ce1ef3116b725800866931fc Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 21 Jan 2021 13:57:06 +0000 Subject: [PATCH 007/170] Add missing GitHub snippet --- auth-next/github.js | 8 ++++++++ auth/github.js | 6 ++++++ .../github/auth_github_provider_credential.js | 10 ++++++++++ 3 files changed, 24 insertions(+) create mode 100644 snippets/auth-next/github/auth_github_provider_credential.js diff --git a/auth-next/github.js b/auth-next/github.js index d59b0f42..0289a53b 100644 --- a/auth-next/github.js +++ b/auth-next/github.js @@ -27,6 +27,14 @@ function githubProvider() { // [END auth_github_provider_params] } +function githubProviderCredential(token) { + // [START auth_github_provider_credential] + const { GithubAuthProvider } = require("firebase/auth"); + + const credential = GithubAuthProvider.credential(token); + // [END auth_github_provider_credential] +} + function githubSignInPopup(provider) { // [START auth_github_signin_popup] const { getAuth, signInWithPopup, GithubAuthProvider } = require("firebase/auth"); diff --git a/auth/github.js b/auth/github.js index bf2db5bf..6ae1e531 100644 --- a/auth/github.js +++ b/auth/github.js @@ -20,6 +20,12 @@ function githubProvider() { // [END auth_github_provider_params] } +function githubProviderCredential(token) { + // [START auth_github_provider_credential] + var credential = firebase.auth.GithubAuthProvider.credential(token); + // [END auth_github_provider_credential] +} + function githubSignInPopup(provider) { // [START auth_github_signin_popup] firebase diff --git a/snippets/auth-next/github/auth_github_provider_credential.js b/snippets/auth-next/github/auth_github_provider_credential.js new file mode 100644 index 00000000..ee159180 --- /dev/null +++ b/snippets/auth-next/github/auth_github_provider_credential.js @@ -0,0 +1,10 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/github.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_github_provider_credential_modular] +import { GithubAuthProvider } from "firebase/auth"; + +const credential = GithubAuthProvider.credential(token); +// [END auth_github_provider_credential_modular] \ No newline at end of file From 03f16b910dc68e4f3c1dd1dff4f4bbcf5c56239a Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Thu, 21 Jan 2021 14:59:05 +0000 Subject: [PATCH 008/170] Add Perf and Storage snippets (#90) --- perf-next/index.js | 19 ++ perf/index.js | 16 ++ snippets/perf-next/index/perf_initialize.js | 21 ++ storage/create-reference.js | 95 +++++++++ storage/delete-files.js | 18 ++ storage/download-files.js | 80 ++++++++ storage/file-metadata.js | 75 +++++++ storage/index.js | 38 ++++ storage/list-files.js | 53 +++++ storage/upload-files.js | 212 ++++++++++++++++++++ 10 files changed, 627 insertions(+) create mode 100644 snippets/perf-next/index/perf_initialize.js create mode 100644 storage/create-reference.js create mode 100644 storage/delete-files.js create mode 100644 storage/download-files.js create mode 100644 storage/file-metadata.js create mode 100644 storage/list-files.js create mode 100644 storage/upload-files.js diff --git a/perf-next/index.js b/perf-next/index.js index 96545d31..58b70ae7 100644 --- a/perf-next/index.js +++ b/perf-next/index.js @@ -10,6 +10,25 @@ const firebaseApp = initializeApp({ }); const perf = getInstance(firebaseApp); +function intialize() { + // [START perf_initialize] + const { initializeApp } = require("firebase/app"); + const { getPerformance } = require("firebase/performance"); + + // TODO: Replace the following with your app's Firebase project configuration + // See: https://firebase.google.com/docs/web/setup#config-object + const firebaseConfig = { + // ... + }; + + // Initialize Firebase + const app = initializeApp(firebaseConfig); + + // Initialize Performance Monitoring and get a reference to the service + const perf = getPerformance(app); + // [END perf_initialize] +} + export function getInstance(firebaseApp) { // [START perf_get_instance] const { getPerformance } = require("firebase/performance"); diff --git a/perf/index.js b/perf/index.js index 9ef0dd9c..6d512e32 100644 --- a/perf/index.js +++ b/perf/index.js @@ -3,6 +3,22 @@ import "firebase/performance"; const perf = firebase.performance(); +function intialize() { + // [START perf_initialize] + // TODO: Replace the following with your app's Firebase project configuration + // See: https://firebase.google.com/docs/web/setup#config-object + var firebaseConfig = { + // ... + }; + + // Initialize Firebase + firebase.initializeApp(firebaseConfig); + + // Initialize Performance Monitoring and get a reference to the service + var perf = firebase.performance(); + // [END perf_initialize] +} + function addCustomTrace() { // [START perf_add_custom_trace] const trace = perf.trace("CUSTOM_TRACE_NAME"); diff --git a/snippets/perf-next/index/perf_initialize.js b/snippets/perf-next/index/perf_initialize.js new file mode 100644 index 00000000..c4802566 --- /dev/null +++ b/snippets/perf-next/index/perf_initialize.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./perf-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START perf_initialize_modular] +import { initializeApp } from "firebase/app"; +import { getPerformance } from "firebase/performance"; + +// TODO: Replace the following with your app's Firebase project configuration +// See: https://firebase.google.com/docs/web/setup#config-object +const firebaseConfig = { + // ... +}; + +// Initialize Firebase +const app = initializeApp(firebaseConfig); + +// Initialize Performance Monitoring and get a reference to the service +const perf = getPerformance(app); +// [END perf_initialize_modular] \ No newline at end of file diff --git a/storage/create-reference.js b/storage/create-reference.js new file mode 100644 index 00000000..09794832 --- /dev/null +++ b/storage/create-reference.js @@ -0,0 +1,95 @@ +import firebase from "firebase/app"; +import "firebase/storage"; + +function createRef() { + // [START storage_create_ref] + // Get a reference to the storage service, which is used to create references in your storage bucket + var storage = firebase.storage(); + + // Create a storage reference from our storage service + var storageRef = storage.ref(); + // [END storage_create_ref] +} + +function createRefChild() { + const storageRef = firebase.storage().ref(); + + // [START storage_create_ref_child] + // Create a child reference + var imagesRef = storageRef.child('images'); + // imagesRef now points to 'images' + + // Child references can also take paths delimited by '/' + var spaceRef = storageRef.child('images/space.jpg'); + // spaceRef now points to "images/space.jpg" + // imagesRef still points to "images" + // [END storage_create_ref_child] +} + +function navigateRef() { + const spaceRef = firebase.storage().ref().child('images/space.jpg'); + + // [START storage_navigate_ref] + // Parent allows us to move to the parent of a reference + var imagesRef = spaceRef.parent; + // imagesRef now points to 'images' + + // Root allows us to move all the way back to the top of our bucket + var rootRef = spaceRef.root; + // rootRef now points to the root + // [END storage_navigate_ref] +} + +function navigateRefChain() { + const spaceRef = firebase.storage().ref().child('images/space.jpg'); + + // [START storage_navigate_ref_chain] + // References can be chained together multiple times + var earthRef = spaceRef.parent.child('earth.jpg'); + // earthRef points to 'images/earth.jpg' + + // nullRef is null, since the parent of root is null + var nullRef = spaceRef.root.parent; + // [END storage_navigate_ref_chain] +} + +function refProperties() { + const spaceRef = firebase.storage().ref().child('images/space.jpg'); + + // [START storage_ref_properties] + // Reference's path is: 'images/space.jpg' + // This is analogous to a file path on disk + spaceRef.fullPath; + + // Reference's name is the last segment of the full path: 'space.jpg' + // This is analogous to the file name + spaceRef.name; + + // Reference's bucket is the name of the storage bucket where files are stored + spaceRef.bucket; + // [END storage_ref_properties] +} + +function refFullExample() { + // [START storage_ref_full_example] + // Points to the root reference + var storageRef = firebase.storage().ref(); + + // Points to 'images' + var imagesRef = storageRef.child('images'); + + // Points to 'images/space.jpg' + // Note that you can use variables to create child values + var fileName = 'space.jpg'; + var spaceRef = imagesRef.child(fileName); + + // File path is 'images/space.jpg' + var path = spaceRef.fullPath; + + // File name is 'space.jpg' + var name = spaceRef.name; + + // Points to 'images' + var imagesRef = spaceRef.parent; + // [END storage_ref_full_example] +} diff --git a/storage/delete-files.js b/storage/delete-files.js new file mode 100644 index 00000000..73b84904 --- /dev/null +++ b/storage/delete-files.js @@ -0,0 +1,18 @@ +import firebase from "firebase/app"; +import "firebase/storage"; + +function deleteFile() { + const storageRef = firebase.storage().ref(); + + // [START storage_delete_file] + // Create a reference to the file to delete + var desertRef = storageRef.child('images/desert.jpg'); + + // Delete the file + desertRef.delete().then(() => { + // File deleted successfully + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_delete_file] +} diff --git a/storage/download-files.js b/storage/download-files.js new file mode 100644 index 00000000..cb2af375 --- /dev/null +++ b/storage/download-files.js @@ -0,0 +1,80 @@ +import firebase from "firebase/app"; +import "firebase/storage"; + +function downloadCreateRef() { + // [START storage_download_create_ref] + // Create a reference with an initial file path and name + var storage = firebase.storage(); + var pathReference = storage.ref('images/stars.jpg'); + + // Create a reference from a Google Cloud Storage URI + var gsReference = storage.refFromURL('gs://bucket/images/stars.jpg'); + + // Create a reference from an HTTPS URL + // Note that in the URL, characters are URL escaped! + var httpsReference = storage.refFromURL('https://firebasestorage.googleapis.com/b/bucket/o/images%20stars.jpg'); + // [END storage_download_create_ref] +} + +function downloadViaUrl() { + const storageRef = firebase.storage().ref(); + + // [START storage_download_via_url] + storageRef.child('images/stars.jpg').getDownloadURL() + .then((url) => { + // `url` is the download URL for 'images/stars.jpg' + + // This can be downloaded directly: + var xhr = new XMLHttpRequest(); + xhr.responseType = 'blob'; + xhr.onload = (event) => { + var blob = xhr.response; + }; + xhr.open('GET', url); + xhr.send(); + + // Or inserted into an element + var img = document.getElementById('myimg'); + img.setAttribute('src', url); + }) + .catch((error) => { + // Handle any errors + }); + // [END storage_download_via_url] +} + +function downloadFullExample() { + const storageRef = firebase.storage().ref(); + + // [START storage_download_full_example] + // Create a reference to the file we want to download + var starsRef = storageRef.child('images/stars.jpg'); + + // Get the download URL + starsRef.getDownloadURL() + .then((url) => { + // Insert url into an tag to "download" + }) + .catch((error) => { + // A full list of error codes is available at + // https://firebase.google.com/docs/storage/web/handle-errors + switch (error.code) { + case 'storage/object-not-found': + // File doesn't exist + break; + case 'storage/unauthorized': + // User doesn't have permission to access the object + break; + case 'storage/canceled': + // User canceled the upload + break; + + // ... + + case 'storage/unknown': + // Unknown error occurred, inspect the server response + break; + } + }); + // [END storage_download_full_example] +} diff --git a/storage/file-metadata.js b/storage/file-metadata.js new file mode 100644 index 00000000..cef42364 --- /dev/null +++ b/storage/file-metadata.js @@ -0,0 +1,75 @@ +import firebase from "firebase/app"; +import "firebase/storage"; + +function getMetadata() { + const storageRef = firebase.storage().ref(); + + // [START storage_get_metadata] + // Create a reference to the file whose metadata we want to retrieve + var forestRef = storageRef.child('images/forest.jpg'); + + // Get metadata properties + forestRef.getMetadata() + .then((metadata) => { + // Metadata now contains the metadata for 'images/forest.jpg' + }) + .catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_get_metadata] +} + +function updateMetadata() { + const storageRef = firebase.storage().ref(); + + // [START storage_update_metadata] + // Create a reference to the file whose metadata we want to change + var forestRef = storageRef.child('images/forest.jpg'); + + // Create file metadata to update + var newMetadata = { + cacheControl: 'public,max-age=300', + contentType: 'image/jpeg' + }; + + // Update metadata properties + forestRef.updateMetadata(newMetadata) + .then((metadata) => { + // Updated metadata for 'images/forest.jpg' is returned in the Promise + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_update_metadata] +} + +function deleteMetadata() { + const storageRef = firebase.storage().ref(); + const forestRef = storageRef.child('images/forest.jpg'); + + // [START storage_delete_metadata] + + // Create file metadata with property to delete + var deleteMetadata = { + contentType: null + }; + + // Delete the metadata property + forestRef.updateMetadata(deleteMetadata) + .then((metadata) => { + // metadata.contentType should be null + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_delete_metadata] +} + +function customMetadata() { + // [START storage_custom_metadata] + var metadata = { + customMetadata: { + 'location': 'Yosemite, CA, USA', + 'activity': 'Hiking' + } + }; + // [END storage_custom_metadata] +} diff --git a/storage/index.js b/storage/index.js index 02598d88..7a7db0df 100644 --- a/storage/index.js +++ b/storage/index.js @@ -1,6 +1,44 @@ import firebase from "firebase/app"; import "firebase/storage"; +function initialize() { + // [START storage_initialize] + // Set the configuration for your app + // TODO: Replace with your app's config object + var firebaseConfig = { + apiKey: '', + authDomain: '', + databaseURL: '', + storageBucket: '' + }; + firebase.initializeApp(firebaseConfig); + + // Get a reference to the storage service, which is used to create references in your storage bucket + var storage = firebase.storage(); + // [END storage_initialize] +} + +function multipleBuckets() { + // [START storage_multiple_buckets] + // Get a non-default Storage bucket + var storage = firebase.app().storage("gs://my-custom-bucket"); + // [END storage_multiple_buckets] +} + +function storageCustomApp() { + const customApp = firebase.initializeApp({ + // ... custom stuff + }); + + // [START storage_custom_app] + // Get the default bucket from a custom firebase.app.App + var storage = customApp.storage(); + + // Get a non-default bucket from a custom firebase.app.App + var storage = customApp.storage("gs://my-custom-bucket"); + // [END storage_custom_app] +} + /** * @param {File} file */ diff --git a/storage/list-files.js b/storage/list-files.js new file mode 100644 index 00000000..ef248da7 --- /dev/null +++ b/storage/list-files.js @@ -0,0 +1,53 @@ +import firebase from "firebase/app"; +import "firebase/storage"; + +function listAll() { + const storageRef = firebase.storage().ref(); + + // [START storage_list_all] + // Create a reference under which you want to list + var listRef = storageRef.child('files/uid'); + + // Find all the prefixes and items. + listRef.listAll() + .then((res) => { + res.prefixes.forEach((folderRef) => { + // All the prefixes under listRef. + // You may call listAll() recursively on them. + }); + res.items.forEach((itemRef) => { + // All the items under listRef. + }); + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_list_all] +} + +function listPaginate() { + const storageRef = firebase.storage().ref(); + + // [START storage_list_paginate] + async function pageTokenExample(){ + // Create a reference under which you want to list + var listRef = storageRef.child('files/uid'); + + // Fetch the first page of 100. + var firstPage = await listRef.list({ maxResults: 100}); + + // Use the result. + // processItems(firstPage.items) + // processPrefixes(firstPage.prefixes) + + // Fetch the second page if there are more elements. + if (firstPage.nextPageToken) { + var secondPage = await listRef.list({ + maxResults: 100, + pageToken: firstPage.nextPageToken, + }); + // processItems(secondPage.items) + // processPrefixes(secondPage.prefixes) + } + } + // [END storage_list_paginate] +} diff --git a/storage/upload-files.js b/storage/upload-files.js new file mode 100644 index 00000000..988fc3eb --- /dev/null +++ b/storage/upload-files.js @@ -0,0 +1,212 @@ +import firebase from "firebase/app"; +import "firebase/storage"; + +function uploadRef() { + // [START storage_upload_ref] + // Create a root reference + var storageRef = firebase.storage().ref(); + + // Create a reference to 'mountains.jpg' + var mountainsRef = storageRef.child('mountains.jpg'); + + // Create a reference to 'images/mountains.jpg' + var mountainImagesRef = storageRef.child('images/mountains.jpg'); + + // While the file names are the same, the references point to different files + mountainsRef.name === mountainImagesRef.name; // true + mountainsRef.fullPath === mountainImagesRef.fullPath; // false + // [END storage_upload_ref] +} + +/** + * @param {File} file + */ +function uploadBlob(file) { + const ref = firebase.storage().ref().child('some-child'); + + // [START storage_upload_blob] + // 'file' comes from the Blob or File API + ref.put(file).then((snapshot) => { + console.log('Uploaded a blob or file!'); + }); + // [END storage_upload_blob] +} + +function uploadBytes() { + const ref = firebase.storage().ref().child('some-child'); + + // [START storage_upload_bytes] + var bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21]); + ref.put(bytes).then((snapshot) => { + console.log('Uploaded an array!'); + }); + // [END storage_upload_bytes] +} + +function uploadString() { + const ref = firebase.storage().ref().child('some-child'); + + // [START storage_upload_string] + // Raw string is the default if no format is provided + var message = 'This is my message.'; + ref.putString(message).then((snapshot) => { + console.log('Uploaded a raw string!'); + }); + + // Base64 formatted string + var message = '5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; + ref.putString(message, 'base64').then((snapshot) => { + console.log('Uploaded a base64 string!'); + }); + + // Base64url formatted string + var message = '5b6p5Y-344GX44G-44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; + ref.putString(message, 'base64url').then((snapshot) => { + console.log('Uploaded a base64url string!'); + }); + + // Data URL string + var message = 'data:text/plain;base64,5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; + ref.putString(message, 'data_url').then((snapshot) => { + console.log('Uploaded a data_url string!'); + }); + // [END storage_upload_string] +} + +/** + * @param {File} file + */ +function uploadMetadata(file) { + const storageRef = firebase.storage().ref(); + + // [START storage_upload_metadata] + // Create file metadata including the content type + var metadata = { + contentType: 'image/jpeg', + }; + + // Upload the file and metadata + var uploadTask = storageRef.child('images/mountains.jpg').put(file, metadata); + // [END storage_upload_metadata] +} + +/** + * @param {File} file + */ +function manageUploads(file) { + const storageRef = firebase.storage().ref(); + + // [START storage_manage_uploads] + // Upload the file and metadata + var uploadTask = storageRef.child('images/mountains.jpg').put(file); + + // Pause the upload + uploadTask.pause(); + + // Resume the upload + uploadTask.resume(); + + // Cancel the upload + uploadTask.cancel(); + // [END storage_manage_uploads] +} + +/** + * @param {File} file + */ +function monitorUpload(file) { + const storageRef = firebase.storage().ref(); + + // [START storage_monitor_upload] + var uploadTask = storageRef.child('images/rivers.jpg').put(file); + + // Register three observers: + // 1. 'state_changed' observer, called any time the state changes + // 2. Error observer, called on failure + // 3. Completion observer, called on successful completion + uploadTask.on('state_changed', + (snapshot) => { + // Observe state change events such as progress, pause, and resume + // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded + var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; + console.log('Upload is ' + progress + '% done'); + switch (snapshot.state) { + case firebase.storage.TaskState.PAUSED: // or 'paused' + console.log('Upload is paused'); + break; + case firebase.storage.TaskState.RUNNING: // or 'running' + console.log('Upload is running'); + break; + } + }, + (error) => { + // Handle unsuccessful uploads + }, + () => { + // Handle successful uploads on complete + // For instance, get the download URL: https://firebasestorage.googleapis.com/... + uploadTask.snapshot.ref.getDownloadURL().then((downloadURL) => { + console.log('File available at', downloadURL); + }); + } + ); + // [END storage_monitor_upload] +} + +/** + * @param {File} file + */ +function uploadHandleError(file) { + const storageRef = firebase.storage().ref(); + + // [START storage_upload_handle_error] + // Create the file metadata + var metadata = { + contentType: 'image/jpeg' + }; + + // Upload file and metadata to the object 'images/mountains.jpg' + var uploadTask = storageRef.child('images/' + file.name).put(file, metadata); + + // Listen for state changes, errors, and completion of the upload. + uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed' + (snapshot) => { + // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded + var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; + console.log('Upload is ' + progress + '% done'); + switch (snapshot.state) { + case firebase.storage.TaskState.PAUSED: // or 'paused' + console.log('Upload is paused'); + break; + case firebase.storage.TaskState.RUNNING: // or 'running' + console.log('Upload is running'); + break; + } + }, + (error) => { + // A full list of error codes is available at + // https://firebase.google.com/docs/storage/web/handle-errors + switch (error.code) { + case 'storage/unauthorized': + // User doesn't have permission to access the object + break; + case 'storage/canceled': + // User canceled the upload + break; + + // ... + + case 'storage/unknown': + // Unknown error occurred, inspect error.serverResponse + break; + } + }, + () => { + // Upload completed successfully, now we can get the download URL + uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) { + console.log('File available at', downloadURL); + }); + } + ); + // [END storage_upload_handle_error] +} From 03c143d872a10b9d9ed4d55cf0f9f98316d4748e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 22 Jan 2021 02:53:18 -0800 Subject: [PATCH 009/170] Auto-update dependencies. (#91) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 41bd45d7..e292956e 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/auth/package.json b/auth/package.json index c814359e..a6ea9b7c 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.3", + "firebase": "^8.2.4", "firebaseui": "^4.7.1" } } diff --git a/database/package.json b/database/package.json index 1063856e..ea1468d3 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index ab98eba2..b057f3d6 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/firestore/package.json b/firestore/package.json index eada0581..32b040f6 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3", + "firebase": "^8.2.4", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 6cf0d5cf..c66ef81b 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/installations/package.json b/installations/package.json index 13361e6d..f5bb3d37 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/messaging/package.json b/messaging/package.json index 6ca0ae56..cc6f7c81 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/perf/package.json b/perf/package.json index 6689d178..f9176094 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 94072b11..1bfa9cc5 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } diff --git a/storage/package.json b/storage/package.json index 655f1d3c..7aad7b77 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.3" + "firebase": "^8.2.4" } } From e3396e052642bf9172171346f1292a1685446457 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 22 Jan 2021 11:11:18 +0000 Subject: [PATCH 010/170] Add messaging-next --- lerna.json | 1 + messaging-next/index.js | 85 +++++++++++++++++++ messaging-next/package.json | 11 +++ messaging-next/service-worker.js | 45 ++++++++++ .../index/messaging_delete_token.js | 16 ++++ .../index/messaging_get_messaging_object.js | 10 +++ .../index/messaging_get_token.js | 25 ++++++ .../index/messaging_receive_message.js | 18 ++++ .../index/messaging_request_permission.js | 16 ++++ .../service-worker/messaging_init_in_sw.js | 27 ++++++ .../messaging_on_background_message.js | 8 ++ 11 files changed, 262 insertions(+) create mode 100644 messaging-next/index.js create mode 100644 messaging-next/package.json create mode 100644 messaging-next/service-worker.js create mode 100644 snippets/messaging-next/index/messaging_delete_token.js create mode 100644 snippets/messaging-next/index/messaging_get_messaging_object.js create mode 100644 snippets/messaging-next/index/messaging_get_token.js create mode 100644 snippets/messaging-next/index/messaging_receive_message.js create mode 100644 snippets/messaging-next/index/messaging_request_permission.js create mode 100644 snippets/messaging-next/service-worker/messaging_init_in_sw.js create mode 100644 snippets/messaging-next/service-worker/messaging_on_background_message.js diff --git a/lerna.json b/lerna.json index ca43200d..4e51b74a 100644 --- a/lerna.json +++ b/lerna.json @@ -12,6 +12,7 @@ "functions-next", "installations", "messaging", + "messaging-next", "perf", "perf-next", "remoteconfig", diff --git a/messaging-next/index.js b/messaging-next/index.js new file mode 100644 index 00000000..dd800938 --- /dev/null +++ b/messaging-next/index.js @@ -0,0 +1,85 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function getMessagingObject() { + // [START messaging_get_messaging_object] + const { getMessaging } = require("firebase/messaging"); + + const messaging = getMessaging(firebaseApp); + // [END messaging_get_messaging_object] +} + +function receiveMessage() { + // [START messaging_receive_message] + // Handle incoming messages. Called when: + // - a message is received while the app has focus + // - the user clicks on an app notification created by a service worker + // `messaging.onBackgroundMessage` handler. + const { getMessaging, onMessage } = require("firebase/messaging"); + + const messaging = getMessaging(firebaseApp); + onMessage(messaging, (payload) => { + console.log('Message received. ', payload); + // ... + }); + // [END messaging_receive_message] +} + +function getToken() { + // [START messaging_get_token] + const { getMessaging, getToken } = require("firebase/messaging"); + + // Get registration token. Initially this makes a network call, once retrieved + // subsequent calls to getToken will return from cache. + const messaging = getMessaging(firebaseApp); + getToken(messaging, { vapidKey: '' }).then((currentToken) => { + if (currentToken) { + // Send the token to your server and update the UI if necessary + // ... + } else { + // Show permission request UI + console.log('No registration token available. Request permission to generate one.'); + // ... + } + }).catch((err) => { + console.log('An error occurred while retrieving token. ', err); + // ... + }); + // [END messaging_get_token] +} + +function requestPermission() { + // [START messaging_request_permission] + Notification.requestPermission().then((permission) => { + if (permission === 'granted') { + console.log('Notification permission granted.'); + // TODO(developer): Retrieve a registration token for use with FCM. + // ... + } else { + console.log('Unable to get permission to notify.'); + } + }); + // [END messaging_request_permission] +} + +function deleteToken() { + // [START messaging_delete_token] + const { getMessaging, deleteToken } = require("firebase/messaging"); + + const messaging = getMessaging(firebaseApp); + deleteToken(messaging).then(() => { + console.log('Token deleted.'); + // ... + }).catch((err) => { + console.log('Unable to delete token. ', err); + }); + // [END messaging_delete_token] +} diff --git a/messaging-next/package.json b/messaging-next/package.json new file mode 100644 index 00000000..c787b7ed --- /dev/null +++ b/messaging-next/package.json @@ -0,0 +1,11 @@ +{ + "name": "messaging-next", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "exp" + } +} diff --git a/messaging-next/service-worker.js b/messaging-next/service-worker.js new file mode 100644 index 00000000..633fb9e5 --- /dev/null +++ b/messaging-next/service-worker.js @@ -0,0 +1,45 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +// See: https://github.com/microsoft/TypeScript/issues/14877 +/** @type {ServiceWorkerGlobalScope} */ +let self; + +function initInSw() { + // [START messaging_init_in_sw] + const { initializeApp } = require("firebase/app"); + const { getMessaging } = require("firebase/messaging"); + + // Initialize the Firebase app in the service worker by passing in + // your app's Firebase config object. + // https://firebase.google.com/docs/web/setup#config-object + const firebaseApp = initializeApp({ + apiKey: 'api-key', + authDomain: 'project-id.firebaseapp.com', + databaseURL: 'https://project-id.firebaseio.com', + projectId: 'project-id', + storageBucket: 'project-id.appspot.com', + messagingSenderId: 'sender-id', + appId: 'app-id', + measurementId: 'G-measurement-id', + }) + + // Retrieve an instance of Firebase Messaging so that it can handle background + // messages. + const messaging = getMessaging(firebaseApp); + // [END messaging_init_in_sw] +} + +function onBackgroundMessage() { + // [START messaging_on_background_message] + // TODO(snippet): This snippet is not yet translated to the @exp SDK + // [END messaging_on_background_message] +} diff --git a/snippets/messaging-next/index/messaging_delete_token.js b/snippets/messaging-next/index/messaging_delete_token.js new file mode 100644 index 00000000..c6e1bf9e --- /dev/null +++ b/snippets/messaging-next/index/messaging_delete_token.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./messaging-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START messaging_delete_token_modular] +import { getMessaging, deleteToken } from "firebase/messaging"; + +const messaging = getMessaging(firebaseApp); +deleteToken(messaging).then(() => { + console.log('Token deleted.'); + // ... +}).catch((err) => { + console.log('Unable to delete token. ', err); +}); +// [END messaging_delete_token_modular] \ No newline at end of file diff --git a/snippets/messaging-next/index/messaging_get_messaging_object.js b/snippets/messaging-next/index/messaging_get_messaging_object.js new file mode 100644 index 00000000..5e75a7a5 --- /dev/null +++ b/snippets/messaging-next/index/messaging_get_messaging_object.js @@ -0,0 +1,10 @@ +// This snippet file was generated by processing the source file: +// ./messaging-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START messaging_get_messaging_object_modular] +import { getMessaging } from "firebase/messaging"; + +const messaging = getMessaging(firebaseApp); +// [END messaging_get_messaging_object_modular] \ No newline at end of file diff --git a/snippets/messaging-next/index/messaging_get_token.js b/snippets/messaging-next/index/messaging_get_token.js new file mode 100644 index 00000000..01773b6d --- /dev/null +++ b/snippets/messaging-next/index/messaging_get_token.js @@ -0,0 +1,25 @@ +// This snippet file was generated by processing the source file: +// ./messaging-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START messaging_get_token_modular] +import { getMessaging, getToken } from "firebase/messaging"; + +// Get registration token. Initially this makes a network call, once retrieved +// subsequent calls to getToken will return from cache. +const messaging = getMessaging(firebaseApp); +getToken(messaging, { vapidKey: '' }).then((currentToken) => { + if (currentToken) { + // Send the token to your server and update the UI if necessary + // ... + } else { + // Show permission request UI + console.log('No registration token available. Request permission to generate one.'); + // ... + } +}).catch((err) => { + console.log('An error occurred while retrieving token. ', err); + // ... +}); +// [END messaging_get_token_modular] \ No newline at end of file diff --git a/snippets/messaging-next/index/messaging_receive_message.js b/snippets/messaging-next/index/messaging_receive_message.js new file mode 100644 index 00000000..c95d1be4 --- /dev/null +++ b/snippets/messaging-next/index/messaging_receive_message.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./messaging-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START messaging_receive_message_modular] +// Handle incoming messages. Called when: +// - a message is received while the app has focus +// - the user clicks on an app notification created by a service worker +// `messaging.onBackgroundMessage` handler. +import { getMessaging, onMessage } from "firebase/messaging"; + +const messaging = getMessaging(firebaseApp); +onMessage(messaging, (payload) => { + console.log('Message received. ', payload); + // ... +}); +// [END messaging_receive_message_modular] \ No newline at end of file diff --git a/snippets/messaging-next/index/messaging_request_permission.js b/snippets/messaging-next/index/messaging_request_permission.js new file mode 100644 index 00000000..77e2d311 --- /dev/null +++ b/snippets/messaging-next/index/messaging_request_permission.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./messaging-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START messaging_request_permission_modular] +Notification.requestPermission().then((permission) => { + if (permission === 'granted') { + console.log('Notification permission granted.'); + // TODO(developer): Retrieve a registration token for use with FCM. + // ... + } else { + console.log('Unable to get permission to notify.'); + } +}); +// [END messaging_request_permission_modular] \ No newline at end of file diff --git a/snippets/messaging-next/service-worker/messaging_init_in_sw.js b/snippets/messaging-next/service-worker/messaging_init_in_sw.js new file mode 100644 index 00000000..c096acfa --- /dev/null +++ b/snippets/messaging-next/service-worker/messaging_init_in_sw.js @@ -0,0 +1,27 @@ +// This snippet file was generated by processing the source file: +// ./messaging-next/service-worker.js +// +// To make edits to the snippets in this file, please edit the source + +// [START messaging_init_in_sw_modular] +import { initializeApp } from "firebase/app"; +import { getMessaging } from "firebase/messaging"; + +// Initialize the Firebase app in the service worker by passing in +// your app's Firebase config object. +// https://firebase.google.com/docs/web/setup#config-object +const firebaseApp = initializeApp({ + apiKey: 'api-key', + authDomain: 'project-id.firebaseapp.com', + databaseURL: 'https://project-id.firebaseio.com', + projectId: 'project-id', + storageBucket: 'project-id.appspot.com', + messagingSenderId: 'sender-id', + appId: 'app-id', + measurementId: 'G-measurement-id', +}) + +// Retrieve an instance of Firebase Messaging so that it can handle background +// messages. +const messaging = getMessaging(firebaseApp); +// [END messaging_init_in_sw_modular] \ No newline at end of file diff --git a/snippets/messaging-next/service-worker/messaging_on_background_message.js b/snippets/messaging-next/service-worker/messaging_on_background_message.js new file mode 100644 index 00000000..2c55eab1 --- /dev/null +++ b/snippets/messaging-next/service-worker/messaging_on_background_message.js @@ -0,0 +1,8 @@ +// This snippet file was generated by processing the source file: +// ./messaging-next/service-worker.js +// +// To make edits to the snippets in this file, please edit the source + +// [START messaging_on_background_message_modular] +// TODO(snippet): This snippet is not yet translated to the @exp SDK +// [END messaging_on_background_message_modular] \ No newline at end of file From 3465c37d0a21ff0e1e050228eb350be55e8cda84 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 22 Jan 2021 11:24:49 +0000 Subject: [PATCH 011/170] Lint --- messaging-next/service-worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messaging-next/service-worker.js b/messaging-next/service-worker.js index 633fb9e5..25ee21db 100644 --- a/messaging-next/service-worker.js +++ b/messaging-next/service-worker.js @@ -30,7 +30,7 @@ function initInSw() { messagingSenderId: 'sender-id', appId: 'app-id', measurementId: 'G-measurement-id', - }) + }); // Retrieve an instance of Firebase Messaging so that it can handle background // messages. From 79fd51982f6575c98c05aa83085ee7f15ef1ac5b Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 22 Jan 2021 11:26:25 +0000 Subject: [PATCH 012/170] Add analytics-next --- analytics-next/ecommerce.js | 293 ++++++++++++++++++ analytics-next/index.js | 58 ++++ analytics-next/package.json | 11 + lerna.json | 1 + .../ecommerce/analytics_ecommerce_add_cart.js | 28 ++ .../ecommerce/analytics_ecommerce_checkout.js | 20 ++ .../ecommerce/analytics_ecommerce_items.js | 36 +++ .../analytics_ecommerce_payment_info.js | 21 ++ .../analytics_ecommerce_promotions.js | 25 ++ .../ecommerce/analytics_ecommerce_purchase.js | 24 ++ .../ecommerce/analytics_ecommerce_refund.js | 29 ++ .../analytics_ecommerce_remove_cart.js | 19 ++ .../analytics_ecommerce_select_item.js | 19 ++ .../analytics_ecommerce_shipping_info.js | 21 ++ .../analytics_ecommerce_view_cart.js | 30 ++ .../analytics_ecommerce_view_item_details.js | 19 ++ .../analytics_ecommerce_view_item_list.js | 19 ++ .../index/analytics_initialize.js | 10 + .../index/analytics_log_event.js | 11 + .../analytics_log_event_custom_params.js | 11 + .../index/analytics_log_event_params.js | 15 + .../index/analytics_set_user_properties.js | 11 + .../service-worker/messaging_init_in_sw.js | 2 +- 23 files changed, 732 insertions(+), 1 deletion(-) create mode 100644 analytics-next/ecommerce.js create mode 100644 analytics-next/index.js create mode 100644 analytics-next/package.json create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_items.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js create mode 100644 snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js create mode 100644 snippets/analytics-next/index/analytics_initialize.js create mode 100644 snippets/analytics-next/index/analytics_log_event.js create mode 100644 snippets/analytics-next/index/analytics_log_event_custom_params.js create mode 100644 snippets/analytics-next/index/analytics_log_event_params.js create mode 100644 snippets/analytics-next/index/analytics_set_user_properties.js diff --git a/analytics-next/ecommerce.js b/analytics-next/ecommerce.js new file mode 100644 index 00000000..b14f0eb2 --- /dev/null +++ b/analytics-next/ecommerce.js @@ -0,0 +1,293 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + + +// [START analytics_ecommerce_items] +// A pair of jeggings +const item_jeggings = { + item_id: 'SKU_123', + item_name: 'jeggings', + item_category: 'pants', + item_variant: 'black', + item_brand: 'Google', + price: 9.99 +}; + +// A pair of boots +const item_boots = { + item_id: 'SKU_456', + item_name: 'boots', + item_category: 'shoes', + item_variant: 'brown', + item_brand: 'Google', + price: 24.99 +}; + +// A pair of socks +const item_socks = { + item_id: 'SKU_789', + item_name: 'ankle_socks', + item_category: 'socks', + item_variant: 'red', + item_brand: 'Google', + price: 5.99 +}; +// [END analytics_ecommerce_items] + +function ecommerceViewItemList() { + // [START analytics_ecommerce_view_item_list] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce params + const params1 = { + item_list_id: 'L001', + item_list_name: 'Related products', + items: [item_jeggings, item_boots, item_socks] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'view_item_list', params1); + // [END analytics_ecommerce_view_item_list] +} + +function ecommerceSelectItem() { + // [START analytics_ecommerce_select_item] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce event params + const params2 = { + item_list_id: 'L001', + item_list_name: 'Related products', + items: [item_jeggings] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'select_item', params2); + // [END analytics_ecommerce_select_item] +} + +function ecommerceViewItemDetails() { + // [START analytics_ecommerce_view_item_details] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce event params + const params3 = { + currency: 'USD', + value: 9.99, + items: [item_jeggings] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'view_item', params3); + // [END analytics_ecommerce_view_item_details] +} + +function ecommerceAddCart() { + // [START analytics_ecommerce_add_cart] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Specify order quantity + const item_jeggings_quantity = { + ...item_jeggings, + quantity: 2 + }; + + // Prepare ecommerce bundle + const params4 = { + currency: 'USD', + value: 19.98, + items: [item_jeggings_quantity] + }; + + // Log event when a product is added to a wishlist + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'add_to_wishlist', params4); + + // Log event when a product is added to the cart + logEvent(analytics, 'add_to_cart', params4); + // [END analytics_ecommerce_add_cart] +} + +function ecommerceViewCart() { + // [START analytics_ecommerce_view_cart] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Specify order quantity + const item_jeggings_quantity = { + ...item_jeggings, + quantity: 2 + }; + + const item_boots_quantity = { + ...item_boots, + quantity: 1 + }; + + // Prepare ecommerce params + const params5 = { + currency: 'USD', + value: 44.97, + items: [item_jeggings_quantity, item_boots_quantity] + }; + + // Log event when the cart is viewed + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'view_cart', params5); + // [END analytics_ecommerce_view_cart] +} + +function ecommerceRemoveCart() { + // [START analytics_ecommerce_remove_cart] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce params + const params6 = { + currency: 'USD', + value: 24.99, + items: [item_jeggings] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'remove_from_cart', params6); + // [END analytics_ecommerce_remove_cart] +} + +function ecommerceCheckout() { + // [START analytics_ecommerce_checkout] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce params + const params7 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + items: [item_jeggings] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'begin_checkout', params7); + // [END analytics_ecommerce_checkout] +} + +function ecommerceShippingInfo() { + // [START analytics_ecommerce_shipping_info] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce params + const params8 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + shipping_tier: 'Ground', + items: [item_jeggings] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'add_shipping_info', params8); + // [END analytics_ecommerce_shipping_info] +} + +function ecommercePaymentInfo() { + // [START analytics_ecommerce_payment_info] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce params + const params9 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + payment_type: 'Visa', + items: [item_jeggings] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'add_payment_info', params9); + // [END analytics_ecommerce_payment_info] +} + +function ecommercePurchase() { + // [START analytics_ecommerce_purchase] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce bundle + const params10 = { + transaction_id: 'T12345', + affiliation: 'Google Store', + currency: 'USD', + value: 14.98, // Total Revenue + tax: 2.85, + shipping: 5.34, + coupon: 'SUMMER_FUN', + items: [item_jeggings] + }; + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'purchase', params10); + // [END analytics_ecommerce_purchase] +} + +function ecommerceRefund() { + // [START analytics_ecommerce_refund] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce params + const params11 = { + transaction_id: 'T12345', // Required + affiliation: 'Google Store', + currency: 'USD', + value: 9.99, + items: [] + }; + + // (Optional) For partial refunds, define the item_id and quantity of refunded items + const refundedProduct = { + item_id: 'SKU_123', // Required + quantity: 1 // Required + }; + + params11.items.push(refundedProduct); + + // Log event + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'refund', params11); + // [END analytics_ecommerce_refund] +} + +function ecommercePromotions() { + // [START analytics_ecommerce_promotions] + const { getAnalytics, logEvent } = require("@firebase/analytics"); + + // Prepare ecommerce params + const params12 = { + promotion_id: 'ABC123', + promotion_name: 'Summer Sale', + creative_name: 'summer2020_promo.jpg', + creative_slot: 'featured_app_1', + location_id: 'HERO_BANNER', + items: [item_jeggings] + }; + + // Log event when a promotion is displayed + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'view_promotion', params12); + + // Log event when a promotion is selected + logEvent(analytics, 'select_promotion', params12); + // [END analytics_ecommerce_promotions] +} diff --git a/analytics-next/index.js b/analytics-next/index.js new file mode 100644 index 00000000..047f1289 --- /dev/null +++ b/analytics-next/index.js @@ -0,0 +1,58 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function initialize() { + // [START analytics_initialize] + const { getAnalytics } = require("firebase/analytics"); + + const analytics = getAnalytics(firebaseApp); + // [END analytics_initialize] +} + +function logEvent() { + // [START analytics_log_event] + const { getAnalytics, logEvent } = require("firebase/analytics"); + + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'notification_received'); + // [END analytics_log_event] +} + +function logEventParams() { + // [START analytics_log_event_params] + const { getAnalytics, logEvent } = require("firebase/analytics"); + + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'select_content', { + content_type: 'image', + content_id: 'P12453', + items: [{ name: 'Kittens' }] + }); + // [END analytics_log_event_params] +} + +function logEventCustomParams() { + // [START analytics_log_event_custom_params] + const { getAnalytics, logEvent } = require("firebase/analytics"); + + const analytics = getAnalytics(firebaseApp); + logEvent(analytics, 'goal_completion', { name: 'lever_puzzle'}); + // [END analytics_log_event_custom_params] +} + +function setUserProperties() { + // [START analytics_set_user_properties] + const { getAnalytics, setUserProperties } = require("firebase/analytics"); + + const analytics = getAnalytics(firebaseApp); + setUserProperties(analytics, { favorite_food: 'apples' }); + // [END analytics_set_user_properties] +} diff --git a/analytics-next/package.json b/analytics-next/package.json new file mode 100644 index 00000000..7b054b75 --- /dev/null +++ b/analytics-next/package.json @@ -0,0 +1,11 @@ +{ + "name": "analytics-next", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "exp" + } +} diff --git a/lerna.json b/lerna.json index 4e51b74a..509b1db7 100644 --- a/lerna.json +++ b/lerna.json @@ -2,6 +2,7 @@ "lerna": "2.8.0", "packages": [ "analytics", + "analytics-next", "auth", "auth-next", "database", diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js new file mode 100644 index 00000000..c93b833e --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js @@ -0,0 +1,28 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_add_cart_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Specify order quantity +const item_jeggings_quantity = { + ...item_jeggings, + quantity: 2 +}; + +// Prepare ecommerce bundle +const params4 = { + currency: 'USD', + value: 19.98, + items: [item_jeggings_quantity] +}; + +// Log event when a product is added to a wishlist +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'add_to_wishlist', params4); + +// Log event when a product is added to the cart +logEvent(analytics, 'add_to_cart', params4); +// [END analytics_ecommerce_add_cart_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js new file mode 100644 index 00000000..7fc10a6c --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_checkout_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce params +const params7 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + items: [item_jeggings] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'begin_checkout', params7); +// [END analytics_ecommerce_checkout_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_items.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_items.js new file mode 100644 index 00000000..e3ad7cbe --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_items.js @@ -0,0 +1,36 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_items_modular] +// A pair of jeggings +const item_jeggings = { + item_id: 'SKU_123', + item_name: 'jeggings', + item_category: 'pants', + item_variant: 'black', + item_brand: 'Google', + price: 9.99 +}; + +// A pair of boots +const item_boots = { + item_id: 'SKU_456', + item_name: 'boots', + item_category: 'shoes', + item_variant: 'brown', + item_brand: 'Google', + price: 24.99 +}; + +// A pair of socks +const item_socks = { + item_id: 'SKU_789', + item_name: 'ankle_socks', + item_category: 'socks', + item_variant: 'red', + item_brand: 'Google', + price: 5.99 +}; +// [END analytics_ecommerce_items_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js new file mode 100644 index 00000000..d4ade3f1 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_payment_info_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce params +const params9 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + payment_type: 'Visa', + items: [item_jeggings] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'add_payment_info', params9); +// [END analytics_ecommerce_payment_info_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js new file mode 100644 index 00000000..1e0e0e37 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js @@ -0,0 +1,25 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_promotions_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce params +const params12 = { + promotion_id: 'ABC123', + promotion_name: 'Summer Sale', + creative_name: 'summer2020_promo.jpg', + creative_slot: 'featured_app_1', + location_id: 'HERO_BANNER', + items: [item_jeggings] +}; + +// Log event when a promotion is displayed +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'view_promotion', params12); + +// Log event when a promotion is selected +logEvent(analytics, 'select_promotion', params12); +// [END analytics_ecommerce_promotions_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js new file mode 100644 index 00000000..28817cd3 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js @@ -0,0 +1,24 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_purchase_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce bundle +const params10 = { + transaction_id: 'T12345', + affiliation: 'Google Store', + currency: 'USD', + value: 14.98, // Total Revenue + tax: 2.85, + shipping: 5.34, + coupon: 'SUMMER_FUN', + items: [item_jeggings] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'purchase', params10); +// [END analytics_ecommerce_purchase_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js new file mode 100644 index 00000000..48984886 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js @@ -0,0 +1,29 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_refund_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce params +const params11 = { + transaction_id: 'T12345', // Required + affiliation: 'Google Store', + currency: 'USD', + value: 9.99, + items: [] +}; + +// (Optional) For partial refunds, define the item_id and quantity of refunded items +const refundedProduct = { + item_id: 'SKU_123', // Required + quantity: 1 // Required +}; + +params11.items.push(refundedProduct); + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'refund', params11); +// [END analytics_ecommerce_refund_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js new file mode 100644 index 00000000..861c73ea --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_remove_cart_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce params +const params6 = { + currency: 'USD', + value: 24.99, + items: [item_jeggings] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'remove_from_cart', params6); +// [END analytics_ecommerce_remove_cart_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js new file mode 100644 index 00000000..537220f7 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_select_item_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce event params +const params2 = { + item_list_id: 'L001', + item_list_name: 'Related products', + items: [item_jeggings] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'select_item', params2); +// [END analytics_ecommerce_select_item_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js new file mode 100644 index 00000000..d4425db8 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_shipping_info_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce params +const params8 = { + currency: 'USD', + value: 14.98, // Total Revenue + coupon: 'SUMMER_FUN', + shipping_tier: 'Ground', + items: [item_jeggings] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'add_shipping_info', params8); +// [END analytics_ecommerce_shipping_info_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js new file mode 100644 index 00000000..4bb85052 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js @@ -0,0 +1,30 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_view_cart_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Specify order quantity +const item_jeggings_quantity = { + ...item_jeggings, + quantity: 2 +}; + +const item_boots_quantity = { + ...item_boots, + quantity: 1 +}; + +// Prepare ecommerce params +const params5 = { + currency: 'USD', + value: 44.97, + items: [item_jeggings_quantity, item_boots_quantity] +}; + +// Log event when the cart is viewed +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'view_cart', params5); +// [END analytics_ecommerce_view_cart_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js new file mode 100644 index 00000000..1fd40596 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_view_item_details_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce event params +const params3 = { + currency: 'USD', + value: 9.99, + items: [item_jeggings] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'view_item', params3); +// [END analytics_ecommerce_view_item_details_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js new file mode 100644 index 00000000..acc8bf08 --- /dev/null +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/ecommerce.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_ecommerce_view_item_list_modular] +import { getAnalytics, logEvent } from "@firebase/analytics"; + +// Prepare ecommerce params +const params1 = { + item_list_id: 'L001', + item_list_name: 'Related products', + items: [item_jeggings, item_boots, item_socks] +}; + +// Log event +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'view_item_list', params1); +// [END analytics_ecommerce_view_item_list_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_initialize.js b/snippets/analytics-next/index/analytics_initialize.js new file mode 100644 index 00000000..8d491090 --- /dev/null +++ b/snippets/analytics-next/index/analytics_initialize.js @@ -0,0 +1,10 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_initialize_modular] +import { getAnalytics } from "firebase/analytics"; + +const analytics = getAnalytics(firebaseApp); +// [END analytics_initialize_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_log_event.js b/snippets/analytics-next/index/analytics_log_event.js new file mode 100644 index 00000000..d4122c71 --- /dev/null +++ b/snippets/analytics-next/index/analytics_log_event.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_log_event_modular] +import { getAnalytics, logEvent } from "firebase/analytics"; + +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'notification_received'); +// [END analytics_log_event_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_log_event_custom_params.js b/snippets/analytics-next/index/analytics_log_event_custom_params.js new file mode 100644 index 00000000..65de3fb4 --- /dev/null +++ b/snippets/analytics-next/index/analytics_log_event_custom_params.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_log_event_custom_params_modular] +import { getAnalytics, logEvent } from "firebase/analytics"; + +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'goal_completion', { name: 'lever_puzzle'}); +// [END analytics_log_event_custom_params_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_log_event_params.js b/snippets/analytics-next/index/analytics_log_event_params.js new file mode 100644 index 00000000..12956c31 --- /dev/null +++ b/snippets/analytics-next/index/analytics_log_event_params.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_log_event_params_modular] +import { getAnalytics, logEvent } from "firebase/analytics"; + +const analytics = getAnalytics(firebaseApp); +logEvent(analytics, 'select_content', { + content_type: 'image', + content_id: 'P12453', + items: [{ name: 'Kittens' }] +}); +// [END analytics_log_event_params_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_set_user_properties.js b/snippets/analytics-next/index/analytics_set_user_properties.js new file mode 100644 index 00000000..ca660ab8 --- /dev/null +++ b/snippets/analytics-next/index/analytics_set_user_properties.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START analytics_set_user_properties_modular] +import { getAnalytics, setUserProperties } from "firebase/analytics"; + +const analytics = getAnalytics(firebaseApp); +setUserProperties(analytics, { favorite_food: 'apples' }); +// [END analytics_set_user_properties_modular] \ No newline at end of file diff --git a/snippets/messaging-next/service-worker/messaging_init_in_sw.js b/snippets/messaging-next/service-worker/messaging_init_in_sw.js index c096acfa..703e687d 100644 --- a/snippets/messaging-next/service-worker/messaging_init_in_sw.js +++ b/snippets/messaging-next/service-worker/messaging_init_in_sw.js @@ -19,7 +19,7 @@ const firebaseApp = initializeApp({ messagingSenderId: 'sender-id', appId: 'app-id', measurementId: 'G-measurement-id', -}) +}); // Retrieve an instance of Firebase Messaging so that it can handle background // messages. From b27016fa3e86cfffd7fef7b3ee6fb34f5dbf9759 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 22 Jan 2021 06:16:46 -0800 Subject: [PATCH 013/170] Auto-update dependencies. (#93) * Auto-update dependencies. * Auto-update dependencies. --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index a02a895c..3941640e 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 20179153..d239e630 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.3/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.3/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.4/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.4/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 282e7117a0e719b4e8a68fa010b5b6887ec233d8 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 25 Jan 2021 11:27:26 +0000 Subject: [PATCH 014/170] Add storage-next snippets --- lerna.json | 3 +- storage-next/create-reference.js | 120 +++++++++++++++ storage-next/delete-files.js | 28 ++++ storage-next/download-files.js | 92 ++++++++++++ storage-next/file-metadata.js | 86 +++++++++++ storage-next/index.js | 77 ++++++++++ storage-next/list-files.js | 64 ++++++++ storage-next/package.json | 11 ++ storage-next/upload-files.js | 245 +++++++++++++++++++++++++++++++ 9 files changed, 725 insertions(+), 1 deletion(-) create mode 100644 storage-next/create-reference.js create mode 100644 storage-next/delete-files.js create mode 100644 storage-next/download-files.js create mode 100644 storage-next/file-metadata.js create mode 100644 storage-next/index.js create mode 100644 storage-next/list-files.js create mode 100644 storage-next/package.json create mode 100644 storage-next/upload-files.js diff --git a/lerna.json b/lerna.json index 509b1db7..68842173 100644 --- a/lerna.json +++ b/lerna.json @@ -18,7 +18,8 @@ "perf-next", "remoteconfig", "remoteconfig-next", - "storage" + "storage", + "storage-next" ], "version": "1.0.0" } diff --git a/storage-next/create-reference.js b/storage-next/create-reference.js new file mode 100644 index 00000000..eae1ff4f --- /dev/null +++ b/storage-next/create-reference.js @@ -0,0 +1,120 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function createRef() { + // [START storage_create_ref] + const { getStorage, ref } = require("firebase/storage"); + + // Get a reference to the storage service, which is used to create references in your storage bucket + const storage = getStorage(firebaseApp); + + // Create a storage reference from our storage service + const storageRef = ref(storage); + // [END storage_create_ref] +} + +function createRefChild() { + // [START storage_create_ref_child] + const { getStorage, ref } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + + // Create a child reference + const imagesRef = ref(storage, 'images'); + // imagesRef now points to 'images' + + // Child references can also take paths delimited by '/' + const spaceRef = ref(storage, 'images/space.jpg'); + // spaceRef now points to "images/space.jpg" + // imagesRef still points to "images" + // [END storage_create_ref_child] +} + +function navigateRef() { + // [START storage_navigate_ref] + const { getStorage, ref } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const spaceRef = ref(storage, 'images/space.jpg'); + + // Parent allows us to move to the parent of a reference + const imagesRef = spaceRef.parent; + // imagesRef now points to 'images' + + // Root allows us to move all the way back to the top of our bucket + const rootRef = spaceRef.root; + // rootRef now points to the root + // [END storage_navigate_ref] +} + +function navigateRefChain() { + // [START storage_navigate_ref_chain] + const { getStorage, ref } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const spaceRef = ref(storage, 'images/space.jpg'); + + // References can be chained together multiple times + const earthRef = ref(spaceRef.parent, 'earth.jpg'); + // earthRef points to 'images/earth.jpg' + + // nullRef is null, since the parent of root is null + const nullRef = spaceRef.root.parent; + // [END storage_navigate_ref_chain] +} + +function refProperties() { + // [START storage_ref_properties] + const { getStorage, ref } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const spaceRef = ref(storage, 'images/space.jpg'); + + // Reference's path is: 'images/space.jpg' + // This is analogous to a file path on disk + spaceRef.fullPath; + + // Reference's name is the last segment of the full path: 'space.jpg' + // This is analogous to the file name + spaceRef.name; + + // Reference's bucket is the name of the storage bucket where files are stored + spaceRef.bucket; + // [END storage_ref_properties] +} + +function refFullExample() { + // [START storage_ref_full_example] + const { getStorage, ref } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + + // Points to the root reference + const storageRef = ref(storage); + + // Points to 'images' + const imagesRef = ref(storageRef, 'images'); + + // Points to 'images/space.jpg' + // Note that you can use variables to create child values + const fileName = 'space.jpg'; + const spaceRef = ref(imagesRef, fileName); + + // File path is 'images/space.jpg' + const path = spaceRef.fullPath; + + // File name is 'space.jpg' + const name = spaceRef.name; + + // Points to 'images' + const imagesRefAgain = spaceRef.parent; + // [END storage_ref_full_example] +} diff --git a/storage-next/delete-files.js b/storage-next/delete-files.js new file mode 100644 index 00000000..d5e640b5 --- /dev/null +++ b/storage-next/delete-files.js @@ -0,0 +1,28 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function deleteFile() { + // [START storage_delete_file] + const { getStorage, ref, deleteObject } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + + // Create a reference to the file to delete + const desertRef = ref(storage, 'images/desert.jpg'); + + // Delete the file + deleteObject(desertRef).then(() => { + // File deleted successfully + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_delete_file] +} diff --git a/storage-next/download-files.js b/storage-next/download-files.js new file mode 100644 index 00000000..5cfec855 --- /dev/null +++ b/storage-next/download-files.js @@ -0,0 +1,92 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function downloadCreateRef() { + // [START storage_download_create_ref] + const { getStorage, ref } = require("firebase/storage"); + + // Create a reference with an initial file path and name + const storage = getStorage(firebaseApp); + const pathReference = ref(storage, 'images/stars.jpg'); + + // Create a reference from a Google Cloud Storage URI + const gsReference = ref(storage, 'gs://bucket/images/stars.jpg'); + + // Create a reference from an HTTPS URL + // Note that in the URL, characters are URL escaped! + const httpsReference = ref(storage, 'https://firebasestorage.googleapis.com/b/bucket/o/images%20stars.jpg'); + // [END storage_download_create_ref] +} + +function downloadViaUrl() { + // [START storage_download_via_url] + const { getStorage, ref, getDownloadURL } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + getDownloadURL(ref(storage, 'images/stars.jpg')) + .then((url) => { + // `url` is the download URL for 'images/stars.jpg' + + // This can be downloaded directly: + const xhr = new XMLHttpRequest(); + xhr.responseType = 'blob'; + xhr.onload = (event) => { + const blob = xhr.response; + }; + xhr.open('GET', url); + xhr.send(); + + // Or inserted into an element + const img = document.getElementById('myimg'); + img.setAttribute('src', url); + }) + .catch((error) => { + // Handle any errors + }); + // [END storage_download_via_url] +} + +function downloadFullExample() { + // [START storage_download_full_example] + const { getStorage, ref, getDownloadURL } = require("firebase/storage"); + + // Create a reference to the file we want to download + const storage = getStorage(firebaseApp); + const starsRef = ref(storage, 'images/stars.jpg'); + + // Get the download URL + getDownloadURL(starsRef) + .then((url) => { + // Insert url into an tag to "download" + }) + .catch((error) => { + // A full list of error codes is available at + // https://firebase.google.com/docs/storage/web/handle-errors + switch (error.code) { + case 'storage/object-not-found': + // File doesn't exist + break; + case 'storage/unauthorized': + // User doesn't have permission to access the object + break; + case 'storage/canceled': + // User canceled the upload + break; + + // ... + + case 'storage/unknown': + // Unknown error occurred, inspect the server response + break; + } + }); + // [END storage_download_full_example] +} diff --git a/storage-next/file-metadata.js b/storage-next/file-metadata.js new file mode 100644 index 00000000..13624cc6 --- /dev/null +++ b/storage-next/file-metadata.js @@ -0,0 +1,86 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function getMetadata() { + // [START storage_get_metadata] + const { getStorage, ref, getMetadata } = require("firebase/storage"); + + // Create a reference to the file whose metadata we want to retrieve + const storage = getStorage(firebaseApp); + const forestRef = ref(storage, 'images/forest.jpg'); + + // Get metadata properties + getMetadata(forestRef) + .then((metadata) => { + // Metadata now contains the metadata for 'images/forest.jpg' + }) + .catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_get_metadata] +} + +function updateMetadata() { + // [START storage_update_metadata] + const { getStorage, ref, updateMetadata } = require("firebase/storage"); + + // Create a reference to the file whose metadata we want to change + const storage = getStorage(firebaseApp); + const forestRef = ref(storage, 'images/forest.jpg'); + + // Create file metadata to update + const newMetadata = { + cacheControl: 'public,max-age=300', + contentType: 'image/jpeg' + }; + + // Update metadata properties + updateMetadata(forestRef, newMetadata) + .then((metadata) => { + // Updated metadata for 'images/forest.jpg' is returned in the Promise + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_update_metadata] +} + +function deleteMetadata() { + // [START storage_delete_metadata] + const { getStorage, ref, updateMetadata } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const forestRef = ref(storage, 'images/forest.jpg'); + + // Create file metadata with property to delete + const deleteMetadata = { + contentType: null + }; + + // Delete the metadata property + updateMetadata(forestRef, deleteMetadata) + .then((metadata) => { + // metadata.contentType should be null + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_delete_metadata] +} + +function customMetadata() { + // [START storage_custom_metadata] + const metadata = { + customMetadata: { + 'location': 'Yosemite, CA, USA', + 'activity': 'Hiking' + } + }; + // [END storage_custom_metadata] +} diff --git a/storage-next/index.js b/storage-next/index.js new file mode 100644 index 00000000..c5d713cc --- /dev/null +++ b/storage-next/index.js @@ -0,0 +1,77 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function initialize() { + // [START storage_initialize] + const { initializeApp } = require("firebase/app"); + const { getStorage, uploadBytesResumable } = require("firebase/storage"); + + // Set the configuration for your app + // TODO: Replace with your app's config object + const firebaseConfig = { + apiKey: '', + authDomain: '', + databaseURL: '', + storageBucket: '' + }; + const firebaseApp = initializeApp(firebaseConfig); + + // Get a reference to the storage service, which is used to create references in your storage bucket + const storage = getStorage(firebaseApp); + // [END storage_initialize] +} + +function multipleBuckets() { + // [START storage_multiple_buckets] + // TODO: Snippet not yet written... + // [END storage_multiple_buckets] +} + +function storageCustomApp() { + // [START storage_custom_app] + // TODO: Snippet not yet written... + // [END storage_custom_app] +} + +/** + * @param {File} file + */ +function storageOnComplete(file) { + // The file param would be a File object from a file selection event in the browser. + // See: + // - https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications + // - https://developer.mozilla.org/en-US/docs/Web/API/File + + /** @type {any} */ + const metadata = { + 'contentType': file.type + }; + + // [START storage_on_complete] + const { getStorage, ref, uploadBytesResumable, getDownloadURL } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const imageRef = ref(storage, 'images/' + file.name); + uploadBytesResumable(imageRef, file, metadata) + .then((snapshot) => { + console.log('Uploaded', snapshot.totalBytes, 'bytes.'); + console.log('File metadata:', snapshot.metadata); + // Let's get a download URL for the file. + getDownloadURL(snapshot.ref).then((url) => { + console.log('File available at', url); + // ... + }); + }).catch((error) => { + console.error('Upload failed', error); + // ... + }); + // [END storage_on_complete] +} diff --git a/storage-next/list-files.js b/storage-next/list-files.js new file mode 100644 index 00000000..4d3f05cc --- /dev/null +++ b/storage-next/list-files.js @@ -0,0 +1,64 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function listAll() { + // [START storage_list_all] + const { getStorage, ref, listAll } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + + // Create a reference under which you want to list + const listRef = ref(storage, 'files/uid'); + + // Find all the prefixes and items. + listAll(listRef) + .then((res) => { + res.prefixes.forEach((folderRef) => { + // All the prefixes under listRef. + // You may call listAll() recursively on them. + }); + res.items.forEach((itemRef) => { + // All the items under listRef. + }); + }).catch((error) => { + // Uh-oh, an error occurred! + }); + // [END storage_list_all] +} + +function listPaginate() { + // [START storage_list_paginate] + const { getStorage, ref, list } = require("firebase/storage"); + + async function pageTokenExample(){ + // Create a reference under which you want to list + const storage = getStorage(firebaseApp); + const listRef = ref(storage, 'files/uid'); + + // Fetch the first page of 100. + const firstPage = await list(listRef, { maxResults: 100 }); + + // Use the result. + // processItems(firstPage.items) + // processPrefixes(firstPage.prefixes) + + // Fetch the second page if there are more elements. + if (firstPage.nextPageToken) { + const secondPage = await list(listRef, { + maxResults: 100, + pageToken: firstPage.nextPageToken, + }); + // processItems(secondPage.items) + // processPrefixes(secondPage.prefixes) + } + } + // [END storage_list_paginate] +} diff --git a/storage-next/package.json b/storage-next/package.json new file mode 100644 index 00000000..f21c67e0 --- /dev/null +++ b/storage-next/package.json @@ -0,0 +1,11 @@ +{ + "name": "storage-next", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "exp" + } +} diff --git a/storage-next/upload-files.js b/storage-next/upload-files.js new file mode 100644 index 00000000..1ff5d4a8 --- /dev/null +++ b/storage-next/upload-files.js @@ -0,0 +1,245 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function uploadRef() { + // [START storage_upload_ref] + const { getStorage, ref } = require("firebase/storage"); + + // Create a root reference + const storage = getStorage(firebaseApp); + + // Create a reference to 'mountains.jpg' + const mountainsRef = ref(storage, 'mountains.jpg'); + + // Create a reference to 'images/mountains.jpg' + const mountainImagesRef = ref(storage, 'images/mountains.jpg'); + + // While the file names are the same, the references point to different files + mountainsRef.name === mountainImagesRef.name; // true + mountainsRef.fullPath === mountainImagesRef.fullPath; // false + // [END storage_upload_ref] +} + +/** + * @param {File} file + */ +function uploadBlob(file) { + // [START storage_upload_blob] + const { getStorage, ref, uploadBytes } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const storageRef = ref(storage, 'some-child'); + + // 'file' comes from the Blob or File API + uploadBytes(storageRef, file).then((snapshot) => { + console.log('Uploaded a blob or file!'); + }); + // [END storage_upload_blob] +} + +function uploadBytes() { + // [START storage_upload_bytes] + const { getStorage, ref, uploadBytes } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const storageRef = ref(storage, 'some-child'); + + const bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21]); + uploadBytes(storageRef, bytes).then((snapshot) => { + console.log('Uploaded an array!'); + }); + // [END storage_upload_bytes] +} + +function uploadString() { + // [START storage_upload_string] + const { getStorage, ref, uploadString } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const storageRef = ref(storage, 'some-child'); + + // Raw string is the default if no format is provided + const message = 'This is my message.'; + uploadString(storageRef, message).then((snapshot) => { + console.log('Uploaded a raw string!'); + }); + + // Base64 formatted string + const message2 = '5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; + uploadString(storageRef, message2, 'base64').then((snapshot) => { + console.log('Uploaded a base64 string!'); + }); + + // Base64url formatted string + const message3 = '5b6p5Y-344GX44G-44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; + uploadString(storageRef, message3, 'base64url').then((snapshot) => { + console.log('Uploaded a base64url string!'); + }); + + // Data URL string + const message4 = 'data:text/plain;base64,5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; + uploadString(storageRef, message4, 'data_url').then((snapshot) => { + console.log('Uploaded a data_url string!'); + }); + // [END storage_upload_string] +} + +/** + * @param {File} file + */ +function uploadMetadata(file) { + // [START storage_upload_metadata] + const { getStorage, ref, uploadBytes } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const storageRef = ref(storage, 'images/mountains.jpg'); + + // Create file metadata including the content type + /** @type {any} */ + const metadata = { + contentType: 'image/jpeg', + }; + + // Upload the file and metadata + const uploadTask = uploadBytes(storageRef, file, metadata); + // [END storage_upload_metadata] +} + +/** + * @param {File} file + */ +function manageUploads(file) { + // [START storage_manage_uploads] + const { getStorage, ref, uploadBytesResumable } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const storageRef = ref(storage, 'images/mountains.jpg'); + + // Upload the file and metadata + const uploadTask = uploadBytesResumable(storageRef, file); + + // Pause the upload + uploadTask.pause(); + + // Resume the upload + uploadTask.resume(); + + // Cancel the upload + uploadTask.cancel(); + // [END storage_manage_uploads] +} + +/** + * @param {File} file + */ +function monitorUpload(file) { + // [START storage_monitor_upload] + const { getStorage, ref, uploadBytesResumable, getDownloadURL } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + const storageRef = ref(storage, 'images/rivers.jpg'); + + const uploadTask = uploadBytesResumable(storageRef, file); + + // Register three observers: + // 1. 'state_changed' observer, called any time the state changes + // 2. Error observer, called on failure + // 3. Completion observer, called on successful completion + uploadTask.on('state_changed', + (snapshot) => { + // Observe state change events such as progress, pause, and resume + // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded + const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; + console.log('Upload is ' + progress + '% done'); + switch (snapshot.state) { + case 'paused': + console.log('Upload is paused'); + break; + case 'running': + console.log('Upload is running'); + break; + } + }, + (error) => { + // Handle unsuccessful uploads + }, + () => { + // Handle successful uploads on complete + // For instance, get the download URL: https://firebasestorage.googleapis.com/... + getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => { + console.log('File available at', downloadURL); + }); + } + ); + // [END storage_monitor_upload] +} + +/** + * @param {File} file + */ +function uploadHandleError(file) { + // [START storage_upload_handle_error] + const { getStorage, ref, uploadBytesResumable, getDownloadURL } = require("firebase/storage"); + + const storage = getStorage(firebaseApp); + + // Create the file metadata + /** @type {any} */ + const metadata = { + contentType: 'image/jpeg' + }; + + // Upload file and metadata to the object 'images/mountains.jpg' + const storageRef = ref(storage, 'images/' + file.name); + const uploadTask = uploadBytesResumable(storageRef, file, metadata); + + // Listen for state changes, errors, and completion of the upload. + uploadTask.on('state_changed', + (snapshot) => { + // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded + const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; + console.log('Upload is ' + progress + '% done'); + switch (snapshot.state) { + case 'paused': + console.log('Upload is paused'); + break; + case 'running': + console.log('Upload is running'); + break; + } + }, + (error) => { + // A full list of error codes is available at + // https://firebase.google.com/docs/storage/web/handle-errors + switch (error.code) { + case 'storage/unauthorized': + // User doesn't have permission to access the object + break; + case 'storage/canceled': + // User canceled the upload + break; + + // ... + + case 'storage/unknown': + // Unknown error occurred, inspect error.serverResponse + break; + } + }, + () => { + // Upload completed successfully, now we can get the download URL + getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => { + console.log('File available at', downloadURL); + }); + } + ); + // [END storage_upload_handle_error] +} From 798d73f4b7166b858deba097caabaabbf76d0220 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 25 Jan 2021 11:28:13 +0000 Subject: [PATCH 015/170] Generate storage snippets --- .../create-reference/storage_create_ref.js | 14 +++++ .../storage_create_ref_child.js | 19 ++++++ .../create-reference/storage_navigate_ref.js | 19 ++++++ .../storage_navigate_ref_chain.js | 18 ++++++ .../storage_ref_full_example.js | 30 +++++++++ .../storage_ref_properties.js | 22 +++++++ .../delete-files/storage_delete_file.js | 20 ++++++ .../storage_download_create_ref.js | 19 ++++++ .../storage_download_full_example.js | 39 ++++++++++++ .../storage_download_via_url.js | 30 +++++++++ .../file-metadata/storage_custom_metadata.js | 13 ++++ .../file-metadata/storage_delete_metadata.js | 24 ++++++++ .../file-metadata/storage_get_metadata.js | 21 +++++++ .../file-metadata/storage_update_metadata.js | 26 ++++++++ .../storage-next/index/storage_custom_app.js | 8 +++ .../storage-next/index/storage_initialize.js | 22 +++++++ .../index/storage_multiple_buckets.js | 8 +++ .../storage-next/index/storage_on_complete.js | 24 ++++++++ .../list-files/storage_list_all.js | 27 ++++++++ .../list-files/storage_list_paginate.js | 31 ++++++++++ .../upload-files/storage_manage_uploads.js | 23 +++++++ .../upload-files/storage_monitor_upload.js | 44 +++++++++++++ .../upload-files/storage_upload_blob.js | 16 +++++ .../upload-files/storage_upload_bytes.js | 16 +++++ .../storage_upload_handle_error.js | 61 +++++++++++++++++++ .../upload-files/storage_upload_metadata.js | 20 ++++++ .../upload-files/storage_upload_ref.js | 21 +++++++ .../upload-files/storage_upload_string.js | 35 +++++++++++ 28 files changed, 670 insertions(+) create mode 100644 snippets/storage-next/create-reference/storage_create_ref.js create mode 100644 snippets/storage-next/create-reference/storage_create_ref_child.js create mode 100644 snippets/storage-next/create-reference/storage_navigate_ref.js create mode 100644 snippets/storage-next/create-reference/storage_navigate_ref_chain.js create mode 100644 snippets/storage-next/create-reference/storage_ref_full_example.js create mode 100644 snippets/storage-next/create-reference/storage_ref_properties.js create mode 100644 snippets/storage-next/delete-files/storage_delete_file.js create mode 100644 snippets/storage-next/download-files/storage_download_create_ref.js create mode 100644 snippets/storage-next/download-files/storage_download_full_example.js create mode 100644 snippets/storage-next/download-files/storage_download_via_url.js create mode 100644 snippets/storage-next/file-metadata/storage_custom_metadata.js create mode 100644 snippets/storage-next/file-metadata/storage_delete_metadata.js create mode 100644 snippets/storage-next/file-metadata/storage_get_metadata.js create mode 100644 snippets/storage-next/file-metadata/storage_update_metadata.js create mode 100644 snippets/storage-next/index/storage_custom_app.js create mode 100644 snippets/storage-next/index/storage_initialize.js create mode 100644 snippets/storage-next/index/storage_multiple_buckets.js create mode 100644 snippets/storage-next/index/storage_on_complete.js create mode 100644 snippets/storage-next/list-files/storage_list_all.js create mode 100644 snippets/storage-next/list-files/storage_list_paginate.js create mode 100644 snippets/storage-next/upload-files/storage_manage_uploads.js create mode 100644 snippets/storage-next/upload-files/storage_monitor_upload.js create mode 100644 snippets/storage-next/upload-files/storage_upload_blob.js create mode 100644 snippets/storage-next/upload-files/storage_upload_bytes.js create mode 100644 snippets/storage-next/upload-files/storage_upload_handle_error.js create mode 100644 snippets/storage-next/upload-files/storage_upload_metadata.js create mode 100644 snippets/storage-next/upload-files/storage_upload_ref.js create mode 100644 snippets/storage-next/upload-files/storage_upload_string.js diff --git a/snippets/storage-next/create-reference/storage_create_ref.js b/snippets/storage-next/create-reference/storage_create_ref.js new file mode 100644 index 00000000..f69cc959 --- /dev/null +++ b/snippets/storage-next/create-reference/storage_create_ref.js @@ -0,0 +1,14 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/create-reference.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_create_ref_modular] +import { getStorage, ref } from "firebase/storage"; + +// Get a reference to the storage service, which is used to create references in your storage bucket +const storage = getStorage(firebaseApp); + +// Create a storage reference from our storage service +const storageRef = ref(storage); +// [END storage_create_ref_modular] \ No newline at end of file diff --git a/snippets/storage-next/create-reference/storage_create_ref_child.js b/snippets/storage-next/create-reference/storage_create_ref_child.js new file mode 100644 index 00000000..ded271e0 --- /dev/null +++ b/snippets/storage-next/create-reference/storage_create_ref_child.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/create-reference.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_create_ref_child_modular] +import { getStorage, ref } from "firebase/storage"; + +const storage = getStorage(firebaseApp); + +// Create a child reference +const imagesRef = ref(storage, 'images'); +// imagesRef now points to 'images' + +// Child references can also take paths delimited by '/' +const spaceRef = ref(storage, 'images/space.jpg'); +// spaceRef now points to "images/space.jpg" +// imagesRef still points to "images" +// [END storage_create_ref_child_modular] \ No newline at end of file diff --git a/snippets/storage-next/create-reference/storage_navigate_ref.js b/snippets/storage-next/create-reference/storage_navigate_ref.js new file mode 100644 index 00000000..3cdc6b6d --- /dev/null +++ b/snippets/storage-next/create-reference/storage_navigate_ref.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/create-reference.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_navigate_ref_modular] +import { getStorage, ref } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const spaceRef = ref(storage, 'images/space.jpg'); + +// Parent allows us to move to the parent of a reference +const imagesRef = spaceRef.parent; +// imagesRef now points to 'images' + +// Root allows us to move all the way back to the top of our bucket +const rootRef = spaceRef.root; +// rootRef now points to the root +// [END storage_navigate_ref_modular] \ No newline at end of file diff --git a/snippets/storage-next/create-reference/storage_navigate_ref_chain.js b/snippets/storage-next/create-reference/storage_navigate_ref_chain.js new file mode 100644 index 00000000..93607b72 --- /dev/null +++ b/snippets/storage-next/create-reference/storage_navigate_ref_chain.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/create-reference.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_navigate_ref_chain_modular] +import { getStorage, ref } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const spaceRef = ref(storage, 'images/space.jpg'); + +// References can be chained together multiple times +const earthRef = ref(spaceRef.parent, 'earth.jpg'); +// earthRef points to 'images/earth.jpg' + +// nullRef is null, since the parent of root is null +const nullRef = spaceRef.root.parent; +// [END storage_navigate_ref_chain_modular] \ No newline at end of file diff --git a/snippets/storage-next/create-reference/storage_ref_full_example.js b/snippets/storage-next/create-reference/storage_ref_full_example.js new file mode 100644 index 00000000..0869f09c --- /dev/null +++ b/snippets/storage-next/create-reference/storage_ref_full_example.js @@ -0,0 +1,30 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/create-reference.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_ref_full_example_modular] +import { getStorage, ref } from "firebase/storage"; + +const storage = getStorage(firebaseApp); + +// Points to the root reference +const storageRef = ref(storage); + +// Points to 'images' +const imagesRef = ref(storageRef, 'images'); + +// Points to 'images/space.jpg' +// Note that you can use variables to create child values +const fileName = 'space.jpg'; +const spaceRef = ref(imagesRef, fileName); + +// File path is 'images/space.jpg' +const path = spaceRef.fullPath; + +// File name is 'space.jpg' +const name = spaceRef.name; + +// Points to 'images' +const imagesRefAgain = spaceRef.parent; +// [END storage_ref_full_example_modular] \ No newline at end of file diff --git a/snippets/storage-next/create-reference/storage_ref_properties.js b/snippets/storage-next/create-reference/storage_ref_properties.js new file mode 100644 index 00000000..4707b931 --- /dev/null +++ b/snippets/storage-next/create-reference/storage_ref_properties.js @@ -0,0 +1,22 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/create-reference.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_ref_properties_modular] +import { getStorage, ref } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const spaceRef = ref(storage, 'images/space.jpg'); + +// Reference's path is: 'images/space.jpg' +// This is analogous to a file path on disk +spaceRef.fullPath; + +// Reference's name is the last segment of the full path: 'space.jpg' +// This is analogous to the file name +spaceRef.name; + +// Reference's bucket is the name of the storage bucket where files are stored +spaceRef.bucket; +// [END storage_ref_properties_modular] \ No newline at end of file diff --git a/snippets/storage-next/delete-files/storage_delete_file.js b/snippets/storage-next/delete-files/storage_delete_file.js new file mode 100644 index 00000000..be582722 --- /dev/null +++ b/snippets/storage-next/delete-files/storage_delete_file.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/delete-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_delete_file_modular] +import { getStorage, ref, deleteObject } from "firebase/storage"; + +const storage = getStorage(firebaseApp); + +// Create a reference to the file to delete +const desertRef = ref(storage, 'images/desert.jpg'); + +// Delete the file +deleteObject(desertRef).then(() => { + // File deleted successfully +}).catch((error) => { + // Uh-oh, an error occurred! +}); +// [END storage_delete_file_modular] \ No newline at end of file diff --git a/snippets/storage-next/download-files/storage_download_create_ref.js b/snippets/storage-next/download-files/storage_download_create_ref.js new file mode 100644 index 00000000..5a17307d --- /dev/null +++ b/snippets/storage-next/download-files/storage_download_create_ref.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/download-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_download_create_ref_modular] +import { getStorage, ref } from "firebase/storage"; + +// Create a reference with an initial file path and name +const storage = getStorage(firebaseApp); +const pathReference = ref(storage, 'images/stars.jpg'); + +// Create a reference from a Google Cloud Storage URI +const gsReference = ref(storage, 'gs://bucket/images/stars.jpg'); + +// Create a reference from an HTTPS URL +// Note that in the URL, characters are URL escaped! +const httpsReference = ref(storage, 'https://firebasestorage.googleapis.com/b/bucket/o/images%20stars.jpg'); +// [END storage_download_create_ref_modular] \ No newline at end of file diff --git a/snippets/storage-next/download-files/storage_download_full_example.js b/snippets/storage-next/download-files/storage_download_full_example.js new file mode 100644 index 00000000..126ce2ea --- /dev/null +++ b/snippets/storage-next/download-files/storage_download_full_example.js @@ -0,0 +1,39 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/download-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_download_full_example_modular] +import { getStorage, ref, getDownloadURL } from "firebase/storage"; + +// Create a reference to the file we want to download +const storage = getStorage(firebaseApp); +const starsRef = ref(storage, 'images/stars.jpg'); + +// Get the download URL +getDownloadURL(starsRef) + .then((url) => { + // Insert url into an tag to "download" + }) + .catch((error) => { + // A full list of error codes is available at + // https://firebase.google.com/docs/storage/web/handle-errors + switch (error.code) { + case 'storage/object-not-found': + // File doesn't exist + break; + case 'storage/unauthorized': + // User doesn't have permission to access the object + break; + case 'storage/canceled': + // User canceled the upload + break; + + // ... + + case 'storage/unknown': + // Unknown error occurred, inspect the server response + break; + } + }); +// [END storage_download_full_example_modular] \ No newline at end of file diff --git a/snippets/storage-next/download-files/storage_download_via_url.js b/snippets/storage-next/download-files/storage_download_via_url.js new file mode 100644 index 00000000..50be6f65 --- /dev/null +++ b/snippets/storage-next/download-files/storage_download_via_url.js @@ -0,0 +1,30 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/download-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_download_via_url_modular] +import { getStorage, ref, getDownloadURL } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +getDownloadURL(ref(storage, 'images/stars.jpg')) + .then((url) => { + // `url` is the download URL for 'images/stars.jpg' + + // This can be downloaded directly: + const xhr = new XMLHttpRequest(); + xhr.responseType = 'blob'; + xhr.onload = (event) => { + const blob = xhr.response; + }; + xhr.open('GET', url); + xhr.send(); + + // Or inserted into an element + const img = document.getElementById('myimg'); + img.setAttribute('src', url); + }) + .catch((error) => { + // Handle any errors + }); +// [END storage_download_via_url_modular] \ No newline at end of file diff --git a/snippets/storage-next/file-metadata/storage_custom_metadata.js b/snippets/storage-next/file-metadata/storage_custom_metadata.js new file mode 100644 index 00000000..7674c7d4 --- /dev/null +++ b/snippets/storage-next/file-metadata/storage_custom_metadata.js @@ -0,0 +1,13 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/file-metadata.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_custom_metadata_modular] +const metadata = { + customMetadata: { + 'location': 'Yosemite, CA, USA', + 'activity': 'Hiking' + } +}; +// [END storage_custom_metadata_modular] \ No newline at end of file diff --git a/snippets/storage-next/file-metadata/storage_delete_metadata.js b/snippets/storage-next/file-metadata/storage_delete_metadata.js new file mode 100644 index 00000000..927e4be8 --- /dev/null +++ b/snippets/storage-next/file-metadata/storage_delete_metadata.js @@ -0,0 +1,24 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/file-metadata.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_delete_metadata_modular] +import { getStorage, ref, updateMetadata } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const forestRef = ref(storage, 'images/forest.jpg'); + +// Create file metadata with property to delete +const deleteMetadata = { + contentType: null +}; + +// Delete the metadata property +updateMetadata(forestRef, deleteMetadata) + .then((metadata) => { + // metadata.contentType should be null + }).catch((error) => { + // Uh-oh, an error occurred! + }); +// [END storage_delete_metadata_modular] \ No newline at end of file diff --git a/snippets/storage-next/file-metadata/storage_get_metadata.js b/snippets/storage-next/file-metadata/storage_get_metadata.js new file mode 100644 index 00000000..8bc462f1 --- /dev/null +++ b/snippets/storage-next/file-metadata/storage_get_metadata.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/file-metadata.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_get_metadata_modular] +import { getStorage, ref, getMetadata } from "firebase/storage"; + +// Create a reference to the file whose metadata we want to retrieve +const storage = getStorage(firebaseApp); +const forestRef = ref(storage, 'images/forest.jpg'); + +// Get metadata properties +getMetadata(forestRef) + .then((metadata) => { + // Metadata now contains the metadata for 'images/forest.jpg' + }) + .catch((error) => { + // Uh-oh, an error occurred! + }); +// [END storage_get_metadata_modular] \ No newline at end of file diff --git a/snippets/storage-next/file-metadata/storage_update_metadata.js b/snippets/storage-next/file-metadata/storage_update_metadata.js new file mode 100644 index 00000000..97cacc4b --- /dev/null +++ b/snippets/storage-next/file-metadata/storage_update_metadata.js @@ -0,0 +1,26 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/file-metadata.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_update_metadata_modular] +import { getStorage, ref, updateMetadata } from "firebase/storage"; + +// Create a reference to the file whose metadata we want to change +const storage = getStorage(firebaseApp); +const forestRef = ref(storage, 'images/forest.jpg'); + +// Create file metadata to update +const newMetadata = { + cacheControl: 'public,max-age=300', + contentType: 'image/jpeg' +}; + +// Update metadata properties +updateMetadata(forestRef, newMetadata) + .then((metadata) => { + // Updated metadata for 'images/forest.jpg' is returned in the Promise + }).catch((error) => { + // Uh-oh, an error occurred! + }); +// [END storage_update_metadata_modular] \ No newline at end of file diff --git a/snippets/storage-next/index/storage_custom_app.js b/snippets/storage-next/index/storage_custom_app.js new file mode 100644 index 00000000..71827148 --- /dev/null +++ b/snippets/storage-next/index/storage_custom_app.js @@ -0,0 +1,8 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_custom_app_modular] +// TODO: Snippet not yet written... +// [END storage_custom_app_modular] \ No newline at end of file diff --git a/snippets/storage-next/index/storage_initialize.js b/snippets/storage-next/index/storage_initialize.js new file mode 100644 index 00000000..ec69f915 --- /dev/null +++ b/snippets/storage-next/index/storage_initialize.js @@ -0,0 +1,22 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_initialize_modular] +import { initializeApp } from "firebase/app"; +import { getStorage, uploadBytesResumable } from "firebase/storage"; + +// Set the configuration for your app +// TODO: Replace with your app's config object +const firebaseConfig = { + apiKey: '', + authDomain: '', + databaseURL: '', + storageBucket: '' +}; +const firebaseApp = initializeApp(firebaseConfig); + +// Get a reference to the storage service, which is used to create references in your storage bucket +const storage = getStorage(firebaseApp); +// [END storage_initialize_modular] \ No newline at end of file diff --git a/snippets/storage-next/index/storage_multiple_buckets.js b/snippets/storage-next/index/storage_multiple_buckets.js new file mode 100644 index 00000000..86908130 --- /dev/null +++ b/snippets/storage-next/index/storage_multiple_buckets.js @@ -0,0 +1,8 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_multiple_buckets_modular] +// TODO: Snippet not yet written... +// [END storage_multiple_buckets_modular] \ No newline at end of file diff --git a/snippets/storage-next/index/storage_on_complete.js b/snippets/storage-next/index/storage_on_complete.js new file mode 100644 index 00000000..c0c615ff --- /dev/null +++ b/snippets/storage-next/index/storage_on_complete.js @@ -0,0 +1,24 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_on_complete_modular] +import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const imageRef = ref(storage, 'images/' + file.name); +uploadBytesResumable(imageRef, file, metadata) + .then((snapshot) => { + console.log('Uploaded', snapshot.totalBytes, 'bytes.'); + console.log('File metadata:', snapshot.metadata); + // Let's get a download URL for the file. + getDownloadURL(snapshot.ref).then((url) => { + console.log('File available at', url); + // ... + }); + }).catch((error) => { + console.error('Upload failed', error); + // ... + }); +// [END storage_on_complete_modular] \ No newline at end of file diff --git a/snippets/storage-next/list-files/storage_list_all.js b/snippets/storage-next/list-files/storage_list_all.js new file mode 100644 index 00000000..9f794ca4 --- /dev/null +++ b/snippets/storage-next/list-files/storage_list_all.js @@ -0,0 +1,27 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/list-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_list_all_modular] +import { getStorage, ref, listAll } from "firebase/storage"; + +const storage = getStorage(firebaseApp); + +// Create a reference under which you want to list +const listRef = ref(storage, 'files/uid'); + +// Find all the prefixes and items. +listAll(listRef) + .then((res) => { + res.prefixes.forEach((folderRef) => { + // All the prefixes under listRef. + // You may call listAll() recursively on them. + }); + res.items.forEach((itemRef) => { + // All the items under listRef. + }); + }).catch((error) => { + // Uh-oh, an error occurred! + }); +// [END storage_list_all_modular] \ No newline at end of file diff --git a/snippets/storage-next/list-files/storage_list_paginate.js b/snippets/storage-next/list-files/storage_list_paginate.js new file mode 100644 index 00000000..4415ccdc --- /dev/null +++ b/snippets/storage-next/list-files/storage_list_paginate.js @@ -0,0 +1,31 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/list-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_list_paginate_modular] +import { getStorage, ref, list } from "firebase/storage"; + +async function pageTokenExample(){ + // Create a reference under which you want to list + const storage = getStorage(firebaseApp); + const listRef = ref(storage, 'files/uid'); + + // Fetch the first page of 100. + const firstPage = await list(listRef, { maxResults: 100 }); + + // Use the result. + // processItems(firstPage.items) + // processPrefixes(firstPage.prefixes) + + // Fetch the second page if there are more elements. + if (firstPage.nextPageToken) { + const secondPage = await list(listRef, { + maxResults: 100, + pageToken: firstPage.nextPageToken, + }); + // processItems(secondPage.items) + // processPrefixes(secondPage.prefixes) + } +} +// [END storage_list_paginate_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_manage_uploads.js b/snippets/storage-next/upload-files/storage_manage_uploads.js new file mode 100644 index 00000000..476503bb --- /dev/null +++ b/snippets/storage-next/upload-files/storage_manage_uploads.js @@ -0,0 +1,23 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_manage_uploads_modular] +import { getStorage, ref, uploadBytesResumable } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const storageRef = ref(storage, 'images/mountains.jpg'); + +// Upload the file and metadata +const uploadTask = uploadBytesResumable(storageRef, file); + +// Pause the upload +uploadTask.pause(); + +// Resume the upload +uploadTask.resume(); + +// Cancel the upload +uploadTask.cancel(); +// [END storage_manage_uploads_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_monitor_upload.js b/snippets/storage-next/upload-files/storage_monitor_upload.js new file mode 100644 index 00000000..f6d81935 --- /dev/null +++ b/snippets/storage-next/upload-files/storage_monitor_upload.js @@ -0,0 +1,44 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_monitor_upload_modular] +import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const storageRef = ref(storage, 'images/rivers.jpg'); + +const uploadTask = uploadBytesResumable(storageRef, file); + +// Register three observers: +// 1. 'state_changed' observer, called any time the state changes +// 2. Error observer, called on failure +// 3. Completion observer, called on successful completion +uploadTask.on('state_changed', + (snapshot) => { + // Observe state change events such as progress, pause, and resume + // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded + const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; + console.log('Upload is ' + progress + '% done'); + switch (snapshot.state) { + case 'paused': + console.log('Upload is paused'); + break; + case 'running': + console.log('Upload is running'); + break; + } + }, + (error) => { + // Handle unsuccessful uploads + }, + () => { + // Handle successful uploads on complete + // For instance, get the download URL: https://firebasestorage.googleapis.com/... + getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => { + console.log('File available at', downloadURL); + }); + } +); +// [END storage_monitor_upload_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_upload_blob.js b/snippets/storage-next/upload-files/storage_upload_blob.js new file mode 100644 index 00000000..11970dea --- /dev/null +++ b/snippets/storage-next/upload-files/storage_upload_blob.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_upload_blob_modular] +import { getStorage, ref, uploadBytes } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const storageRef = ref(storage, 'some-child'); + +// 'file' comes from the Blob or File API +uploadBytes(storageRef, file).then((snapshot) => { + console.log('Uploaded a blob or file!'); +}); +// [END storage_upload_blob_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_upload_bytes.js b/snippets/storage-next/upload-files/storage_upload_bytes.js new file mode 100644 index 00000000..aa906060 --- /dev/null +++ b/snippets/storage-next/upload-files/storage_upload_bytes.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_upload_bytes_modular] +import { getStorage, ref, uploadBytes } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const storageRef = ref(storage, 'some-child'); + +const bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21]); +uploadBytes(storageRef, bytes).then((snapshot) => { + console.log('Uploaded an array!'); +}); +// [END storage_upload_bytes_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_upload_handle_error.js b/snippets/storage-next/upload-files/storage_upload_handle_error.js new file mode 100644 index 00000000..3baa5758 --- /dev/null +++ b/snippets/storage-next/upload-files/storage_upload_handle_error.js @@ -0,0 +1,61 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_upload_handle_error_modular] +import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; + +const storage = getStorage(firebaseApp); + +// Create the file metadata +/** @type {any} */ +const metadata = { + contentType: 'image/jpeg' +}; + +// Upload file and metadata to the object 'images/mountains.jpg' +const storageRef = ref(storage, 'images/' + file.name); +const uploadTask = uploadBytesResumable(storageRef, file, metadata); + +// Listen for state changes, errors, and completion of the upload. +uploadTask.on('state_changed', + (snapshot) => { + // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded + const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; + console.log('Upload is ' + progress + '% done'); + switch (snapshot.state) { + case 'paused': + console.log('Upload is paused'); + break; + case 'running': + console.log('Upload is running'); + break; + } + }, + (error) => { + // A full list of error codes is available at + // https://firebase.google.com/docs/storage/web/handle-errors + switch (error.code) { + case 'storage/unauthorized': + // User doesn't have permission to access the object + break; + case 'storage/canceled': + // User canceled the upload + break; + + // ... + + case 'storage/unknown': + // Unknown error occurred, inspect error.serverResponse + break; + } + }, + () => { + // Upload completed successfully, now we can get the download URL + getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => { + console.log('File available at', downloadURL); + }); + } +); +// [END storage_upload_handle_error_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_upload_metadata.js b/snippets/storage-next/upload-files/storage_upload_metadata.js new file mode 100644 index 00000000..6632cfb6 --- /dev/null +++ b/snippets/storage-next/upload-files/storage_upload_metadata.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_upload_metadata_modular] +import { getStorage, ref, uploadBytes } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const storageRef = ref(storage, 'images/mountains.jpg'); + +// Create file metadata including the content type +/** @type {any} */ +const metadata = { + contentType: 'image/jpeg', +}; + +// Upload the file and metadata +const uploadTask = uploadBytes(storageRef, file, metadata); +// [END storage_upload_metadata_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_upload_ref.js b/snippets/storage-next/upload-files/storage_upload_ref.js new file mode 100644 index 00000000..820b2632 --- /dev/null +++ b/snippets/storage-next/upload-files/storage_upload_ref.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_upload_ref_modular] +import { getStorage, ref } from "firebase/storage"; + +// Create a root reference +const storage = getStorage(firebaseApp); + +// Create a reference to 'mountains.jpg' +const mountainsRef = ref(storage, 'mountains.jpg'); + +// Create a reference to 'images/mountains.jpg' +const mountainImagesRef = ref(storage, 'images/mountains.jpg'); + +// While the file names are the same, the references point to different files +mountainsRef.name === mountainImagesRef.name; // true +mountainsRef.fullPath === mountainImagesRef.fullPath; // false +// [END storage_upload_ref_modular] \ No newline at end of file diff --git a/snippets/storage-next/upload-files/storage_upload_string.js b/snippets/storage-next/upload-files/storage_upload_string.js new file mode 100644 index 00000000..80b8aaa3 --- /dev/null +++ b/snippets/storage-next/upload-files/storage_upload_string.js @@ -0,0 +1,35 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/upload-files.js +// +// To make edits to the snippets in this file, please edit the source + +// [START storage_upload_string_modular] +import { getStorage, ref, uploadString } from "firebase/storage"; + +const storage = getStorage(firebaseApp); +const storageRef = ref(storage, 'some-child'); + +// Raw string is the default if no format is provided +const message = 'This is my message.'; +uploadString(storageRef, message).then((snapshot) => { + console.log('Uploaded a raw string!'); +}); + +// Base64 formatted string +const message2 = '5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; +uploadString(storageRef, message2, 'base64').then((snapshot) => { + console.log('Uploaded a base64 string!'); +}); + +// Base64url formatted string +const message3 = '5b6p5Y-344GX44G-44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; +uploadString(storageRef, message3, 'base64url').then((snapshot) => { + console.log('Uploaded a base64url string!'); +}); + +// Data URL string +const message4 = 'data:text/plain;base64,5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB'; +uploadString(storageRef, message4, 'data_url').then((snapshot) => { + console.log('Uploaded a data_url string!'); +}); +// [END storage_upload_string_modular] \ No newline at end of file From db0ad0d144f6c9336f99928e79819e7415c5b052 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 25 Jan 2021 11:45:49 +0000 Subject: [PATCH 016/170] Add Database snippets --- database-next/emulator-suite.js | 32 ++++ database-next/index.js | 18 ++ database-next/lists-of-data.js | 99 +++++++++++ database-next/package.json | 11 ++ database-next/read-and-write.js | 161 ++++++++++++++++++ database-next/sharding.js | 31 ++++ database/read-and-write.js | 2 +- lerna.json | 1 + .../emulator-suite/rtdb_emulator_connect.js | 14 ++ .../emulator-suite/rtdb_emulator_flush.js | 12 ++ .../database-next/index/rtdb_get_reference.js | 10 ++ .../rtdb_social_listen_children.js | 22 +++ .../lists-of-data/rtdb_social_listen_value.js | 19 +++ .../lists-of-data/rtdb_social_most_starred.js | 15 ++ .../lists-of-data/rtdb_social_most_viewed.js | 11 ++ .../lists-of-data/rtdb_social_push.js | 16 ++ .../lists-of-data/rtdb_social_recent.js | 11 ++ .../rtdb_social_completion_callback.js | 21 +++ .../rtdb_social_listen_star_count.js | 15 ++ .../rtdb_social_single_value_read.js | 18 ++ .../rtdb_social_star_transaction.js | 29 ++++ .../rtdb_social_write_fan_out.js | 30 ++++ .../read-and-write/rtdb_write_new_user.js | 17 ++ .../rtdb_write_new_user_completion.js | 21 +++ .../sharding/rtdb_multiple_instances.js | 23 +++ 25 files changed, 658 insertions(+), 1 deletion(-) create mode 100644 database-next/emulator-suite.js create mode 100644 database-next/index.js create mode 100644 database-next/lists-of-data.js create mode 100644 database-next/package.json create mode 100644 database-next/read-and-write.js create mode 100644 database-next/sharding.js create mode 100644 snippets/database-next/emulator-suite/rtdb_emulator_connect.js create mode 100644 snippets/database-next/emulator-suite/rtdb_emulator_flush.js create mode 100644 snippets/database-next/index/rtdb_get_reference.js create mode 100644 snippets/database-next/lists-of-data/rtdb_social_listen_children.js create mode 100644 snippets/database-next/lists-of-data/rtdb_social_listen_value.js create mode 100644 snippets/database-next/lists-of-data/rtdb_social_most_starred.js create mode 100644 snippets/database-next/lists-of-data/rtdb_social_most_viewed.js create mode 100644 snippets/database-next/lists-of-data/rtdb_social_push.js create mode 100644 snippets/database-next/lists-of-data/rtdb_social_recent.js create mode 100644 snippets/database-next/read-and-write/rtdb_social_completion_callback.js create mode 100644 snippets/database-next/read-and-write/rtdb_social_listen_star_count.js create mode 100644 snippets/database-next/read-and-write/rtdb_social_single_value_read.js create mode 100644 snippets/database-next/read-and-write/rtdb_social_star_transaction.js create mode 100644 snippets/database-next/read-and-write/rtdb_social_write_fan_out.js create mode 100644 snippets/database-next/read-and-write/rtdb_write_new_user.js create mode 100644 snippets/database-next/read-and-write/rtdb_write_new_user_completion.js create mode 100644 snippets/database-next/sharding/rtdb_multiple_instances.js diff --git a/database-next/emulator-suite.js b/database-next/emulator-suite.js new file mode 100644 index 00000000..cdcf4896 --- /dev/null +++ b/database-next/emulator-suite.js @@ -0,0 +1,32 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function onDocumentReady() { + // [START rtdb_emulator_connect] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + if (location.hostname === "localhost") { + // Point to the RTDB emulator running on localhost. + db.useEmulator("localhost", 9000); + } + // [END rtdb_emulator_connect] +} + +function flushRealtimeDatabase() { + // [START rtdb_emulator_flush] + const { getDatabase } = require("firebase/database"); + + // With a database Reference, write null to clear the database. + const db = getDatabase(firebaseApp); + db.ref().set(null); + // [END rtdb_emulator_flush] +} diff --git a/database-next/index.js b/database-next/index.js new file mode 100644 index 00000000..53c8584d --- /dev/null +++ b/database-next/index.js @@ -0,0 +1,18 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function getReference() { + // [START rtdb_get_reference] + const { getDatabase } = require("firebase/database"); + + const database = getDatabase(firebaseApp); + // [END rtdb_get_reference] +} diff --git a/database-next/lists-of-data.js b/database-next/lists-of-data.js new file mode 100644 index 00000000..b19371e4 --- /dev/null +++ b/database-next/lists-of-data.js @@ -0,0 +1,99 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function socialPush() { + // [START rtdb_social_push] + const { getDatabase } = require("firebase/database"); + + // Create a new post reference with an auto-generated id + const db = getDatabase(firebaseApp); + const postListRef = db.ref('posts'); + const newPostRef = postListRef.push(); + newPostRef.set({ + // ... + }); + // [END rtdb_social_push] +} + +function socialListenChildren() { + const postElement = document.querySelector("#post"); + const postId = "1234"; + function addCommentElement(el, key, text, author) {} + function setCommentValues(el, key, text, author) {}; + function deleteComment(el, key) {}; + + // [START rtdb_social_listen_children] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const commentsRef = db.ref('post-comments/' + postId); + commentsRef.on('child_added', (data) => { + addCommentElement(postElement, data.key, data.val().text, data.val().author); + }); + + commentsRef.on('child_changed', (data) => { + setCommentValues(postElement, data.key, data.val().text, data.val().author); + }); + + commentsRef.on('child_removed', (data) => { + deleteComment(postElement, data.key); + }); + // [END rtdb_social_listen_children] +} + +function socialListenValue() { + + // [START rtdb_social_listen_value] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const ref = db.ref('/a/b/c'); + + ref.once('value', (snapshot) => { + snapshot.forEach((childSnapshot) => { + const childKey = childSnapshot.key; + const childData = childSnapshot.val(); + // ... + }); + }); + // [END rtdb_social_listen_value] +} + +function socialMostStarred() { + // [START rtdb_social_most_starred] + const { getDatabase } = require("firebase/database"); + const { getAuth } = require("firebase/auth"); + + const db = getDatabase(firebaseApp); + const auth = getAuth(firebaseApp); + + const myUserId = auth.currentUser.uid; + const topUserPostsRef = db.ref('user-posts/' + myUserId).orderByChild('starCount'); + // [END rtdb_social_most_starred] +} + +function socialMostViewed() { + // [START rtdb_social_most_viewed] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const mostViewedPosts = db.ref('posts').orderByChild('metrics/views'); + // [END rtdb_social_most_viewed] +} + +function socialRecent() { + // [START rtdb_social_recent] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const recentPostsRef = db.ref('posts').limitToLast(100); + // [END rtdb_social_recent] +} diff --git a/database-next/package.json b/database-next/package.json new file mode 100644 index 00000000..927237f7 --- /dev/null +++ b/database-next/package.json @@ -0,0 +1,11 @@ +{ + "name": "database-next", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "exp" + } +} diff --git a/database-next/read-and-write.js b/database-next/read-and-write.js new file mode 100644 index 00000000..6d890183 --- /dev/null +++ b/database-next/read-and-write.js @@ -0,0 +1,161 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function writeUserData_wrapped() { + // [START rtdb_write_new_user] + const { getDatabase } = require("firebase/database"); + + function writeUserData(userId, name, email, imageUrl) { + const db = getDatabase(firebaseApp); + db.ref('users/' + userId).set({ + username: name, + email: email, + profile_picture : imageUrl + }); + } + // [END rtdb_write_new_user] +} + + +function writeUserDataWithCompletion(userId, name, email, imageUrl) { + // [START rtdb_write_new_user_completion] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + db.ref('users/' + userId).set({ + username: name, + email: email, + profile_picture : imageUrl + }, (error) => { + if (error) { + // The write failed... + } else { + // Data saved successfully! + } + }); + // [END rtdb_write_new_user_completion] +} + +function socialListenStarCount() { + const postElement = document.querySelector('#post'); + const postId = "1234"; + function updateStarCount(a, b) { + // ... + } + + // [START rtdb_social_listen_star_count] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const starCountRef = db.ref('posts/' + postId + '/starCount'); + starCountRef.on('value', (snapshot) => { + const data = snapshot.val(); + updateStarCount(postElement, data); + }); + // [END rtdb_social_listen_star_count] +} + +function socialSingleValueRead() { + // [START rtdb_social_single_value_read] + const { getDatabase } = require("firebase/database"); + const { getAuth } = require("firebase/auth"); + + const db = getDatabase(firebaseApp); + const auth = getAuth(firebaseApp); + + const userId = auth.currentUser.uid; + return db.ref('/users/' + userId).once('value').then((snapshot) => { + const username = (snapshot.val() && snapshot.val().username) || 'Anonymous'; + // ... + }); + // [END rtdb_social_single_value_read] +} + +function writeNewPost_wrapped() { + const { getDatabase } = require("firebase/database"); + + // [START rtdb_social_write_fan_out] + function writeNewPost(uid, username, picture, title, body) { + const db = getDatabase(firebaseApp); + + // A post entry. + const postData = { + author: username, + uid: uid, + body: body, + title: title, + starCount: 0, + authorPic: picture + }; + + // Get a key for a new Post. + const newPostKey = db.ref().child('posts').push().key; + + // Write the new post's data simultaneously in the posts list and the user's post list. + const updates = {}; + updates['/posts/' + newPostKey] = postData; + updates['/user-posts/' + uid + '/' + newPostKey] = postData; + + return db.ref().update(updates); + } + // [END rtdb_social_write_fan_out] +} + +function socialCompletionCallback() { + const userId = "123"; + const email = "test@example.com"; + const imageUrl = "https://example.com/image.png"; + + // [START rtdb_social_completion_callback] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + db.ref('users/' + userId).set({ + username: name, + email: email, + profile_picture : imageUrl + }, (error) => { + if (error) { + // The write failed... + } else { + // Data saved successfully! + } + }); + // [END rtdb_social_completion_callback] +} + +function toggleStar_wrapped() { + // [START rtdb_social_star_transaction] + const { getDatabase } = require("firebase/database"); + + function toggleStar(uid) { + const db = getDatabase(firebaseApp); + const postRef = db.ref('/posts/foo-bar-123'); + + postRef.transaction((post) => { + if (post) { + if (post.stars && post.stars[uid]) { + post.starCount--; + post.stars[uid] = null; + } else { + post.starCount++; + if (!post.stars) { + post.stars = {}; + } + post.stars[uid] = true; + } + } + return post; + }); + } + // [END rtdb_social_star_transaction] +} + diff --git a/database-next/sharding.js b/database-next/sharding.js new file mode 100644 index 00000000..509503ef --- /dev/null +++ b/database-next/sharding.js @@ -0,0 +1,31 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function multipleInstances() { + // [START rtdb_multiple_instances] + const { initializeApp } = require("firebase/app"); + const { getDatabase } = require("firebase/database"); + + const app1 = initializeApp({ + databaseURL: "https://testapp-1234-1.firebaseio.com" + }); + + const app2 = initializeApp({ + databaseURL: "https://testapp-1234-2.firebaseio.com" + }, 'app2'); + + // Get the default database instance for an app1 + const database1 = getDatabase(app1); + + // Get a database instance for app2 + const database2 = getDatabase(app2); + // [END rtdb_multiple_instances] +} diff --git a/database/read-and-write.js b/database/read-and-write.js index 24b87b61..5fce6c97 100644 --- a/database/read-and-write.js +++ b/database/read-and-write.js @@ -27,7 +27,7 @@ function writeUserDataWithCompletion(userId, name, email, imageUrl) { // Data saved successfully! } }); - // [START rtdb_write_new_user_completion] + // [END rtdb_write_new_user_completion] } function socialListenStarCount() { diff --git a/lerna.json b/lerna.json index 68842173..1275a07e 100644 --- a/lerna.json +++ b/lerna.json @@ -6,6 +6,7 @@ "auth", "auth-next", "database", + "database-next", "firebaseapp", "firestore", "firestore-next", diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js new file mode 100644 index 00000000..c16f0210 --- /dev/null +++ b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js @@ -0,0 +1,14 @@ +// This snippet file was generated by processing the source file: +// ./database-next/emulator-suite.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_emulator_connect_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +if (location.hostname === "localhost") { + // Point to the RTDB emulator running on localhost. + db.useEmulator("localhost", 9000); +} +// [END rtdb_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_flush.js b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js new file mode 100644 index 00000000..66f8b282 --- /dev/null +++ b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js @@ -0,0 +1,12 @@ +// This snippet file was generated by processing the source file: +// ./database-next/emulator-suite.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_emulator_flush_modular] +import { getDatabase } from "firebase/database"; + +// With a database Reference, write null to clear the database. +const db = getDatabase(firebaseApp); +db.ref().set(null); +// [END rtdb_emulator_flush_modular] \ No newline at end of file diff --git a/snippets/database-next/index/rtdb_get_reference.js b/snippets/database-next/index/rtdb_get_reference.js new file mode 100644 index 00000000..2e2f31c7 --- /dev/null +++ b/snippets/database-next/index/rtdb_get_reference.js @@ -0,0 +1,10 @@ +// This snippet file was generated by processing the source file: +// ./database-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_get_reference_modular] +import { getDatabase } from "firebase/database"; + +const database = getDatabase(firebaseApp); +// [END rtdb_get_reference_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_children.js b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js new file mode 100644 index 00000000..5aefb875 --- /dev/null +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js @@ -0,0 +1,22 @@ +// This snippet file was generated by processing the source file: +// ./database-next/lists-of-data.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_listen_children_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const commentsRef = db.ref('post-comments/' + postId); +commentsRef.on('child_added', (data) => { + addCommentElement(postElement, data.key, data.val().text, data.val().author); +}); + +commentsRef.on('child_changed', (data) => { + setCommentValues(postElement, data.key, data.val().text, data.val().author); +}); + +commentsRef.on('child_removed', (data) => { + deleteComment(postElement, data.key); +}); +// [END rtdb_social_listen_children_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_value.js b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js new file mode 100644 index 00000000..3958a0d9 --- /dev/null +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./database-next/lists-of-data.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_listen_value_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const ref = db.ref('/a/b/c'); + +ref.once('value', (snapshot) => { + snapshot.forEach((childSnapshot) => { + const childKey = childSnapshot.key; + const childData = childSnapshot.val(); + // ... + }); +}); +// [END rtdb_social_listen_value_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_starred.js b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js new file mode 100644 index 00000000..8c20de7a --- /dev/null +++ b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./database-next/lists-of-data.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_most_starred_modular] +import { getDatabase } from "firebase/database"; +import { getAuth } from "firebase/auth"; + +const db = getDatabase(firebaseApp); +const auth = getAuth(firebaseApp); + +const myUserId = auth.currentUser.uid; +const topUserPostsRef = db.ref('user-posts/' + myUserId).orderByChild('starCount'); +// [END rtdb_social_most_starred_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js new file mode 100644 index 00000000..2f5c03f8 --- /dev/null +++ b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./database-next/lists-of-data.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_most_viewed_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const mostViewedPosts = db.ref('posts').orderByChild('metrics/views'); +// [END rtdb_social_most_viewed_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_push.js b/snippets/database-next/lists-of-data/rtdb_social_push.js new file mode 100644 index 00000000..e3c7f81c --- /dev/null +++ b/snippets/database-next/lists-of-data/rtdb_social_push.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./database-next/lists-of-data.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_push_modular] +import { getDatabase } from "firebase/database"; + +// Create a new post reference with an auto-generated id +const db = getDatabase(firebaseApp); +const postListRef = db.ref('posts'); +const newPostRef = postListRef.push(); +newPostRef.set({ + // ... +}); +// [END rtdb_social_push_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_recent.js b/snippets/database-next/lists-of-data/rtdb_social_recent.js new file mode 100644 index 00000000..58fa2e38 --- /dev/null +++ b/snippets/database-next/lists-of-data/rtdb_social_recent.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./database-next/lists-of-data.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_recent_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const recentPostsRef = db.ref('posts').limitToLast(100); +// [END rtdb_social_recent_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_completion_callback.js b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js new file mode 100644 index 00000000..5251b5c4 --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_completion_callback_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +db.ref('users/' + userId).set({ + username: name, + email: email, + profile_picture : imageUrl +}, (error) => { + if (error) { + // The write failed... + } else { + // Data saved successfully! + } +}); +// [END rtdb_social_completion_callback_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js new file mode 100644 index 00000000..186afb4f --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_listen_star_count_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const starCountRef = db.ref('posts/' + postId + '/starCount'); +starCountRef.on('value', (snapshot) => { + const data = snapshot.val(); + updateStarCount(postElement, data); +}); +// [END rtdb_social_listen_star_count_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_single_value_read.js b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js new file mode 100644 index 00000000..b5bfc662 --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_single_value_read_modular] +import { getDatabase } from "firebase/database"; +import { getAuth } from "firebase/auth"; + +const db = getDatabase(firebaseApp); +const auth = getAuth(firebaseApp); + +const userId = auth.currentUser.uid; +return db.ref('/users/' + userId).once('value').then((snapshot) => { + const username = (snapshot.val() && snapshot.val().username) || 'Anonymous'; + // ... +}); +// [END rtdb_social_single_value_read_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_star_transaction.js b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js new file mode 100644 index 00000000..9c905d2c --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js @@ -0,0 +1,29 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_star_transaction_modular] +import { getDatabase } from "firebase/database"; + +function toggleStar(uid) { + const db = getDatabase(firebaseApp); + const postRef = db.ref('/posts/foo-bar-123'); + + postRef.transaction((post) => { + if (post) { + if (post.stars && post.stars[uid]) { + post.starCount--; + post.stars[uid] = null; + } else { + post.starCount++; + if (!post.stars) { + post.stars = {}; + } + post.stars[uid] = true; + } + } + return post; + }); +} +// [END rtdb_social_star_transaction_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js new file mode 100644 index 00000000..0c2973c4 --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js @@ -0,0 +1,30 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_write_fan_out_modular] +function writeNewPost(uid, username, picture, title, body) { + const db = getDatabase(firebaseApp); + + // A post entry. + const postData = { + author: username, + uid: uid, + body: body, + title: title, + starCount: 0, + authorPic: picture + }; + + // Get a key for a new Post. + const newPostKey = db.ref().child('posts').push().key; + + // Write the new post's data simultaneously in the posts list and the user's post list. + const updates = {}; + updates['/posts/' + newPostKey] = postData; + updates['/user-posts/' + uid + '/' + newPostKey] = postData; + + return db.ref().update(updates); +} +// [END rtdb_social_write_fan_out_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user.js b/snippets/database-next/read-and-write/rtdb_write_new_user.js new file mode 100644 index 00000000..c6a84358 --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_write_new_user.js @@ -0,0 +1,17 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_write_new_user_modular] +import { getDatabase } from "firebase/database"; + +function writeUserData(userId, name, email, imageUrl) { + const db = getDatabase(firebaseApp); + db.ref('users/' + userId).set({ + username: name, + email: email, + profile_picture : imageUrl + }); +} +// [END rtdb_write_new_user_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js new file mode 100644 index 00000000..cd10104d --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_write_new_user_completion_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +db.ref('users/' + userId).set({ + username: name, + email: email, + profile_picture : imageUrl +}, (error) => { + if (error) { + // The write failed... + } else { + // Data saved successfully! + } +}); +// [END rtdb_write_new_user_completion_modular] \ No newline at end of file diff --git a/snippets/database-next/sharding/rtdb_multiple_instances.js b/snippets/database-next/sharding/rtdb_multiple_instances.js new file mode 100644 index 00000000..cd40b918 --- /dev/null +++ b/snippets/database-next/sharding/rtdb_multiple_instances.js @@ -0,0 +1,23 @@ +// This snippet file was generated by processing the source file: +// ./database-next/sharding.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_multiple_instances_modular] +import { initializeApp } from "firebase/app"; +import { getDatabase } from "firebase/database"; + +const app1 = initializeApp({ + databaseURL: "https://testapp-1234-1.firebaseio.com" +}); + +const app2 = initializeApp({ + databaseURL: "https://testapp-1234-2.firebaseio.com" +}, 'app2'); + +// Get the default database instance for an app1 +const database1 = getDatabase(app1); + +// Get a database instance for app2 +const database2 = getDatabase(app2); +// [END rtdb_multiple_instances_modular] \ No newline at end of file From d01cdd5bb99621cf790b30505f1a2a9fec744584 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 25 Jan 2021 11:59:07 +0000 Subject: [PATCH 017/170] Add FirebaseApp vNext Snippets (#94) --- firebaseapp-next/firebaseapp.js | 27 +++++++++++++++++++ firebaseapp-next/package.json | 11 ++++++++ lerna.json | 1 + .../firebaseapp/firebase_options.js | 20 ++++++++++++++ .../firebaseapp/firebase_secondary.js | 11 ++++++++ 5 files changed, 70 insertions(+) create mode 100644 firebaseapp-next/firebaseapp.js create mode 100644 firebaseapp-next/package.json create mode 100644 snippets/firebaseapp-next/firebaseapp/firebase_options.js create mode 100644 snippets/firebaseapp-next/firebaseapp/firebase_secondary.js diff --git a/firebaseapp-next/firebaseapp.js b/firebaseapp-next/firebaseapp.js new file mode 100644 index 00000000..8bd6838f --- /dev/null +++ b/firebaseapp-next/firebaseapp.js @@ -0,0 +1,27 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function multpleFirebaseApps() { + // [START firebase_options] + const { initializeApp } = require("firebase/app"); + + // The following fields are REQUIRED: + // - Project ID + // - App ID + // - API Key + const secondaryAppConfig = { + projectId: "", + appId: "", + apiKey: "", + // databaseURL: "...", + // storageBucket: "...", + }; + // [END firebase_options] + + // [START firebase_secondary] + // Initialize another app with a different config + const secondaryApp = initializeApp(secondaryAppConfig, "secondary"); + // Access services, such as the Realtime Database + // getDatabase(secondaryApp) + // [END firebase_secondary] +} diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json new file mode 100644 index 00000000..a3f38088 --- /dev/null +++ b/firebaseapp-next/package.json @@ -0,0 +1,11 @@ +{ + "name": "firebaseapp-next", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "exp" + } +} diff --git a/lerna.json b/lerna.json index 1275a07e..a14444a4 100644 --- a/lerna.json +++ b/lerna.json @@ -8,6 +8,7 @@ "database", "database-next", "firebaseapp", + "firebaseapp-next", "firestore", "firestore-next", "functions", diff --git a/snippets/firebaseapp-next/firebaseapp/firebase_options.js b/snippets/firebaseapp-next/firebaseapp/firebase_options.js new file mode 100644 index 00000000..76a420e9 --- /dev/null +++ b/snippets/firebaseapp-next/firebaseapp/firebase_options.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./firebaseapp-next/firebaseapp.js +// +// To make edits to the snippets in this file, please edit the source + +// [START firebase_options_modular] +import { initializeApp } from "firebase/app"; + +// The following fields are REQUIRED: +// - Project ID +// - App ID +// - API Key +const secondaryAppConfig = { + projectId: "", + appId: "", + apiKey: "", + // databaseURL: "...", + // storageBucket: "...", +}; +// [END firebase_options_modular] \ No newline at end of file diff --git a/snippets/firebaseapp-next/firebaseapp/firebase_secondary.js b/snippets/firebaseapp-next/firebaseapp/firebase_secondary.js new file mode 100644 index 00000000..c78f2b3f --- /dev/null +++ b/snippets/firebaseapp-next/firebaseapp/firebase_secondary.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./firebaseapp-next/firebaseapp.js +// +// To make edits to the snippets in this file, please edit the source + +// [START firebase_secondary_modular] +// Initialize another app with a different config +const secondaryApp = initializeApp(secondaryAppConfig, "secondary"); +// Access services, such as the Realtime Database +// getDatabase(secondaryApp) +// [END firebase_secondary_modular] \ No newline at end of file From 82a7449c98400e814978b699703e36c9b67c2dd6 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 1 Feb 2021 02:40:25 -0800 Subject: [PATCH 018/170] Auto-update dependencies. (#95) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index e292956e..1f7c2809 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/auth/package.json b/auth/package.json index a6ea9b7c..12127fc3 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.4", + "firebase": "^8.2.5", "firebaseui": "^4.7.1" } } diff --git a/database/package.json b/database/package.json index ea1468d3..d1a5c823 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index b057f3d6..896fcaff 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/firestore/package.json b/firestore/package.json index 32b040f6..4e907d38 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4", + "firebase": "^8.2.5", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index c66ef81b..ba64715b 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/installations/package.json b/installations/package.json index f5bb3d37..42db7bac 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/messaging/package.json b/messaging/package.json index cc6f7c81..11ba5bc7 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/perf/package.json b/perf/package.json index f9176094..7593b96e 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 1bfa9cc5..21becdc2 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } diff --git a/storage/package.json b/storage/package.json index 7aad7b77..23f2231a 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.4" + "firebase": "^8.2.5" } } From a0d95bd6cfff7427f8f604f1d06024fe42d84c95 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 1 Feb 2021 05:52:32 -0500 Subject: [PATCH 019/170] Explain repo purpose in README See #96 --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index f0f7a3bc..49015f4f 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,18 @@ This repository holds code snippets used in Web documentation on [firebase.google.com](https://firebase.google.com/docs/). +These snippets are part of our documentation and best read in the context of a documentation page rather than used directly. If you're looking to get started with the Firebase Web SDK the best place to start is [quicstart-web](https://github.com/firebase/quickstart-web). + +## Example + +Consider this page: +https://firebase.google.com/docs/database/web/lists-of-data + +Each snippet in the page is dynamically included from the source in this repository, in this case mostly from this file: +https://github.com/firebase/snippets-web/blob/master/database/lists-of-data.js + +Each snippet has a "region tag" which is defined by `// [START tag]` and `// [END tag]` comments. The code between the tags can be included in our documentation. Keeping the code on GitHub, rather than hard-coded into the HTML of our documentation, allows us to ensure the code is correct and up to date. + ## Contributing We love contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines. From 4a1c4e54db54ba790829c5ab695631a2ac2c2fd6 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 1 Feb 2021 05:16:21 -0800 Subject: [PATCH 020/170] Auto-update dependencies. --- firestore/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 3941640e..743db2c2 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + From e50024d3d8917cdef336d2a8e8a65f38dc2fe570 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 1 Feb 2021 05:16:26 -0800 Subject: [PATCH 021/170] Auto-update dependencies. --- messaging/service-worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messaging/service-worker.js b/messaging/service-worker.js index d239e630..62d8b30b 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.4/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.4/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.5/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.5/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From ee4f83e790df4868839a3aa22bab82df88bd4819 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Wed, 3 Feb 2021 12:28:50 +0000 Subject: [PATCH 022/170] Prefer arrow functions, const (#99) --- .eslintrc.json | 1 + auth/cordova.js | 2 +- auth/firebaseui.js | 4 +- auth/link-multiple-accounts.js | 28 ++-- database/read-and-write.js | 2 +- firestore-next/test.firestore.js | 20 +-- firestore/test.firestore.js | 132 +++++++++--------- .../test-firestore/city_custom_object.js | 6 +- .../test-firestore/delete_collection.js | 2 +- .../test-firestore/listen_for_users.js | 2 +- storage/upload-files.js | 2 +- 11 files changed, 101 insertions(+), 100 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 2a16144c..7e4337ee 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,6 +13,7 @@ "arrow-spacing": ["error"], "no-const-assign": ["error"], "prefer-const": ["error"], + "prefer-arrow-callback": ["error"], "spaced-comment": ["error", "always"], "semi": ["error", "always"] } diff --git a/auth/cordova.js b/auth/cordova.js index 1da36ef1..e7c3fc40 100644 --- a/auth/cordova.js +++ b/auth/cordova.js @@ -14,7 +14,7 @@ function createGoogleProvider() { function cordovaSignInRedirect(provider) { // [START auth_cordova_sign_in_redirect] - firebase.auth().signInWithRedirect(provider).then(function() { + firebase.auth().signInWithRedirect(provider).then(() => { return firebase.auth().getRedirectResult(); }).then((result) => { /** @type {firebase.auth.OAuthCredential} */ diff --git a/auth/firebaseui.js b/auth/firebaseui.js index 2a359d5a..dbbf9031 100644 --- a/auth/firebaseui.js +++ b/auth/firebaseui.js @@ -218,13 +218,13 @@ function fuiConfig() { // [START auth_fui_config] var uiConfig = { callbacks: { - signInSuccessWithAuthResult: function(authResult, redirectUrl) { + signInSuccessWithAuthResult: (authResult, redirectUrl) => { // User successfully signed in. // Return type determines whether we continue the redirect automatically // or whether we leave that to developer to handle. return true; }, - uiShown: function() { + uiShown: () => { // The widget is rendered. // Hide the loader. document.getElementById('loader').style.display = 'none'; diff --git a/auth/link-multiple-accounts.js b/auth/link-multiple-accounts.js index b6419431..30f5a2ec 100644 --- a/auth/link-multiple-accounts.js +++ b/auth/link-multiple-accounts.js @@ -41,10 +41,10 @@ function getProviders() { function simpleLink(credential) { // [START auth_simple_link] auth.currentUser.linkWithCredential(credential) - .then(function(usercred) { + .then((usercred) => { var user = usercred.user; console.log("Account linking success", user); - }).catch(function(error) { + }).catch((error) => { console.log("Account linking error", error); }); // [END auth_simple_link] @@ -53,10 +53,10 @@ function simpleLink(credential) { function anonymousLink(credential) { // [START auth_anonymous_link] auth.currentUser.linkWithCredential(credential) - .then(function(usercred) { + .then((usercred) => { var user = usercred.user; console.log("Anonymous account successfully upgraded", user); - }).catch(function(error) { + }).catch((error) => { console.log("Error upgrading anonymous account", error); }); // [END auth_anonymous_link] @@ -66,12 +66,12 @@ function linkWithPopup() { var provider = new firebase.auth.GoogleAuthProvider(); // [START auth_link_with_popup] - auth.currentUser.linkWithPopup(provider).then(function(result) { + auth.currentUser.linkWithPopup(provider).then((result) => { // Accounts successfully linked. var credential = result.credential; var user = result.user; // ... - }).catch(function(error) { + }).catch((error) => { // Handle Errors here. // ... }); @@ -88,14 +88,14 @@ function linkWithRedirect() { // [END auth_link_with_redirect] // [START auth_get_redirect_result] - auth.getRedirectResult().then(function(result) { + auth.getRedirectResult().then((result) => { if (result.credential) { // Accounts successfully linked. var credential = result.credential; var user = result.user; // ... } - }).catch(function(error) { + }).catch((error) => { // Handle Errors here. // ... }); @@ -118,7 +118,7 @@ function mergeAccounts(newCredential) { repo.delete(prevUser); // Sign in user with the account you want to link to - auth.signInWithCredential(newCredential).then(function(result) { + auth.signInWithCredential(newCredential).then((result) => { console.log("Sign In Success", result); var currentUser = result.user; var currentUserData = repo.get(currentUser); @@ -128,15 +128,15 @@ function mergeAccounts(newCredential) { var mergedData = repo.merge(prevUserData, currentUserData); return prevUser.linkWithCredential(result.credential) - .then(function(linkResult) { + .then((linkResult) => { // Sign in with the newly linked credential return auth.signInWithCredential(linkResult.credential); }) - .then(function(signInResult) { + .then((signInResult) => { // Save the merged data to the new user repo.set(signInResult.user, mergedData); }); - }).catch(function(error) { + }).catch((error) => { // If there are errors we want to undo the data merge/deletion console.log("Sign In Error", error); repo.set(prevUser, prevUserData); @@ -157,10 +157,10 @@ function unlink(providerId) { var user = auth.currentUser; // [START auth_unlink_provider] - user.unlink(providerId).then(function() { + user.unlink(providerId).then(() => { // Auth provider unlinked from account // ... - }).catch(function(error) { + }).catch((error) => { // An error happened // ... }); diff --git a/database/read-and-write.js b/database/read-and-write.js index 5fce6c97..59336c8f 100644 --- a/database/read-and-write.js +++ b/database/read-and-write.js @@ -20,7 +20,7 @@ function writeUserDataWithCompletion(userId, name, email, imageUrl) { username: name, email: email, profile_picture : imageUrl - }, function(error) { + }, (error) => { if (error) { // The write failed... } else { diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 0be9c3ef..15bc159e 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -16,15 +16,15 @@ class City { } // Firestore data converter -var cityConverter = { - toFirestore: function(city) { +const cityConverter = { + toFirestore: (city) => { return { name: city.name, state: city.state, country: city.country }; }, - fromFirestore: function(snapshot, options){ + fromFirestore: (snapshot, options) => { const data = snapshot.data(options); return new City(data.name, data.state, data.country); } @@ -190,7 +190,7 @@ describe("firestore", () => { const q = query(collection(db, "users"), where("born", "<", 1900)); const unsubscribe = onSnapshot(q, (snapshot) => { console.log("Current users born before 1900:"); - snapshot.forEach(function (userSnapshot) { + snapshot.forEach((userSnapshot) => { console.log(userSnapshot.data()); }); }); @@ -360,7 +360,7 @@ describe("firestore", () => { function deleteCollection(db, collectionRef, batchSize) { const q = query(collectionRef, orderBy('__name__'), limit(batchSize)); - return new Promise(function(resolve) { + return new Promise((resolve) => { deleteQueryBatch(db, q, batchSize, resolve); }); } @@ -616,7 +616,7 @@ describe("firestore", () => { }); // [END listen_document] - setTimeout(function() { + setTimeout(() => { unsub(); done(); }, 3000); @@ -632,7 +632,7 @@ describe("firestore", () => { }); // [END listen_document_local] - setTimeout(function() { + setTimeout(() => { unsub(); done(); }, 3000); @@ -650,7 +650,7 @@ describe("firestore", () => { }); // [END listen_with_metadata] - setTimeout(function() { + setTimeout(() => { unsub(); done(); }, 3000); @@ -695,7 +695,7 @@ describe("firestore", () => { console.log("Current cities in CA: ", cities.join(", ")); }); // [END listen_multiple] - setTimeout(function() { + setTimeout(() => { unsubscribe(); done(); }, 2500); @@ -720,7 +720,7 @@ describe("firestore", () => { }); }); // [END listen_diffs] - setTimeout(function() { + setTimeout(() => { unsubscribe(); done(); }, 2500); diff --git a/firestore/test.firestore.js b/firestore/test.firestore.js index fe600769..988a3c97 100644 --- a/firestore/test.firestore.js +++ b/firestore/test.firestore.js @@ -61,7 +61,7 @@ describe("firestore", () => { // [START initialize_persistence] firebase.firestore().enablePersistence() - .catch(function(err) { + .catch((err) => { if (err.code == 'failed-precondition') { // Multiple tabs open, persistence can only be enabled // in one tab at a a time. @@ -80,7 +80,7 @@ describe("firestore", () => { var disable = // [START disable_network] firebase.firestore().disableNetwork() - .then(function() { + .then(() => { // Do offline actions // [START_EXCLUDE] console.log("Network disabled!"); @@ -91,7 +91,7 @@ describe("firestore", () => { var enable = // [START enable_network] firebase.firestore().enableNetwork() - .then(function() { + .then(() => { // Do online actions // [START_EXCLUDE] console.log("Network enabled!"); @@ -105,8 +105,8 @@ describe("firestore", () => { it("should reply with .fromCache fields", () => { // [START use_from_cache] db.collection("cities").where("state", "==", "CA") - .onSnapshot({ includeMetadataChanges: true }, function(snapshot) { - snapshot.docChanges().forEach(function(change) { + .onSnapshot({ includeMetadataChanges: true }, (snapshot) => { + snapshot.docChanges().forEach((change) => { if (change.type === "added") { console.log("New city: ", change.doc.data()); } @@ -127,10 +127,10 @@ describe("firestore", () => { last: "Lovelace", born: 1815 }) - .then(function(docRef) { + .then((docRef) => { console.log("Document written with ID: ", docRef.id); }) - .catch(function(error) { + .catch((error) => { console.error("Error adding document: ", error); }); // [END add_ada_lovelace] @@ -159,10 +159,10 @@ describe("firestore", () => { last: "Turing", born: 1912 }) - .then(function(docRef) { + .then((docRef) => { console.log("Document written with ID: ", docRef.id); }) - .catch(function(error) { + .catch((error) => { console.error("Error adding document: ", error); }); // [END add_alan_turing] @@ -176,9 +176,9 @@ describe("firestore", () => { // [START listen_for_users] db.collection("users") .where("born", "<", 1900) - .onSnapshot(function(snapshot) { + .onSnapshot((snapshot) => { console.log("Current users born before 1900:"); - snapshot.forEach(function (userSnapshot) { + snapshot.forEach((userSnapshot) => { console.log(userSnapshot.data()); }); }); @@ -224,10 +224,10 @@ describe("firestore", () => { state: "CA", country: "USA" }) - .then(function() { + .then(() => { console.log("Document successfully written!"); }) - .catch(function(error) { + .catch((error) => { console.error("Error writing document: ", error); }); // [END set_document] @@ -250,7 +250,7 @@ describe("firestore", () => { // [START get_custom_object] db.collection("cities").doc("LA") .withConverter(cityConverter) - .get().then(function(doc) { + .get().then((doc) => { if (doc.exists){ // Convert to City object var city = doc.data(); @@ -258,7 +258,7 @@ describe("firestore", () => { console.log(city.toString()); } else { console.log("No such document!"); - }}).catch(function(error) { + }}).catch((error) => { console.log("Error getting document:", error); }); // [END get_custom_object] @@ -283,7 +283,7 @@ describe("firestore", () => { batch.delete(laRef); // Commit the batch - batch.commit().then(function () { + batch.commit().then(() => { // [START_EXCLUDE] done(); // [END_EXCLUDE] @@ -307,7 +307,7 @@ describe("firestore", () => { } } }; - db.collection("data").doc("one").set(docData).then(function() { + db.collection("data").doc("one").set(docData).then(() => { console.log("Document successfully written!"); }); // [END data_types] @@ -339,7 +339,7 @@ describe("firestore", () => { "age": 13, "favorites.color": "Red" }) - .then(function() { + .then(() => { console.log("Document successfully updated!"); }); // [END update_document_nested] @@ -354,7 +354,7 @@ describe("firestore", () => { function deleteCollection(db, collectionRef, batchSize) { var query = collectionRef.orderBy('__name__').limit(batchSize); - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { deleteQueryBatch(db, query, batchSize, resolve, reject); }); } @@ -369,14 +369,14 @@ describe("firestore", () => { // Delete documents in a batch var batch = db.batch(); - snapshot.docs.forEach(function(doc) { + snapshot.docs.forEach((doc) => { batch.delete(doc.ref); }); - return batch.commit().then(function() { + return batch.commit().then(() => { return snapshot.size; }); - }).then(function(numDeleted) { + }).then((numDeleted) => { if (numDeleted < batchSize) { resolve(); return; @@ -384,7 +384,7 @@ describe("firestore", () => { // Recurse on the next process tick, to avoid // exploding the stack. - setTimeout(function() { + setTimeout(() => { deleteQueryBatch(db, query, batchSize, resolve, reject); }, 0); }) @@ -440,10 +440,10 @@ describe("firestore", () => { name: "Tokyo", country: "Japan" }) - .then(function(docRef) { + .then((docRef) => { console.log("Document written with ID: ", docRef.id); }) - .catch(function(error) { + .catch((error) => { console.error("Error adding document: ", error); }); // [END add_document] @@ -470,10 +470,10 @@ describe("firestore", () => { return washingtonRef.update({ capital: true }) - .then(function() { + .then(() => { console.log("Document successfully updated!"); }) - .catch(function(error) { + .catch((error) => { // The document probably doesn't exist. console.error("Error updating document: ", error); }); @@ -510,9 +510,9 @@ describe("firestore", () => { it("should delete a document", () => { var output = // [START delete_document] - db.collection("cities").doc("DC").delete().then(function() { + db.collection("cities").doc("DC").delete().then(() => { console.log("Document successfully deleted!"); - }).catch(function(error) { + }).catch((error) => { console.error("Error removing document: ", error); }); // [END delete_document] @@ -528,9 +528,9 @@ describe("firestore", () => { // Uncomment to initialize the doc. // sfDocRef.set({ population: 0 }); - return db.runTransaction(function(transaction) { + return db.runTransaction((transaction) => { // This code may get re-run multiple times if there are conflicts. - return transaction.get(sfDocRef).then(function(sfDoc) { + return transaction.get(sfDocRef).then((sfDoc) => { if (!sfDoc.exists) { throw "Document does not exist!"; } @@ -541,9 +541,9 @@ describe("firestore", () => { var newPopulation = sfDoc.data().population + 1; transaction.update(sfDocRef, { population: newPopulation }); }); - }).then(function() { + }).then(() => { console.log("Transaction successfully committed!"); - }).catch(function(error) { + }).catch((error) => { console.log("Transaction failed: ", error); }); // [END transaction] @@ -555,8 +555,8 @@ describe("firestore", () => { // Create a reference to the SF doc. var sfDocRef = db.collection("cities").doc("SF"); - db.runTransaction(function(transaction) { - return transaction.get(sfDocRef).then(function(sfDoc) { + db.runTransaction((transaction) => { + return transaction.get(sfDocRef).then((sfDoc) => { if (!sfDoc.exists) { throw "Document does not exist!"; } @@ -569,9 +569,9 @@ describe("firestore", () => { return Promise.reject("Sorry! Population is too big."); } }); - }).then(function(newPopulation) { + }).then((newPopulation) => { console.log("Population increased to ", newPopulation); - }).catch(function(err) { + }).catch((err) => { // This will be an "population is too big" error. console.error(err); }); @@ -582,14 +582,14 @@ describe("firestore", () => { // [START get_document] var docRef = db.collection("cities").doc("SF"); - docRef.get().then(function(doc) { + docRef.get().then((doc) => { if (doc.exists) { console.log("Document data:", doc.data()); } else { // doc.data() will be undefined in this case console.log("No such document!"); } - }).catch(function(error) { + }).catch((error) => { console.log("Error getting document:", error); }); // [END get_document] @@ -607,11 +607,11 @@ describe("firestore", () => { }; // Get a document, forcing the SDK to fetch from the offline cache. - docRef.get(getOptions).then(function(doc) { + docRef.get(getOptions).then((doc) => { // Document was found in the cache. If no cached document exists, // an error will be returned to the 'catch' block below. console.log("Cached document data:", doc.data()); - }).catch(function(error) { + }).catch((error) => { console.log("Error getting cached document:", error); }); // [END get_document_options] @@ -621,12 +621,12 @@ describe("firestore", () => { var unsub = // [START listen_document] db.collection("cities").doc("SF") - .onSnapshot(function(doc) { + .onSnapshot((doc) => { console.log("Current data: ", doc.data()); }); // [END listen_document] - setTimeout(function() { + setTimeout(() => { unsub(); done(); }, 3000); @@ -636,13 +636,13 @@ describe("firestore", () => { var unsub = // [START listen_document_local] db.collection("cities").doc("SF") - .onSnapshot(function(doc) { + .onSnapshot((doc) => { var source = doc.metadata.hasPendingWrites ? "Local" : "Server"; console.log(source, " data: ", doc.data()); }); // [END listen_document_local] - setTimeout(function() { + setTimeout(() => { unsub(); done(); }, 3000); @@ -655,12 +655,12 @@ describe("firestore", () => { .onSnapshot({ // Listen for document metadata changes includeMetadataChanges: true - }, function(doc) { + }, (doc) => { // ... }); // [END listen_with_metadata] - setTimeout(function() { + setTimeout(() => { unsub(); done(); }, 3000); @@ -671,13 +671,13 @@ describe("firestore", () => { // [START get_multiple] db.collection("cities").where("capital", "==", true) .get() - .then(function(querySnapshot) { - querySnapshot.forEach(function(doc) { + .then((querySnapshot) => { + querySnapshot.forEach((doc) => { // doc.data() is never undefined for query doc snapshots console.log(doc.id, " => ", doc.data()); }); }) - .catch(function(error) { + .catch((error) => { console.log("Error getting documents: ", error); }); // [END get_multiple] @@ -687,8 +687,8 @@ describe("firestore", () => { it("should get all documents from a collection", () => { var output = // [START get_multiple_all] - db.collection("cities").get().then(function(querySnapshot) { - querySnapshot.forEach(function(doc) { + db.collection("cities").get().then((querySnapshot) => { + querySnapshot.forEach((doc) => { // doc.data() is never undefined for query doc snapshots console.log(doc.id, " => ", doc.data()); }); @@ -701,15 +701,15 @@ describe("firestore", () => { var unsubscribe = // [START listen_multiple] db.collection("cities").where("state", "==", "CA") - .onSnapshot(function(querySnapshot) { + .onSnapshot((querySnapshot) => { var cities = []; - querySnapshot.forEach(function(doc) { + querySnapshot.forEach((doc) => { cities.push(doc.data().name); }); console.log("Current cities in CA: ", cities.join(", ")); }); // [END listen_multiple] - setTimeout(function() { + setTimeout(() => { unsubscribe(); done(); }, 2500); @@ -719,8 +719,8 @@ describe("firestore", () => { var unsubscribe = // [START listen_diffs] db.collection("cities").where("state", "==", "CA") - .onSnapshot(function(snapshot) { - snapshot.docChanges().forEach(function(change) { + .onSnapshot((snapshot) => { + snapshot.docChanges().forEach((change) => { if (change.type === "added") { console.log("New city: ", change.doc.data()); } @@ -733,7 +733,7 @@ describe("firestore", () => { }); }); // [END listen_diffs] - setTimeout(function() { + setTimeout(() => { unsubscribe(); done(); }, 2500); @@ -742,7 +742,7 @@ describe("firestore", () => { it("should unsubscribe a listener", () => { // [START detach_listener] var unsubscribe = db.collection("cities") - .onSnapshot(function (){ + .onSnapshot(() => { // Respond to data // ... }); @@ -758,9 +758,9 @@ describe("firestore", () => { var unsubscribe = // [START handle_listen_errors] db.collection("cities") - .onSnapshot(function(snapshot) { + .onSnapshot((snapshot) => { // ... - }, function(error) { + }, (error) => { // ... }); // [END handle_listen_errors] @@ -803,7 +803,7 @@ describe("firestore", () => { docRef.update({ timestamp: firebase.firestore.FieldValue.serverTimestamp() }); - docRef.onSnapshot(function(snapshot) { + docRef.onSnapshot((snapshot) => { var data = snapshot.data(options); console.log( 'Timestamp: ' + data.timestamp + @@ -984,7 +984,7 @@ describe("firestore", () => { // [START start_doc] var citiesRef = db.collection("cities"); - return citiesRef.doc("SF").get().then(function(doc) { + return citiesRef.doc("SF").get().then((doc) => { // Get all cities with a population bigger than San Francisco var biggerThanSf = citiesRef .orderBy("population") @@ -1017,7 +1017,7 @@ describe("firestore", () => { .orderBy("population") .limit(25); - return first.get().then(function (documentSnapshots) { + return first.get().then((documentSnapshots) => { // Get the last visible document var lastVisible = documentSnapshots.docs[documentSnapshots.docs.length-1]; console.log("last", lastVisible); @@ -1087,8 +1087,8 @@ describe("firestore", () => { it("should query a collection group", () => { // [START fs_collection_group_query] var museums = db.collectionGroup('landmarks').where('type', '==', 'museum'); - museums.get().then(function (querySnapshot) { - querySnapshot.forEach(function (doc) { + museums.get().then((querySnapshot) => { + querySnapshot.forEach((doc) => { console.log(doc.id, ' => ', doc.data()); }); }); diff --git a/snippets/firestore-next/test-firestore/city_custom_object.js b/snippets/firestore-next/test-firestore/city_custom_object.js index 4335d06e..2b9f2c02 100644 --- a/snippets/firestore-next/test-firestore/city_custom_object.js +++ b/snippets/firestore-next/test-firestore/city_custom_object.js @@ -16,15 +16,15 @@ class City { } // Firestore data converter -var cityConverter = { - toFirestore: function(city) { +const cityConverter = { + toFirestore: (city) => { return { name: city.name, state: city.state, country: city.country }; }, - fromFirestore: function(snapshot, options){ + fromFirestore: (snapshot, options) => { const data = snapshot.data(options); return new City(data.name, data.state, data.country); } diff --git a/snippets/firestore-next/test-firestore/delete_collection.js b/snippets/firestore-next/test-firestore/delete_collection.js index d9d6c70a..758e653e 100644 --- a/snippets/firestore-next/test-firestore/delete_collection.js +++ b/snippets/firestore-next/test-firestore/delete_collection.js @@ -13,7 +13,7 @@ import { collection, query, orderBy, limit, getDocs, writeBatch } from "firebase function deleteCollection(db, collectionRef, batchSize) { const q = query(collectionRef, orderBy('__name__'), limit(batchSize)); - return new Promise(function(resolve) { + return new Promise((resolve) => { deleteQueryBatch(db, q, batchSize, resolve); }); } diff --git a/snippets/firestore-next/test-firestore/listen_for_users.js b/snippets/firestore-next/test-firestore/listen_for_users.js index 4a8de4a9..3c42287a 100644 --- a/snippets/firestore-next/test-firestore/listen_for_users.js +++ b/snippets/firestore-next/test-firestore/listen_for_users.js @@ -9,7 +9,7 @@ import { collection, where, query, onSnapshot } from "firebase/firestore"; const q = query(collection(db, "users"), where("born", "<", 1900)); const unsubscribe = onSnapshot(q, (snapshot) => { console.log("Current users born before 1900:"); - snapshot.forEach(function (userSnapshot) { + snapshot.forEach((userSnapshot) => { console.log(userSnapshot.data()); }); }); diff --git a/storage/upload-files.js b/storage/upload-files.js index 988fc3eb..2f889019 100644 --- a/storage/upload-files.js +++ b/storage/upload-files.js @@ -203,7 +203,7 @@ function uploadHandleError(file) { }, () => { // Upload completed successfully, now we can get the download URL - uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) { + uploadTask.snapshot.ref.getDownloadURL().then((downloadURL) => { console.log('File available at', downloadURL); }); } From 22d6b043bbeac62f09a8d2f525be692e479605bb Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 4 Feb 2021 11:00:05 -0800 Subject: [PATCH 023/170] Auto-update dependencies. (#100) Brought to you by your friendly [Repository Gardener](https://github.com/GoogleCloudPlatform/repository-gardener). --- auth/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/package.json b/auth/package.json index 12127fc3..9c757188 100644 --- a/auth/package.json +++ b/auth/package.json @@ -7,6 +7,6 @@ "license": "Apache 2.0", "dependencies": { "firebase": "^8.2.5", - "firebaseui": "^4.7.1" + "firebaseui": "^4.7.3" } } From 0dd7d82bff02c857d5d3d31725a8d81b406ce042 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Sun, 7 Feb 2021 05:16:12 -0800 Subject: [PATCH 024/170] Auto-update dependencies. --- firestore/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 743db2c2..a55dcc9c 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + From d4d41b3067dccd5bd9a08d48793d5cea4910f92f Mon Sep 17 00:00:00 2001 From: DPE bot Date: Sun, 7 Feb 2021 05:16:17 -0800 Subject: [PATCH 025/170] Auto-update dependencies. --- messaging/service-worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 62d8b30b..37012e93 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.5/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.5/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.6/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.6/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 25f5a82c6dff073d23692225bf38f4c154831d69 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 8 Feb 2021 01:55:28 -0800 Subject: [PATCH 026/170] Auto-update dependencies. (#102) Co-authored-by: Sam Stern --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 1f7c2809..a0988552 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/auth/package.json b/auth/package.json index 9c757188..16be0875 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.5", + "firebase": "^8.2.6", "firebaseui": "^4.7.3" } } diff --git a/database/package.json b/database/package.json index d1a5c823..5ee62477 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 896fcaff..14c4b5a6 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/firestore/package.json b/firestore/package.json index 4e907d38..c83aec8d 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5", + "firebase": "^8.2.6", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index ba64715b..b51992ce 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/installations/package.json b/installations/package.json index 42db7bac..52328369 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/messaging/package.json b/messaging/package.json index 11ba5bc7..f7cd38d0 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/perf/package.json b/perf/package.json index 7593b96e..62d1460d 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 21becdc2..a4fe3292 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } diff --git a/storage/package.json b/storage/package.json index 23f2231a..fbb15a0f 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.5" + "firebase": "^8.2.6" } } From 1952112596708e2039a571cd97c838a9cf301f34 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 8 Feb 2021 11:42:24 +0000 Subject: [PATCH 027/170] Add missing storage snippets (#104) --- .../storage-next/index/storage_custom_app.js | 8 ++++++- .../storage-next/index/storage_initialize.js | 2 +- .../index/storage_multiple_buckets.js | 5 ++++- storage-next/index.js | 21 ++++++++++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/snippets/storage-next/index/storage_custom_app.js b/snippets/storage-next/index/storage_custom_app.js index 71827148..0c4f26fe 100644 --- a/snippets/storage-next/index/storage_custom_app.js +++ b/snippets/storage-next/index/storage_custom_app.js @@ -4,5 +4,11 @@ // To make edits to the snippets in this file, please edit the source // [START storage_custom_app_modular] -// TODO: Snippet not yet written... +import { getStorage } from "firebase/storage"; + +// Get the default bucket from a custom firebase.app.App +const storage1 = getStorage(customApp); + +// Get a non-default bucket from a custom firebase.app.App +const storage2 = getStorage(customApp, "gs://my-custom-bucket"); // [END storage_custom_app_modular] \ No newline at end of file diff --git a/snippets/storage-next/index/storage_initialize.js b/snippets/storage-next/index/storage_initialize.js index ec69f915..61ad21be 100644 --- a/snippets/storage-next/index/storage_initialize.js +++ b/snippets/storage-next/index/storage_initialize.js @@ -5,7 +5,7 @@ // [START storage_initialize_modular] import { initializeApp } from "firebase/app"; -import { getStorage, uploadBytesResumable } from "firebase/storage"; +import { getStorage } from "firebase/storage"; // Set the configuration for your app // TODO: Replace with your app's config object diff --git a/snippets/storage-next/index/storage_multiple_buckets.js b/snippets/storage-next/index/storage_multiple_buckets.js index 86908130..83c3770e 100644 --- a/snippets/storage-next/index/storage_multiple_buckets.js +++ b/snippets/storage-next/index/storage_multiple_buckets.js @@ -4,5 +4,8 @@ // To make edits to the snippets in this file, please edit the source // [START storage_multiple_buckets_modular] -// TODO: Snippet not yet written... +import { getStorage } from "firebase/storage"; + +// Get a non-default Storage bucket +const storage = getStorage(firebaseApp, "gs://my-custom-bucket"); // [END storage_multiple_buckets_modular] \ No newline at end of file diff --git a/storage-next/index.js b/storage-next/index.js index c5d713cc..1b18b957 100644 --- a/storage-next/index.js +++ b/storage-next/index.js @@ -12,7 +12,7 @@ const firebaseApp = initializeApp({ function initialize() { // [START storage_initialize] const { initializeApp } = require("firebase/app"); - const { getStorage, uploadBytesResumable } = require("firebase/storage"); + const { getStorage } = require("firebase/storage"); // Set the configuration for your app // TODO: Replace with your app's config object @@ -31,13 +31,28 @@ function initialize() { function multipleBuckets() { // [START storage_multiple_buckets] - // TODO: Snippet not yet written... + const { getStorage } = require("firebase/storage"); + + // Get a non-default Storage bucket + const storage = getStorage(firebaseApp, "gs://my-custom-bucket"); // [END storage_multiple_buckets] } function storageCustomApp() { + const { initializeApp } = require("firebase/app"); + + const customApp = initializeApp({ + // ... custom stuff + }); + // [START storage_custom_app] - // TODO: Snippet not yet written... + const { getStorage } = require("firebase/storage"); + + // Get the default bucket from a custom firebase.app.App + const storage1 = getStorage(customApp); + + // Get a non-default bucket from a custom firebase.app.App + const storage2 = getStorage(customApp, "gs://my-custom-bucket"); // [END storage_custom_app] } From a2dc0d922d6321fa8aca4456eb3d0319348b795e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 12 Feb 2021 03:02:14 -0800 Subject: [PATCH 028/170] Auto-update dependencies. (#105) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index a0988552..b2635d82 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/auth/package.json b/auth/package.json index 16be0875..4aab7e8f 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.6", + "firebase": "^8.2.7", "firebaseui": "^4.7.3" } } diff --git a/database/package.json b/database/package.json index 5ee62477..f7be56cc 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 14c4b5a6..1da0806b 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/firestore/package.json b/firestore/package.json index c83aec8d..a908d40b 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6", + "firebase": "^8.2.7", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index b51992ce..4933574a 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/installations/package.json b/installations/package.json index 52328369..c0728c77 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/messaging/package.json b/messaging/package.json index f7cd38d0..89c1df76 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/perf/package.json b/perf/package.json index 62d1460d..9f5c5e3b 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index a4fe3292..f4dc706f 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } diff --git a/storage/package.json b/storage/package.json index fbb15a0f..490d15a4 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.6" + "firebase": "^8.2.7" } } From 9bf44f18df2e8ca8f1052676e2e82c80504504d0 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Fri, 12 Feb 2021 05:16:06 -0800 Subject: [PATCH 029/170] Auto-update dependencies. --- firestore/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index a55dcc9c..2b88c6df 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + From 27cf6bf8f026323ae2081612f74c7d3cf2515ce0 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Fri, 12 Feb 2021 05:16:11 -0800 Subject: [PATCH 030/170] Auto-update dependencies. --- messaging/service-worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 37012e93..682a6c70 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.6/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.6/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.7/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.7/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 1c8d1145cd8ce9665dacbfa2e7ab06ac8984f3e4 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 15 Feb 2021 11:39:05 +0000 Subject: [PATCH 031/170] Auth emulator snippets (#107) --- auth-next/emulator-suite.js | 20 +++++++++++++++++++ auth/emulator-suite.js | 9 +++++++++ .../emulator-suite/auth_emulator_connect.js | 11 ++++++++++ 3 files changed, 40 insertions(+) create mode 100644 auth-next/emulator-suite.js create mode 100644 auth/emulator-suite.js create mode 100644 snippets/auth-next/emulator-suite/auth_emulator_connect.js diff --git a/auth-next/emulator-suite.js b/auth-next/emulator-suite.js new file mode 100644 index 00000000..aca56cff --- /dev/null +++ b/auth-next/emulator-suite.js @@ -0,0 +1,20 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + projectId: '### PROJECT ID ###', + apiKey: '### FIREBASE API KEY ###', + authDomain: '### FIREBASE AUTH DOMAIN ###', +}); + +function emulatorConnect() { + // [START auth_emulator_connect] + const { getAuth, useAuthEmulator } = require("firebase/auth"); + + const auth = getAuth(firebaseApp); + useAuthEmulator(auth, "http://localhost:9099"); + // [END auth_emulator_connect] +} + diff --git a/auth/emulator-suite.js b/auth/emulator-suite.js new file mode 100644 index 00000000..044795a7 --- /dev/null +++ b/auth/emulator-suite.js @@ -0,0 +1,9 @@ +import firebase from "firebase/app"; +import "firebase/auth"; + +function emulatorConnect() { + // [START auth_emulator_connect] + var auth = firebase.auth(); + auth.useEmulator("http://localhost:9099"); + // [END auth_emulator_connect] +} diff --git a/snippets/auth-next/emulator-suite/auth_emulator_connect.js b/snippets/auth-next/emulator-suite/auth_emulator_connect.js new file mode 100644 index 00000000..e2b805ff --- /dev/null +++ b/snippets/auth-next/emulator-suite/auth_emulator_connect.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/emulator-suite.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_emulator_connect_modular] +import { getAuth, useAuthEmulator } from "firebase/auth"; + +const auth = getAuth(firebaseApp); +useAuthEmulator(auth, "http://localhost:9099"); +// [END auth_emulator_connect_modular] \ No newline at end of file From 3bf1495d864cd50e6cf38b7a674ce8ad3cf0e911 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 15 Feb 2021 11:43:55 +0000 Subject: [PATCH 032/170] Add RTDB offline snippets (#98) --- database-next/offline.js | 121 ++++++++++++++++++ database/offline.js | 95 ++++++++++++++ .../offline/rtdb_detect_connection_state.js | 18 +++ .../offline/rtdb_estimate_clock_skew.js | 15 +++ .../offline/rtdb_ondisconnect_callback.js | 12 ++ .../offline/rtdb_ondisconnect_cancel.js | 11 ++ .../offline/rtdb_ondisconnect_simple.js | 13 ++ .../offline/rtdb_sample_presence_app.js | 34 +++++ .../offline/rtdb_set_server_timestamp.js | 12 ++ 9 files changed, 331 insertions(+) create mode 100644 database-next/offline.js create mode 100644 database/offline.js create mode 100644 snippets/database-next/offline/rtdb_detect_connection_state.js create mode 100644 snippets/database-next/offline/rtdb_estimate_clock_skew.js create mode 100644 snippets/database-next/offline/rtdb_ondisconnect_callback.js create mode 100644 snippets/database-next/offline/rtdb_ondisconnect_cancel.js create mode 100644 snippets/database-next/offline/rtdb_ondisconnect_simple.js create mode 100644 snippets/database-next/offline/rtdb_sample_presence_app.js create mode 100644 snippets/database-next/offline/rtdb_set_server_timestamp.js diff --git a/database-next/offline.js b/database-next/offline.js new file mode 100644 index 00000000..461f3854 --- /dev/null +++ b/database-next/offline.js @@ -0,0 +1,121 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +import { initializeApp } from "firebase/app"; + +const firebaseApp = initializeApp({ + apiKey: '### FIREBASE API KEY ###', + appId: '### FIREBASE APP ID ###', + projectId: '### FIREBASE PROJECT ID ###' +}); + +function onDisconnectSimple() { + // [START rtdb_ondisconnect_simple] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const presenceRef = db.ref("disconnectmessage"); + // Write a string when this client loses connection + presenceRef.onDisconnect().set("I disconnected!"); + // [END rtdb_ondisconnect_simple] +} + +function onDisconnectCallback() { + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const presenceRef = db.ref("disconnectmessage"); + + // [START rtdb_ondisconnect_callback] + presenceRef.onDisconnect().remove((err) => { + if (err) { + console.error("could not establish onDisconnect event", err); + } + }); + // [END rtdb_ondisconnect_callback] +} + +function onDisconnectCancel() { + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const presenceRef = db.ref("disconnectmessage"); + + // [START rtdb_ondisconnect_cancel] + const onDisconnectRef = presenceRef.onDisconnect(); + onDisconnectRef.set("I disconnected"); + // some time later when we change our minds + onDisconnectRef.cancel(); + // [END rtdb_ondisconnect_cancel] +} + +function detectConnectionState() { + // [START rtdb_detect_connection_state] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const connectedRef = db.ref(".info/connected"); + connectedRef.on("value", (snap) => { + if (snap.val() === true) { + console.log("connected"); + } else { + console.log("not connected"); + } + }); + // [END rtdb_detect_connection_state] +} + +function setServerTimestamp() { + // [START rtdb_set_server_timestamp] + const { getDatabase, ServerValue } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const userLastOnlineRef = db.ref("users/joe/lastOnline"); + userLastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); + // [END rtdb_set_server_timestamp] +} + +function estimateClockSkew() { + // [START rtdb_estimate_clock_skew] + const { getDatabase } = require("firebase/database"); + + const db = getDatabase(firebaseApp); + const offsetRef = db.ref(".info/serverTimeOffset"); + offsetRef.on("value", (snap) => { + const offset = snap.val(); + const estimatedServerTimeMs = new Date().getTime() + offset; + }); + // [END rtdb_estimate_clock_skew] +} + +function samplePresenceApp() { + // [START rtdb_sample_presence_app] + const { getDatabase, ServerValue } = require("firebase/database"); + + // Since I can connect from multiple devices or browser tabs, we store each connection instance separately + // any time that connectionsRef's value is null (i.e. has no children) I am offline + const db = getDatabase(firebaseApp); + const myConnectionsRef = db.ref('users/joe/connections'); + + // stores the timestamp of my last disconnect (the last time I was seen online) + const lastOnlineRef = db.ref('users/joe/lastOnline'); + + const connectedRef = db.ref('.info/connected'); + connectedRef.on('value', (snap) => { + if (snap.val() === true) { + // We're connected (or reconnected)! Do anything here that should happen only if online (or on reconnect) + const con = myConnectionsRef.push(); + + // When I disconnect, remove this device + con.onDisconnect().remove(); + + // Add this device to my connections list + // this value could contain info about the device or a timestamp too + con.set(true); + + // When I disconnect, update the last time I was seen online + lastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); + } + }); + // [END rtdb_sample_presence_app] +} diff --git a/database/offline.js b/database/offline.js new file mode 100644 index 00000000..66df4825 --- /dev/null +++ b/database/offline.js @@ -0,0 +1,95 @@ +// These samples are intended for Web so this import would normally be +// done in HTML however using modules here is more convenient for +// ensuring sample correctness offline. +import firebase from "firebase/app"; +import "firebase/database"; + +function onDisconnectSimple() { + // [START rtdb_ondisconnect_simple] + var presenceRef = firebase.database().ref("disconnectmessage"); + // Write a string when this client loses connection + presenceRef.onDisconnect().set("I disconnected!"); + // [END rtdb_ondisconnect_simple] +} + +function onDisconnectCallback() { + var presenceRef = firebase.database().ref("disconnectmessage"); + + // [START rtdb_ondisconnect_callback] + presenceRef.onDisconnect().remove((err) => { + if (err) { + console.error("could not establish onDisconnect event", err); + } + }); + // [END rtdb_ondisconnect_callback] +} + +function onDisconnectCancel() { + var presenceRef = firebase.database().ref("disconnectmessage"); + + // [START rtdb_ondisconnect_cancel] + var onDisconnectRef = presenceRef.onDisconnect(); + onDisconnectRef.set("I disconnected"); + // some time later when we change our minds + onDisconnectRef.cancel(); + // [END rtdb_ondisconnect_cancel] +} + +function detectConnectionState() { + // [START rtdb_detect_connection_state] + var connectedRef = firebase.database().ref(".info/connected"); + connectedRef.on("value", (snap) => { + if (snap.val() === true) { + console.log("connected"); + } else { + console.log("not connected"); + } + }); + // [END rtdb_detect_connection_state] +} + +function setServerTimestamp() { + // [START rtdb_set_server_timestamp] + var userLastOnlineRef = firebase.database().ref("users/joe/lastOnline"); + userLastOnlineRef.onDisconnect().set(firebase.database.ServerValue.TIMESTAMP); + // [END rtdb_set_server_timestamp] +} + +function estimateClockSkew() { + // [START rtdb_estimate_clock_skew] + var offsetRef = firebase.database().ref(".info/serverTimeOffset"); + offsetRef.on("value", (snap) => { + var offset = snap.val(); + var estimatedServerTimeMs = new Date().getTime() + offset; + }); + // [END rtdb_estimate_clock_skew] +} + +function samplePresenceApp() { + // [START rtdb_sample_presence_app] + // Since I can connect from multiple devices or browser tabs, we store each connection instance separately + // any time that connectionsRef's value is null (i.e. has no children) I am offline + var myConnectionsRef = firebase.database().ref('users/joe/connections'); + + // stores the timestamp of my last disconnect (the last time I was seen online) + var lastOnlineRef = firebase.database().ref('users/joe/lastOnline'); + + var connectedRef = firebase.database().ref('.info/connected'); + connectedRef.on('value', (snap) => { + if (snap.val() === true) { + // We're connected (or reconnected)! Do anything here that should happen only if online (or on reconnect) + var con = myConnectionsRef.push(); + + // When I disconnect, remove this device + con.onDisconnect().remove(); + + // Add this device to my connections list + // this value could contain info about the device or a timestamp too + con.set(true); + + // When I disconnect, update the last time I was seen online + lastOnlineRef.onDisconnect().set(firebase.database.ServerValue.TIMESTAMP); + } + }); + // [END rtdb_sample_presence_app] +} diff --git a/snippets/database-next/offline/rtdb_detect_connection_state.js b/snippets/database-next/offline/rtdb_detect_connection_state.js new file mode 100644 index 00000000..3756f5be --- /dev/null +++ b/snippets/database-next/offline/rtdb_detect_connection_state.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./database-next/offline.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_detect_connection_state_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const connectedRef = db.ref(".info/connected"); +connectedRef.on("value", (snap) => { + if (snap.val() === true) { + console.log("connected"); + } else { + console.log("not connected"); + } +}); +// [END rtdb_detect_connection_state_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_estimate_clock_skew.js b/snippets/database-next/offline/rtdb_estimate_clock_skew.js new file mode 100644 index 00000000..cdb19491 --- /dev/null +++ b/snippets/database-next/offline/rtdb_estimate_clock_skew.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./database-next/offline.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_estimate_clock_skew_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const offsetRef = db.ref(".info/serverTimeOffset"); +offsetRef.on("value", (snap) => { + const offset = snap.val(); + const estimatedServerTimeMs = new Date().getTime() + offset; +}); +// [END rtdb_estimate_clock_skew_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_ondisconnect_callback.js b/snippets/database-next/offline/rtdb_ondisconnect_callback.js new file mode 100644 index 00000000..6af1ee61 --- /dev/null +++ b/snippets/database-next/offline/rtdb_ondisconnect_callback.js @@ -0,0 +1,12 @@ +// This snippet file was generated by processing the source file: +// ./database-next/offline.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_ondisconnect_callback_modular] +presenceRef.onDisconnect().remove((err) => { + if (err) { + console.error("could not establish onDisconnect event", err); + } +}); +// [END rtdb_ondisconnect_callback_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_ondisconnect_cancel.js b/snippets/database-next/offline/rtdb_ondisconnect_cancel.js new file mode 100644 index 00000000..7af11312 --- /dev/null +++ b/snippets/database-next/offline/rtdb_ondisconnect_cancel.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./database-next/offline.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_ondisconnect_cancel_modular] +const onDisconnectRef = presenceRef.onDisconnect(); +onDisconnectRef.set("I disconnected"); +// some time later when we change our minds +onDisconnectRef.cancel(); +// [END rtdb_ondisconnect_cancel_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_ondisconnect_simple.js b/snippets/database-next/offline/rtdb_ondisconnect_simple.js new file mode 100644 index 00000000..eedfab7f --- /dev/null +++ b/snippets/database-next/offline/rtdb_ondisconnect_simple.js @@ -0,0 +1,13 @@ +// This snippet file was generated by processing the source file: +// ./database-next/offline.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_ondisconnect_simple_modular] +import { getDatabase } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const presenceRef = db.ref("disconnectmessage"); +// Write a string when this client loses connection +presenceRef.onDisconnect().set("I disconnected!"); +// [END rtdb_ondisconnect_simple_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_sample_presence_app.js b/snippets/database-next/offline/rtdb_sample_presence_app.js new file mode 100644 index 00000000..bef04145 --- /dev/null +++ b/snippets/database-next/offline/rtdb_sample_presence_app.js @@ -0,0 +1,34 @@ +// This snippet file was generated by processing the source file: +// ./database-next/offline.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_sample_presence_app_modular] +import { getDatabase, ServerValue } from "firebase/database"; + +// Since I can connect from multiple devices or browser tabs, we store each connection instance separately +// any time that connectionsRef's value is null (i.e. has no children) I am offline +const db = getDatabase(firebaseApp); +const myConnectionsRef = db.ref('users/joe/connections'); + +// stores the timestamp of my last disconnect (the last time I was seen online) +const lastOnlineRef = db.ref('users/joe/lastOnline'); + +const connectedRef = db.ref('.info/connected'); +connectedRef.on('value', (snap) => { + if (snap.val() === true) { + // We're connected (or reconnected)! Do anything here that should happen only if online (or on reconnect) + const con = myConnectionsRef.push(); + + // When I disconnect, remove this device + con.onDisconnect().remove(); + + // Add this device to my connections list + // this value could contain info about the device or a timestamp too + con.set(true); + + // When I disconnect, update the last time I was seen online + lastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); + } +}); +// [END rtdb_sample_presence_app_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_set_server_timestamp.js b/snippets/database-next/offline/rtdb_set_server_timestamp.js new file mode 100644 index 00000000..f9319e07 --- /dev/null +++ b/snippets/database-next/offline/rtdb_set_server_timestamp.js @@ -0,0 +1,12 @@ +// This snippet file was generated by processing the source file: +// ./database-next/offline.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_set_server_timestamp_modular] +import { getDatabase, ServerValue } from "firebase/database"; + +const db = getDatabase(firebaseApp); +const userLastOnlineRef = db.ref("users/joe/lastOnline"); +userLastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); +// [END rtdb_set_server_timestamp_modular] \ No newline at end of file From e0a7847dd12aad5de015f90f874b92ff7a1f42f6 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Wed, 17 Feb 2021 09:50:39 -0500 Subject: [PATCH 033/170] Disable snippets from the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 49015f4f..8b6f50ee 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # Firebase Web Snippets This repository holds code snippets used in Web documentation From 1e85bf60d95b775c2014e8e6f6760df13aa74172 Mon Sep 17 00:00:00 2001 From: Emmanuel Adeboje <46830860+emmanueldevs@users.noreply.github.com> Date: Wed, 17 Feb 2021 18:28:05 +0100 Subject: [PATCH 034/170] Changed typo error (#108) i just changed out the typo on line 24 --- auth/email.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/email.js b/auth/email.js index cdb4bde3..5520f71c 100644 --- a/auth/email.js +++ b/auth/email.js @@ -21,7 +21,7 @@ function signInWithEmailPassword() { // [END auth_signin_password] } -function signUpWithEmailPasswoerd() { +function signUpWithEmailPassword() { var email = "test@example.com"; var password = "hunter2"; // [START auth_signup_password] From e44ad145efd1aac5459bbb41abe8294aeaa9c904 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 19 Feb 2021 03:01:36 -0800 Subject: [PATCH 035/170] Auto-update dependencies. (#109) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index b2635d82..35916cc7 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/auth/package.json b/auth/package.json index 4aab7e8f..068dbbe0 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.7", + "firebase": "^8.2.8", "firebaseui": "^4.7.3" } } diff --git a/database/package.json b/database/package.json index f7be56cc..17ed84e2 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 1da0806b..8b7d0c89 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/firestore/package.json b/firestore/package.json index a908d40b..f9d92f4f 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7", + "firebase": "^8.2.8", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 4933574a..192658a6 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/installations/package.json b/installations/package.json index c0728c77..1d757ce5 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/messaging/package.json b/messaging/package.json index 89c1df76..63917f26 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/perf/package.json b/perf/package.json index 9f5c5e3b..bb72a39f 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index f4dc706f..0a000149 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } diff --git a/storage/package.json b/storage/package.json index 490d15a4..bafa0042 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.7" + "firebase": "^8.2.8" } } From be635d5bf29ae2e6dbe655a2bcc0330332c4cbbb Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 19 Feb 2021 05:23:05 -0800 Subject: [PATCH 036/170] Auto-update dependencies. (#110) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 2b88c6df..5e9a73ea 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 682a6c70..3441b999 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.7/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.7/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.8/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.8/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 174088f73e9ebfa6d8fabe04cbdd1d54d257d9c6 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 22 Feb 2021 02:14:42 -0800 Subject: [PATCH 037/170] Auto-update dependencies. (#112) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 5e9a73ea..a90802c1 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 3441b999..b211b8df 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.8/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.8/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.9/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.9/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 0cb8dac0c5023535b510ebe61e10e727dd598332 Mon Sep 17 00:00:00 2001 From: David East Date: Thu, 25 Feb 2021 15:36:35 -0500 Subject: [PATCH 038/170] Update Firestore Emulator for vNext (#113) * Update Firestore Emulator for vNext * actually run snippets * Fix unknown types for functions --- firestore-next/emulator-suite.js | 13 +++---------- functions-next/callable.js | 8 ++++++-- functions-next/emulator-suite.js | 4 +++- .../emulator-suite/fs_emulator_connect.js | 13 +++---------- .../callable/functions_call_add_message.js | 4 +++- .../callable/functions_call_add_message_error.js | 4 +++- .../emulator-suite/functions_callable_call.js | 4 +++- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/firestore-next/emulator-suite.js b/firestore-next/emulator-suite.js index cbcea744..fbbb9599 100644 --- a/firestore-next/emulator-suite.js +++ b/firestore-next/emulator-suite.js @@ -3,17 +3,10 @@ function onDocumentReady(firebaseApp) { // [START fs_emulator_connect] - const { initializeFirestore } = require("firebase/firestore"); - - let settings = {}; - if (location.hostname === "localhost") { - settings = { - host: "localhost:8080", - ssl: false - }; - } + const { getFirestore, useFirestoreEmulator } = require("firebase/firestore"); // firebaseApps previously initialized using initializeApp() - const db = initializeFirestore(firebaseApp, settings); + const db = getFirestore(firebaseApp); + useFirestoreEmulator(db, 'localhost', 8080); // [END fs_emulator_connect] } diff --git a/functions-next/callable.js b/functions-next/callable.js index 193a3c2e..8a8a56ab 100644 --- a/functions-next/callable.js +++ b/functions-next/callable.js @@ -12,7 +12,9 @@ export function callAddMessage(firebaseApp) { addMessage({ text: messageText }) .then((result) => { // Read result of the Cloud Function. - const sanitizedMessage = result.data.text; + /** @type {any} */ + const data = result.data; + const sanitizedMessage = data.text; }); // [END functions_call_add_message] } @@ -28,7 +30,9 @@ export function callAddMessageError(firebaseApp) { addMessage({ text: messageText }) .then((result) => { // Read result of the Cloud Function. - const sanitizedMessage = result.data.text; + /** @type {any} */ + const data = result.data; + const sanitizedMessage = data.text; }) .catch((error) => { // Getting the Error details. diff --git a/functions-next/emulator-suite.js b/functions-next/emulator-suite.js index 48b6c681..8f1fb043 100644 --- a/functions-next/emulator-suite.js +++ b/functions-next/emulator-suite.js @@ -28,7 +28,9 @@ export async function callFunction() { const addMessage = httpsCallable(functions, 'addMessage'); const result = await addMessage({ text: ''}); - const sanitizedMessage = result.data.text; + /** @type {any} */ + const data = result.data; + const sanitizedMessage = data.text; // ... // [END functions_callable_call] } diff --git a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js index 9824a297..f0984d8b 100644 --- a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js +++ b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js @@ -4,16 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START fs_emulator_connect_modular] -import { initializeFirestore } from "firebase/firestore"; - -let settings = {}; -if (location.hostname === "localhost") { - settings = { - host: "localhost:8080", - ssl: false - }; -} +import { getFirestore, useFirestoreEmulator } from "firebase/firestore"; // firebaseApps previously initialized using initializeApp() -const db = initializeFirestore(firebaseApp, settings); +const db = getFirestore(firebaseApp); +useFirestoreEmulator(db, 'localhost', 8080); // [END fs_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/functions-next/callable/functions_call_add_message.js b/snippets/functions-next/callable/functions_call_add_message.js index 7836b85c..a524ce66 100644 --- a/snippets/functions-next/callable/functions_call_add_message.js +++ b/snippets/functions-next/callable/functions_call_add_message.js @@ -11,6 +11,8 @@ const addMessage = httpsCallable(functions, 'addMessage'); addMessage({ text: messageText }) .then((result) => { // Read result of the Cloud Function. - const sanitizedMessage = result.data.text; + /** @type {any} */ + const data = result.data; + const sanitizedMessage = data.text; }); // [END functions_call_add_message_modular] \ No newline at end of file diff --git a/snippets/functions-next/callable/functions_call_add_message_error.js b/snippets/functions-next/callable/functions_call_add_message_error.js index 84d8a381..ee54b65f 100644 --- a/snippets/functions-next/callable/functions_call_add_message_error.js +++ b/snippets/functions-next/callable/functions_call_add_message_error.js @@ -11,7 +11,9 @@ const addMessage = httpsCallable(functions, 'addMessage'); addMessage({ text: messageText }) .then((result) => { // Read result of the Cloud Function. - const sanitizedMessage = result.data.text; + /** @type {any} */ + const data = result.data; + const sanitizedMessage = data.text; }) .catch((error) => { // Getting the Error details. diff --git a/snippets/functions-next/emulator-suite/functions_callable_call.js b/snippets/functions-next/emulator-suite/functions_callable_call.js index 8ac5f8ed..4174cbdf 100644 --- a/snippets/functions-next/emulator-suite/functions_callable_call.js +++ b/snippets/functions-next/emulator-suite/functions_callable_call.js @@ -11,6 +11,8 @@ const functions = getFunctions(getApp()); const addMessage = httpsCallable(functions, 'addMessage'); const result = await addMessage({ text: ''}); -const sanitizedMessage = result.data.text; +/** @type {any} */ +const data = result.data; +const sanitizedMessage = data.text; // ... // [END functions_callable_call_modular] \ No newline at end of file From cd15fbe80f62ee0658d1a5dd35d9754c6733bb87 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 26 Feb 2021 02:25:28 -0800 Subject: [PATCH 039/170] Auto-update dependencies. (#111) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 35916cc7..bb500b45 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/auth/package.json b/auth/package.json index 068dbbe0..7cc909c4 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.8", + "firebase": "^8.2.9", "firebaseui": "^4.7.3" } } diff --git a/database/package.json b/database/package.json index 17ed84e2..42f00040 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 8b7d0c89..3c8bfa2b 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/firestore/package.json b/firestore/package.json index f9d92f4f..c22f8658 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8", + "firebase": "^8.2.9", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 192658a6..efe52b58 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/installations/package.json b/installations/package.json index 1d757ce5..0e03bf66 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/messaging/package.json b/messaging/package.json index 63917f26..8b31f774 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/perf/package.json b/perf/package.json index bb72a39f..b3d5f11b 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 0a000149..1998fd9f 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } diff --git a/storage/package.json b/storage/package.json index bafa0042..8d950613 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.8" + "firebase": "^8.2.9" } } From 9951802f2817346f113d93ca3bce40535ba804c2 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 5 Mar 2021 03:29:11 -0800 Subject: [PATCH 040/170] Auto-update dependencies. (#115) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index bb500b45..e60e84ae 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/auth/package.json b/auth/package.json index 7cc909c4..103fa2c7 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.9", + "firebase": "^8.2.10", "firebaseui": "^4.7.3" } } diff --git a/database/package.json b/database/package.json index 42f00040..8f7352ef 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 3c8bfa2b..29df45c3 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/firestore/package.json b/firestore/package.json index c22f8658..2e312d95 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9", + "firebase": "^8.2.10", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index efe52b58..84d634fc 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/installations/package.json b/installations/package.json index 0e03bf66..ffdb6bec 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/messaging/package.json b/messaging/package.json index 8b31f774..7783756f 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/perf/package.json b/perf/package.json index b3d5f11b..b04cbe97 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 1998fd9f..9ed4a646 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } diff --git a/storage/package.json b/storage/package.json index 8d950613..9d206aba 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.9" + "firebase": "^8.2.10" } } From 6667c6eb7ea335ac1e37066c8e170a1ee783e8de Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 5 Mar 2021 05:23:02 -0800 Subject: [PATCH 041/170] Auto-update dependencies. (#116) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index a90802c1..552ee0aa 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index b211b8df..d71a58d4 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.9/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.9/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.10/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.2.10/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 9b2526407965d21173f810a559a3013f72117813 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Wed, 10 Mar 2021 02:19:39 -0800 Subject: [PATCH 042/170] Auto-update dependencies. (#117) --- auth/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/package.json b/auth/package.json index 103fa2c7..1b1648ad 100644 --- a/auth/package.json +++ b/auth/package.json @@ -7,6 +7,6 @@ "license": "Apache 2.0", "dependencies": { "firebase": "^8.2.10", - "firebaseui": "^4.7.3" + "firebaseui": "^4.8.0" } } From 2ab4c978ce9b0672d0833f46c6cd5a057efea23c Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 11 Mar 2021 02:46:22 -0800 Subject: [PATCH 043/170] Auto-update dependencies. (#118) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index e60e84ae..59f26bdc 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/auth/package.json b/auth/package.json index 1b1648ad..325eb14e 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.10", + "firebase": "^8.3.0", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 8f7352ef..4ee9aef2 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 29df45c3..5717d947 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/firestore/package.json b/firestore/package.json index 2e312d95..11dd0ac4 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10", + "firebase": "^8.3.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 84d634fc..4e5cf591 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/installations/package.json b/installations/package.json index ffdb6bec..68aa047e 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/messaging/package.json b/messaging/package.json index 7783756f..1a61fafe 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/perf/package.json b/perf/package.json index b04cbe97..45b1bdc2 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 9ed4a646..c13fe2c6 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } diff --git a/storage/package.json b/storage/package.json index 9d206aba..8bcd5013 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.2.10" + "firebase": "^8.3.0" } } From 3f94f3a87fe1e522eca95632c9725c8cdcc5810e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 11 Mar 2021 05:19:03 -0800 Subject: [PATCH 044/170] Auto-update dependencies. (#119) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 552ee0aa..174f14bd 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index d71a58d4..d1869db6 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.2.10/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.2.10/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From a9ac6e6628816293e850eafa6c994a7b9d4d5831 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 12 Mar 2021 10:40:35 -0500 Subject: [PATCH 045/170] Add Firestore bundles snippets (#120) --- firestore-next/test.solution-bundles.js | 50 +++++++++++++++++++ firestore/test.solution-bundles.js | 48 ++++++++++++++++++ .../test-solution-bundles/fs_bundle_load.js | 24 +++++++++ 3 files changed, 122 insertions(+) create mode 100644 firestore-next/test.solution-bundles.js create mode 100644 firestore/test.solution-bundles.js create mode 100644 snippets/firestore-next/test-solution-bundles/fs_bundle_load.js diff --git a/firestore-next/test.solution-bundles.js b/firestore-next/test.solution-bundles.js new file mode 100644 index 00000000..400aeeb8 --- /dev/null +++ b/firestore-next/test.solution-bundles.js @@ -0,0 +1,50 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +const { FirebaseFirestore } = require('firebase/firestore'); + +/** + * @type FirebaseFirestore + */ +var db; + +// [START fs_bundle_load] +const { loadBundle, namedQuery, getDocsFromCache } = require("firebase/firestore"); + +async function fetchFromBundle() { + // Fetch the bundle from Firebase Hosting, if the CDN cache is hit the 'X-Cache' + // response header will be set to 'HIT' + const resp = await fetch('/createBundle'); + + // Load the bundle contents into the Firestore SDK + await loadBundle(db, resp.body); + + // Query the results from the cache + const query = await namedQuery(db, 'latest-stories-query'); + const storiesSnap = await getDocsFromCache(query); + + // Use the results + // ... +} +// [END fs_bundle_load] + +describe("firestore-solution-bundles", () => { + before(() => { + const { initializeApp } = require("firebase/app"); + const { getFirestore} = require("firebase/firestore"); + + const config = { + apiKey: "AIzaSyArvVh6VSdXicubcvIyuB-GZs8ua0m0DTI", + authDomain: "firestorequickstarts.firebaseapp.com", + projectId: "firestorequickstarts", + }; + const app = initializeApp(config, "solution-bundles"); + db = getFirestore(app); + }); + + describe("solution-bundles", () => { + it("should fetch a bundle", (done) => { + fetchFromBundle().finally(done); + }); + }); +}); diff --git a/firestore/test.solution-bundles.js b/firestore/test.solution-bundles.js new file mode 100644 index 00000000..4bece2c8 --- /dev/null +++ b/firestore/test.solution-bundles.js @@ -0,0 +1,48 @@ +// [START fs_bundle_load] +// If you are using module bundlers. +import firebase from "firebase/app"; +import "firebase/firestore"; +import "firebase/firestore/bundle"; // This line enables bundle loading as a side effect. + +// [START_EXCLUDE] +/** + * @type firebase.firestore.Firestore + */ +var db; +// [END_EXCLUDE] + +async function fetchFromBundle() { + // Fetch the bundle from Firebase Hosting, if the CDN cache is hit the 'X-Cache' + // response header will be set to 'HIT' + const resp = await fetch('/createBundle'); + + // Load the bundle contents into the Firestore SDK + await db.loadBundle(resp.body); + + // Query the results from the cache + // Note: omitting "source: cache" will query the Firestore backend. + const query = await db.namedQuery('latest-stories-query'); + const storiesSnap = await query.get({ source: 'cache' }); + + // Use the results + // ... +} +// [END fs_bundle_load] + +describe("firestore-solution-bundles", () => { + before(() => { + var config = { + apiKey: "AIzaSyArvVh6VSdXicubcvIyuB-GZs8ua0m0DTI", + authDomain: "firestorequickstarts.firebaseapp.com", + projectId: "firestorequickstarts", + }; + var app = firebase.initializeApp(config, "solution-bundles"); + db = firebase.firestore(app); + }); + + describe("solution-bundles", () => { + it("should fetch a bundle", (done) => { + fetchFromBundle().finally(done); + }); + }); +}); diff --git a/snippets/firestore-next/test-solution-bundles/fs_bundle_load.js b/snippets/firestore-next/test-solution-bundles/fs_bundle_load.js new file mode 100644 index 00000000..9aa8f430 --- /dev/null +++ b/snippets/firestore-next/test-solution-bundles/fs_bundle_load.js @@ -0,0 +1,24 @@ +// This snippet file was generated by processing the source file: +// ./firestore-next/test.solution-bundles.js +// +// To make edits to the snippets in this file, please edit the source + +// [START fs_bundle_load_modular] +import { loadBundle, namedQuery, getDocsFromCache } from "firebase/firestore"; + +async function fetchFromBundle() { + // Fetch the bundle from Firebase Hosting, if the CDN cache is hit the 'X-Cache' + // response header will be set to 'HIT' + const resp = await fetch('/createBundle'); + + // Load the bundle contents into the Firestore SDK + await loadBundle(db, resp.body); + + // Query the results from the cache + const query = await namedQuery(db, 'latest-stories-query'); + const storiesSnap = await getDocsFromCache(query); + + // Use the results + // ... +} +// [END fs_bundle_load_modular] \ No newline at end of file From 8d7c2207f6f1ff8a767d070f1d690c5627c07094 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 19 Mar 2021 04:02:42 -0700 Subject: [PATCH 046/170] Auto-update dependencies. (#124) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 59f26bdc..5db47115 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/auth/package.json b/auth/package.json index 325eb14e..4fbd49df 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.0", + "firebase": "^8.3.1", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 4ee9aef2..90bf52ee 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 5717d947..e6e46207 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/firestore/package.json b/firestore/package.json index 11dd0ac4..7b7b880d 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0", + "firebase": "^8.3.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 4e5cf591..7a96e04c 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/installations/package.json b/installations/package.json index 68aa047e..216dd060 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/messaging/package.json b/messaging/package.json index 1a61fafe..9b1a8c91 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/perf/package.json b/perf/package.json index 45b1bdc2..9099a7dc 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index c13fe2c6..3a713b76 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } diff --git a/storage/package.json b/storage/package.json index 8bcd5013..f134a6c7 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.0" + "firebase": "^8.3.1" } } From 206ed040feb7f76fd5332cdc8e006c4443884964 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 19 Mar 2021 05:17:48 -0700 Subject: [PATCH 047/170] Auto-update dependencies. (#125) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 174f14bd..11d4c84f 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index d1869db6..7589f6f6 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.3.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.3.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.1/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.1/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From ae35741af1fa521de7b3afcd122e694b1e5766ba Mon Sep 17 00:00:00 2001 From: Grant Timmerman <744973+grant@users.noreply.github.com> Date: Tue, 23 Mar 2021 10:23:02 -0500 Subject: [PATCH 048/170] docs: update region tag prefix to fb_functions_ (#127) --- functions-next/callable.js | 8 ++++---- functions-next/emulator-suite.js | 8 ++++---- functions/callable.js | 8 ++++---- functions/emulator-suite.js | 4 ++-- ...ll_add_message.js => fb_functions_call_add_message.js} | 4 ++-- ...ge_error.js => fb_functions_call_add_message_error.js} | 4 ++-- ...ons_callable_call.js => fb_functions_callable_call.js} | 4 ++-- ...ulator_connect.js => fb_functions_emulator_connect.js} | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) rename snippets/functions-next/callable/{functions_call_add_message.js => fb_functions_call_add_message.js} (85%) rename snippets/functions-next/callable/{functions_call_add_message_error.js => fb_functions_call_add_message_error.js} (86%) rename snippets/functions-next/emulator-suite/{functions_callable_call.js => fb_functions_callable_call.js} (85%) rename snippets/functions-next/emulator-suite/{functions_emulator_connect.js => fb_functions_emulator_connect.js} (80%) diff --git a/functions-next/callable.js b/functions-next/callable.js index 8a8a56ab..4b866cd3 100644 --- a/functions-next/callable.js +++ b/functions-next/callable.js @@ -4,7 +4,7 @@ export function callAddMessage(firebaseApp) { const messageText = "Hello, World!"; - // [START functions_call_add_message] + // [START fb_functions_call_add_message] const { getFunctions, httpsCallable } = require("firebase/functions"); const functions = getFunctions(firebaseApp); @@ -16,13 +16,13 @@ export function callAddMessage(firebaseApp) { const data = result.data; const sanitizedMessage = data.text; }); - // [END functions_call_add_message] + // [END fb_functions_call_add_message] } export function callAddMessageError(firebaseApp) { const messageText = "Hello, World!"; - // [START functions_call_add_message_error] + // [START fb_functions_call_add_message_error] const { getFunctions, httpsCallable } = require("firebase/functions"); const functions = getFunctions(firebaseApp); @@ -41,5 +41,5 @@ export function callAddMessageError(firebaseApp) { const details = error.details; // ... }); - // [END functions_call_add_message_error] + // [END fb_functions_call_add_message_error] } diff --git a/functions-next/emulator-suite.js b/functions-next/emulator-suite.js index 8f1fb043..1f519a2e 100644 --- a/functions-next/emulator-suite.js +++ b/functions-next/emulator-suite.js @@ -10,17 +10,17 @@ initializeApp({ }); export function emulatorSettings() { - // [START functions_emulator_connect] + // [START fb_functions_emulator_connect] const { getApp } = require("firebase/app"); const { getFunctions, useFunctionsEmulator } = require("firebase/functions"); const functions = getFunctions(getApp()); useFunctionsEmulator(functions, "localhost", 5001); - // [END functions_emulator_connect] + // [END fb_functions_emulator_connect] } export async function callFunction() { - // [START functions_callable_call] + // [START fb_functions_callable_call] const { getApp } = require("firebase/app"); const { getFunctions, httpsCallable } = require("firebase/functions"); @@ -32,5 +32,5 @@ export async function callFunction() { const data = result.data; const sanitizedMessage = data.text; // ... - // [END functions_callable_call] + // [END fb_functions_callable_call] } diff --git a/functions/callable.js b/functions/callable.js index 5cb6a515..2b605ae1 100644 --- a/functions/callable.js +++ b/functions/callable.js @@ -4,20 +4,20 @@ import "firebase/functions"; function callAddMessage() { const messageText = "Hello, World!"; - // [START functions_call_add_message] + // [START fb_functions_call_add_message] var addMessage = firebase.functions().httpsCallable('addMessage'); addMessage({ text: messageText }) .then((result) => { // Read result of the Cloud Function. var sanitizedMessage = result.data.text; }); - // [END functions_call_add_message] + // [END fb_functions_call_add_message] } function callAddMessageError() { const messageText = "Hello, World!"; - // [START functions_call_add_message_error] + // [START fb_functions_call_add_message_error] var addMessage = firebase.functions().httpsCallable('addMessage'); addMessage({ text: messageText }) .then((result) => { @@ -31,5 +31,5 @@ function callAddMessageError() { var details = error.details; // ... }); - // [END functions_call_add_message_error] + // [END fb_functions_call_add_message_error] } diff --git a/functions/emulator-suite.js b/functions/emulator-suite.js index e2c244ca..a9cdc7d7 100644 --- a/functions/emulator-suite.js +++ b/functions/emulator-suite.js @@ -2,7 +2,7 @@ import firebase from "firebase/app"; import "firebase/functions"; function emulatorSettings() { - // [START functions_emulator_connect] + // [START fb_functions_emulator_connect] firebase.functions().useEmulator("localhost", 5001); - // [END functions_emulator_connect] + // [END fb_functions_emulator_connect] } diff --git a/snippets/functions-next/callable/functions_call_add_message.js b/snippets/functions-next/callable/fb_functions_call_add_message.js similarity index 85% rename from snippets/functions-next/callable/functions_call_add_message.js rename to snippets/functions-next/callable/fb_functions_call_add_message.js index a524ce66..c2e1b34f 100644 --- a/snippets/functions-next/callable/functions_call_add_message.js +++ b/snippets/functions-next/callable/fb_functions_call_add_message.js @@ -3,7 +3,7 @@ // // To make edits to the snippets in this file, please edit the source -// [START functions_call_add_message_modular] +// [START fb_functions_call_add_message_modular] import { getFunctions, httpsCallable } from "firebase/functions"; const functions = getFunctions(firebaseApp); @@ -15,4 +15,4 @@ addMessage({ text: messageText }) const data = result.data; const sanitizedMessage = data.text; }); -// [END functions_call_add_message_modular] \ No newline at end of file +// [END fb_functions_call_add_message_modular] \ No newline at end of file diff --git a/snippets/functions-next/callable/functions_call_add_message_error.js b/snippets/functions-next/callable/fb_functions_call_add_message_error.js similarity index 86% rename from snippets/functions-next/callable/functions_call_add_message_error.js rename to snippets/functions-next/callable/fb_functions_call_add_message_error.js index ee54b65f..e5186ea9 100644 --- a/snippets/functions-next/callable/functions_call_add_message_error.js +++ b/snippets/functions-next/callable/fb_functions_call_add_message_error.js @@ -3,7 +3,7 @@ // // To make edits to the snippets in this file, please edit the source -// [START functions_call_add_message_error_modular] +// [START fb_functions_call_add_message_error_modular] import { getFunctions, httpsCallable } from "firebase/functions"; const functions = getFunctions(firebaseApp); @@ -22,4 +22,4 @@ addMessage({ text: messageText }) const details = error.details; // ... }); -// [END functions_call_add_message_error_modular] \ No newline at end of file +// [END fb_functions_call_add_message_error_modular] \ No newline at end of file diff --git a/snippets/functions-next/emulator-suite/functions_callable_call.js b/snippets/functions-next/emulator-suite/fb_functions_callable_call.js similarity index 85% rename from snippets/functions-next/emulator-suite/functions_callable_call.js rename to snippets/functions-next/emulator-suite/fb_functions_callable_call.js index 4174cbdf..2619806b 100644 --- a/snippets/functions-next/emulator-suite/functions_callable_call.js +++ b/snippets/functions-next/emulator-suite/fb_functions_callable_call.js @@ -3,7 +3,7 @@ // // To make edits to the snippets in this file, please edit the source -// [START functions_callable_call_modular] +// [START fb_functions_callable_call_modular] import { getApp } from "firebase/app"; import { getFunctions, httpsCallable } from "firebase/functions"; @@ -15,4 +15,4 @@ const result = await addMessage({ text: ''}); const data = result.data; const sanitizedMessage = data.text; // ... -// [END functions_callable_call_modular] \ No newline at end of file +// [END fb_functions_callable_call_modular] \ No newline at end of file diff --git a/snippets/functions-next/emulator-suite/functions_emulator_connect.js b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js similarity index 80% rename from snippets/functions-next/emulator-suite/functions_emulator_connect.js rename to snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js index e9d5fead..62fc3dd2 100644 --- a/snippets/functions-next/emulator-suite/functions_emulator_connect.js +++ b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js @@ -3,10 +3,10 @@ // // To make edits to the snippets in this file, please edit the source -// [START functions_emulator_connect_modular] +// [START fb_functions_emulator_connect_modular] import { getApp } from "firebase/app"; import { getFunctions, useFunctionsEmulator } from "firebase/functions"; const functions = getFunctions(getApp()); useFunctionsEmulator(functions, "localhost", 5001); -// [END functions_emulator_connect_modular] \ No newline at end of file +// [END fb_functions_emulator_connect_modular] \ No newline at end of file From c93b4a40600b0615b72f54d0d585d0a6cd4a0b9d Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 1 Apr 2021 02:32:01 -0700 Subject: [PATCH 049/170] Auto-update dependencies. (#128) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 5db47115..2f87eaf0 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/auth/package.json b/auth/package.json index 4fbd49df..77a36fd2 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.1", + "firebase": "^8.3.2", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 90bf52ee..ab6ad90d 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index e6e46207..caa83383 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/firestore/package.json b/firestore/package.json index 7b7b880d..806fdb30 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1", + "firebase": "^8.3.2", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 7a96e04c..9cda8101 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/installations/package.json b/installations/package.json index 216dd060..1d2f4cec 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/messaging/package.json b/messaging/package.json index 9b1a8c91..8a389487 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/perf/package.json b/perf/package.json index 9099a7dc..7d14e302 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 3a713b76..251d1f2f 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } diff --git a/storage/package.json b/storage/package.json index f134a6c7..2e146416 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.1" + "firebase": "^8.3.2" } } From f61ee63d407f4a71ef9e677284c292b0a083d723 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 1 Apr 2021 05:27:04 -0700 Subject: [PATCH 050/170] Auto-update dependencies. (#129) * Auto-update dependencies. * Auto-update dependencies. --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 11d4c84f..c74ad8de 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 7589f6f6..9392cc13 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.3.1/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.3.1/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From e70c313cb393a23892ba1dd346c4505ea2637cec Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 9 Apr 2021 06:33:41 -0400 Subject: [PATCH 051/170] Update RTDB snippets to new API (#132) --- database-next/emulator-suite.js | 8 +-- database-next/lists-of-data.js | 38 ++++++------ database-next/offline.js | 54 ++++++++--------- database-next/read-and-write.js | 60 ++++++++++--------- .../emulator-suite/rtdb_emulator_connect.js | 4 +- .../emulator-suite/rtdb_emulator_flush.js | 4 +- .../rtdb_social_listen_children.js | 10 ++-- .../lists-of-data/rtdb_social_listen_value.js | 8 ++- .../lists-of-data/rtdb_social_most_starred.js | 4 +- .../lists-of-data/rtdb_social_most_viewed.js | 4 +- .../lists-of-data/rtdb_social_push.js | 8 +-- .../lists-of-data/rtdb_social_recent.js | 4 +- .../offline/rtdb_detect_connection_state.js | 6 +- .../offline/rtdb_estimate_clock_skew.js | 6 +- .../offline/rtdb_ondisconnect_callback.js | 2 +- .../offline/rtdb_ondisconnect_cancel.js | 2 +- .../offline/rtdb_ondisconnect_simple.js | 6 +- .../offline/rtdb_sample_presence_app.js | 18 +++--- .../offline/rtdb_set_server_timestamp.js | 6 +- .../rtdb_social_completion_callback.js | 16 ++--- .../rtdb_social_listen_star_count.js | 6 +- .../rtdb_social_single_value_read.js | 6 +- .../rtdb_social_star_transaction.js | 6 +- .../rtdb_social_write_fan_out.js | 4 +- .../read-and-write/rtdb_write_new_user.js | 4 +- .../rtdb_write_new_user_completion.js | 16 ++--- 26 files changed, 159 insertions(+), 151 deletions(-) diff --git a/database-next/emulator-suite.js b/database-next/emulator-suite.js index cdcf4896..c19f6829 100644 --- a/database-next/emulator-suite.js +++ b/database-next/emulator-suite.js @@ -11,22 +11,22 @@ const firebaseApp = initializeApp({ function onDocumentReady() { // [START rtdb_emulator_connect] - const { getDatabase } = require("firebase/database"); + const { getDatabase, useDatabaseEmulator } = require("firebase/database"); const db = getDatabase(firebaseApp); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. - db.useEmulator("localhost", 9000); + useDatabaseEmulator(db, "localhost", 9000); } // [END rtdb_emulator_connect] } function flushRealtimeDatabase() { // [START rtdb_emulator_flush] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, set } = require("firebase/database"); // With a database Reference, write null to clear the database. const db = getDatabase(firebaseApp); - db.ref().set(null); + set(ref(db), null); // [END rtdb_emulator_flush] } diff --git a/database-next/lists-of-data.js b/database-next/lists-of-data.js index b19371e4..8e47c1dd 100644 --- a/database-next/lists-of-data.js +++ b/database-next/lists-of-data.js @@ -11,13 +11,13 @@ const firebaseApp = initializeApp({ function socialPush() { // [START rtdb_social_push] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, push, set } = require("firebase/database"); // Create a new post reference with an auto-generated id const db = getDatabase(firebaseApp); - const postListRef = db.ref('posts'); - const newPostRef = postListRef.push(); - newPostRef.set({ + const postListRef = ref(db, 'posts'); + const newPostRef = push(postListRef); + set(newPostRef, { // ... }); // [END rtdb_social_push] @@ -31,19 +31,19 @@ function socialListenChildren() { function deleteComment(el, key) {}; // [START rtdb_social_listen_children] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onChildAdded, onChildChanged, onChildRemoved } = require("firebase/database"); const db = getDatabase(firebaseApp); - const commentsRef = db.ref('post-comments/' + postId); - commentsRef.on('child_added', (data) => { + const commentsRef = ref(db, 'post-comments/' + postId); + onChildAdded(commentsRef, (data) => { addCommentElement(postElement, data.key, data.val().text, data.val().author); }); - commentsRef.on('child_changed', (data) => { + onChildChanged(commentsRef, (data) => { setCommentValues(postElement, data.key, data.val().text, data.val().author); }); - commentsRef.on('child_removed', (data) => { + onChildRemoved(commentsRef, (data) => { deleteComment(postElement, data.key); }); // [END rtdb_social_listen_children] @@ -52,48 +52,50 @@ function socialListenChildren() { function socialListenValue() { // [START rtdb_social_listen_value] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onValue } = require("firebase/database"); const db = getDatabase(firebaseApp); - const ref = db.ref('/a/b/c'); + const dbRef = ref(db, '/a/b/c'); - ref.once('value', (snapshot) => { + onValue(dbRef, (snapshot) => { snapshot.forEach((childSnapshot) => { const childKey = childSnapshot.key; const childData = childSnapshot.val(); // ... }); + }, { + onlyOnce: true }); // [END rtdb_social_listen_value] } function socialMostStarred() { // [START rtdb_social_most_starred] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, query, orderByChild } = require("firebase/database"); const { getAuth } = require("firebase/auth"); const db = getDatabase(firebaseApp); const auth = getAuth(firebaseApp); const myUserId = auth.currentUser.uid; - const topUserPostsRef = db.ref('user-posts/' + myUserId).orderByChild('starCount'); + const topUserPostsRef = query(ref(db, 'user-posts/' + myUserId), orderByChild('starCount')); // [END rtdb_social_most_starred] } function socialMostViewed() { // [START rtdb_social_most_viewed] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, query, orderByChild } = require("firebase/database"); const db = getDatabase(firebaseApp); - const mostViewedPosts = db.ref('posts').orderByChild('metrics/views'); + const mostViewedPosts = query(ref(db, 'posts'), orderByChild('metrics/views')); // [END rtdb_social_most_viewed] } function socialRecent() { // [START rtdb_social_recent] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, query, limitToLast } = require("firebase/database"); const db = getDatabase(firebaseApp); - const recentPostsRef = db.ref('posts').limitToLast(100); + const recentPostsRef = query(ref(db, 'posts'), limitToLast(100)); // [END rtdb_social_recent] } diff --git a/database-next/offline.js b/database-next/offline.js index 461f3854..49009268 100644 --- a/database-next/offline.js +++ b/database-next/offline.js @@ -11,23 +11,23 @@ const firebaseApp = initializeApp({ function onDisconnectSimple() { // [START rtdb_ondisconnect_simple] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onDisconnect } = require("firebase/database"); const db = getDatabase(firebaseApp); - const presenceRef = db.ref("disconnectmessage"); + const presenceRef = ref(db, "disconnectmessage"); // Write a string when this client loses connection - presenceRef.onDisconnect().set("I disconnected!"); + onDisconnect(presenceRef).set("I disconnected!"); // [END rtdb_ondisconnect_simple] } function onDisconnectCallback() { - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onDisconnect } = require("firebase/database"); const db = getDatabase(firebaseApp); - const presenceRef = db.ref("disconnectmessage"); + const presenceRef = ref(db, "disconnectmessage"); // [START rtdb_ondisconnect_callback] - presenceRef.onDisconnect().remove((err) => { + onDisconnect(presenceRef).remove().catch((err) => { if (err) { console.error("could not establish onDisconnect event", err); } @@ -36,13 +36,13 @@ function onDisconnectCallback() { } function onDisconnectCancel() { - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onDisconnect } = require("firebase/database"); const db = getDatabase(firebaseApp); - const presenceRef = db.ref("disconnectmessage"); + const presenceRef = ref(db, "disconnectmessage"); // [START rtdb_ondisconnect_cancel] - const onDisconnectRef = presenceRef.onDisconnect(); + const onDisconnectRef = onDisconnect(presenceRef); onDisconnectRef.set("I disconnected"); // some time later when we change our minds onDisconnectRef.cancel(); @@ -51,11 +51,11 @@ function onDisconnectCancel() { function detectConnectionState() { // [START rtdb_detect_connection_state] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onValue } = require("firebase/database"); const db = getDatabase(firebaseApp); - const connectedRef = db.ref(".info/connected"); - connectedRef.on("value", (snap) => { + const connectedRef = ref(db, ".info/connected"); + onValue(connectedRef, (snap) => { if (snap.val() === true) { console.log("connected"); } else { @@ -67,21 +67,21 @@ function detectConnectionState() { function setServerTimestamp() { // [START rtdb_set_server_timestamp] - const { getDatabase, ServerValue } = require("firebase/database"); + const { getDatabase, ref, onDisconnect, serverTimestamp } = require("firebase/database"); const db = getDatabase(firebaseApp); - const userLastOnlineRef = db.ref("users/joe/lastOnline"); - userLastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); + const userLastOnlineRef = ref(db, "users/joe/lastOnline"); + onDisconnect(userLastOnlineRef).set(serverTimestamp()); // [END rtdb_set_server_timestamp] } function estimateClockSkew() { // [START rtdb_estimate_clock_skew] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onValue } = require("firebase/database"); const db = getDatabase(firebaseApp); - const offsetRef = db.ref(".info/serverTimeOffset"); - offsetRef.on("value", (snap) => { + const offsetRef = ref(db, ".info/serverTimeOffset"); + onValue(offsetRef, (snap) => { const offset = snap.val(); const estimatedServerTimeMs = new Date().getTime() + offset; }); @@ -90,31 +90,31 @@ function estimateClockSkew() { function samplePresenceApp() { // [START rtdb_sample_presence_app] - const { getDatabase, ServerValue } = require("firebase/database"); + const { getDatabase, ref, onValue, push, onDisconnect, set, serverTimestamp } = require("firebase/database"); // Since I can connect from multiple devices or browser tabs, we store each connection instance separately // any time that connectionsRef's value is null (i.e. has no children) I am offline const db = getDatabase(firebaseApp); - const myConnectionsRef = db.ref('users/joe/connections'); + const myConnectionsRef = ref(db, 'users/joe/connections'); // stores the timestamp of my last disconnect (the last time I was seen online) - const lastOnlineRef = db.ref('users/joe/lastOnline'); + const lastOnlineRef = ref(db, 'users/joe/lastOnline'); - const connectedRef = db.ref('.info/connected'); - connectedRef.on('value', (snap) => { + const connectedRef = ref(db, '.info/connected'); + onValue(connectedRef, (snap) => { if (snap.val() === true) { // We're connected (or reconnected)! Do anything here that should happen only if online (or on reconnect) - const con = myConnectionsRef.push(); + const con = push(myConnectionsRef); // When I disconnect, remove this device - con.onDisconnect().remove(); + onDisconnect(con).remove(); // Add this device to my connections list // this value could contain info about the device or a timestamp too - con.set(true); + set(con, true); // When I disconnect, update the last time I was seen online - lastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); + onDisconnect(lastOnlineRef).set(serverTimestamp()); } }); // [END rtdb_sample_presence_app] diff --git a/database-next/read-and-write.js b/database-next/read-and-write.js index 6d890183..6e3ac273 100644 --- a/database-next/read-and-write.js +++ b/database-next/read-and-write.js @@ -11,11 +11,11 @@ const firebaseApp = initializeApp({ function writeUserData_wrapped() { // [START rtdb_write_new_user] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, set} = require("firebase/database"); function writeUserData(userId, name, email, imageUrl) { const db = getDatabase(firebaseApp); - db.ref('users/' + userId).set({ + set(ref(db, 'users/' + userId), { username: name, email: email, profile_picture : imageUrl @@ -27,19 +27,19 @@ function writeUserData_wrapped() { function writeUserDataWithCompletion(userId, name, email, imageUrl) { // [START rtdb_write_new_user_completion] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, set } = require("firebase/database"); const db = getDatabase(firebaseApp); - db.ref('users/' + userId).set({ + set(ref(db, 'users/' + userId), { username: name, email: email, profile_picture : imageUrl - }, (error) => { - if (error) { - // The write failed... - } else { - // Data saved successfully! - } + }) + .then(() => { + // Data saved successfully! + }) + .catch((error) => { + // The write failed... }); // [END rtdb_write_new_user_completion] } @@ -52,11 +52,11 @@ function socialListenStarCount() { } // [START rtdb_social_listen_star_count] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onValue} = require("firebase/database"); const db = getDatabase(firebaseApp); - const starCountRef = db.ref('posts/' + postId + '/starCount'); - starCountRef.on('value', (snapshot) => { + const starCountRef = ref(db, 'posts/' + postId + '/starCount'); + onValue(starCountRef, (snapshot) => { const data = snapshot.val(); updateStarCount(postElement, data); }); @@ -65,22 +65,24 @@ function socialListenStarCount() { function socialSingleValueRead() { // [START rtdb_social_single_value_read] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, onValue } = require("firebase/database"); const { getAuth } = require("firebase/auth"); const db = getDatabase(firebaseApp); const auth = getAuth(firebaseApp); const userId = auth.currentUser.uid; - return db.ref('/users/' + userId).once('value').then((snapshot) => { + return onValue(ref(db, '/users/' + userId), (snapshot) => { const username = (snapshot.val() && snapshot.val().username) || 'Anonymous'; // ... + }, { + onlyOnce: true }); // [END rtdb_social_single_value_read] } function writeNewPost_wrapped() { - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, child, push, update } = require("firebase/database"); // [START rtdb_social_write_fan_out] function writeNewPost(uid, username, picture, title, body) { @@ -97,14 +99,14 @@ function writeNewPost_wrapped() { }; // Get a key for a new Post. - const newPostKey = db.ref().child('posts').push().key; + const newPostKey = push(child(ref(db), 'posts')).key; // Write the new post's data simultaneously in the posts list and the user's post list. const updates = {}; updates['/posts/' + newPostKey] = postData; updates['/user-posts/' + uid + '/' + newPostKey] = postData; - return db.ref().update(updates); + return update(ref(db), updates); } // [END rtdb_social_write_fan_out] } @@ -115,32 +117,32 @@ function socialCompletionCallback() { const imageUrl = "https://example.com/image.png"; // [START rtdb_social_completion_callback] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, set } = require("firebase/database"); const db = getDatabase(firebaseApp); - db.ref('users/' + userId).set({ + set(ref(db, 'users/' + userId), { username: name, email: email, profile_picture : imageUrl - }, (error) => { - if (error) { - // The write failed... - } else { - // Data saved successfully! - } + }) + .then(() => { + // Data saved successfully! + }) + .catch((error) => { + // The write failed... }); // [END rtdb_social_completion_callback] } function toggleStar_wrapped() { // [START rtdb_social_star_transaction] - const { getDatabase } = require("firebase/database"); + const { getDatabase, ref, runTransaction } = require("firebase/database"); function toggleStar(uid) { const db = getDatabase(firebaseApp); - const postRef = db.ref('/posts/foo-bar-123'); + const postRef = ref(db, '/posts/foo-bar-123'); - postRef.transaction((post) => { + runTransaction(postRef, (post) => { if (post) { if (post.stars && post.stars[uid]) { post.starCount--; diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js index c16f0210..b666d9b1 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js @@ -4,11 +4,11 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_emulator_connect_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, useDatabaseEmulator } from "firebase/database"; const db = getDatabase(firebaseApp); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. - db.useEmulator("localhost", 9000); + useDatabaseEmulator(db, "localhost", 9000); } // [END rtdb_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_flush.js b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js index 66f8b282..5f0e3f5c 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_flush.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_emulator_flush_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, set } from "firebase/database"; // With a database Reference, write null to clear the database. const db = getDatabase(firebaseApp); -db.ref().set(null); +set(ref(db), null); // [END rtdb_emulator_flush_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_children.js b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js index 5aefb875..a527edeb 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_listen_children.js +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js @@ -4,19 +4,19 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_listen_children_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, onChildAdded, onChildChanged, onChildRemoved } from "firebase/database"; const db = getDatabase(firebaseApp); -const commentsRef = db.ref('post-comments/' + postId); -commentsRef.on('child_added', (data) => { +const commentsRef = ref(db, 'post-comments/' + postId); +onChildAdded(commentsRef, (data) => { addCommentElement(postElement, data.key, data.val().text, data.val().author); }); -commentsRef.on('child_changed', (data) => { +onChildChanged(commentsRef, (data) => { setCommentValues(postElement, data.key, data.val().text, data.val().author); }); -commentsRef.on('child_removed', (data) => { +onChildRemoved(commentsRef, (data) => { deleteComment(postElement, data.key); }); // [END rtdb_social_listen_children_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_value.js b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js index 3958a0d9..7250cc86 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_listen_value.js +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js @@ -4,16 +4,18 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_listen_value_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, onValue } from "firebase/database"; const db = getDatabase(firebaseApp); -const ref = db.ref('/a/b/c'); +const dbRef = ref(db, '/a/b/c'); -ref.once('value', (snapshot) => { +onValue(dbRef, (snapshot) => { snapshot.forEach((childSnapshot) => { const childKey = childSnapshot.key; const childData = childSnapshot.val(); // ... }); +}, { + onlyOnce: true }); // [END rtdb_social_listen_value_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_starred.js b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js index 8c20de7a..96354b52 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_most_starred.js +++ b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js @@ -4,12 +4,12 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_most_starred_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, query, orderByChild } from "firebase/database"; import { getAuth } from "firebase/auth"; const db = getDatabase(firebaseApp); const auth = getAuth(firebaseApp); const myUserId = auth.currentUser.uid; -const topUserPostsRef = db.ref('user-posts/' + myUserId).orderByChild('starCount'); +const topUserPostsRef = query(ref(db, 'user-posts/' + myUserId), orderByChild('starCount')); // [END rtdb_social_most_starred_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js index 2f5c03f8..3d661562 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js +++ b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js @@ -4,8 +4,8 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_most_viewed_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, query, orderByChild } from "firebase/database"; const db = getDatabase(firebaseApp); -const mostViewedPosts = db.ref('posts').orderByChild('metrics/views'); +const mostViewedPosts = query(ref(db, 'posts'), orderByChild('metrics/views')); // [END rtdb_social_most_viewed_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_push.js b/snippets/database-next/lists-of-data/rtdb_social_push.js index e3c7f81c..313ff67c 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_push.js +++ b/snippets/database-next/lists-of-data/rtdb_social_push.js @@ -4,13 +4,13 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_push_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, push, set } from "firebase/database"; // Create a new post reference with an auto-generated id const db = getDatabase(firebaseApp); -const postListRef = db.ref('posts'); -const newPostRef = postListRef.push(); -newPostRef.set({ +const postListRef = ref(db, 'posts'); +const newPostRef = push(postListRef); +set(newPostRef, { // ... }); // [END rtdb_social_push_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_recent.js b/snippets/database-next/lists-of-data/rtdb_social_recent.js index 58fa2e38..a946817f 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_recent.js +++ b/snippets/database-next/lists-of-data/rtdb_social_recent.js @@ -4,8 +4,8 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_recent_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, query, limitToLast } from "firebase/database"; const db = getDatabase(firebaseApp); -const recentPostsRef = db.ref('posts').limitToLast(100); +const recentPostsRef = query(ref(db, 'posts'), limitToLast(100)); // [END rtdb_social_recent_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_detect_connection_state.js b/snippets/database-next/offline/rtdb_detect_connection_state.js index 3756f5be..b2bedd44 100644 --- a/snippets/database-next/offline/rtdb_detect_connection_state.js +++ b/snippets/database-next/offline/rtdb_detect_connection_state.js @@ -4,11 +4,11 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_detect_connection_state_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, onValue } from "firebase/database"; const db = getDatabase(firebaseApp); -const connectedRef = db.ref(".info/connected"); -connectedRef.on("value", (snap) => { +const connectedRef = ref(db, ".info/connected"); +onValue(connectedRef, (snap) => { if (snap.val() === true) { console.log("connected"); } else { diff --git a/snippets/database-next/offline/rtdb_estimate_clock_skew.js b/snippets/database-next/offline/rtdb_estimate_clock_skew.js index cdb19491..0d7fea48 100644 --- a/snippets/database-next/offline/rtdb_estimate_clock_skew.js +++ b/snippets/database-next/offline/rtdb_estimate_clock_skew.js @@ -4,11 +4,11 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_estimate_clock_skew_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, onValue } from "firebase/database"; const db = getDatabase(firebaseApp); -const offsetRef = db.ref(".info/serverTimeOffset"); -offsetRef.on("value", (snap) => { +const offsetRef = ref(db, ".info/serverTimeOffset"); +onValue(offsetRef, (snap) => { const offset = snap.val(); const estimatedServerTimeMs = new Date().getTime() + offset; }); diff --git a/snippets/database-next/offline/rtdb_ondisconnect_callback.js b/snippets/database-next/offline/rtdb_ondisconnect_callback.js index 6af1ee61..6b7f2950 100644 --- a/snippets/database-next/offline/rtdb_ondisconnect_callback.js +++ b/snippets/database-next/offline/rtdb_ondisconnect_callback.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_ondisconnect_callback_modular] -presenceRef.onDisconnect().remove((err) => { +onDisconnect(presenceRef).remove().catch((err) => { if (err) { console.error("could not establish onDisconnect event", err); } diff --git a/snippets/database-next/offline/rtdb_ondisconnect_cancel.js b/snippets/database-next/offline/rtdb_ondisconnect_cancel.js index 7af11312..f5c3c972 100644 --- a/snippets/database-next/offline/rtdb_ondisconnect_cancel.js +++ b/snippets/database-next/offline/rtdb_ondisconnect_cancel.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_ondisconnect_cancel_modular] -const onDisconnectRef = presenceRef.onDisconnect(); +const onDisconnectRef = onDisconnect(presenceRef); onDisconnectRef.set("I disconnected"); // some time later when we change our minds onDisconnectRef.cancel(); diff --git a/snippets/database-next/offline/rtdb_ondisconnect_simple.js b/snippets/database-next/offline/rtdb_ondisconnect_simple.js index eedfab7f..838ab744 100644 --- a/snippets/database-next/offline/rtdb_ondisconnect_simple.js +++ b/snippets/database-next/offline/rtdb_ondisconnect_simple.js @@ -4,10 +4,10 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_ondisconnect_simple_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, onDisconnect } from "firebase/database"; const db = getDatabase(firebaseApp); -const presenceRef = db.ref("disconnectmessage"); +const presenceRef = ref(db, "disconnectmessage"); // Write a string when this client loses connection -presenceRef.onDisconnect().set("I disconnected!"); +onDisconnect(presenceRef).set("I disconnected!"); // [END rtdb_ondisconnect_simple_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_sample_presence_app.js b/snippets/database-next/offline/rtdb_sample_presence_app.js index bef04145..e093238e 100644 --- a/snippets/database-next/offline/rtdb_sample_presence_app.js +++ b/snippets/database-next/offline/rtdb_sample_presence_app.js @@ -4,31 +4,31 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_sample_presence_app_modular] -import { getDatabase, ServerValue } from "firebase/database"; +import { getDatabase, ref, onValue, push, onDisconnect, set, serverTimestamp } from "firebase/database"; // Since I can connect from multiple devices or browser tabs, we store each connection instance separately // any time that connectionsRef's value is null (i.e. has no children) I am offline const db = getDatabase(firebaseApp); -const myConnectionsRef = db.ref('users/joe/connections'); +const myConnectionsRef = ref(db, 'users/joe/connections'); // stores the timestamp of my last disconnect (the last time I was seen online) -const lastOnlineRef = db.ref('users/joe/lastOnline'); +const lastOnlineRef = ref(db, 'users/joe/lastOnline'); -const connectedRef = db.ref('.info/connected'); -connectedRef.on('value', (snap) => { +const connectedRef = ref(db, '.info/connected'); +onValue(connectedRef, (snap) => { if (snap.val() === true) { // We're connected (or reconnected)! Do anything here that should happen only if online (or on reconnect) - const con = myConnectionsRef.push(); + const con = push(myConnectionsRef); // When I disconnect, remove this device - con.onDisconnect().remove(); + onDisconnect(con).remove(); // Add this device to my connections list // this value could contain info about the device or a timestamp too - con.set(true); + set(con, true); // When I disconnect, update the last time I was seen online - lastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); + onDisconnect(lastOnlineRef).set(serverTimestamp()); } }); // [END rtdb_sample_presence_app_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_set_server_timestamp.js b/snippets/database-next/offline/rtdb_set_server_timestamp.js index f9319e07..14850121 100644 --- a/snippets/database-next/offline/rtdb_set_server_timestamp.js +++ b/snippets/database-next/offline/rtdb_set_server_timestamp.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_set_server_timestamp_modular] -import { getDatabase, ServerValue } from "firebase/database"; +import { getDatabase, ref, onDisconnect, serverTimestamp } from "firebase/database"; const db = getDatabase(firebaseApp); -const userLastOnlineRef = db.ref("users/joe/lastOnline"); -userLastOnlineRef.onDisconnect().set(ServerValue.TIMESTAMP); +const userLastOnlineRef = ref(db, "users/joe/lastOnline"); +onDisconnect(userLastOnlineRef).set(serverTimestamp()); // [END rtdb_set_server_timestamp_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_completion_callback.js b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js index 5251b5c4..cb22a488 100644 --- a/snippets/database-next/read-and-write/rtdb_social_completion_callback.js +++ b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js @@ -4,18 +4,18 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_completion_callback_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, set } from "firebase/database"; const db = getDatabase(firebaseApp); -db.ref('users/' + userId).set({ +set(ref(db, 'users/' + userId), { username: name, email: email, profile_picture : imageUrl -}, (error) => { - if (error) { - // The write failed... - } else { - // Data saved successfully! - } +}) +.then(() => { + // Data saved successfully! +}) +.catch((error) => { + // The write failed... }); // [END rtdb_social_completion_callback_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js index 186afb4f..3a7c7e85 100644 --- a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js +++ b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js @@ -4,11 +4,11 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_listen_star_count_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, onValue} from "firebase/database"; const db = getDatabase(firebaseApp); -const starCountRef = db.ref('posts/' + postId + '/starCount'); -starCountRef.on('value', (snapshot) => { +const starCountRef = ref(db, 'posts/' + postId + '/starCount'); +onValue(starCountRef, (snapshot) => { const data = snapshot.val(); updateStarCount(postElement, data); }); diff --git a/snippets/database-next/read-and-write/rtdb_social_single_value_read.js b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js index b5bfc662..5e68d8c1 100644 --- a/snippets/database-next/read-and-write/rtdb_social_single_value_read.js +++ b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js @@ -4,15 +4,17 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_single_value_read_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, onValue } from "firebase/database"; import { getAuth } from "firebase/auth"; const db = getDatabase(firebaseApp); const auth = getAuth(firebaseApp); const userId = auth.currentUser.uid; -return db.ref('/users/' + userId).once('value').then((snapshot) => { +return onValue(ref(db, '/users/' + userId), (snapshot) => { const username = (snapshot.val() && snapshot.val().username) || 'Anonymous'; // ... +}, { + onlyOnce: true }); // [END rtdb_social_single_value_read_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_star_transaction.js b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js index 9c905d2c..9f0679a8 100644 --- a/snippets/database-next/read-and-write/rtdb_social_star_transaction.js +++ b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js @@ -4,13 +4,13 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_social_star_transaction_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, runTransaction } from "firebase/database"; function toggleStar(uid) { const db = getDatabase(firebaseApp); - const postRef = db.ref('/posts/foo-bar-123'); + const postRef = ref(db, '/posts/foo-bar-123'); - postRef.transaction((post) => { + runTransaction(postRef, (post) => { if (post) { if (post.stars && post.stars[uid]) { post.starCount--; diff --git a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js index 0c2973c4..d51a23eb 100644 --- a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js +++ b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js @@ -18,13 +18,13 @@ function writeNewPost(uid, username, picture, title, body) { }; // Get a key for a new Post. - const newPostKey = db.ref().child('posts').push().key; + const newPostKey = push(child(ref(db), 'posts')).key; // Write the new post's data simultaneously in the posts list and the user's post list. const updates = {}; updates['/posts/' + newPostKey] = postData; updates['/user-posts/' + uid + '/' + newPostKey] = postData; - return db.ref().update(updates); + return update(ref(db), updates); } // [END rtdb_social_write_fan_out_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user.js b/snippets/database-next/read-and-write/rtdb_write_new_user.js index c6a84358..85f0ad83 100644 --- a/snippets/database-next/read-and-write/rtdb_write_new_user.js +++ b/snippets/database-next/read-and-write/rtdb_write_new_user.js @@ -4,11 +4,11 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_write_new_user_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, set} from "firebase/database"; function writeUserData(userId, name, email, imageUrl) { const db = getDatabase(firebaseApp); - db.ref('users/' + userId).set({ + set(ref(db, 'users/' + userId), { username: name, email: email, profile_picture : imageUrl diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js index cd10104d..41dffc81 100644 --- a/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js +++ b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js @@ -4,18 +4,18 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_write_new_user_completion_modular] -import { getDatabase } from "firebase/database"; +import { getDatabase, ref, set } from "firebase/database"; const db = getDatabase(firebaseApp); -db.ref('users/' + userId).set({ +set(ref(db, 'users/' + userId), { username: name, email: email, profile_picture : imageUrl -}, (error) => { - if (error) { - // The write failed... - } else { - // Data saved successfully! - } +}) +.then(() => { + // Data saved successfully! +}) +.catch((error) => { + // The write failed... }); // [END rtdb_write_new_user_completion_modular] \ No newline at end of file From 554bf3657a9a4f68539af36a3736e281f05f83e4 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 9 Apr 2021 06:44:55 -0400 Subject: [PATCH 052/170] Add RTDB get() snippet (#133) --- database-next/read-and-write.js | 16 ++++++++++++++++ database/read-and-write.js | 15 +++++++++++++++ .../read-and-write/rtdb_read_once_get.js | 19 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 snippets/database-next/read-and-write/rtdb_read_once_get.js diff --git a/database-next/read-and-write.js b/database-next/read-and-write.js index 6e3ac273..db7da0db 100644 --- a/database-next/read-and-write.js +++ b/database-next/read-and-write.js @@ -161,3 +161,19 @@ function toggleStar_wrapped() { // [END rtdb_social_star_transaction] } +function readOnceWithGet(userId) { + // [START rtdb_read_once_get] + const { getDatabase, ref, child, get } = require("firebase/database"); + + const dbRef = ref(getDatabase(firebaseApp)); + get(child(dbRef, `users/${userId}`)).then((snapshot) => { + if (snapshot.exists()) { + console.log(snapshot.val()); + } else { + console.log("No data available"); + } + }).catch((error) => { + console.error(error); + }); + // [END rtdb_read_once_get] +} diff --git a/database/read-and-write.js b/database/read-and-write.js index 59336c8f..e14b741b 100644 --- a/database/read-and-write.js +++ b/database/read-and-write.js @@ -123,3 +123,18 @@ function toggleStar(postRef, uid) { }); } // [END rtdb_social_star_transaction] + +function readOnceWithGet(userId) { + // [START rtdb_read_once_get] + const dbRef = firebase.database().ref(); + dbRef.child("users").child(userId).get().then((snapshot) => { + if (snapshot.exists()) { + console.log(snapshot.val()); + } else { + console.log("No data available"); + } + }).catch((error) => { + console.error(error); + }); + // [END rtdb_read_once_get] +} diff --git a/snippets/database-next/read-and-write/rtdb_read_once_get.js b/snippets/database-next/read-and-write/rtdb_read_once_get.js new file mode 100644 index 00000000..13799f3a --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_read_once_get.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_read_once_get_modular] +import { getDatabase, ref, child, get } from "firebase/database"; + +const dbRef = ref(getDatabase(firebaseApp)); +get(child(dbRef, `users/${userId}`)).then((snapshot) => { + if (snapshot.exists()) { + console.log(snapshot.val()); + } else { + console.log("No data available"); + } +}).catch((error) => { + console.error(error); +}); +// [END rtdb_read_once_get_modular] \ No newline at end of file From 8afe3fad0bca9d6ecc49dbfb20bbe4719be1da2c Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 9 Apr 2021 04:15:23 -0700 Subject: [PATCH 053/170] Auto-update dependencies. (#131) Co-authored-by: Sam Stern --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 2f87eaf0..3883772f 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/auth/package.json b/auth/package.json index 77a36fd2..bb6f53ad 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.2", + "firebase": "^8.3.3", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index ab6ad90d..52076305 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index caa83383..4e0c769f 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/firestore/package.json b/firestore/package.json index 806fdb30..788d5a65 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2", + "firebase": "^8.3.3", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 9cda8101..68327016 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/installations/package.json b/installations/package.json index 1d2f4cec..2c2ac3bf 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/messaging/package.json b/messaging/package.json index 8a389487..c53fa8c6 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/perf/package.json b/perf/package.json index 7d14e302..3fda34fd 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 251d1f2f..45a411e2 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } diff --git a/storage/package.json b/storage/package.json index 2e146416..b777b198 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.2" + "firebase": "^8.3.3" } } From d9fbdfc0e39725e16c6d720ba04e801baf94fd4c Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 9 Apr 2021 08:36:54 -0400 Subject: [PATCH 054/170] Remove default app where possible (#135) --- analytics-next/ecommerce.js | 33 +++++++------------ analytics-next/index.js | 16 +++------ auth-next/anonymous.js | 10 +----- auth-next/apple.js | 20 ++++------- auth-next/auth-state-persistence.js | 12 ++----- auth-next/cordova.js | 12 ++----- auth-next/custom-email-handler.js | 8 ----- auth-next/custom.js | 10 +----- auth-next/email-link-auth.js | 18 +++------- auth-next/email.js | 16 +++------ auth-next/emulator-suite.js | 10 +----- auth-next/facebook.js | 16 +++------ auth-next/github.js | 12 ++----- auth-next/google-signin.js | 16 +++------ auth-next/index.js | 18 +++------- auth-next/link-multiple-accounts.js | 20 ++++------- auth-next/microsoft-oauth.js | 18 +++------- auth-next/phone-auth.js | 16 +++------ auth-next/service-worker-sessions.js | 14 ++------ auth-next/twitter.js | 12 ++----- auth-next/yahoo-oauth.js | 18 +++------- database-next/emulator-suite.js | 12 ++----- database-next/index.js | 10 +----- database-next/lists-of-data.js | 22 ++++--------- database-next/offline.js | 22 ++++--------- database-next/read-and-write.js | 28 ++++++---------- firestore-next/emulator-suite.js | 4 +-- functions-next/callable.js | 6 ++-- messaging-next/index.js | 16 +++------ perf-next/index.js | 13 ++------ remoteconfig-next/index.js | 10 +----- .../ecommerce/analytics_ecommerce_add_cart.js | 2 +- .../ecommerce/analytics_ecommerce_checkout.js | 2 +- .../analytics_ecommerce_payment_info.js | 2 +- .../analytics_ecommerce_promotions.js | 2 +- .../ecommerce/analytics_ecommerce_purchase.js | 2 +- .../ecommerce/analytics_ecommerce_refund.js | 2 +- .../analytics_ecommerce_remove_cart.js | 2 +- .../analytics_ecommerce_select_item.js | 2 +- .../analytics_ecommerce_shipping_info.js | 2 +- .../analytics_ecommerce_view_cart.js | 2 +- .../analytics_ecommerce_view_item_details.js | 2 +- .../analytics_ecommerce_view_item_list.js | 2 +- .../index/analytics_initialize.js | 2 +- .../index/analytics_log_event.js | 2 +- .../analytics_log_event_custom_params.js | 2 +- .../index/analytics_log_event_params.js | 2 +- .../index/analytics_set_user_properties.js | 2 +- .../auth-next/anonymous/auth_anon_sign_in.js | 2 +- .../apple/auth_apple_link_facebook.js | 2 +- .../apple/auth_apple_reauthenticate_popup.js | 2 +- .../apple/auth_apple_signin_nonce.js | 2 +- .../apple/auth_apple_signin_popup.js | 2 +- .../apple/auth_apple_signin_redirect.js | 2 +- .../auth_apple_signin_redirect_result.js | 2 +- .../auth_set_persistence_none.js | 2 +- .../auth_set_persistence_session.js | 2 +- .../cordova/auth_cordova_redirect_result.js | 2 +- .../cordova/auth_cordova_sign_in_redirect.js | 2 +- .../auth-next/custom/auth_sign_in_custom.js | 2 +- .../email-link-auth/auth_email_link_link.js | 2 +- .../email-link-auth/auth_email_link_reauth.js | 2 +- .../email-link-auth/auth_email_link_send.js | 2 +- .../email-link-auth/email_link_complete.js | 2 +- .../email_link_diferentiate.js | 2 +- .../email/auth_send_email_verification.js | 2 +- .../email/auth_send_password_reset.js | 2 +- .../auth-next/email/auth_signin_password.js | 2 +- .../auth-next/email/auth_signup_password.js | 2 +- .../emulator-suite/auth_emulator_connect.js | 2 +- .../facebook/auth_facebook_callback.js | 2 +- .../auth_facebook_signin_credential.js | 2 +- .../facebook/auth_facebook_signin_popup.js | 2 +- .../auth_facebook_signin_redirect_result.js | 2 +- .../github/auth_github_signin_popup.js | 2 +- .../auth_github_signin_redirect_result.js | 2 +- .../google-signin/auth_google_build_signin.js | 2 +- .../google-signin/auth_google_callback.js | 2 +- .../google-signin/auth_google_signin_popup.js | 2 +- .../auth_google_signin_redirect_result.js | 2 +- .../auth-next/index/auth_set_language_code.js | 2 +- snippets/auth-next/index/auth_sign_out.js | 2 +- .../auth-next/index/auth_signin_credential.js | 2 +- .../auth-next/index/auth_signin_redirect.js | 2 +- .../auth-next/index/auth_state_listener.js | 2 +- .../auth_anonymous_link.js | 2 +- .../auth_link_with_popup.js | 2 +- .../auth_link_with_redirect.js | 2 +- .../auth_merge_accounts.js | 2 +- .../auth_simple_link.js | 2 +- .../auth_unlink_provider.js | 2 +- .../microsoft-oauth/auth_msft_link_popup.js | 2 +- .../microsoft-oauth/auth_msft_reauth_popup.js | 2 +- .../microsoft-oauth/auth_msft_signin_popup.js | 2 +- .../auth_msft_signin_redirect.js | 2 +- .../auth_msft_signin_redirect_result.js | 2 +- ...auth_phone_recaptcha_verifier_invisible.js | 2 +- .../auth_phone_recaptcha_verifier_simple.js | 2 +- .../auth_phone_recaptcha_verifier_visible.js | 2 +- .../auth-next/phone-auth/auth_phone_signin.js | 2 +- .../auth_svc_get_idtoken.js | 2 +- .../auth_svc_sign_in_email.js | 2 +- .../auth_svc_subscribe.js | 2 +- .../twitter/auth_twitter_signin_popup.js | 2 +- .../auth_twitter_signin_redirect_result.js | 2 +- .../yahoo-oauth/auth_yahoo_link_popup.js | 2 +- .../yahoo-oauth/auth_yahoo_reauth_popup.js | 2 +- .../yahoo-oauth/auth_yahoo_signin_popup.js | 2 +- .../yahoo-oauth/auth_yahoo_signin_redirect.js | 2 +- .../auth_yahoo_signin_redirect_result.js | 2 +- .../emulator-suite/rtdb_emulator_connect.js | 2 +- .../emulator-suite/rtdb_emulator_flush.js | 2 +- .../database-next/index/rtdb_get_reference.js | 2 +- .../rtdb_social_listen_children.js | 2 +- .../lists-of-data/rtdb_social_listen_value.js | 2 +- .../lists-of-data/rtdb_social_most_starred.js | 4 +-- .../lists-of-data/rtdb_social_most_viewed.js | 2 +- .../lists-of-data/rtdb_social_push.js | 2 +- .../lists-of-data/rtdb_social_recent.js | 2 +- .../offline/rtdb_detect_connection_state.js | 2 +- .../offline/rtdb_estimate_clock_skew.js | 2 +- .../offline/rtdb_ondisconnect_simple.js | 2 +- .../offline/rtdb_sample_presence_app.js | 2 +- .../offline/rtdb_set_server_timestamp.js | 2 +- .../read-and-write/rtdb_read_once_get.js | 2 +- .../rtdb_social_completion_callback.js | 2 +- .../rtdb_social_listen_star_count.js | 2 +- .../rtdb_social_single_value_read.js | 4 +-- .../rtdb_social_star_transaction.js | 2 +- .../rtdb_social_write_fan_out.js | 2 +- .../read-and-write/rtdb_write_new_user.js | 4 +-- .../rtdb_write_new_user_completion.js | 2 +- .../emulator-suite/fs_emulator_connect.js | 2 +- .../callable/fb_functions_call_add_message.js | 2 +- .../fb_functions_call_add_message_error.js | 2 +- .../index/messaging_delete_token.js | 2 +- .../index/messaging_get_messaging_object.js | 2 +- .../index/messaging_get_token.js | 2 +- .../index/messaging_receive_message.js | 2 +- snippets/perf-next/index/perf_get_instance.js | 2 +- .../index/rc_get_instance.js | 2 +- .../create-reference/storage_create_ref.js | 2 +- .../storage_create_ref_child.js | 2 +- .../create-reference/storage_navigate_ref.js | 2 +- .../storage_navigate_ref_chain.js | 2 +- .../storage_ref_full_example.js | 2 +- .../storage_ref_properties.js | 2 +- .../delete-files/storage_delete_file.js | 2 +- .../storage_download_create_ref.js | 2 +- .../storage_download_full_example.js | 2 +- .../storage_download_via_url.js | 2 +- .../file-metadata/storage_delete_metadata.js | 2 +- .../file-metadata/storage_get_metadata.js | 2 +- .../file-metadata/storage_update_metadata.js | 2 +- .../index/storage_multiple_buckets.js | 2 ++ .../storage-next/index/storage_on_complete.js | 2 +- .../list-files/storage_list_all.js | 2 +- .../list-files/storage_list_paginate.js | 2 +- .../upload-files/storage_manage_uploads.js | 2 +- .../upload-files/storage_monitor_upload.js | 2 +- .../upload-files/storage_upload_blob.js | 2 +- .../upload-files/storage_upload_bytes.js | 2 +- .../storage_upload_handle_error.js | 2 +- .../upload-files/storage_upload_metadata.js | 2 +- .../upload-files/storage_upload_ref.js | 2 +- .../upload-files/storage_upload_string.js | 2 +- storage-next/create-reference.js | 20 ++++------- storage-next/delete-files.js | 10 +----- storage-next/download-files.js | 14 ++------ storage-next/file-metadata.js | 14 ++------ storage-next/index.js | 12 ++----- storage-next/list-files.js | 12 ++----- storage-next/upload-files.js | 24 +++++--------- 173 files changed, 284 insertions(+), 566 deletions(-) diff --git a/analytics-next/ecommerce.js b/analytics-next/ecommerce.js index b14f0eb2..c4c7807c 100644 --- a/analytics-next/ecommerce.js +++ b/analytics-next/ecommerce.js @@ -1,15 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - - // [START analytics_ecommerce_items] // A pair of jeggings const item_jeggings = { @@ -54,7 +45,7 @@ function ecommerceViewItemList() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'view_item_list', params1); // [END analytics_ecommerce_view_item_list] } @@ -71,7 +62,7 @@ function ecommerceSelectItem() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'select_item', params2); // [END analytics_ecommerce_select_item] } @@ -88,7 +79,7 @@ function ecommerceViewItemDetails() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'view_item', params3); // [END analytics_ecommerce_view_item_details] } @@ -111,7 +102,7 @@ function ecommerceAddCart() { }; // Log event when a product is added to a wishlist - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'add_to_wishlist', params4); // Log event when a product is added to the cart @@ -142,7 +133,7 @@ function ecommerceViewCart() { }; // Log event when the cart is viewed - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'view_cart', params5); // [END analytics_ecommerce_view_cart] } @@ -159,7 +150,7 @@ function ecommerceRemoveCart() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'remove_from_cart', params6); // [END analytics_ecommerce_remove_cart] } @@ -177,7 +168,7 @@ function ecommerceCheckout() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'begin_checkout', params7); // [END analytics_ecommerce_checkout] } @@ -196,7 +187,7 @@ function ecommerceShippingInfo() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'add_shipping_info', params8); // [END analytics_ecommerce_shipping_info] } @@ -215,7 +206,7 @@ function ecommercePaymentInfo() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'add_payment_info', params9); // [END analytics_ecommerce_payment_info] } @@ -237,7 +228,7 @@ function ecommercePurchase() { }; // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'purchase', params10); // [END analytics_ecommerce_purchase] } @@ -264,7 +255,7 @@ function ecommerceRefund() { params11.items.push(refundedProduct); // Log event - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'refund', params11); // [END analytics_ecommerce_refund] } @@ -284,7 +275,7 @@ function ecommercePromotions() { }; // Log event when a promotion is displayed - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'view_promotion', params12); // Log event when a promotion is selected diff --git a/analytics-next/index.js b/analytics-next/index.js index 047f1289..a93de88a 100644 --- a/analytics-next/index.js +++ b/analytics-next/index.js @@ -3,17 +3,11 @@ import { initializeApp } from "firebase/app"; -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function initialize() { // [START analytics_initialize] const { getAnalytics } = require("firebase/analytics"); - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); // [END analytics_initialize] } @@ -21,7 +15,7 @@ function logEvent() { // [START analytics_log_event] const { getAnalytics, logEvent } = require("firebase/analytics"); - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'notification_received'); // [END analytics_log_event] } @@ -30,7 +24,7 @@ function logEventParams() { // [START analytics_log_event_params] const { getAnalytics, logEvent } = require("firebase/analytics"); - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'select_content', { content_type: 'image', content_id: 'P12453', @@ -43,7 +37,7 @@ function logEventCustomParams() { // [START analytics_log_event_custom_params] const { getAnalytics, logEvent } = require("firebase/analytics"); - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); logEvent(analytics, 'goal_completion', { name: 'lever_puzzle'}); // [END analytics_log_event_custom_params] } @@ -52,7 +46,7 @@ function setUserProperties() { // [START analytics_set_user_properties] const { getAnalytics, setUserProperties } = require("firebase/analytics"); - const analytics = getAnalytics(firebaseApp); + const analytics = getAnalytics(); setUserProperties(analytics, { favorite_food: 'apples' }); // [END analytics_set_user_properties] } diff --git a/auth-next/anonymous.js b/auth-next/anonymous.js index 56a56c39..33d5a936 100644 --- a/auth-next/anonymous.js +++ b/auth-next/anonymous.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function anonSignIn() { // [START auth_anon_sign_in] const { getAuth, signInAnonymously } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInAnonymously(auth) .then(() => { // Signed in.. diff --git a/auth-next/apple.js b/auth-next/apple.js index 177aa065..29a33dea 100644 --- a/auth-next/apple.js +++ b/auth-next/apple.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/apple.md function appleProvider() { @@ -35,7 +27,7 @@ function appleSignInPopup(provider) { // [START auth_apple_signin_popup] const { getAuth, signInWithPopup, OAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // The signed-in user info. @@ -66,7 +58,7 @@ function appleSignInRedirect(provider) { // [START auth_apple_signin_redirect] const { getAuth, signInWithRedirect } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_apple_signin_redirect] } @@ -76,7 +68,7 @@ function appleSignInRedirectResult() { const { getAuth, getRedirectResult, OAuthProvider } = require("firebase/auth"); // Result from Redirect auth flow. - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { const credential = OAuthProvider.credentialFromResult(result); @@ -107,7 +99,7 @@ function appleReauthenticatePopup() { const { getAuth, reauthenticateWithPopup, OAuthProvider } = require("firebase/auth"); // Result from Redirect auth flow. - const auth = getAuth(firebaseApp); + const auth = getAuth(); const provider = new OAuthProvider('apple.com'); reauthenticateWithPopup(auth.currentUser, provider) @@ -144,7 +136,7 @@ function appleLinkFacebook() { // [START auth_apple_link_facebook] const { getAuth, linkWithPopup, FacebookAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); const provider = new FacebookAuthProvider(); provider.addScope('user_birthday'); @@ -192,7 +184,7 @@ function appleSignInNonce(appleIdToken, unhashedNonce,) { // [START auth_apple_signin_nonce] const { getAuth, signInWithCredential, OAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); // Build Firebase credential with the Apple ID token. const provider = new OAuthProvider('apple.com'); diff --git a/auth-next/auth-state-persistence.js b/auth-next/auth-state-persistence.js index cef52522..2d36c429 100644 --- a/auth-next/auth-state-persistence.js +++ b/auth-next/auth-state-persistence.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function setPersistenceSession() { const email = "..."; const password = "..."; @@ -16,7 +8,7 @@ function setPersistenceSession() { // [START auth_set_persistence_session] const { getAuth, setPersistence, signInWithEmailAndPassword, browserSessionPersistence } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); setPersistence(auth, browserSessionPersistence) .then(() => { // Existing and future Auth states are now persisted in the current @@ -38,7 +30,7 @@ function setPersistenceNone() { // [START auth_set_persistence_none] const { getAuth, setPersistence, signInWithRedirect, inMemoryPersistence, GoogleAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); setPersistence(auth, inMemoryPersistence) .then(() => { const provider = new GoogleAuthProvider(); diff --git a/auth-next/cordova.js b/auth-next/cordova.js index ec637576..1823b33c 100644 --- a/auth-next/cordova.js +++ b/auth-next/cordova.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/cordova.md function createGoogleProvider() { @@ -23,7 +15,7 @@ function cordovaSignInRedirect() { // [START auth_cordova_sign_in_redirect] const { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithRedirect(auth, new GoogleAuthProvider()) .then(() => { return getRedirectResult(auth); @@ -50,7 +42,7 @@ function cordovaRedirectResult() { // [START auth_cordova_redirect_result] const { getAuth, getRedirectResult, GoogleAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { const credential = GoogleAuthProvider.credentialFromResult(result); diff --git a/auth-next/custom-email-handler.js b/auth-next/custom-email-handler.js index eccb9219..728baff8 100644 --- a/auth-next/custom-email-handler.js +++ b/auth-next/custom-email-handler.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/custom-email-handler.md function handleUserManagementQueryParams() { diff --git a/auth-next/custom.js b/auth-next/custom.js index 8f4ac547..8975672e 100644 --- a/auth-next/custom.js +++ b/auth-next/custom.js @@ -1,21 +1,13 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function signInCustom() { const token = "token123"; // [START auth_sign_in_custom] const { getAuth, signInWithCustomToken } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithCustomToken(auth, token) .then((userCredential) => { // Signed in diff --git a/auth-next/email-link-auth.js b/auth-next/email-link-auth.js index a2ec5cf5..59ea2115 100644 --- a/auth-next/email-link-auth.js +++ b/auth-next/email-link-auth.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/email-link-auth.md function emailLinkActionCodeSettings() { @@ -36,7 +28,7 @@ function emailLinkSend(email, actionCodeSettings) { // [START auth_email_link_send] const { getAuth, sendSignInLinkToEmail } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); sendSignInLinkToEmail(auth, email, actionCodeSettings) .then(() => { // The link was successfully sent. Inform the user. @@ -58,7 +50,7 @@ function emailLinkComplete() { const { getAuth, isSignInWithEmailLink, signInWithEmailLink } = require("firebase/auth"); // Confirm the link is a sign-in with email link. - const auth = getAuth(firebaseApp); + const auth = getAuth(); if (isSignInWithEmailLink(auth, window.location.href)) { // Additional state parameters can also be passed via URL. // This can be used to continue the user's intended action before triggering @@ -99,7 +91,7 @@ function emailLinkLink(email) { email, window.location.href); // Link the credential to the current user. - const auth = getAuth(firebaseApp); + const auth = getAuth(); linkWithCredential(auth.currentUser, credential) .then((usercred) => { // The provider is now successfully linked. @@ -120,7 +112,7 @@ function emailLinkReauth(email) { email, window.location.href); // Re-authenticate the user with this credential. - const auth = getAuth(firebaseApp); + const auth = getAuth(); reauthenticateWithCredential(auth.currentUser, credential) .then((usercred) => { // The user is now successfully re-authenticated and can execute sensitive @@ -139,7 +131,7 @@ function emailLinkDifferentiate() { // After asking the user for their email. const email = window.prompt('Please provide your email'); - const auth = getAuth(firebaseApp); + const auth = getAuth(); fetchSignInMethodsForEmail(auth, email) .then((signInMethods) => { // This returns the same array as fetchProvidersForEmail but for email diff --git a/auth-next/email.js b/auth-next/email.js index 7285185a..b00551c8 100644 --- a/auth-next/email.js +++ b/auth-next/email.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function signInWithEmailPassword() { const email = "test@example.com"; const password = "hunter2"; @@ -16,7 +8,7 @@ function signInWithEmailPassword() { // [START auth_signin_password] const { getAuth, signInWithEmailAndPassword } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithEmailAndPassword(auth, email, password) .then((userCredential) => { // Signed in @@ -37,7 +29,7 @@ function signUpWithEmailPassword() { // [START auth_signup_password] const { getAuth, createUserWithEmailAndPassword } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); createUserWithEmailAndPassword(auth, email, password) .then((userCredential) => { // Signed in @@ -56,7 +48,7 @@ function sendEmailVerification() { // [START auth_send_email_verification] const { getAuth, sendEmailVerification } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); sendEmailVerification(auth.currentUser) .then(() => { // Email verification sent! @@ -71,7 +63,7 @@ function sendPasswordReset() { // [START auth_send_password_reset] const { getAuth, sendPasswordResetEmail } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); sendPasswordResetEmail(auth, email) .then(() => { // Password reset email sent! diff --git a/auth-next/emulator-suite.js b/auth-next/emulator-suite.js index aca56cff..ed24e78b 100644 --- a/auth-next/emulator-suite.js +++ b/auth-next/emulator-suite.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function emulatorConnect() { // [START auth_emulator_connect] const { getAuth, useAuthEmulator } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); useAuthEmulator(auth, "http://localhost:9099"); // [END auth_emulator_connect] } diff --git a/auth-next/facebook.js b/auth-next/facebook.js index 0ec084bd..4b61f4be 100644 --- a/auth-next/facebook.js +++ b/auth-next/facebook.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function facebookProvider() { // [START auth_facebook_provider_create] const { FacebookAuthProvider } = require("firebase/auth"); @@ -31,7 +23,7 @@ function facebookSignInPopup(provider) { // [START auth_facebook_signin_popup] const { getAuth, signInWithPopup, FacebookAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // The signed-in user info. @@ -61,7 +53,7 @@ function facebookSignInRedirectResult() { // [START auth_facebook_signin_redirect_result] const { getAuth, getRedirectResult, FacebookAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { // This gives you a Facebook Access Token. You can use it to access the Facebook API. @@ -90,7 +82,7 @@ function checkLoginState_wrapper() { // [START auth_facebook_callback] const { getAuth, onAuthStateChanged, signInWithCredential, signOut, FacebookAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); function checkLoginState(response) { if (response.authResponse) { @@ -153,7 +145,7 @@ function authWithCredential(credential) { const { getAuth, signInWithCredential, FacebookAuthProvider } = require("firebase/auth"); // Sign in with the credential from the Facebook user. - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithCredential(auth, credential) .then((result) => { // Signed in diff --git a/auth-next/github.js b/auth-next/github.js index 0289a53b..941a9047 100644 --- a/auth-next/github.js +++ b/auth-next/github.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function githubProvider() { // [START auth_github_provider_create] const { GithubAuthProvider } = require("firebase/auth"); @@ -39,7 +31,7 @@ function githubSignInPopup(provider) { // [START auth_github_signin_popup] const { getAuth, signInWithPopup, GithubAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // This gives you a GitHub Access Token. You can use it to access the GitHub API. @@ -66,7 +58,7 @@ function githubSignInRedirectResult() { // [START auth_github_signin_redirect_result] const { getAuth, getRedirectResult, GithubAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { const credential = GithubAuthProvider.credentialFromResult(result); diff --git a/auth-next/google-signin.js b/auth-next/google-signin.js index 4661212b..78b79a61 100644 --- a/auth-next/google-signin.js +++ b/auth-next/google-signin.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/google-signin.md function googleProvider() { @@ -33,7 +25,7 @@ function googleSignInPopup(provider) { // [START auth_google_signin_popup] const { getAuth, signInWithPopup, GoogleAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // This gives you a Google Access Token. You can use it to access the Google API. @@ -59,7 +51,7 @@ function googleSignInRedirectResult() { // [START auth_google_signin_redirect_result] const { getAuth, getRedirectResult, GoogleAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { // This gives you a Google Access Token. You can use it to access Google APIs. @@ -89,7 +81,7 @@ function googleBuildAndSignIn(id_token) { const credential = GoogleAuthProvider.credential(id_token); // Sign in with credential from the Google user. - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithCredential(auth, credential).catch((error) => { // Handle Errors here. const errorCode = error.code; @@ -111,7 +103,7 @@ function onSignIn_wrapper() { // [START auth_google_callback] const { getAuth, onAuthStateChanged, signInWithCredential, GoogleAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); function onSignIn(googleUser) { console.log('Google Auth Response', googleUser); diff --git a/auth-next/index.js b/auth-next/index.js index bf5bec57..9c8168b8 100644 --- a/auth-next/index.js +++ b/auth-next/index.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // ========================================================================================== // Docs: Snippets in this file are "general purpose" and are used on more than one docs page // ========================================================================================== @@ -43,7 +35,7 @@ function signOut() { // [START auth_sign_out] const { getAuth, signOut } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signOut(auth).then(() => { // Sign-out successful. }).catch((error) => { @@ -56,7 +48,7 @@ function authStateListener() { // [START auth_state_listener] const { getAuth, onAuthStateChanged } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); onAuthStateChanged(auth, (user) => { if (user) { // User is signed in, see docs for a list of available properties @@ -75,7 +67,7 @@ function setLanguageCode() { // [START auth_set_language_code] const { getAuth } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); auth.languageCode = 'it'; // To apply the default browser preference instead of explicitly setting it. // firebase.auth().useDeviceLanguage(); @@ -87,7 +79,7 @@ function authWithCredential(credential) { const { getAuth, signInWithCredential } = require("firebase/auth"); // Sign in with the credential from the user. - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithCredential(auth, credential) .then((result) => { // Signed in @@ -108,7 +100,7 @@ function signInRedirect(provider) { // [START auth_signin_redirect] const { getAuth, signInWithRedirect } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_signin_redirect] } diff --git a/auth-next/link-multiple-accounts.js b/auth-next/link-multiple-accounts.js index 0c612af9..34c0db58 100644 --- a/auth-next/link-multiple-accounts.js +++ b/auth-next/link-multiple-accounts.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - const MyUserDataRepo = function() {}; MyUserDataRepo.prototype.merge = function(data1, data2) { @@ -47,7 +39,7 @@ function simpleLink(credential) { // [START auth_simple_link] const { getAuth, linkWithCredential } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); linkWithCredential(auth.currentUser, credential) .then((usercred) => { const user = usercred.user; @@ -62,7 +54,7 @@ function anonymousLink(credential) { // [START auth_anonymous_link] const { getAuth, linkWithCredential } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); linkWithCredential(auth.currentUser, credential) .then((usercred) => { const user = usercred.user; @@ -78,7 +70,7 @@ function linkWithPopup() { const { getAuth, linkWithPopup, GoogleAuthProvider } = require("firebase/auth"); const provider = new GoogleAuthProvider(); - const auth = getAuth(firebaseApp); + const auth = getAuth(); linkWithPopup(auth.currentUser, provider).then((result) => { // Accounts successfully linked. const credential = GoogleAuthProvider.credentialFromResult(result); @@ -96,7 +88,7 @@ function linkWithRedirect() { const { getAuth, linkWithRedirect, GoogleAuthProvider } = require("firebase/auth"); const provider = new GoogleAuthProvider(); - const auth = getAuth(firebaseApp); + const auth = getAuth(); linkWithRedirect(auth.currentUser, provider) .then(/* ... */) .catch(/* ... */); @@ -126,7 +118,7 @@ function mergeAccounts(newCredential) { const repo = new MyUserDataRepo(); // Get reference to the currently signed-in user - const auth = getAuth(firebaseApp); + const auth = getAuth(); const prevUser = auth.currentUser; // Get the data which you will want to merge. This should be done now @@ -180,7 +172,7 @@ function unlink(providerId) { // [START auth_unlink_provider] const { getAuth, unlink } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); unlink(auth.currentUser, providerId).then(() => { // Auth provider unlinked from account // ... diff --git a/auth-next/microsoft-oauth.js b/auth-next/microsoft-oauth.js index 0179ffc6..be0abffd 100644 --- a/auth-next/microsoft-oauth.js +++ b/auth-next/microsoft-oauth.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/microsoft-oauth.md function msftCreateProvider() { @@ -47,7 +39,7 @@ function msftSignInPopup(provider) { // [START auth_msft_signin_popup] const { getAuth, signInWithPopup, OAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // User is signed in. @@ -68,7 +60,7 @@ function msftSignInRedirect(provider) { // [START auth_msft_signin_redirect] const { getAuth, signInWithRedirect } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_msft_signin_redirect] } @@ -77,7 +69,7 @@ function msftSignInRedirectResult() { // [START auth_msft_signin_redirect_result] const { getAuth, getRedirectResult, OAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { // User is signed in. @@ -99,7 +91,7 @@ function msftLinkWithPopup() { const { getAuth, linkWithPopup, OAuthProvider } = require("firebase/auth"); const provider = new OAuthProvider('microsoft.com'); - const auth = getAuth(firebaseApp); + const auth = getAuth(); linkWithPopup(auth.currentUser, provider) .then((result) => { @@ -122,7 +114,7 @@ function msftReauthPopup() { const { getAuth, reauthenticateWithPopup, OAuthProvider } = require("firebase/auth"); const provider = new OAuthProvider('microsoft.com'); - const auth = getAuth(firebaseApp); + const auth = getAuth(); reauthenticateWithPopup(auth.currentUser, provider) .then((result) => { // User is re-authenticated with fresh tokens minted and diff --git a/auth-next/phone-auth.js b/auth-next/phone-auth.js index 510dd219..cd894c64 100644 --- a/auth-next/phone-auth.js +++ b/auth-next/phone-auth.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Mask the global 'window' for this snippet file const window = { recaptchaVerifier: undefined @@ -22,7 +14,7 @@ function recaptchaVerifierInvisible() { // [START auth_phone_recaptcha_verifier_invisible] const { getAuth, RecaptchaVerifier } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); window.recaptchaVerifier = new RecaptchaVerifier('sign-in-button', { 'size': 'invisible', 'callback': (response) => { @@ -37,7 +29,7 @@ function recaptchaVerifierVisible() { // [START auth_phone_recaptcha_verifier_visible] const { getAuth, RecaptchaVerifier } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', { 'size': 'normal', 'callback': (response) => { @@ -56,7 +48,7 @@ function recaptchaVerifierSimple() { // [START auth_phone_recaptcha_verifier_simple] const { getAuth, RecaptchaVerifier } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {}, auth); // [END auth_phone_recaptcha_verifier_simple] } @@ -85,7 +77,7 @@ function phoneSignIn() { const phoneNumber = getPhoneNumberFromUserInput(); const appVerifier = window.recaptchaVerifier; - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPhoneNumber(auth, phoneNumber, appVerifier) .then((confirmationResult) => { // SMS sent. Prompt user to type the code from the message, then sign the diff --git a/auth-next/service-worker-sessions.js b/auth-next/service-worker-sessions.js index b9d87cbf..abef386b 100644 --- a/auth-next/service-worker-sessions.js +++ b/auth-next/service-worker-sessions.js @@ -1,21 +1,13 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/service-worker-sessions.md function svcGetIdToken() { // [START auth_svc_get_idtoken] const { getAuth, getIdToken } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getIdToken(auth.currentUser) .then((idToken) => { // idToken can be passed back to server. @@ -39,7 +31,7 @@ function svcSubscribe(config) { * @return {!Promise} The promise that resolves with an ID token if * available. Otherwise, the promise resolves with null. */ - const auth = getAuth(firebaseApp); + const auth = getAuth(); const getIdTokenPromise = () => { return new Promise((resolve, reject) => { const unsubscribe = onAuthStateChanged(auth, (user) => { @@ -165,7 +157,7 @@ function svcSignInEmail(email, password) { const { getAuth, signInWithEmailAndPassword } = require("firebase/auth"); // Sign in screen. - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithEmailAndPassword(auth, email, password) .then((result) => { // Redirect to profile page after sign-in. The service worker will detect diff --git a/auth-next/twitter.js b/auth-next/twitter.js index 6e204cb3..8024bbe5 100644 --- a/auth-next/twitter.js +++ b/auth-next/twitter.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - function twitterProvider() { // [START auth_twitter_provider_create] const { TwitterAuthProvider } = require("firebase/auth"); @@ -27,7 +19,7 @@ function twitterSignInPopup(provider) { // [START auth_twitter_signin_popup] const { getAuth, signInWithPopup, TwitterAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // This gives you a the Twitter OAuth 1.0 Access Token and Secret. @@ -56,7 +48,7 @@ function twitterSignInRedirectResult() { // [START auth_twitter_signin_redirect_result] const { getAuth, getRedirectResult, TwitterAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { // This gives you a the Twitter OAuth 1.0 Access Token and Secret. diff --git a/auth-next/yahoo-oauth.js b/auth-next/yahoo-oauth.js index e03c9bba..e08150e7 100644 --- a/auth-next/yahoo-oauth.js +++ b/auth-next/yahoo-oauth.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); - // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/yahoo-oauth.md function yahooProvider() { @@ -40,7 +32,7 @@ function yahooSignInPopup(provider) { // [START auth_yahoo_signin_popup] const { getAuth, signInWithPopup, OAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // IdP data available in result.additionalUserInfo.profile @@ -61,7 +53,7 @@ function yahooSignInRedirect(provider) { // [START auth_yahoo_signin_redirect] const { getAuth, signInWithRedirect } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_yahoo_signin_redirect] } @@ -70,7 +62,7 @@ function yahooSigninRedirectResult() { // [START auth_yahoo_signin_redirect_result] const { getAuth, getRedirectResult, OAuthProvider } = require("firebase/auth"); - const auth = getAuth(firebaseApp); + const auth = getAuth(); getRedirectResult(auth) .then((result) => { // IdP data available in result.additionalUserInfo.profile @@ -92,7 +84,7 @@ function yahooLinkPopup() { const { getAuth, linkWithPopup, OAuthProvider } = require("firebase/auth"); const provider = new OAuthProvider('yahoo.com'); - const auth = getAuth(firebaseApp); + const auth = getAuth(); linkWithPopup(auth.currentUser, provider) .then((result) => { // Yahoo credential is linked to the current user. @@ -114,7 +106,7 @@ function yahooReauthPopup() { const { getAuth, reauthenticateWithPopup, OAuthProvider } = require("firebase/auth"); const provider = new OAuthProvider('yahoo.com'); - const auth = getAuth(firebaseApp); + const auth = getAuth(); reauthenticateWithPopup(auth.currentUser, provider) .then((result) => { // User is re-authenticated with fresh tokens minted and diff --git a/database-next/emulator-suite.js b/database-next/emulator-suite.js index c19f6829..083fea80 100644 --- a/database-next/emulator-suite.js +++ b/database-next/emulator-suite.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function onDocumentReady() { // [START rtdb_emulator_connect] const { getDatabase, useDatabaseEmulator } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. useDatabaseEmulator(db, "localhost", 9000); @@ -26,7 +18,7 @@ function flushRealtimeDatabase() { const { getDatabase, ref, set } = require("firebase/database"); // With a database Reference, write null to clear the database. - const db = getDatabase(firebaseApp); + const db = getDatabase(); set(ref(db), null); // [END rtdb_emulator_flush] } diff --git a/database-next/index.js b/database-next/index.js index 53c8584d..b0a3400e 100644 --- a/database-next/index.js +++ b/database-next/index.js @@ -1,18 +1,10 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function getReference() { // [START rtdb_get_reference] const { getDatabase } = require("firebase/database"); - const database = getDatabase(firebaseApp); + const database = getDatabase(); // [END rtdb_get_reference] } diff --git a/database-next/lists-of-data.js b/database-next/lists-of-data.js index 8e47c1dd..53afbc08 100644 --- a/database-next/lists-of-data.js +++ b/database-next/lists-of-data.js @@ -1,20 +1,12 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function socialPush() { // [START rtdb_social_push] const { getDatabase, ref, push, set } = require("firebase/database"); // Create a new post reference with an auto-generated id - const db = getDatabase(firebaseApp); + const db = getDatabase(); const postListRef = ref(db, 'posts'); const newPostRef = push(postListRef); set(newPostRef, { @@ -33,7 +25,7 @@ function socialListenChildren() { // [START rtdb_social_listen_children] const { getDatabase, ref, onChildAdded, onChildChanged, onChildRemoved } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const commentsRef = ref(db, 'post-comments/' + postId); onChildAdded(commentsRef, (data) => { addCommentElement(postElement, data.key, data.val().text, data.val().author); @@ -54,7 +46,7 @@ function socialListenValue() { // [START rtdb_social_listen_value] const { getDatabase, ref, onValue } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const dbRef = ref(db, '/a/b/c'); onValue(dbRef, (snapshot) => { @@ -74,8 +66,8 @@ function socialMostStarred() { const { getDatabase, ref, query, orderByChild } = require("firebase/database"); const { getAuth } = require("firebase/auth"); - const db = getDatabase(firebaseApp); - const auth = getAuth(firebaseApp); + const db = getDatabase(); + const auth = getAuth(); const myUserId = auth.currentUser.uid; const topUserPostsRef = query(ref(db, 'user-posts/' + myUserId), orderByChild('starCount')); @@ -86,7 +78,7 @@ function socialMostViewed() { // [START rtdb_social_most_viewed] const { getDatabase, ref, query, orderByChild } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const mostViewedPosts = query(ref(db, 'posts'), orderByChild('metrics/views')); // [END rtdb_social_most_viewed] } @@ -95,7 +87,7 @@ function socialRecent() { // [START rtdb_social_recent] const { getDatabase, ref, query, limitToLast } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const recentPostsRef = query(ref(db, 'posts'), limitToLast(100)); // [END rtdb_social_recent] } diff --git a/database-next/offline.js b/database-next/offline.js index 49009268..3dd9e22b 100644 --- a/database-next/offline.js +++ b/database-next/offline.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function onDisconnectSimple() { // [START rtdb_ondisconnect_simple] const { getDatabase, ref, onDisconnect } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const presenceRef = ref(db, "disconnectmessage"); // Write a string when this client loses connection onDisconnect(presenceRef).set("I disconnected!"); @@ -23,7 +15,7 @@ function onDisconnectSimple() { function onDisconnectCallback() { const { getDatabase, ref, onDisconnect } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const presenceRef = ref(db, "disconnectmessage"); // [START rtdb_ondisconnect_callback] @@ -38,7 +30,7 @@ function onDisconnectCallback() { function onDisconnectCancel() { const { getDatabase, ref, onDisconnect } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const presenceRef = ref(db, "disconnectmessage"); // [START rtdb_ondisconnect_cancel] @@ -53,7 +45,7 @@ function detectConnectionState() { // [START rtdb_detect_connection_state] const { getDatabase, ref, onValue } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const connectedRef = ref(db, ".info/connected"); onValue(connectedRef, (snap) => { if (snap.val() === true) { @@ -69,7 +61,7 @@ function setServerTimestamp() { // [START rtdb_set_server_timestamp] const { getDatabase, ref, onDisconnect, serverTimestamp } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const userLastOnlineRef = ref(db, "users/joe/lastOnline"); onDisconnect(userLastOnlineRef).set(serverTimestamp()); // [END rtdb_set_server_timestamp] @@ -79,7 +71,7 @@ function estimateClockSkew() { // [START rtdb_estimate_clock_skew] const { getDatabase, ref, onValue } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const offsetRef = ref(db, ".info/serverTimeOffset"); onValue(offsetRef, (snap) => { const offset = snap.val(); @@ -94,7 +86,7 @@ function samplePresenceApp() { // Since I can connect from multiple devices or browser tabs, we store each connection instance separately // any time that connectionsRef's value is null (i.e. has no children) I am offline - const db = getDatabase(firebaseApp); + const db = getDatabase(); const myConnectionsRef = ref(db, 'users/joe/connections'); // stores the timestamp of my last disconnect (the last time I was seen online) diff --git a/database-next/read-and-write.js b/database-next/read-and-write.js index db7da0db..717ddeae 100644 --- a/database-next/read-and-write.js +++ b/database-next/read-and-write.js @@ -1,20 +1,12 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function writeUserData_wrapped() { // [START rtdb_write_new_user] - const { getDatabase, ref, set} = require("firebase/database"); + const { getDatabase, ref, set } = require("firebase/database"); function writeUserData(userId, name, email, imageUrl) { - const db = getDatabase(firebaseApp); + const db = getDatabase(); set(ref(db, 'users/' + userId), { username: name, email: email, @@ -29,7 +21,7 @@ function writeUserDataWithCompletion(userId, name, email, imageUrl) { // [START rtdb_write_new_user_completion] const { getDatabase, ref, set } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); set(ref(db, 'users/' + userId), { username: name, email: email, @@ -54,7 +46,7 @@ function socialListenStarCount() { // [START rtdb_social_listen_star_count] const { getDatabase, ref, onValue} = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); const starCountRef = ref(db, 'posts/' + postId + '/starCount'); onValue(starCountRef, (snapshot) => { const data = snapshot.val(); @@ -68,8 +60,8 @@ function socialSingleValueRead() { const { getDatabase, ref, onValue } = require("firebase/database"); const { getAuth } = require("firebase/auth"); - const db = getDatabase(firebaseApp); - const auth = getAuth(firebaseApp); + const db = getDatabase(); + const auth = getAuth(); const userId = auth.currentUser.uid; return onValue(ref(db, '/users/' + userId), (snapshot) => { @@ -86,7 +78,7 @@ function writeNewPost_wrapped() { // [START rtdb_social_write_fan_out] function writeNewPost(uid, username, picture, title, body) { - const db = getDatabase(firebaseApp); + const db = getDatabase(); // A post entry. const postData = { @@ -119,7 +111,7 @@ function socialCompletionCallback() { // [START rtdb_social_completion_callback] const { getDatabase, ref, set } = require("firebase/database"); - const db = getDatabase(firebaseApp); + const db = getDatabase(); set(ref(db, 'users/' + userId), { username: name, email: email, @@ -139,7 +131,7 @@ function toggleStar_wrapped() { const { getDatabase, ref, runTransaction } = require("firebase/database"); function toggleStar(uid) { - const db = getDatabase(firebaseApp); + const db = getDatabase(); const postRef = ref(db, '/posts/foo-bar-123'); runTransaction(postRef, (post) => { @@ -165,7 +157,7 @@ function readOnceWithGet(userId) { // [START rtdb_read_once_get] const { getDatabase, ref, child, get } = require("firebase/database"); - const dbRef = ref(getDatabase(firebaseApp)); + const dbRef = ref(getDatabase()); get(child(dbRef, `users/${userId}`)).then((snapshot) => { if (snapshot.exists()) { console.log(snapshot.val()); diff --git a/firestore-next/emulator-suite.js b/firestore-next/emulator-suite.js index fbbb9599..61463eee 100644 --- a/firestore-next/emulator-suite.js +++ b/firestore-next/emulator-suite.js @@ -1,12 +1,12 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -function onDocumentReady(firebaseApp) { +function onDocumentReady() { // [START fs_emulator_connect] const { getFirestore, useFirestoreEmulator } = require("firebase/firestore"); // firebaseApps previously initialized using initializeApp() - const db = getFirestore(firebaseApp); + const db = getFirestore(); useFirestoreEmulator(db, 'localhost', 8080); // [END fs_emulator_connect] } diff --git a/functions-next/callable.js b/functions-next/callable.js index 4b866cd3..70049563 100644 --- a/functions-next/callable.js +++ b/functions-next/callable.js @@ -1,13 +1,13 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -export function callAddMessage(firebaseApp) { +export function callAddMessage() { const messageText = "Hello, World!"; // [START fb_functions_call_add_message] const { getFunctions, httpsCallable } = require("firebase/functions"); - const functions = getFunctions(firebaseApp); + const functions = getFunctions(); const addMessage = httpsCallable(functions, 'addMessage'); addMessage({ text: messageText }) .then((result) => { @@ -25,7 +25,7 @@ export function callAddMessageError(firebaseApp) { // [START fb_functions_call_add_message_error] const { getFunctions, httpsCallable } = require("firebase/functions"); - const functions = getFunctions(firebaseApp); + const functions = getFunctions(); const addMessage = httpsCallable(functions, 'addMessage'); addMessage({ text: messageText }) .then((result) => { diff --git a/messaging-next/index.js b/messaging-next/index.js index dd800938..491ff84e 100644 --- a/messaging-next/index.js +++ b/messaging-next/index.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function getMessagingObject() { // [START messaging_get_messaging_object] const { getMessaging } = require("firebase/messaging"); - const messaging = getMessaging(firebaseApp); + const messaging = getMessaging(); // [END messaging_get_messaging_object] } @@ -25,7 +17,7 @@ function receiveMessage() { // `messaging.onBackgroundMessage` handler. const { getMessaging, onMessage } = require("firebase/messaging"); - const messaging = getMessaging(firebaseApp); + const messaging = getMessaging(); onMessage(messaging, (payload) => { console.log('Message received. ', payload); // ... @@ -39,7 +31,7 @@ function getToken() { // Get registration token. Initially this makes a network call, once retrieved // subsequent calls to getToken will return from cache. - const messaging = getMessaging(firebaseApp); + const messaging = getMessaging(); getToken(messaging, { vapidKey: '' }).then((currentToken) => { if (currentToken) { // Send the token to your server and update the UI if necessary @@ -74,7 +66,7 @@ function deleteToken() { // [START messaging_delete_token] const { getMessaging, deleteToken } = require("firebase/messaging"); - const messaging = getMessaging(firebaseApp); + const messaging = getMessaging(); deleteToken(messaging).then(() => { console.log('Token deleted.'); // ... diff --git a/perf-next/index.js b/perf-next/index.js index 58b70ae7..20f9b4f4 100644 --- a/perf-next/index.js +++ b/perf-next/index.js @@ -1,14 +1,7 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - projectId: '### PROJECT ID ###', - apiKey: '### FIREBASE API KEY ###', - authDomain: '### FIREBASE AUTH DOMAIN ###', -}); -const perf = getInstance(firebaseApp); +const perf = getInstance(); function intialize() { // [START perf_initialize] @@ -29,10 +22,10 @@ function intialize() { // [END perf_initialize] } -export function getInstance(firebaseApp) { +export function getInstance() { // [START perf_get_instance] const { getPerformance } = require("firebase/performance"); - const perf = getPerformance(firebaseApp); + const perf = getPerformance(); // [END perf_get_instance] return perf; diff --git a/remoteconfig-next/index.js b/remoteconfig-next/index.js index 364bcd17..aeeb263a 100644 --- a/remoteconfig-next/index.js +++ b/remoteconfig-next/index.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function getInstance() { // [START rc_get_instance] const { getRemoteConfig } = require("firebase/remote-config"); - const remoteConfig = getRemoteConfig(firebaseApp); + const remoteConfig = getRemoteConfig(); // [END rc_get_instance] return remoteConfig; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js index c93b833e..0fc501d9 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js @@ -20,7 +20,7 @@ const params4 = { }; // Log event when a product is added to a wishlist -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'add_to_wishlist', params4); // Log event when a product is added to the cart diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js index 7fc10a6c..0e369459 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js @@ -15,6 +15,6 @@ const params7 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'begin_checkout', params7); // [END analytics_ecommerce_checkout_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js index d4ade3f1..17ea80d1 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js @@ -16,6 +16,6 @@ const params9 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'add_payment_info', params9); // [END analytics_ecommerce_payment_info_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js index 1e0e0e37..a099a1ac 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js @@ -17,7 +17,7 @@ const params12 = { }; // Log event when a promotion is displayed -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'view_promotion', params12); // Log event when a promotion is selected diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js index 28817cd3..ea589cb7 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js @@ -19,6 +19,6 @@ const params10 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'purchase', params10); // [END analytics_ecommerce_purchase_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js index 48984886..f7d1f8f8 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js @@ -24,6 +24,6 @@ const refundedProduct = { params11.items.push(refundedProduct); // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'refund', params11); // [END analytics_ecommerce_refund_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js index 861c73ea..9bec3f7d 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js @@ -14,6 +14,6 @@ const params6 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'remove_from_cart', params6); // [END analytics_ecommerce_remove_cart_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js index 537220f7..a4e7ec58 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js @@ -14,6 +14,6 @@ const params2 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'select_item', params2); // [END analytics_ecommerce_select_item_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js index d4425db8..d2f2ccaa 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js @@ -16,6 +16,6 @@ const params8 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'add_shipping_info', params8); // [END analytics_ecommerce_shipping_info_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js index 4bb85052..bfe02fd0 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js @@ -25,6 +25,6 @@ const params5 = { }; // Log event when the cart is viewed -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'view_cart', params5); // [END analytics_ecommerce_view_cart_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js index 1fd40596..ebd74763 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js @@ -14,6 +14,6 @@ const params3 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'view_item', params3); // [END analytics_ecommerce_view_item_details_modular] \ No newline at end of file diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js index acc8bf08..c66f0d20 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js @@ -14,6 +14,6 @@ const params1 = { }; // Log event -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'view_item_list', params1); // [END analytics_ecommerce_view_item_list_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_initialize.js b/snippets/analytics-next/index/analytics_initialize.js index 8d491090..4fb42cb3 100644 --- a/snippets/analytics-next/index/analytics_initialize.js +++ b/snippets/analytics-next/index/analytics_initialize.js @@ -6,5 +6,5 @@ // [START analytics_initialize_modular] import { getAnalytics } from "firebase/analytics"; -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); // [END analytics_initialize_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_log_event.js b/snippets/analytics-next/index/analytics_log_event.js index d4122c71..c5537b5b 100644 --- a/snippets/analytics-next/index/analytics_log_event.js +++ b/snippets/analytics-next/index/analytics_log_event.js @@ -6,6 +6,6 @@ // [START analytics_log_event_modular] import { getAnalytics, logEvent } from "firebase/analytics"; -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'notification_received'); // [END analytics_log_event_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_log_event_custom_params.js b/snippets/analytics-next/index/analytics_log_event_custom_params.js index 65de3fb4..122d94d1 100644 --- a/snippets/analytics-next/index/analytics_log_event_custom_params.js +++ b/snippets/analytics-next/index/analytics_log_event_custom_params.js @@ -6,6 +6,6 @@ // [START analytics_log_event_custom_params_modular] import { getAnalytics, logEvent } from "firebase/analytics"; -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'goal_completion', { name: 'lever_puzzle'}); // [END analytics_log_event_custom_params_modular] \ No newline at end of file diff --git a/snippets/analytics-next/index/analytics_log_event_params.js b/snippets/analytics-next/index/analytics_log_event_params.js index 12956c31..86831dbd 100644 --- a/snippets/analytics-next/index/analytics_log_event_params.js +++ b/snippets/analytics-next/index/analytics_log_event_params.js @@ -6,7 +6,7 @@ // [START analytics_log_event_params_modular] import { getAnalytics, logEvent } from "firebase/analytics"; -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); logEvent(analytics, 'select_content', { content_type: 'image', content_id: 'P12453', diff --git a/snippets/analytics-next/index/analytics_set_user_properties.js b/snippets/analytics-next/index/analytics_set_user_properties.js index ca660ab8..b064cdbf 100644 --- a/snippets/analytics-next/index/analytics_set_user_properties.js +++ b/snippets/analytics-next/index/analytics_set_user_properties.js @@ -6,6 +6,6 @@ // [START analytics_set_user_properties_modular] import { getAnalytics, setUserProperties } from "firebase/analytics"; -const analytics = getAnalytics(firebaseApp); +const analytics = getAnalytics(); setUserProperties(analytics, { favorite_food: 'apples' }); // [END analytics_set_user_properties_modular] \ No newline at end of file diff --git a/snippets/auth-next/anonymous/auth_anon_sign_in.js b/snippets/auth-next/anonymous/auth_anon_sign_in.js index 7195632f..b495ec28 100644 --- a/snippets/auth-next/anonymous/auth_anon_sign_in.js +++ b/snippets/auth-next/anonymous/auth_anon_sign_in.js @@ -6,7 +6,7 @@ // [START auth_anon_sign_in_modular] import { getAuth, signInAnonymously } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInAnonymously(auth) .then(() => { // Signed in.. diff --git a/snippets/auth-next/apple/auth_apple_link_facebook.js b/snippets/auth-next/apple/auth_apple_link_facebook.js index 431f2621..a9f116ad 100644 --- a/snippets/auth-next/apple/auth_apple_link_facebook.js +++ b/snippets/auth-next/apple/auth_apple_link_facebook.js @@ -6,7 +6,7 @@ // [START auth_apple_link_facebook_modular] import { getAuth, linkWithPopup, FacebookAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); const provider = new FacebookAuthProvider(); provider.addScope('user_birthday'); diff --git a/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js b/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js index 2023c2cf..5d1b9257 100644 --- a/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js +++ b/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js @@ -7,7 +7,7 @@ import { getAuth, reauthenticateWithPopup, OAuthProvider } from "firebase/auth"; // Result from Redirect auth flow. -const auth = getAuth(firebaseApp); +const auth = getAuth(); const provider = new OAuthProvider('apple.com'); reauthenticateWithPopup(auth.currentUser, provider) diff --git a/snippets/auth-next/apple/auth_apple_signin_nonce.js b/snippets/auth-next/apple/auth_apple_signin_nonce.js index 7f7dd884..36962b8f 100644 --- a/snippets/auth-next/apple/auth_apple_signin_nonce.js +++ b/snippets/auth-next/apple/auth_apple_signin_nonce.js @@ -6,7 +6,7 @@ // [START auth_apple_signin_nonce_modular] import { getAuth, signInWithCredential, OAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); // Build Firebase credential with the Apple ID token. const provider = new OAuthProvider('apple.com'); diff --git a/snippets/auth-next/apple/auth_apple_signin_popup.js b/snippets/auth-next/apple/auth_apple_signin_popup.js index 1c5cc27f..3fb9436c 100644 --- a/snippets/auth-next/apple/auth_apple_signin_popup.js +++ b/snippets/auth-next/apple/auth_apple_signin_popup.js @@ -6,7 +6,7 @@ // [START auth_apple_signin_popup_modular] import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // The signed-in user info. diff --git a/snippets/auth-next/apple/auth_apple_signin_redirect.js b/snippets/auth-next/apple/auth_apple_signin_redirect.js index e00445f0..9b97a683 100644 --- a/snippets/auth-next/apple/auth_apple_signin_redirect.js +++ b/snippets/auth-next/apple/auth_apple_signin_redirect.js @@ -6,6 +6,6 @@ // [START auth_apple_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_apple_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/apple/auth_apple_signin_redirect_result.js b/snippets/auth-next/apple/auth_apple_signin_redirect_result.js index 8872d0f7..f0b2d64c 100644 --- a/snippets/auth-next/apple/auth_apple_signin_redirect_result.js +++ b/snippets/auth-next/apple/auth_apple_signin_redirect_result.js @@ -7,7 +7,7 @@ import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth"; // Result from Redirect auth flow. -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { const credential = OAuthProvider.credentialFromResult(result); diff --git a/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js b/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js index 5a1ce6fe..88b579f9 100644 --- a/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js +++ b/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js @@ -6,7 +6,7 @@ // [START auth_set_persistence_none_modular] import { getAuth, setPersistence, signInWithRedirect, inMemoryPersistence, GoogleAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); setPersistence(auth, inMemoryPersistence) .then(() => { const provider = new GoogleAuthProvider(); diff --git a/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js b/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js index 26917559..6644370d 100644 --- a/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js +++ b/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js @@ -6,7 +6,7 @@ // [START auth_set_persistence_session_modular] import { getAuth, setPersistence, signInWithEmailAndPassword, browserSessionPersistence } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); setPersistence(auth, browserSessionPersistence) .then(() => { // Existing and future Auth states are now persisted in the current diff --git a/snippets/auth-next/cordova/auth_cordova_redirect_result.js b/snippets/auth-next/cordova/auth_cordova_redirect_result.js index d86e7672..f4794507 100644 --- a/snippets/auth-next/cordova/auth_cordova_redirect_result.js +++ b/snippets/auth-next/cordova/auth_cordova_redirect_result.js @@ -6,7 +6,7 @@ // [START auth_cordova_redirect_result_modular] import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { const credential = GoogleAuthProvider.credentialFromResult(result); diff --git a/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js b/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js index bd7a0360..14084a12 100644 --- a/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js +++ b/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js @@ -6,7 +6,7 @@ // [START auth_cordova_sign_in_redirect_modular] import { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithRedirect(auth, new GoogleAuthProvider()) .then(() => { return getRedirectResult(auth); diff --git a/snippets/auth-next/custom/auth_sign_in_custom.js b/snippets/auth-next/custom/auth_sign_in_custom.js index 018c8b07..3500d6d9 100644 --- a/snippets/auth-next/custom/auth_sign_in_custom.js +++ b/snippets/auth-next/custom/auth_sign_in_custom.js @@ -6,7 +6,7 @@ // [START auth_sign_in_custom_modular] import { getAuth, signInWithCustomToken } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithCustomToken(auth, token) .then((userCredential) => { // Signed in diff --git a/snippets/auth-next/email-link-auth/auth_email_link_link.js b/snippets/auth-next/email-link-auth/auth_email_link_link.js index 8c0147ed..07abe3c8 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_link.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_link.js @@ -11,7 +11,7 @@ const credential = EmailAuthProvider.credentialWithLink( email, window.location.href); // Link the credential to the current user. -const auth = getAuth(firebaseApp); +const auth = getAuth(); linkWithCredential(auth.currentUser, credential) .then((usercred) => { // The provider is now successfully linked. diff --git a/snippets/auth-next/email-link-auth/auth_email_link_reauth.js b/snippets/auth-next/email-link-auth/auth_email_link_reauth.js index e72b1c24..f6c57144 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_reauth.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_reauth.js @@ -11,7 +11,7 @@ const credential = EmailAuthProvider.credentialWithLink( email, window.location.href); // Re-authenticate the user with this credential. -const auth = getAuth(firebaseApp); +const auth = getAuth(); reauthenticateWithCredential(auth.currentUser, credential) .then((usercred) => { // The user is now successfully re-authenticated and can execute sensitive diff --git a/snippets/auth-next/email-link-auth/auth_email_link_send.js b/snippets/auth-next/email-link-auth/auth_email_link_send.js index 6fe2c15e..8a3065c8 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_send.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_send.js @@ -6,7 +6,7 @@ // [START auth_email_link_send_modular] import { getAuth, sendSignInLinkToEmail } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); sendSignInLinkToEmail(auth, email, actionCodeSettings) .then(() => { // The link was successfully sent. Inform the user. diff --git a/snippets/auth-next/email-link-auth/email_link_complete.js b/snippets/auth-next/email-link-auth/email_link_complete.js index af6b28ef..b0da2093 100644 --- a/snippets/auth-next/email-link-auth/email_link_complete.js +++ b/snippets/auth-next/email-link-auth/email_link_complete.js @@ -7,7 +7,7 @@ import { getAuth, isSignInWithEmailLink, signInWithEmailLink } from "firebase/auth"; // Confirm the link is a sign-in with email link. -const auth = getAuth(firebaseApp); +const auth = getAuth(); if (isSignInWithEmailLink(auth, window.location.href)) { // Additional state parameters can also be passed via URL. // This can be used to continue the user's intended action before triggering diff --git a/snippets/auth-next/email-link-auth/email_link_diferentiate.js b/snippets/auth-next/email-link-auth/email_link_diferentiate.js index 53bc1f32..cbbe0e57 100644 --- a/snippets/auth-next/email-link-auth/email_link_diferentiate.js +++ b/snippets/auth-next/email-link-auth/email_link_diferentiate.js @@ -9,7 +9,7 @@ import { getAuth, fetchSignInMethodsForEmail, EmailAuthProvider} from "firebase/ // After asking the user for their email. const email = window.prompt('Please provide your email'); -const auth = getAuth(firebaseApp); +const auth = getAuth(); fetchSignInMethodsForEmail(auth, email) .then((signInMethods) => { // This returns the same array as fetchProvidersForEmail but for email diff --git a/snippets/auth-next/email/auth_send_email_verification.js b/snippets/auth-next/email/auth_send_email_verification.js index a5e310c4..ef0c64b8 100644 --- a/snippets/auth-next/email/auth_send_email_verification.js +++ b/snippets/auth-next/email/auth_send_email_verification.js @@ -6,7 +6,7 @@ // [START auth_send_email_verification_modular] import { getAuth, sendEmailVerification } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); sendEmailVerification(auth.currentUser) .then(() => { // Email verification sent! diff --git a/snippets/auth-next/email/auth_send_password_reset.js b/snippets/auth-next/email/auth_send_password_reset.js index 86458fa1..1b195344 100644 --- a/snippets/auth-next/email/auth_send_password_reset.js +++ b/snippets/auth-next/email/auth_send_password_reset.js @@ -6,7 +6,7 @@ // [START auth_send_password_reset_modular] import { getAuth, sendPasswordResetEmail } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); sendPasswordResetEmail(auth, email) .then(() => { // Password reset email sent! diff --git a/snippets/auth-next/email/auth_signin_password.js b/snippets/auth-next/email/auth_signin_password.js index 43817787..2652af74 100644 --- a/snippets/auth-next/email/auth_signin_password.js +++ b/snippets/auth-next/email/auth_signin_password.js @@ -6,7 +6,7 @@ // [START auth_signin_password_modular] import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithEmailAndPassword(auth, email, password) .then((userCredential) => { // Signed in diff --git a/snippets/auth-next/email/auth_signup_password.js b/snippets/auth-next/email/auth_signup_password.js index 3a20884c..679bfbb0 100644 --- a/snippets/auth-next/email/auth_signup_password.js +++ b/snippets/auth-next/email/auth_signup_password.js @@ -6,7 +6,7 @@ // [START auth_signup_password_modular] import { getAuth, createUserWithEmailAndPassword } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); createUserWithEmailAndPassword(auth, email, password) .then((userCredential) => { // Signed in diff --git a/snippets/auth-next/emulator-suite/auth_emulator_connect.js b/snippets/auth-next/emulator-suite/auth_emulator_connect.js index e2b805ff..99f222ff 100644 --- a/snippets/auth-next/emulator-suite/auth_emulator_connect.js +++ b/snippets/auth-next/emulator-suite/auth_emulator_connect.js @@ -6,6 +6,6 @@ // [START auth_emulator_connect_modular] import { getAuth, useAuthEmulator } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); useAuthEmulator(auth, "http://localhost:9099"); // [END auth_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/auth-next/facebook/auth_facebook_callback.js b/snippets/auth-next/facebook/auth_facebook_callback.js index 489cabf9..144928d8 100644 --- a/snippets/auth-next/facebook/auth_facebook_callback.js +++ b/snippets/auth-next/facebook/auth_facebook_callback.js @@ -5,7 +5,7 @@ // [START auth_facebook_callback_modular] import { getAuth, onAuthStateChanged, signInWithCredential, signOut, FacebookAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); function checkLoginState(response) { if (response.authResponse) { diff --git a/snippets/auth-next/facebook/auth_facebook_signin_credential.js b/snippets/auth-next/facebook/auth_facebook_signin_credential.js index a5d8e551..84ce9612 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_credential.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_credential.js @@ -7,7 +7,7 @@ import { getAuth, signInWithCredential, FacebookAuthProvider } from "firebase/auth"; // Sign in with the credential from the Facebook user. -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithCredential(auth, credential) .then((result) => { // Signed in diff --git a/snippets/auth-next/facebook/auth_facebook_signin_popup.js b/snippets/auth-next/facebook/auth_facebook_signin_popup.js index 65cc1fd1..164948a2 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_popup.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_popup.js @@ -6,7 +6,7 @@ // [START auth_facebook_signin_popup_modular] import { getAuth, signInWithPopup, FacebookAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // The signed-in user info. diff --git a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js index a70191dc..9c2d5e30 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js @@ -6,7 +6,7 @@ // [START auth_facebook_signin_redirect_result_modular] import { getAuth, getRedirectResult, FacebookAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { // This gives you a Facebook Access Token. You can use it to access the Facebook API. diff --git a/snippets/auth-next/github/auth_github_signin_popup.js b/snippets/auth-next/github/auth_github_signin_popup.js index b5ac46a2..5b7a78b1 100644 --- a/snippets/auth-next/github/auth_github_signin_popup.js +++ b/snippets/auth-next/github/auth_github_signin_popup.js @@ -6,7 +6,7 @@ // [START auth_github_signin_popup_modular] import { getAuth, signInWithPopup, GithubAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // This gives you a GitHub Access Token. You can use it to access the GitHub API. diff --git a/snippets/auth-next/github/auth_github_signin_redirect_result.js b/snippets/auth-next/github/auth_github_signin_redirect_result.js index 423440fa..6884ed36 100644 --- a/snippets/auth-next/github/auth_github_signin_redirect_result.js +++ b/snippets/auth-next/github/auth_github_signin_redirect_result.js @@ -6,7 +6,7 @@ // [START auth_github_signin_redirect_result_modular] import { getAuth, getRedirectResult, GithubAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { const credential = GithubAuthProvider.credentialFromResult(result); diff --git a/snippets/auth-next/google-signin/auth_google_build_signin.js b/snippets/auth-next/google-signin/auth_google_build_signin.js index a462cb9e..b6f4bbb9 100644 --- a/snippets/auth-next/google-signin/auth_google_build_signin.js +++ b/snippets/auth-next/google-signin/auth_google_build_signin.js @@ -10,7 +10,7 @@ import { getAuth, signInWithCredential, GoogleAuthProvider } from "firebase/auth const credential = GoogleAuthProvider.credential(id_token); // Sign in with credential from the Google user. -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithCredential(auth, credential).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/snippets/auth-next/google-signin/auth_google_callback.js b/snippets/auth-next/google-signin/auth_google_callback.js index c79fc89f..2c23aa69 100644 --- a/snippets/auth-next/google-signin/auth_google_callback.js +++ b/snippets/auth-next/google-signin/auth_google_callback.js @@ -5,7 +5,7 @@ // [START auth_google_callback_modular] import { getAuth, onAuthStateChanged, signInWithCredential, GoogleAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); function onSignIn(googleUser) { console.log('Google Auth Response', googleUser); diff --git a/snippets/auth-next/google-signin/auth_google_signin_popup.js b/snippets/auth-next/google-signin/auth_google_signin_popup.js index b5763bf8..f74b800d 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_popup.js +++ b/snippets/auth-next/google-signin/auth_google_signin_popup.js @@ -6,7 +6,7 @@ // [START auth_google_signin_popup_modular] import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // This gives you a Google Access Token. You can use it to access the Google API. diff --git a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js index 410eae3f..2e91c4c6 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js +++ b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js @@ -6,7 +6,7 @@ // [START auth_google_signin_redirect_result_modular] import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { // This gives you a Google Access Token. You can use it to access Google APIs. diff --git a/snippets/auth-next/index/auth_set_language_code.js b/snippets/auth-next/index/auth_set_language_code.js index de11d4ce..6d4126f9 100644 --- a/snippets/auth-next/index/auth_set_language_code.js +++ b/snippets/auth-next/index/auth_set_language_code.js @@ -6,7 +6,7 @@ // [START auth_set_language_code_modular] import { getAuth } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); auth.languageCode = 'it'; // To apply the default browser preference instead of explicitly setting it. // firebase.auth().useDeviceLanguage(); diff --git a/snippets/auth-next/index/auth_sign_out.js b/snippets/auth-next/index/auth_sign_out.js index 9387b791..7360528c 100644 --- a/snippets/auth-next/index/auth_sign_out.js +++ b/snippets/auth-next/index/auth_sign_out.js @@ -6,7 +6,7 @@ // [START auth_sign_out_modular] import { getAuth, signOut } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signOut(auth).then(() => { // Sign-out successful. }).catch((error) => { diff --git a/snippets/auth-next/index/auth_signin_credential.js b/snippets/auth-next/index/auth_signin_credential.js index 6885e033..eccad4e6 100644 --- a/snippets/auth-next/index/auth_signin_credential.js +++ b/snippets/auth-next/index/auth_signin_credential.js @@ -7,7 +7,7 @@ import { getAuth, signInWithCredential } from "firebase/auth"; // Sign in with the credential from the user. -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithCredential(auth, credential) .then((result) => { // Signed in diff --git a/snippets/auth-next/index/auth_signin_redirect.js b/snippets/auth-next/index/auth_signin_redirect.js index 9062ac87..f5187cb3 100644 --- a/snippets/auth-next/index/auth_signin_redirect.js +++ b/snippets/auth-next/index/auth_signin_redirect.js @@ -6,6 +6,6 @@ // [START auth_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/index/auth_state_listener.js b/snippets/auth-next/index/auth_state_listener.js index 04f58e21..4764642b 100644 --- a/snippets/auth-next/index/auth_state_listener.js +++ b/snippets/auth-next/index/auth_state_listener.js @@ -6,7 +6,7 @@ // [START auth_state_listener_modular] import { getAuth, onAuthStateChanged } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); onAuthStateChanged(auth, (user) => { if (user) { // User is signed in, see docs for a list of available properties diff --git a/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js b/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js index fdffb99e..fb3cc1a8 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js +++ b/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js @@ -6,7 +6,7 @@ // [START auth_anonymous_link_modular] import { getAuth, linkWithCredential } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); linkWithCredential(auth.currentUser, credential) .then((usercred) => { const user = usercred.user; diff --git a/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js b/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js index b7ff7374..b531cbc6 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js +++ b/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js @@ -7,7 +7,7 @@ import { getAuth, linkWithPopup, GoogleAuthProvider } from "firebase/auth"; const provider = new GoogleAuthProvider(); -const auth = getAuth(firebaseApp); +const auth = getAuth(); linkWithPopup(auth.currentUser, provider).then((result) => { // Accounts successfully linked. const credential = GoogleAuthProvider.credentialFromResult(result); diff --git a/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js b/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js index 4df66560..fc06ec47 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js +++ b/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js @@ -7,7 +7,7 @@ import { getAuth, linkWithRedirect, GoogleAuthProvider } from "firebase/auth"; const provider = new GoogleAuthProvider(); -const auth = getAuth(firebaseApp); +const auth = getAuth(); linkWithRedirect(auth.currentUser, provider) .then(/* ... */) .catch(/* ... */); diff --git a/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js b/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js index 1f7205f2..2525d20a 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js +++ b/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js @@ -10,7 +10,7 @@ import { getAuth, signInWithCredential, linkWithCredential, OAuthProvider } from const repo = new MyUserDataRepo(); // Get reference to the currently signed-in user -const auth = getAuth(firebaseApp); +const auth = getAuth(); const prevUser = auth.currentUser; // Get the data which you will want to merge. This should be done now diff --git a/snippets/auth-next/link-multiple-accounts/auth_simple_link.js b/snippets/auth-next/link-multiple-accounts/auth_simple_link.js index 4aef5f6d..ca360976 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_simple_link.js +++ b/snippets/auth-next/link-multiple-accounts/auth_simple_link.js @@ -6,7 +6,7 @@ // [START auth_simple_link_modular] import { getAuth, linkWithCredential } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); linkWithCredential(auth.currentUser, credential) .then((usercred) => { const user = usercred.user; diff --git a/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js b/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js index 0140810a..7818cb06 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js +++ b/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js @@ -6,7 +6,7 @@ // [START auth_unlink_provider_modular] import { getAuth, unlink } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); unlink(auth.currentUser, providerId).then(() => { // Auth provider unlinked from account // ... diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js b/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js index 67a8ba9a..8e4da503 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js @@ -7,7 +7,7 @@ import { getAuth, linkWithPopup, OAuthProvider } from "firebase/auth"; const provider = new OAuthProvider('microsoft.com'); -const auth = getAuth(firebaseApp); +const auth = getAuth(); linkWithPopup(auth.currentUser, provider) .then((result) => { diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js b/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js index a15c3759..b257ec88 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js @@ -7,7 +7,7 @@ import { getAuth, reauthenticateWithPopup, OAuthProvider } from "firebase/auth"; const provider = new OAuthProvider('microsoft.com'); -const auth = getAuth(firebaseApp); +const auth = getAuth(); reauthenticateWithPopup(auth.currentUser, provider) .then((result) => { // User is re-authenticated with fresh tokens minted and diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js b/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js index 93c34d0a..2b1fffa9 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js @@ -6,7 +6,7 @@ // [START auth_msft_signin_popup_modular] import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // User is signed in. diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js index 7edec614..7e04a832 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js @@ -6,6 +6,6 @@ // [START auth_msft_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_msft_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js index 2d624588..3992a4d1 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js @@ -6,7 +6,7 @@ // [START auth_msft_signin_redirect_result_modular] import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { // User is signed in. diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js index 2be4c94b..2ee43e7c 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js @@ -6,7 +6,7 @@ // [START auth_phone_recaptcha_verifier_invisible_modular] import { getAuth, RecaptchaVerifier } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); window.recaptchaVerifier = new RecaptchaVerifier('sign-in-button', { 'size': 'invisible', 'callback': (response) => { diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js index e36af4f5..5a318bce 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js @@ -6,6 +6,6 @@ // [START auth_phone_recaptcha_verifier_simple_modular] import { getAuth, RecaptchaVerifier } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {}, auth); // [END auth_phone_recaptcha_verifier_simple_modular] \ No newline at end of file diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js index a3f4e28c..4b987ee7 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js @@ -6,7 +6,7 @@ // [START auth_phone_recaptcha_verifier_visible_modular] import { getAuth, RecaptchaVerifier } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', { 'size': 'normal', 'callback': (response) => { diff --git a/snippets/auth-next/phone-auth/auth_phone_signin.js b/snippets/auth-next/phone-auth/auth_phone_signin.js index 1c9ecb69..a7a3f0af 100644 --- a/snippets/auth-next/phone-auth/auth_phone_signin.js +++ b/snippets/auth-next/phone-auth/auth_phone_signin.js @@ -9,7 +9,7 @@ import { getAuth, signInWithPhoneNumber } from "firebase/auth"; const phoneNumber = getPhoneNumberFromUserInput(); const appVerifier = window.recaptchaVerifier; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPhoneNumber(auth, phoneNumber, appVerifier) .then((confirmationResult) => { // SMS sent. Prompt user to type the code from the message, then sign the diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js b/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js index fbed7d6b..e3a61d07 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js @@ -6,7 +6,7 @@ // [START auth_svc_get_idtoken_modular] import { getAuth, getIdToken } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getIdToken(auth.currentUser) .then((idToken) => { // idToken can be passed back to server. diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js b/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js index 14db554d..a7d6e30b 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js @@ -7,7 +7,7 @@ import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; // Sign in screen. -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithEmailAndPassword(auth, email, password) .then((result) => { // Redirect to profile page after sign-in. The service worker will detect diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js b/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js index c927fc4f..a3bb5c2a 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js @@ -15,7 +15,7 @@ initializeApp(config); * @return {!Promise} The promise that resolves with an ID token if * available. Otherwise, the promise resolves with null. */ -const auth = getAuth(firebaseApp); +const auth = getAuth(); const getIdTokenPromise = () => { return new Promise((resolve, reject) => { const unsubscribe = onAuthStateChanged(auth, (user) => { diff --git a/snippets/auth-next/twitter/auth_twitter_signin_popup.js b/snippets/auth-next/twitter/auth_twitter_signin_popup.js index d500a504..be2b7f57 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_popup.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_popup.js @@ -6,7 +6,7 @@ // [START auth_twitter_signin_popup_modular] import { getAuth, signInWithPopup, TwitterAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // This gives you a the Twitter OAuth 1.0 Access Token and Secret. diff --git a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js index 5d781644..cfecf9cc 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js @@ -6,7 +6,7 @@ // [START auth_twitter_signin_redirect_result_modular] import { getAuth, getRedirectResult, TwitterAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { // This gives you a the Twitter OAuth 1.0 Access Token and Secret. diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js index fbdaaeb1..8f672f6b 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js @@ -7,7 +7,7 @@ import { getAuth, linkWithPopup, OAuthProvider } from "firebase/auth"; const provider = new OAuthProvider('yahoo.com'); -const auth = getAuth(firebaseApp); +const auth = getAuth(); linkWithPopup(auth.currentUser, provider) .then((result) => { // Yahoo credential is linked to the current user. diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js index d14b58e3..b35e162d 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js @@ -7,7 +7,7 @@ import { getAuth, reauthenticateWithPopup, OAuthProvider } from "firebase/auth"; const provider = new OAuthProvider('yahoo.com'); -const auth = getAuth(firebaseApp); +const auth = getAuth(); reauthenticateWithPopup(auth.currentUser, provider) .then((result) => { // User is re-authenticated with fresh tokens minted and diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js index cad34a24..8c8c2713 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js @@ -6,7 +6,7 @@ // [START auth_yahoo_signin_popup_modular] import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithPopup(auth, provider) .then((result) => { // IdP data available in result.additionalUserInfo.profile diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js index 98ae3029..5acb5687 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js @@ -6,6 +6,6 @@ // [START auth_yahoo_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); signInWithRedirect(auth, provider); // [END auth_yahoo_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js index 11be5523..73f69951 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js @@ -6,7 +6,7 @@ // [START auth_yahoo_signin_redirect_result_modular] import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth"; -const auth = getAuth(firebaseApp); +const auth = getAuth(); getRedirectResult(auth) .then((result) => { // IdP data available in result.additionalUserInfo.profile diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js index b666d9b1..0015f451 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js @@ -6,7 +6,7 @@ // [START rtdb_emulator_connect_modular] import { getDatabase, useDatabaseEmulator } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. useDatabaseEmulator(db, "localhost", 9000); diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_flush.js b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js index 5f0e3f5c..0476a256 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_flush.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js @@ -7,6 +7,6 @@ import { getDatabase, ref, set } from "firebase/database"; // With a database Reference, write null to clear the database. -const db = getDatabase(firebaseApp); +const db = getDatabase(); set(ref(db), null); // [END rtdb_emulator_flush_modular] \ No newline at end of file diff --git a/snippets/database-next/index/rtdb_get_reference.js b/snippets/database-next/index/rtdb_get_reference.js index 2e2f31c7..fe16c855 100644 --- a/snippets/database-next/index/rtdb_get_reference.js +++ b/snippets/database-next/index/rtdb_get_reference.js @@ -6,5 +6,5 @@ // [START rtdb_get_reference_modular] import { getDatabase } from "firebase/database"; -const database = getDatabase(firebaseApp); +const database = getDatabase(); // [END rtdb_get_reference_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_children.js b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js index a527edeb..644c0334 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_listen_children.js +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js @@ -6,7 +6,7 @@ // [START rtdb_social_listen_children_modular] import { getDatabase, ref, onChildAdded, onChildChanged, onChildRemoved } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const commentsRef = ref(db, 'post-comments/' + postId); onChildAdded(commentsRef, (data) => { addCommentElement(postElement, data.key, data.val().text, data.val().author); diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_value.js b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js index 7250cc86..938308ad 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_listen_value.js +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js @@ -6,7 +6,7 @@ // [START rtdb_social_listen_value_modular] import { getDatabase, ref, onValue } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const dbRef = ref(db, '/a/b/c'); onValue(dbRef, (snapshot) => { diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_starred.js b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js index 96354b52..5c364682 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_most_starred.js +++ b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js @@ -7,8 +7,8 @@ import { getDatabase, ref, query, orderByChild } from "firebase/database"; import { getAuth } from "firebase/auth"; -const db = getDatabase(firebaseApp); -const auth = getAuth(firebaseApp); +const db = getDatabase(); +const auth = getAuth(); const myUserId = auth.currentUser.uid; const topUserPostsRef = query(ref(db, 'user-posts/' + myUserId), orderByChild('starCount')); diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js index 3d661562..784df41e 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js +++ b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js @@ -6,6 +6,6 @@ // [START rtdb_social_most_viewed_modular] import { getDatabase, ref, query, orderByChild } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const mostViewedPosts = query(ref(db, 'posts'), orderByChild('metrics/views')); // [END rtdb_social_most_viewed_modular] \ No newline at end of file diff --git a/snippets/database-next/lists-of-data/rtdb_social_push.js b/snippets/database-next/lists-of-data/rtdb_social_push.js index 313ff67c..c62c0a0a 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_push.js +++ b/snippets/database-next/lists-of-data/rtdb_social_push.js @@ -7,7 +7,7 @@ import { getDatabase, ref, push, set } from "firebase/database"; // Create a new post reference with an auto-generated id -const db = getDatabase(firebaseApp); +const db = getDatabase(); const postListRef = ref(db, 'posts'); const newPostRef = push(postListRef); set(newPostRef, { diff --git a/snippets/database-next/lists-of-data/rtdb_social_recent.js b/snippets/database-next/lists-of-data/rtdb_social_recent.js index a946817f..0f26c486 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_recent.js +++ b/snippets/database-next/lists-of-data/rtdb_social_recent.js @@ -6,6 +6,6 @@ // [START rtdb_social_recent_modular] import { getDatabase, ref, query, limitToLast } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const recentPostsRef = query(ref(db, 'posts'), limitToLast(100)); // [END rtdb_social_recent_modular] \ No newline at end of file diff --git a/snippets/database-next/offline/rtdb_detect_connection_state.js b/snippets/database-next/offline/rtdb_detect_connection_state.js index b2bedd44..e37375d2 100644 --- a/snippets/database-next/offline/rtdb_detect_connection_state.js +++ b/snippets/database-next/offline/rtdb_detect_connection_state.js @@ -6,7 +6,7 @@ // [START rtdb_detect_connection_state_modular] import { getDatabase, ref, onValue } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const connectedRef = ref(db, ".info/connected"); onValue(connectedRef, (snap) => { if (snap.val() === true) { diff --git a/snippets/database-next/offline/rtdb_estimate_clock_skew.js b/snippets/database-next/offline/rtdb_estimate_clock_skew.js index 0d7fea48..9e4b6f5d 100644 --- a/snippets/database-next/offline/rtdb_estimate_clock_skew.js +++ b/snippets/database-next/offline/rtdb_estimate_clock_skew.js @@ -6,7 +6,7 @@ // [START rtdb_estimate_clock_skew_modular] import { getDatabase, ref, onValue } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const offsetRef = ref(db, ".info/serverTimeOffset"); onValue(offsetRef, (snap) => { const offset = snap.val(); diff --git a/snippets/database-next/offline/rtdb_ondisconnect_simple.js b/snippets/database-next/offline/rtdb_ondisconnect_simple.js index 838ab744..da1fdf4f 100644 --- a/snippets/database-next/offline/rtdb_ondisconnect_simple.js +++ b/snippets/database-next/offline/rtdb_ondisconnect_simple.js @@ -6,7 +6,7 @@ // [START rtdb_ondisconnect_simple_modular] import { getDatabase, ref, onDisconnect } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const presenceRef = ref(db, "disconnectmessage"); // Write a string when this client loses connection onDisconnect(presenceRef).set("I disconnected!"); diff --git a/snippets/database-next/offline/rtdb_sample_presence_app.js b/snippets/database-next/offline/rtdb_sample_presence_app.js index e093238e..504f396f 100644 --- a/snippets/database-next/offline/rtdb_sample_presence_app.js +++ b/snippets/database-next/offline/rtdb_sample_presence_app.js @@ -8,7 +8,7 @@ import { getDatabase, ref, onValue, push, onDisconnect, set, serverTimestamp } f // Since I can connect from multiple devices or browser tabs, we store each connection instance separately // any time that connectionsRef's value is null (i.e. has no children) I am offline -const db = getDatabase(firebaseApp); +const db = getDatabase(); const myConnectionsRef = ref(db, 'users/joe/connections'); // stores the timestamp of my last disconnect (the last time I was seen online) diff --git a/snippets/database-next/offline/rtdb_set_server_timestamp.js b/snippets/database-next/offline/rtdb_set_server_timestamp.js index 14850121..4a1a219b 100644 --- a/snippets/database-next/offline/rtdb_set_server_timestamp.js +++ b/snippets/database-next/offline/rtdb_set_server_timestamp.js @@ -6,7 +6,7 @@ // [START rtdb_set_server_timestamp_modular] import { getDatabase, ref, onDisconnect, serverTimestamp } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const userLastOnlineRef = ref(db, "users/joe/lastOnline"); onDisconnect(userLastOnlineRef).set(serverTimestamp()); // [END rtdb_set_server_timestamp_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_read_once_get.js b/snippets/database-next/read-and-write/rtdb_read_once_get.js index 13799f3a..ec618da0 100644 --- a/snippets/database-next/read-and-write/rtdb_read_once_get.js +++ b/snippets/database-next/read-and-write/rtdb_read_once_get.js @@ -6,7 +6,7 @@ // [START rtdb_read_once_get_modular] import { getDatabase, ref, child, get } from "firebase/database"; -const dbRef = ref(getDatabase(firebaseApp)); +const dbRef = ref(getDatabase()); get(child(dbRef, `users/${userId}`)).then((snapshot) => { if (snapshot.exists()) { console.log(snapshot.val()); diff --git a/snippets/database-next/read-and-write/rtdb_social_completion_callback.js b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js index cb22a488..483dd962 100644 --- a/snippets/database-next/read-and-write/rtdb_social_completion_callback.js +++ b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js @@ -6,7 +6,7 @@ // [START rtdb_social_completion_callback_modular] import { getDatabase, ref, set } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); set(ref(db, 'users/' + userId), { username: name, email: email, diff --git a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js index 3a7c7e85..3f7f498b 100644 --- a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js +++ b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js @@ -6,7 +6,7 @@ // [START rtdb_social_listen_star_count_modular] import { getDatabase, ref, onValue} from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); const starCountRef = ref(db, 'posts/' + postId + '/starCount'); onValue(starCountRef, (snapshot) => { const data = snapshot.val(); diff --git a/snippets/database-next/read-and-write/rtdb_social_single_value_read.js b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js index 5e68d8c1..276bdfd3 100644 --- a/snippets/database-next/read-and-write/rtdb_social_single_value_read.js +++ b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js @@ -7,8 +7,8 @@ import { getDatabase, ref, onValue } from "firebase/database"; import { getAuth } from "firebase/auth"; -const db = getDatabase(firebaseApp); -const auth = getAuth(firebaseApp); +const db = getDatabase(); +const auth = getAuth(); const userId = auth.currentUser.uid; return onValue(ref(db, '/users/' + userId), (snapshot) => { diff --git a/snippets/database-next/read-and-write/rtdb_social_star_transaction.js b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js index 9f0679a8..af817f0c 100644 --- a/snippets/database-next/read-and-write/rtdb_social_star_transaction.js +++ b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js @@ -7,7 +7,7 @@ import { getDatabase, ref, runTransaction } from "firebase/database"; function toggleStar(uid) { - const db = getDatabase(firebaseApp); + const db = getDatabase(); const postRef = ref(db, '/posts/foo-bar-123'); runTransaction(postRef, (post) => { diff --git a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js index d51a23eb..a87824e9 100644 --- a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js +++ b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js @@ -5,7 +5,7 @@ // [START rtdb_social_write_fan_out_modular] function writeNewPost(uid, username, picture, title, body) { - const db = getDatabase(firebaseApp); + const db = getDatabase(); // A post entry. const postData = { diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user.js b/snippets/database-next/read-and-write/rtdb_write_new_user.js index 85f0ad83..85ecc9f4 100644 --- a/snippets/database-next/read-and-write/rtdb_write_new_user.js +++ b/snippets/database-next/read-and-write/rtdb_write_new_user.js @@ -4,10 +4,10 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_write_new_user_modular] -import { getDatabase, ref, set} from "firebase/database"; +import { getDatabase, ref, set } from "firebase/database"; function writeUserData(userId, name, email, imageUrl) { - const db = getDatabase(firebaseApp); + const db = getDatabase(); set(ref(db, 'users/' + userId), { username: name, email: email, diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js index 41dffc81..b6e0dacb 100644 --- a/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js +++ b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js @@ -6,7 +6,7 @@ // [START rtdb_write_new_user_completion_modular] import { getDatabase, ref, set } from "firebase/database"; -const db = getDatabase(firebaseApp); +const db = getDatabase(); set(ref(db, 'users/' + userId), { username: name, email: email, diff --git a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js index f0984d8b..140f6a09 100644 --- a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js +++ b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js @@ -7,6 +7,6 @@ import { getFirestore, useFirestoreEmulator } from "firebase/firestore"; // firebaseApps previously initialized using initializeApp() -const db = getFirestore(firebaseApp); +const db = getFirestore(); useFirestoreEmulator(db, 'localhost', 8080); // [END fs_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/functions-next/callable/fb_functions_call_add_message.js b/snippets/functions-next/callable/fb_functions_call_add_message.js index c2e1b34f..12d4d242 100644 --- a/snippets/functions-next/callable/fb_functions_call_add_message.js +++ b/snippets/functions-next/callable/fb_functions_call_add_message.js @@ -6,7 +6,7 @@ // [START fb_functions_call_add_message_modular] import { getFunctions, httpsCallable } from "firebase/functions"; -const functions = getFunctions(firebaseApp); +const functions = getFunctions(); const addMessage = httpsCallable(functions, 'addMessage'); addMessage({ text: messageText }) .then((result) => { diff --git a/snippets/functions-next/callable/fb_functions_call_add_message_error.js b/snippets/functions-next/callable/fb_functions_call_add_message_error.js index e5186ea9..3a34c845 100644 --- a/snippets/functions-next/callable/fb_functions_call_add_message_error.js +++ b/snippets/functions-next/callable/fb_functions_call_add_message_error.js @@ -6,7 +6,7 @@ // [START fb_functions_call_add_message_error_modular] import { getFunctions, httpsCallable } from "firebase/functions"; -const functions = getFunctions(firebaseApp); +const functions = getFunctions(); const addMessage = httpsCallable(functions, 'addMessage'); addMessage({ text: messageText }) .then((result) => { diff --git a/snippets/messaging-next/index/messaging_delete_token.js b/snippets/messaging-next/index/messaging_delete_token.js index c6e1bf9e..f8d6ef63 100644 --- a/snippets/messaging-next/index/messaging_delete_token.js +++ b/snippets/messaging-next/index/messaging_delete_token.js @@ -6,7 +6,7 @@ // [START messaging_delete_token_modular] import { getMessaging, deleteToken } from "firebase/messaging"; -const messaging = getMessaging(firebaseApp); +const messaging = getMessaging(); deleteToken(messaging).then(() => { console.log('Token deleted.'); // ... diff --git a/snippets/messaging-next/index/messaging_get_messaging_object.js b/snippets/messaging-next/index/messaging_get_messaging_object.js index 5e75a7a5..5dc88c68 100644 --- a/snippets/messaging-next/index/messaging_get_messaging_object.js +++ b/snippets/messaging-next/index/messaging_get_messaging_object.js @@ -6,5 +6,5 @@ // [START messaging_get_messaging_object_modular] import { getMessaging } from "firebase/messaging"; -const messaging = getMessaging(firebaseApp); +const messaging = getMessaging(); // [END messaging_get_messaging_object_modular] \ No newline at end of file diff --git a/snippets/messaging-next/index/messaging_get_token.js b/snippets/messaging-next/index/messaging_get_token.js index 01773b6d..f1f4b3aa 100644 --- a/snippets/messaging-next/index/messaging_get_token.js +++ b/snippets/messaging-next/index/messaging_get_token.js @@ -8,7 +8,7 @@ import { getMessaging, getToken } from "firebase/messaging"; // Get registration token. Initially this makes a network call, once retrieved // subsequent calls to getToken will return from cache. -const messaging = getMessaging(firebaseApp); +const messaging = getMessaging(); getToken(messaging, { vapidKey: '' }).then((currentToken) => { if (currentToken) { // Send the token to your server and update the UI if necessary diff --git a/snippets/messaging-next/index/messaging_receive_message.js b/snippets/messaging-next/index/messaging_receive_message.js index c95d1be4..94c3864d 100644 --- a/snippets/messaging-next/index/messaging_receive_message.js +++ b/snippets/messaging-next/index/messaging_receive_message.js @@ -10,7 +10,7 @@ // `messaging.onBackgroundMessage` handler. import { getMessaging, onMessage } from "firebase/messaging"; -const messaging = getMessaging(firebaseApp); +const messaging = getMessaging(); onMessage(messaging, (payload) => { console.log('Message received. ', payload); // ... diff --git a/snippets/perf-next/index/perf_get_instance.js b/snippets/perf-next/index/perf_get_instance.js index c17d5103..cbee11e6 100644 --- a/snippets/perf-next/index/perf_get_instance.js +++ b/snippets/perf-next/index/perf_get_instance.js @@ -5,5 +5,5 @@ // [START perf_get_instance_modular] import { getPerformance } from "firebase/performance"; -const perf = getPerformance(firebaseApp); +const perf = getPerformance(); // [END perf_get_instance_modular] \ No newline at end of file diff --git a/snippets/remoteconfig-next/index/rc_get_instance.js b/snippets/remoteconfig-next/index/rc_get_instance.js index e20bd5a9..7d59bf9d 100644 --- a/snippets/remoteconfig-next/index/rc_get_instance.js +++ b/snippets/remoteconfig-next/index/rc_get_instance.js @@ -6,5 +6,5 @@ // [START rc_get_instance_modular] import { getRemoteConfig } from "firebase/remote-config"; -const remoteConfig = getRemoteConfig(firebaseApp); +const remoteConfig = getRemoteConfig(); // [END rc_get_instance_modular] \ No newline at end of file diff --git a/snippets/storage-next/create-reference/storage_create_ref.js b/snippets/storage-next/create-reference/storage_create_ref.js index f69cc959..eb27bacb 100644 --- a/snippets/storage-next/create-reference/storage_create_ref.js +++ b/snippets/storage-next/create-reference/storage_create_ref.js @@ -7,7 +7,7 @@ import { getStorage, ref } from "firebase/storage"; // Get a reference to the storage service, which is used to create references in your storage bucket -const storage = getStorage(firebaseApp); +const storage = getStorage(); // Create a storage reference from our storage service const storageRef = ref(storage); diff --git a/snippets/storage-next/create-reference/storage_create_ref_child.js b/snippets/storage-next/create-reference/storage_create_ref_child.js index ded271e0..53b6834c 100644 --- a/snippets/storage-next/create-reference/storage_create_ref_child.js +++ b/snippets/storage-next/create-reference/storage_create_ref_child.js @@ -6,7 +6,7 @@ // [START storage_create_ref_child_modular] import { getStorage, ref } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); // Create a child reference const imagesRef = ref(storage, 'images'); diff --git a/snippets/storage-next/create-reference/storage_navigate_ref.js b/snippets/storage-next/create-reference/storage_navigate_ref.js index 3cdc6b6d..00a9e53f 100644 --- a/snippets/storage-next/create-reference/storage_navigate_ref.js +++ b/snippets/storage-next/create-reference/storage_navigate_ref.js @@ -6,7 +6,7 @@ // [START storage_navigate_ref_modular] import { getStorage, ref } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const spaceRef = ref(storage, 'images/space.jpg'); // Parent allows us to move to the parent of a reference diff --git a/snippets/storage-next/create-reference/storage_navigate_ref_chain.js b/snippets/storage-next/create-reference/storage_navigate_ref_chain.js index 93607b72..e0f2a056 100644 --- a/snippets/storage-next/create-reference/storage_navigate_ref_chain.js +++ b/snippets/storage-next/create-reference/storage_navigate_ref_chain.js @@ -6,7 +6,7 @@ // [START storage_navigate_ref_chain_modular] import { getStorage, ref } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const spaceRef = ref(storage, 'images/space.jpg'); // References can be chained together multiple times diff --git a/snippets/storage-next/create-reference/storage_ref_full_example.js b/snippets/storage-next/create-reference/storage_ref_full_example.js index 0869f09c..3c9f94c6 100644 --- a/snippets/storage-next/create-reference/storage_ref_full_example.js +++ b/snippets/storage-next/create-reference/storage_ref_full_example.js @@ -6,7 +6,7 @@ // [START storage_ref_full_example_modular] import { getStorage, ref } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); // Points to the root reference const storageRef = ref(storage); diff --git a/snippets/storage-next/create-reference/storage_ref_properties.js b/snippets/storage-next/create-reference/storage_ref_properties.js index 4707b931..494817ea 100644 --- a/snippets/storage-next/create-reference/storage_ref_properties.js +++ b/snippets/storage-next/create-reference/storage_ref_properties.js @@ -6,7 +6,7 @@ // [START storage_ref_properties_modular] import { getStorage, ref } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const spaceRef = ref(storage, 'images/space.jpg'); // Reference's path is: 'images/space.jpg' diff --git a/snippets/storage-next/delete-files/storage_delete_file.js b/snippets/storage-next/delete-files/storage_delete_file.js index be582722..86520968 100644 --- a/snippets/storage-next/delete-files/storage_delete_file.js +++ b/snippets/storage-next/delete-files/storage_delete_file.js @@ -6,7 +6,7 @@ // [START storage_delete_file_modular] import { getStorage, ref, deleteObject } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); // Create a reference to the file to delete const desertRef = ref(storage, 'images/desert.jpg'); diff --git a/snippets/storage-next/download-files/storage_download_create_ref.js b/snippets/storage-next/download-files/storage_download_create_ref.js index 5a17307d..bf12aaa9 100644 --- a/snippets/storage-next/download-files/storage_download_create_ref.js +++ b/snippets/storage-next/download-files/storage_download_create_ref.js @@ -7,7 +7,7 @@ import { getStorage, ref } from "firebase/storage"; // Create a reference with an initial file path and name -const storage = getStorage(firebaseApp); +const storage = getStorage(); const pathReference = ref(storage, 'images/stars.jpg'); // Create a reference from a Google Cloud Storage URI diff --git a/snippets/storage-next/download-files/storage_download_full_example.js b/snippets/storage-next/download-files/storage_download_full_example.js index 126ce2ea..4b66880e 100644 --- a/snippets/storage-next/download-files/storage_download_full_example.js +++ b/snippets/storage-next/download-files/storage_download_full_example.js @@ -7,7 +7,7 @@ import { getStorage, ref, getDownloadURL } from "firebase/storage"; // Create a reference to the file we want to download -const storage = getStorage(firebaseApp); +const storage = getStorage(); const starsRef = ref(storage, 'images/stars.jpg'); // Get the download URL diff --git a/snippets/storage-next/download-files/storage_download_via_url.js b/snippets/storage-next/download-files/storage_download_via_url.js index 50be6f65..0e45cada 100644 --- a/snippets/storage-next/download-files/storage_download_via_url.js +++ b/snippets/storage-next/download-files/storage_download_via_url.js @@ -6,7 +6,7 @@ // [START storage_download_via_url_modular] import { getStorage, ref, getDownloadURL } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); getDownloadURL(ref(storage, 'images/stars.jpg')) .then((url) => { // `url` is the download URL for 'images/stars.jpg' diff --git a/snippets/storage-next/file-metadata/storage_delete_metadata.js b/snippets/storage-next/file-metadata/storage_delete_metadata.js index 927e4be8..c6b2ece3 100644 --- a/snippets/storage-next/file-metadata/storage_delete_metadata.js +++ b/snippets/storage-next/file-metadata/storage_delete_metadata.js @@ -6,7 +6,7 @@ // [START storage_delete_metadata_modular] import { getStorage, ref, updateMetadata } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const forestRef = ref(storage, 'images/forest.jpg'); // Create file metadata with property to delete diff --git a/snippets/storage-next/file-metadata/storage_get_metadata.js b/snippets/storage-next/file-metadata/storage_get_metadata.js index 8bc462f1..e77444db 100644 --- a/snippets/storage-next/file-metadata/storage_get_metadata.js +++ b/snippets/storage-next/file-metadata/storage_get_metadata.js @@ -7,7 +7,7 @@ import { getStorage, ref, getMetadata } from "firebase/storage"; // Create a reference to the file whose metadata we want to retrieve -const storage = getStorage(firebaseApp); +const storage = getStorage(); const forestRef = ref(storage, 'images/forest.jpg'); // Get metadata properties diff --git a/snippets/storage-next/file-metadata/storage_update_metadata.js b/snippets/storage-next/file-metadata/storage_update_metadata.js index 97cacc4b..fd9d6183 100644 --- a/snippets/storage-next/file-metadata/storage_update_metadata.js +++ b/snippets/storage-next/file-metadata/storage_update_metadata.js @@ -7,7 +7,7 @@ import { getStorage, ref, updateMetadata } from "firebase/storage"; // Create a reference to the file whose metadata we want to change -const storage = getStorage(firebaseApp); +const storage = getStorage(); const forestRef = ref(storage, 'images/forest.jpg'); // Create file metadata to update diff --git a/snippets/storage-next/index/storage_multiple_buckets.js b/snippets/storage-next/index/storage_multiple_buckets.js index 83c3770e..1022299b 100644 --- a/snippets/storage-next/index/storage_multiple_buckets.js +++ b/snippets/storage-next/index/storage_multiple_buckets.js @@ -4,8 +4,10 @@ // To make edits to the snippets in this file, please edit the source // [START storage_multiple_buckets_modular] +import { getApp } from "firebase/app"; import { getStorage } from "firebase/storage"; // Get a non-default Storage bucket +const firebaseApp = getApp(); const storage = getStorage(firebaseApp, "gs://my-custom-bucket"); // [END storage_multiple_buckets_modular] \ No newline at end of file diff --git a/snippets/storage-next/index/storage_on_complete.js b/snippets/storage-next/index/storage_on_complete.js index c0c615ff..aa3edca8 100644 --- a/snippets/storage-next/index/storage_on_complete.js +++ b/snippets/storage-next/index/storage_on_complete.js @@ -6,7 +6,7 @@ // [START storage_on_complete_modular] import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const imageRef = ref(storage, 'images/' + file.name); uploadBytesResumable(imageRef, file, metadata) .then((snapshot) => { diff --git a/snippets/storage-next/list-files/storage_list_all.js b/snippets/storage-next/list-files/storage_list_all.js index 9f794ca4..1adf935a 100644 --- a/snippets/storage-next/list-files/storage_list_all.js +++ b/snippets/storage-next/list-files/storage_list_all.js @@ -6,7 +6,7 @@ // [START storage_list_all_modular] import { getStorage, ref, listAll } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); // Create a reference under which you want to list const listRef = ref(storage, 'files/uid'); diff --git a/snippets/storage-next/list-files/storage_list_paginate.js b/snippets/storage-next/list-files/storage_list_paginate.js index 4415ccdc..d04cd1d3 100644 --- a/snippets/storage-next/list-files/storage_list_paginate.js +++ b/snippets/storage-next/list-files/storage_list_paginate.js @@ -8,7 +8,7 @@ import { getStorage, ref, list } from "firebase/storage"; async function pageTokenExample(){ // Create a reference under which you want to list - const storage = getStorage(firebaseApp); + const storage = getStorage(); const listRef = ref(storage, 'files/uid'); // Fetch the first page of 100. diff --git a/snippets/storage-next/upload-files/storage_manage_uploads.js b/snippets/storage-next/upload-files/storage_manage_uploads.js index 476503bb..2623e8a1 100644 --- a/snippets/storage-next/upload-files/storage_manage_uploads.js +++ b/snippets/storage-next/upload-files/storage_manage_uploads.js @@ -6,7 +6,7 @@ // [START storage_manage_uploads_modular] import { getStorage, ref, uploadBytesResumable } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const storageRef = ref(storage, 'images/mountains.jpg'); // Upload the file and metadata diff --git a/snippets/storage-next/upload-files/storage_monitor_upload.js b/snippets/storage-next/upload-files/storage_monitor_upload.js index f6d81935..101f509a 100644 --- a/snippets/storage-next/upload-files/storage_monitor_upload.js +++ b/snippets/storage-next/upload-files/storage_monitor_upload.js @@ -6,7 +6,7 @@ // [START storage_monitor_upload_modular] import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const storageRef = ref(storage, 'images/rivers.jpg'); const uploadTask = uploadBytesResumable(storageRef, file); diff --git a/snippets/storage-next/upload-files/storage_upload_blob.js b/snippets/storage-next/upload-files/storage_upload_blob.js index 11970dea..c33593cb 100644 --- a/snippets/storage-next/upload-files/storage_upload_blob.js +++ b/snippets/storage-next/upload-files/storage_upload_blob.js @@ -6,7 +6,7 @@ // [START storage_upload_blob_modular] import { getStorage, ref, uploadBytes } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const storageRef = ref(storage, 'some-child'); // 'file' comes from the Blob or File API diff --git a/snippets/storage-next/upload-files/storage_upload_bytes.js b/snippets/storage-next/upload-files/storage_upload_bytes.js index aa906060..ebf12e66 100644 --- a/snippets/storage-next/upload-files/storage_upload_bytes.js +++ b/snippets/storage-next/upload-files/storage_upload_bytes.js @@ -6,7 +6,7 @@ // [START storage_upload_bytes_modular] import { getStorage, ref, uploadBytes } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const storageRef = ref(storage, 'some-child'); const bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21]); diff --git a/snippets/storage-next/upload-files/storage_upload_handle_error.js b/snippets/storage-next/upload-files/storage_upload_handle_error.js index 3baa5758..434fc230 100644 --- a/snippets/storage-next/upload-files/storage_upload_handle_error.js +++ b/snippets/storage-next/upload-files/storage_upload_handle_error.js @@ -6,7 +6,7 @@ // [START storage_upload_handle_error_modular] import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); // Create the file metadata /** @type {any} */ diff --git a/snippets/storage-next/upload-files/storage_upload_metadata.js b/snippets/storage-next/upload-files/storage_upload_metadata.js index 6632cfb6..1ac39783 100644 --- a/snippets/storage-next/upload-files/storage_upload_metadata.js +++ b/snippets/storage-next/upload-files/storage_upload_metadata.js @@ -6,7 +6,7 @@ // [START storage_upload_metadata_modular] import { getStorage, ref, uploadBytes } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const storageRef = ref(storage, 'images/mountains.jpg'); // Create file metadata including the content type diff --git a/snippets/storage-next/upload-files/storage_upload_ref.js b/snippets/storage-next/upload-files/storage_upload_ref.js index 820b2632..e776120d 100644 --- a/snippets/storage-next/upload-files/storage_upload_ref.js +++ b/snippets/storage-next/upload-files/storage_upload_ref.js @@ -7,7 +7,7 @@ import { getStorage, ref } from "firebase/storage"; // Create a root reference -const storage = getStorage(firebaseApp); +const storage = getStorage(); // Create a reference to 'mountains.jpg' const mountainsRef = ref(storage, 'mountains.jpg'); diff --git a/snippets/storage-next/upload-files/storage_upload_string.js b/snippets/storage-next/upload-files/storage_upload_string.js index 80b8aaa3..ce0d4736 100644 --- a/snippets/storage-next/upload-files/storage_upload_string.js +++ b/snippets/storage-next/upload-files/storage_upload_string.js @@ -6,7 +6,7 @@ // [START storage_upload_string_modular] import { getStorage, ref, uploadString } from "firebase/storage"; -const storage = getStorage(firebaseApp); +const storage = getStorage(); const storageRef = ref(storage, 'some-child'); // Raw string is the default if no format is provided diff --git a/storage-next/create-reference.js b/storage-next/create-reference.js index eae1ff4f..47a6e227 100644 --- a/storage-next/create-reference.js +++ b/storage-next/create-reference.js @@ -1,20 +1,12 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function createRef() { // [START storage_create_ref] const { getStorage, ref } = require("firebase/storage"); // Get a reference to the storage service, which is used to create references in your storage bucket - const storage = getStorage(firebaseApp); + const storage = getStorage(); // Create a storage reference from our storage service const storageRef = ref(storage); @@ -25,7 +17,7 @@ function createRefChild() { // [START storage_create_ref_child] const { getStorage, ref } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); // Create a child reference const imagesRef = ref(storage, 'images'); @@ -42,7 +34,7 @@ function navigateRef() { // [START storage_navigate_ref] const { getStorage, ref } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const spaceRef = ref(storage, 'images/space.jpg'); // Parent allows us to move to the parent of a reference @@ -59,7 +51,7 @@ function navigateRefChain() { // [START storage_navigate_ref_chain] const { getStorage, ref } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const spaceRef = ref(storage, 'images/space.jpg'); // References can be chained together multiple times @@ -75,7 +67,7 @@ function refProperties() { // [START storage_ref_properties] const { getStorage, ref } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const spaceRef = ref(storage, 'images/space.jpg'); // Reference's path is: 'images/space.jpg' @@ -95,7 +87,7 @@ function refFullExample() { // [START storage_ref_full_example] const { getStorage, ref } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); // Points to the root reference const storageRef = ref(storage); diff --git a/storage-next/delete-files.js b/storage-next/delete-files.js index d5e640b5..767a26f2 100644 --- a/storage-next/delete-files.js +++ b/storage-next/delete-files.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function deleteFile() { // [START storage_delete_file] const { getStorage, ref, deleteObject } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); // Create a reference to the file to delete const desertRef = ref(storage, 'images/desert.jpg'); diff --git a/storage-next/download-files.js b/storage-next/download-files.js index 5cfec855..6e94e63a 100644 --- a/storage-next/download-files.js +++ b/storage-next/download-files.js @@ -1,20 +1,12 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function downloadCreateRef() { // [START storage_download_create_ref] const { getStorage, ref } = require("firebase/storage"); // Create a reference with an initial file path and name - const storage = getStorage(firebaseApp); + const storage = getStorage(); const pathReference = ref(storage, 'images/stars.jpg'); // Create a reference from a Google Cloud Storage URI @@ -30,7 +22,7 @@ function downloadViaUrl() { // [START storage_download_via_url] const { getStorage, ref, getDownloadURL } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); getDownloadURL(ref(storage, 'images/stars.jpg')) .then((url) => { // `url` is the download URL for 'images/stars.jpg' @@ -59,7 +51,7 @@ function downloadFullExample() { const { getStorage, ref, getDownloadURL } = require("firebase/storage"); // Create a reference to the file we want to download - const storage = getStorage(firebaseApp); + const storage = getStorage(); const starsRef = ref(storage, 'images/stars.jpg'); // Get the download URL diff --git a/storage-next/file-metadata.js b/storage-next/file-metadata.js index 13624cc6..c45827cd 100644 --- a/storage-next/file-metadata.js +++ b/storage-next/file-metadata.js @@ -1,20 +1,12 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function getMetadata() { // [START storage_get_metadata] const { getStorage, ref, getMetadata } = require("firebase/storage"); // Create a reference to the file whose metadata we want to retrieve - const storage = getStorage(firebaseApp); + const storage = getStorage(); const forestRef = ref(storage, 'images/forest.jpg'); // Get metadata properties @@ -33,7 +25,7 @@ function updateMetadata() { const { getStorage, ref, updateMetadata } = require("firebase/storage"); // Create a reference to the file whose metadata we want to change - const storage = getStorage(firebaseApp); + const storage = getStorage(); const forestRef = ref(storage, 'images/forest.jpg'); // Create file metadata to update @@ -56,7 +48,7 @@ function deleteMetadata() { // [START storage_delete_metadata] const { getStorage, ref, updateMetadata } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const forestRef = ref(storage, 'images/forest.jpg'); // Create file metadata with property to delete diff --git a/storage-next/index.js b/storage-next/index.js index 1b18b957..15b07e5f 100644 --- a/storage-next/index.js +++ b/storage-next/index.js @@ -1,14 +1,6 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function initialize() { // [START storage_initialize] const { initializeApp } = require("firebase/app"); @@ -31,9 +23,11 @@ function initialize() { function multipleBuckets() { // [START storage_multiple_buckets] + const { getApp } = require("firebase/app"); const { getStorage } = require("firebase/storage"); // Get a non-default Storage bucket + const firebaseApp = getApp(); const storage = getStorage(firebaseApp, "gs://my-custom-bucket"); // [END storage_multiple_buckets] } @@ -73,7 +67,7 @@ function storageOnComplete(file) { // [START storage_on_complete] const { getStorage, ref, uploadBytesResumable, getDownloadURL } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const imageRef = ref(storage, 'images/' + file.name); uploadBytesResumable(imageRef, file, metadata) .then((snapshot) => { diff --git a/storage-next/list-files.js b/storage-next/list-files.js index 4d3f05cc..493972d2 100644 --- a/storage-next/list-files.js +++ b/storage-next/list-files.js @@ -1,19 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function listAll() { // [START storage_list_all] const { getStorage, ref, listAll } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); // Create a reference under which you want to list const listRef = ref(storage, 'files/uid'); @@ -40,7 +32,7 @@ function listPaginate() { async function pageTokenExample(){ // Create a reference under which you want to list - const storage = getStorage(firebaseApp); + const storage = getStorage(); const listRef = ref(storage, 'files/uid'); // Fetch the first page of 100. diff --git a/storage-next/upload-files.js b/storage-next/upload-files.js index 1ff5d4a8..98b93225 100644 --- a/storage-next/upload-files.js +++ b/storage-next/upload-files.js @@ -1,20 +1,12 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -import { initializeApp } from "firebase/app"; - -const firebaseApp = initializeApp({ - apiKey: '### FIREBASE API KEY ###', - appId: '### FIREBASE APP ID ###', - projectId: '### FIREBASE PROJECT ID ###' -}); - function uploadRef() { // [START storage_upload_ref] const { getStorage, ref } = require("firebase/storage"); // Create a root reference - const storage = getStorage(firebaseApp); + const storage = getStorage(); // Create a reference to 'mountains.jpg' const mountainsRef = ref(storage, 'mountains.jpg'); @@ -35,7 +27,7 @@ function uploadBlob(file) { // [START storage_upload_blob] const { getStorage, ref, uploadBytes } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const storageRef = ref(storage, 'some-child'); // 'file' comes from the Blob or File API @@ -49,7 +41,7 @@ function uploadBytes() { // [START storage_upload_bytes] const { getStorage, ref, uploadBytes } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const storageRef = ref(storage, 'some-child'); const bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21]); @@ -63,7 +55,7 @@ function uploadString() { // [START storage_upload_string] const { getStorage, ref, uploadString } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const storageRef = ref(storage, 'some-child'); // Raw string is the default if no format is provided @@ -99,7 +91,7 @@ function uploadMetadata(file) { // [START storage_upload_metadata] const { getStorage, ref, uploadBytes } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const storageRef = ref(storage, 'images/mountains.jpg'); // Create file metadata including the content type @@ -120,7 +112,7 @@ function manageUploads(file) { // [START storage_manage_uploads] const { getStorage, ref, uploadBytesResumable } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const storageRef = ref(storage, 'images/mountains.jpg'); // Upload the file and metadata @@ -144,7 +136,7 @@ function monitorUpload(file) { // [START storage_monitor_upload] const { getStorage, ref, uploadBytesResumable, getDownloadURL } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); const storageRef = ref(storage, 'images/rivers.jpg'); const uploadTask = uploadBytesResumable(storageRef, file); @@ -189,7 +181,7 @@ function uploadHandleError(file) { // [START storage_upload_handle_error] const { getStorage, ref, uploadBytesResumable, getDownloadURL } = require("firebase/storage"); - const storage = getStorage(firebaseApp); + const storage = getStorage(); // Create the file metadata /** @type {any} */ From 08446878a9fe9d09028e08cc17e529802c60f00e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 9 Apr 2021 05:55:21 -0700 Subject: [PATCH 055/170] Auto-update dependencies. (#134) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index c74ad8de..a9f82e88 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 9392cc13..ff88e29f 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.3/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.3.3/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From d27cf934bf0fafbaa69463cb6df3993fadf237e0 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 9 Apr 2021 09:41:14 -0400 Subject: [PATCH 056/170] Simplify Firestore references (#136) --- firestore-next/test.firestore.js | 132 +++++++++--------- firestore-next/test.solution-aggregation.js | 6 +- firestore-next/test.solution-counters.js | 6 +- .../test-firestore/add_rating_transaction.js | 2 +- .../test-firestore/cities_document_set.js | 4 +- .../test-firestore/data_types.js | 4 +- .../test-firestore/delete_document.js | 4 +- .../test-firestore/doc_reference.js | 4 +- .../fs_collection_group_query_data_setup.js | 20 +-- .../test-firestore/get_custom_object.js | 4 +- .../test-firestore/get_document.js | 4 +- .../test-firestore/get_document_options.js | 4 +- .../test-firestore/listen_document.js | 4 +- .../test-firestore/listen_document_local.js | 4 +- .../test-firestore/listen_with_metadata.js | 4 +- .../server_timestamp_resolution_options.js | 4 +- .../test-firestore/set_custom_object.js | 4 +- .../test-firestore/set_document.js | 4 +- .../test-firestore/set_with_merge.js | 4 +- .../test-firestore/subcollection_reference.js | 4 +- .../test-firestore/transaction_promise.js | 4 +- .../test-firestore/update_delete_field.js | 4 +- .../test-firestore/update_document.js | 4 +- .../test-firestore/update_document_array.js | 4 +- .../update_document_increment.js | 4 +- .../test-firestore/update_document_nested.js | 4 +- .../update_with_server_timestamp.js | 4 +- .../test-firestore/write_batch.js | 8 +- .../get_collection_ratings.js | 4 +- .../test-solution-counters/create_counter.js | 4 +- .../increment_counter.js | 2 +- 31 files changed, 136 insertions(+), 136 deletions(-) diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 15bc159e..2a452e80 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -204,9 +204,9 @@ describe("firestore", () => { it("should reference a specific document", () => { // [START doc_reference] - const { collection, doc } = require("firebase/firestore"); + const { doc } = require("firebase/firestore"); - const alovelaceDocumentRef = doc(collection(db, 'users'), 'alovelace'); + const alovelaceDocumentRef = doc(db, 'users', 'alovelace'); // [END doc_reference] }); @@ -228,18 +228,18 @@ describe("firestore", () => { it("should reference a document in a subcollection", () => { // [START subcollection_reference] - const { doc, collection } = require("firebase/firestore"); + const { doc } = require("firebase/firestore"); - const messageRef = doc(collection(doc(collection(db, "rooms"), "roomA"), "messages"), "message1"); + const messageRef = doc(db, "rooms", "roomA", "messages", "message1"); // [END subcollection_reference] }); it("should set a document", async () => { // [START set_document] - const { doc, collection, setDoc } = require("firebase/firestore"); + const { doc, setDoc } = require("firebase/firestore"); // Add a new document in collection "cities" - await setDoc(doc(collection(db, "cities"), "LA"), { + await setDoc(doc(db, "cities", "LA"), { name: "Los Angeles", state: "CA", country: "USA" @@ -249,19 +249,19 @@ describe("firestore", () => { it("should set document with a custom object converter", async () => { // [START set_custom_object] - const { doc, collection, setDoc } = require("firebase/firestore"); + const { doc, setDoc } = require("firebase/firestore"); // Set with cityConverter - const ref = doc(collection(db, "cities"), "LA").withConverter(cityConverter); + const ref = doc(db, "cities", "LA").withConverter(cityConverter); await setDoc(ref, new City("Los Angeles", "CA", "USA")); // [END set_custom_object] }); it("should get document with a custom object converter", async () => { // [START get_custom_object] - const { doc, collection, getDoc} = require("firebase/firestore"); + const { doc, getDoc} = require("firebase/firestore"); - const ref = doc(collection(db, "cities"), "LA").withConverter(cityConverter); + const ref = doc(db, "cities", "LA").withConverter(cityConverter); const docSnap = await getDoc(ref); if (docSnap.exists()) { // Convert to City object @@ -276,21 +276,21 @@ describe("firestore", () => { it("should support batch writes", async () => { // [START write_batch] - const { writeBatch, doc, collection } = require("firebase/firestore"); + const { writeBatch, doc } = require("firebase/firestore"); // Get a new write batch const batch = writeBatch(db); // Set the value of 'NYC' - const nycRef = doc(collection(db, "cities"), "NYC"); + const nycRef = doc(db, "cities", "NYC"); batch.set(nycRef, {name: "New York City"}); // Update the population of 'SF' - const sfRef = doc(collection(db, "cities"), "SF"); + const sfRef = doc(db, "cities", "SF"); batch.update(sfRef, {"population": 1000000}); // Delete the city 'LA' - const laRef = doc(collection(db, "cities"), "LA"); + const laRef = doc(db, "cities", "LA"); batch.delete(laRef); // Commit the batch @@ -300,7 +300,7 @@ describe("firestore", () => { it("should set a document with every datatype #UNVERIFIED", async () => { // [START data_types] - const { doc, collection, setDoc, Timestamp } = require("firebase/firestore"); + const { doc, setDoc, Timestamp } = require("firebase/firestore"); const docData = { stringExample: "Hello world!", @@ -316,25 +316,25 @@ describe("firestore", () => { } } }; - await setDoc(doc(collection(db, "data"), "one"), docData); + await setDoc(doc(db, "data", "one"), docData); // [END data_types] }); it("should allow set with merge", async () => { // [START set_with_merge] - const { doc, collection, setDoc } = require("firebase/firestore"); + const { doc, setDoc } = require("firebase/firestore"); - const cityRef = doc(collection(db, 'cities'), 'BJ'); + const cityRef = doc(db, 'cities', 'BJ'); setDoc(cityRef, { capital: true }, { merge: true }); // [END set_with_merge] }); it("should update a document's nested fields #UNVERIFIED", async () => { // [START update_document_nested] - const { doc, collection, setDoc, updateDoc } = require("firebase/firestore"); + const { doc, setDoc, updateDoc } = require("firebase/firestore"); // Create an initial document to update. - const frankDocRef = doc(collection(db, "users"), "frank"); + const frankDocRef = doc(db, "users", "frank"); await setDoc(frankDocRef, { name: "Frank", favorites: { food: "Pizza", color: "Blue", subject: "recess" }, @@ -431,9 +431,9 @@ describe("firestore", () => { const data = {}; // [START cities_document_set] - const { collection, doc, setDoc } = require("firebase/firestore"); + const { doc, setDoc } = require("firebase/firestore"); - await setDoc(doc(collection(db, "cities"), "new-city-id"), data); + await setDoc(doc(db, "cities", "new-city-id"), data); // [END cities_document_set] }); @@ -466,9 +466,9 @@ describe("firestore", () => { it("should update a document", async () => { const data = {}; // [START update_document] - const { collection, doc, updateDoc } = require("firebase/firestore"); + const { doc, updateDoc } = require("firebase/firestore"); - const washingtonRef = doc(collection(db, "cities"), "DC"); + const washingtonRef = doc(db, "cities", "DC"); // Set the "capital" field of the city 'DC' await updateDoc(washingtonRef, { @@ -479,9 +479,9 @@ describe("firestore", () => { it("should update an array field in a document", async () => { // [START update_document_array] - const { collection, doc, updateDoc, arrayUnion, arrayRemove } = require("firebase/firestore"); + const { doc, updateDoc, arrayUnion, arrayRemove } = require("firebase/firestore"); - const washingtonRef = doc(collection(db, "cities"), "DC"); + const washingtonRef = doc(db, "cities", "DC"); // Atomically add a new region to the "regions" array field. await updateDoc(washingtonRef, { @@ -497,9 +497,9 @@ describe("firestore", () => { it("should update a document using numeric transforms", async () => { // [START update_document_increment] - const { collection, doc, updateDoc, increment } = require("firebase/firestore"); + const { doc, updateDoc, increment } = require("firebase/firestore"); - const washingtonRef = doc(collection(db, "cities"), "DC"); + const washingtonRef = doc(db, "cities", "DC"); // Atomically increment the population of the city by 50. await updateDoc(washingtonRef, { @@ -510,16 +510,16 @@ describe("firestore", () => { it("should delete a document", async () => { // [START delete_document] - const { collection, doc, deleteDoc } = require("firebase/firestore"); + const { doc, deleteDoc } = require("firebase/firestore"); - await deleteDoc(doc(collection(db, "cities"), "DC")); + await deleteDoc(doc(db, "cities", "DC")); // [END delete_document] }); it("should handle transactions", async () => { - const { collection, doc, setDoc } = require("firebase/firestore"); + const { doc, setDoc } = require("firebase/firestore"); - const sfDocRef = doc(collection(db, "cities"), "SF"); + const sfDocRef = doc(db, "cities", "SF"); await setDoc(sfDocRef, { population: 0 }); // [START transaction] @@ -544,10 +544,10 @@ describe("firestore", () => { it("should handle transaction which bubble out data", async () => { // [START transaction_promise] - const { collection, doc, runTransaction } = require("firebase/firestore"); + const { doc, runTransaction } = require("firebase/firestore"); // Create a reference to the SF doc. - const sfDocRef = doc(collection(db, "cities"), "SF"); + const sfDocRef = doc(db, "cities", "SF"); try { const newPopulation = await runTransaction(db, async (transaction) => { @@ -574,9 +574,9 @@ describe("firestore", () => { it("should get a single document", async () => { // [START get_document] - const { collection, doc, getDoc } = require("firebase/firestore"); + const { doc, getDoc } = require("firebase/firestore"); - const docRef = doc(collection(db, "cities"), "SF"); + const docRef = doc(db, "cities", "SF"); const docSnap = await getDoc(docRef); if (docSnap.exists()) { @@ -590,9 +590,9 @@ describe("firestore", () => { it("should get a document with options", async () => { // [START get_document_options] - const { collection, doc, getDocFromCache } = require("firebase/firestore"); + const { doc, getDocFromCache } = require("firebase/firestore"); - const docRef = doc(collection(db, "cities"), "SF"); + const docRef = doc(db, "cities", "SF"); // Get a document, forcing the SDK to fetch from the offline cache. try { @@ -609,9 +609,9 @@ describe("firestore", () => { it("should listen on a single document", (done) => { // [START listen_document] - const { collection, doc, onSnapshot } = require("firebase/firestore"); + const { doc, onSnapshot } = require("firebase/firestore"); - const unsub = onSnapshot(doc(collection(db, "cities"), "SF"), (doc) => { + const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => { console.log("Current data: ", doc.data()); }); // [END listen_document] @@ -624,9 +624,9 @@ describe("firestore", () => { it("should listen on a single document with metadata", (done) => { // [START listen_document_local] - const { collection, doc, onSnapshot } = require("firebase/firestore"); + const { doc, onSnapshot } = require("firebase/firestore"); - const unsub = onSnapshot(doc(collection(db, "cities"), "SF"), (doc) => { + const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => { const source = doc.metadata.hasPendingWrites ? "Local" : "Server"; console.log(source, " data: ", doc.data()); }); @@ -640,10 +640,10 @@ describe("firestore", () => { it("should listen on a single document with options #UNVERIFIED", (done) => { // [START listen_with_metadata] - const { collection, doc, onSnapshot } = require("firebase/firestore"); + const { doc, onSnapshot } = require("firebase/firestore"); const unsub = onSnapshot( - doc(collection(db, "cities"), "SF"), + doc(db, "cities", "SF"), { includeMetadataChanges: true }, (doc) => { // ... @@ -761,9 +761,9 @@ describe("firestore", () => { it("should update a document with server timestamp", async () => { async function update() { // [START update_with_server_timestamp] - const { collection, updateDoc, serverTimestamp } = require("firebase/firestore"); + const { updateDoc, serverTimestamp } = require("firebase/firestore"); - const docRef = doc(collection(db, 'objects'), 'some-id'); + const docRef = doc(db, 'objects', 'some-id'); // Update the timestamp field with the value from the server const updateTimestamp = await updateDoc(docRef, { @@ -774,21 +774,21 @@ describe("firestore", () => { return updateTimestamp; } - const { collection, doc, setDoc } = require("firebase/firestore"); + const { doc, setDoc } = require("firebase/firestore"); - await setDoc(doc(collection(db, 'objects'), 'some-id'), {}); + await setDoc(doc(db, 'objects', 'some-id'), {}); await update(); console.log('Document updated with server timestamp'); }); it("should use options to control server timestamp resolution", async () => { // [START server_timestamp_resolution_options] - const { collection, doc, updateDoc, serverTimestamp, onSnapshot } = require("firebase/firestore"); + const { doc, updateDoc, serverTimestamp, onSnapshot } = require("firebase/firestore"); // Perform an update followed by an immediate read without // waiting for the update to complete. Due to the snapshot // options we will get two results: one with an estimate // timestamp and one with the resolved server timestamp. - const docRef = doc(collection(db, 'objects'), 'some-id'); + const docRef = doc(db, 'objects', 'some-id'); updateDoc(docRef, { timestamp: serverTimestamp() }); @@ -808,9 +808,9 @@ describe("firestore", () => { it("should delete a document field", async () => { async function update() { // [START update_delete_field] - const { doc, collection, updateDoc, deleteField } = require("firebase/firestore"); + const { doc, updateDoc, deleteField } = require("firebase/firestore"); - const cityRef = doc(collection(db, 'cities'), 'BJ'); + const cityRef = doc(db, 'cities', 'BJ'); // Remove the 'capital' field from the document await updateDoc(cityRef, { @@ -819,9 +819,9 @@ describe("firestore", () => { // [END update_delete_field] } - const { doc, collection, setDoc } = require("firebase/firestore"); + const { doc, setDoc } = require("firebase/firestore"); - await setDoc(doc(collection(db,'cities'), 'BJ'), { capital: true }); + await setDoc(doc(db, 'cities', 'BJ'), { capital: true }); await update(); }); @@ -1099,43 +1099,43 @@ describe("firestore", () => { const citiesRef = collection(db, 'cities'); await Promise.all([ - setDoc(doc(collection(doc(citiesRef, 'SF'), 'landmarks')), { + setDoc(doc(citiesRef, 'SF', 'landmarks'), { name: 'Golden Gate Bridge', type: 'bridge' }), - setDoc(doc(collection(doc(citiesRef, 'SF'), 'landmarks')), { + setDoc(doc(citiesRef, 'SF', 'landmarks'), { name: 'Legion of Honor', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'LA'), 'landmarks')), { + setDoc(doc(citiesRef, 'LA', 'landmarks'), { name: 'Griffith Park', type: 'park' }), - setDoc(doc(collection(doc(citiesRef, 'LA'), 'landmarks')), { + setDoc(doc(citiesRef, 'LA', 'landmarks'), { name: 'The Getty', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'DC'), 'landmarks')), { + setDoc(doc(citiesRef, 'DC', 'landmarks'), { name: 'Lincoln Memorial', type: 'memorial' }), - setDoc(doc(collection(doc(citiesRef, 'DC'), 'landmarks')), { + setDoc(doc(citiesRef, 'DC', 'landmarks'), { name: 'National Air and Space Museum', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'TOK'), 'landmarks')), { + setDoc(doc(citiesRef, 'TOK', 'landmarks'), { name: 'Ueno Park', type: 'park' }), - setDoc(doc(collection(doc(citiesRef, 'TOK'), 'landmarks')), { + setDoc(doc(citiesRef, 'TOK', 'landmarks'), { name: 'National Museum of Nature and Science', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'BJ'), 'landmarks')), { + setDoc(doc(citiesRef, 'BJ', 'landmarks'), { name: 'Jingshan Park', type: 'park' }), - setDoc(doc(collection(doc(citiesRef, 'BJ'), 'landmarks')), { + setDoc(doc(citiesRef, 'BJ', 'landmarks'), { name: 'Beijing Ancient Observatory', type: 'museum' }) @@ -1161,7 +1161,7 @@ describe("firestore", () => { describe("solution-aggregation", () => { it("should update a restaurant in a transaction #UNVERIFIED", async () => { // [START add_rating_transaction] - const { collection, doc, runTransaction} = require("firebase/firestore"); + const { collection, doc, runTransaction } = require("firebase/firestore"); async function addRating(restaurantRef, rating) { // Create a reference for a new rating, for use inside the transaction @@ -1193,7 +1193,7 @@ describe("firestore", () => { // Create document and add a rating const { setDoc } = require("firebase/firestore"); - const ref = doc(collection(db, 'restaurants'), ('arinell-pizza')); + const ref = doc(db, 'restaurants', 'arinell-pizza'); await setDoc(ref, { name: 'Arinell Pizza', avgRating: 4.63, diff --git a/firestore-next/test.solution-aggregation.js b/firestore-next/test.solution-aggregation.js index 82e1d602..c0a825b5 100644 --- a/firestore-next/test.solution-aggregation.js +++ b/firestore-next/test.solution-aggregation.js @@ -27,15 +27,15 @@ describe("firestore-solution-arrays", () => { const app = initializeApp(config, "solution-arrays"); db = getFirestore(app); - await setDoc(doc(collection(db, "restaurants"), "arinell-pizza"), arinellDoc); + await setDoc(doc(db, "restaurants", "arinell-pizza"), arinellDoc); }); describe("solution-arrays", () => { it("should get a collection of ratings", async () => { // [START get_collection_ratings] - const { collection, doc, getDocs } = require("firebase/firestore"); + const { collection, getDocs } = require("firebase/firestore"); - const ratingsRef = collection(doc(collection(db, "restaurants"), "arinell-pizza"), "ratings"); + const ratingsRef = collection(db, "restaurants", "arinell-pizza", "ratings"); const ratingsDocs = await getDocs(ratingsRef); // [END get_collection_ratings] }); diff --git a/firestore-next/test.solution-counters.js b/firestore-next/test.solution-counters.js index a76cfc24..2e00e8d9 100644 --- a/firestore-next/test.solution-counters.js +++ b/firestore-next/test.solution-counters.js @@ -8,7 +8,7 @@ let db; // [START create_counter] function createCounter(ref, num_shards) { - const { collection, doc, writeBatch } = require("firebase/firestore"); + const { doc, writeBatch } = require("firebase/firestore"); const batch = writeBatch(db); @@ -17,7 +17,7 @@ function createCounter(ref, num_shards) { // Initialize each shard with count=0 for (let i = 0; i < num_shards; i++) { - const shardRef = doc(collection(ref, 'shards'), i.toString()); + const shardRef = doc(ref, 'shards', i.toString()); batch.set(shardRef, { count: 0 }); } @@ -32,7 +32,7 @@ function incrementCounter(db, ref, num_shards) { // Select a shard of the counter at random const shardId = Math.floor(Math.random() * num_shards).toString(); - const shardRef = doc(collection(ref, 'shards'), shardId); + const shardRef = doc(ref, 'shards', shardId); // Update count return updateDoc(shardRef, "count", increment(1)); diff --git a/snippets/firestore-next/test-firestore/add_rating_transaction.js b/snippets/firestore-next/test-firestore/add_rating_transaction.js index 248f5e54..e5c279a9 100644 --- a/snippets/firestore-next/test-firestore/add_rating_transaction.js +++ b/snippets/firestore-next/test-firestore/add_rating_transaction.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START add_rating_transaction_modular] -import { collection, doc, runTransaction} from "firebase/firestore"; +import { collection, doc, runTransaction } from "firebase/firestore"; async function addRating(restaurantRef, rating) { // Create a reference for a new rating, for use inside the transaction diff --git a/snippets/firestore-next/test-firestore/cities_document_set.js b/snippets/firestore-next/test-firestore/cities_document_set.js index edebdc0c..793c4a8e 100644 --- a/snippets/firestore-next/test-firestore/cities_document_set.js +++ b/snippets/firestore-next/test-firestore/cities_document_set.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START cities_document_set_modular] -import { collection, doc, setDoc } from "firebase/firestore"; +import { doc, setDoc } from "firebase/firestore"; -await setDoc(doc(collection(db, "cities"), "new-city-id"), data); +await setDoc(doc(db, "cities", "new-city-id"), data); // [END cities_document_set_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/data_types.js b/snippets/firestore-next/test-firestore/data_types.js index faace529..9aa46b2b 100644 --- a/snippets/firestore-next/test-firestore/data_types.js +++ b/snippets/firestore-next/test-firestore/data_types.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START data_types_modular] -import { doc, collection, setDoc, Timestamp } from "firebase/firestore"; +import { doc, setDoc, Timestamp } from "firebase/firestore"; const docData = { stringExample: "Hello world!", @@ -20,5 +20,5 @@ const docData = { } } }; -await setDoc(doc(collection(db, "data"), "one"), docData); +await setDoc(doc(db, "data", "one"), docData); // [END data_types_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/delete_document.js b/snippets/firestore-next/test-firestore/delete_document.js index 27c0bec9..0933d311 100644 --- a/snippets/firestore-next/test-firestore/delete_document.js +++ b/snippets/firestore-next/test-firestore/delete_document.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START delete_document_modular] -import { collection, doc, deleteDoc } from "firebase/firestore"; +import { doc, deleteDoc } from "firebase/firestore"; -await deleteDoc(doc(collection(db, "cities"), "DC")); +await deleteDoc(doc(db, "cities", "DC")); // [END delete_document_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/doc_reference.js b/snippets/firestore-next/test-firestore/doc_reference.js index 4f3fc134..10b96445 100644 --- a/snippets/firestore-next/test-firestore/doc_reference.js +++ b/snippets/firestore-next/test-firestore/doc_reference.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START doc_reference_modular] -import { collection, doc } from "firebase/firestore"; +import { doc } from "firebase/firestore"; -const alovelaceDocumentRef = doc(collection(db, 'users'), 'alovelace'); +const alovelaceDocumentRef = doc(db, 'users', 'alovelace'); // [END doc_reference_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js b/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js index ab8964f1..a4e07952 100644 --- a/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js +++ b/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js @@ -9,43 +9,43 @@ import { collection, doc, setDoc } from "firebase/firestore"; const citiesRef = collection(db, 'cities'); await Promise.all([ - setDoc(doc(collection(doc(citiesRef, 'SF'), 'landmarks')), { + setDoc(doc(citiesRef, 'SF', 'landmarks'), { name: 'Golden Gate Bridge', type: 'bridge' }), - setDoc(doc(collection(doc(citiesRef, 'SF'), 'landmarks')), { + setDoc(doc(citiesRef, 'SF', 'landmarks'), { name: 'Legion of Honor', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'LA'), 'landmarks')), { + setDoc(doc(citiesRef, 'LA', 'landmarks'), { name: 'Griffith Park', type: 'park' }), - setDoc(doc(collection(doc(citiesRef, 'LA'), 'landmarks')), { + setDoc(doc(citiesRef, 'LA', 'landmarks'), { name: 'The Getty', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'DC'), 'landmarks')), { + setDoc(doc(citiesRef, 'DC', 'landmarks'), { name: 'Lincoln Memorial', type: 'memorial' }), - setDoc(doc(collection(doc(citiesRef, 'DC'), 'landmarks')), { + setDoc(doc(citiesRef, 'DC', 'landmarks'), { name: 'National Air and Space Museum', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'TOK'), 'landmarks')), { + setDoc(doc(citiesRef, 'TOK', 'landmarks'), { name: 'Ueno Park', type: 'park' }), - setDoc(doc(collection(doc(citiesRef, 'TOK'), 'landmarks')), { + setDoc(doc(citiesRef, 'TOK', 'landmarks'), { name: 'National Museum of Nature and Science', type: 'museum' }), - setDoc(doc(collection(doc(citiesRef, 'BJ'), 'landmarks')), { + setDoc(doc(citiesRef, 'BJ', 'landmarks'), { name: 'Jingshan Park', type: 'park' }), - setDoc(doc(collection(doc(citiesRef, 'BJ'), 'landmarks')), { + setDoc(doc(citiesRef, 'BJ', 'landmarks'), { name: 'Beijing Ancient Observatory', type: 'museum' }) diff --git a/snippets/firestore-next/test-firestore/get_custom_object.js b/snippets/firestore-next/test-firestore/get_custom_object.js index 92b27330..3e39eafa 100644 --- a/snippets/firestore-next/test-firestore/get_custom_object.js +++ b/snippets/firestore-next/test-firestore/get_custom_object.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START get_custom_object_modular] -import { doc, collection, getDoc} from "firebase/firestore"; +import { doc, getDoc} from "firebase/firestore"; -const ref = doc(collection(db, "cities"), "LA").withConverter(cityConverter); +const ref = doc(db, "cities", "LA").withConverter(cityConverter); const docSnap = await getDoc(ref); if (docSnap.exists()) { // Convert to City object diff --git a/snippets/firestore-next/test-firestore/get_document.js b/snippets/firestore-next/test-firestore/get_document.js index 79886025..1ca4787d 100644 --- a/snippets/firestore-next/test-firestore/get_document.js +++ b/snippets/firestore-next/test-firestore/get_document.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START get_document_modular] -import { collection, doc, getDoc } from "firebase/firestore"; +import { doc, getDoc } from "firebase/firestore"; -const docRef = doc(collection(db, "cities"), "SF"); +const docRef = doc(db, "cities", "SF"); const docSnap = await getDoc(docRef); if (docSnap.exists()) { diff --git a/snippets/firestore-next/test-firestore/get_document_options.js b/snippets/firestore-next/test-firestore/get_document_options.js index ecaf4b55..8b161b27 100644 --- a/snippets/firestore-next/test-firestore/get_document_options.js +++ b/snippets/firestore-next/test-firestore/get_document_options.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START get_document_options_modular] -import { collection, doc, getDocFromCache } from "firebase/firestore"; +import { doc, getDocFromCache } from "firebase/firestore"; -const docRef = doc(collection(db, "cities"), "SF"); +const docRef = doc(db, "cities", "SF"); // Get a document, forcing the SDK to fetch from the offline cache. try { diff --git a/snippets/firestore-next/test-firestore/listen_document.js b/snippets/firestore-next/test-firestore/listen_document.js index 54affb09..9b6507fc 100644 --- a/snippets/firestore-next/test-firestore/listen_document.js +++ b/snippets/firestore-next/test-firestore/listen_document.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START listen_document_modular] -import { collection, doc, onSnapshot } from "firebase/firestore"; +import { doc, onSnapshot } from "firebase/firestore"; -const unsub = onSnapshot(doc(collection(db, "cities"), "SF"), (doc) => { +const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => { console.log("Current data: ", doc.data()); }); // [END listen_document_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/listen_document_local.js b/snippets/firestore-next/test-firestore/listen_document_local.js index 63a70475..08041a3f 100644 --- a/snippets/firestore-next/test-firestore/listen_document_local.js +++ b/snippets/firestore-next/test-firestore/listen_document_local.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START listen_document_local_modular] -import { collection, doc, onSnapshot } from "firebase/firestore"; +import { doc, onSnapshot } from "firebase/firestore"; -const unsub = onSnapshot(doc(collection(db, "cities"), "SF"), (doc) => { +const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => { const source = doc.metadata.hasPendingWrites ? "Local" : "Server"; console.log(source, " data: ", doc.data()); }); diff --git a/snippets/firestore-next/test-firestore/listen_with_metadata.js b/snippets/firestore-next/test-firestore/listen_with_metadata.js index c40746b9..42848f62 100644 --- a/snippets/firestore-next/test-firestore/listen_with_metadata.js +++ b/snippets/firestore-next/test-firestore/listen_with_metadata.js @@ -4,10 +4,10 @@ // To make edits to the snippets in this file, please edit the source // [START listen_with_metadata_modular] -import { collection, doc, onSnapshot } from "firebase/firestore"; +import { doc, onSnapshot } from "firebase/firestore"; const unsub = onSnapshot( - doc(collection(db, "cities"), "SF"), + doc(db, "cities", "SF"), { includeMetadataChanges: true }, (doc) => { // ... diff --git a/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js b/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js index f59048e2..9fab8f77 100644 --- a/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js +++ b/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js @@ -4,12 +4,12 @@ // To make edits to the snippets in this file, please edit the source // [START server_timestamp_resolution_options_modular] -import { collection, doc, updateDoc, serverTimestamp, onSnapshot } from "firebase/firestore"; +import { doc, updateDoc, serverTimestamp, onSnapshot } from "firebase/firestore"; // Perform an update followed by an immediate read without // waiting for the update to complete. Due to the snapshot // options we will get two results: one with an estimate // timestamp and one with the resolved server timestamp. -const docRef = doc(collection(db, 'objects'), 'some-id'); +const docRef = doc(db, 'objects', 'some-id'); updateDoc(docRef, { timestamp: serverTimestamp() }); diff --git a/snippets/firestore-next/test-firestore/set_custom_object.js b/snippets/firestore-next/test-firestore/set_custom_object.js index a71d06ef..54febc9f 100644 --- a/snippets/firestore-next/test-firestore/set_custom_object.js +++ b/snippets/firestore-next/test-firestore/set_custom_object.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START set_custom_object_modular] -import { doc, collection, setDoc } from "firebase/firestore"; +import { doc, setDoc } from "firebase/firestore"; // Set with cityConverter -const ref = doc(collection(db, "cities"), "LA").withConverter(cityConverter); +const ref = doc(db, "cities", "LA").withConverter(cityConverter); await setDoc(ref, new City("Los Angeles", "CA", "USA")); // [END set_custom_object_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/set_document.js b/snippets/firestore-next/test-firestore/set_document.js index d3c246ad..94a562af 100644 --- a/snippets/firestore-next/test-firestore/set_document.js +++ b/snippets/firestore-next/test-firestore/set_document.js @@ -4,10 +4,10 @@ // To make edits to the snippets in this file, please edit the source // [START set_document_modular] -import { doc, collection, setDoc } from "firebase/firestore"; +import { doc, setDoc } from "firebase/firestore"; // Add a new document in collection "cities" -await setDoc(doc(collection(db, "cities"), "LA"), { +await setDoc(doc(db, "cities", "LA"), { name: "Los Angeles", state: "CA", country: "USA" diff --git a/snippets/firestore-next/test-firestore/set_with_merge.js b/snippets/firestore-next/test-firestore/set_with_merge.js index e3981920..ca0fd3b6 100644 --- a/snippets/firestore-next/test-firestore/set_with_merge.js +++ b/snippets/firestore-next/test-firestore/set_with_merge.js @@ -4,8 +4,8 @@ // To make edits to the snippets in this file, please edit the source // [START set_with_merge_modular] -import { doc, collection, setDoc } from "firebase/firestore"; +import { doc, setDoc } from "firebase/firestore"; -const cityRef = doc(collection(db, 'cities'), 'BJ'); +const cityRef = doc(db, 'cities', 'BJ'); setDoc(cityRef, { capital: true }, { merge: true }); // [END set_with_merge_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/subcollection_reference.js b/snippets/firestore-next/test-firestore/subcollection_reference.js index 56019331..7b42af67 100644 --- a/snippets/firestore-next/test-firestore/subcollection_reference.js +++ b/snippets/firestore-next/test-firestore/subcollection_reference.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START subcollection_reference_modular] -import { doc, collection } from "firebase/firestore"; +import { doc } from "firebase/firestore"; -const messageRef = doc(collection(doc(collection(db, "rooms"), "roomA"), "messages"), "message1"); +const messageRef = doc(db, "rooms", "roomA", "messages", "message1"); // [END subcollection_reference_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/transaction_promise.js b/snippets/firestore-next/test-firestore/transaction_promise.js index ef5ca4c7..cda47859 100644 --- a/snippets/firestore-next/test-firestore/transaction_promise.js +++ b/snippets/firestore-next/test-firestore/transaction_promise.js @@ -4,10 +4,10 @@ // To make edits to the snippets in this file, please edit the source // [START transaction_promise_modular] -import { collection, doc, runTransaction } from "firebase/firestore"; +import { doc, runTransaction } from "firebase/firestore"; // Create a reference to the SF doc. -const sfDocRef = doc(collection(db, "cities"), "SF"); +const sfDocRef = doc(db, "cities", "SF"); try { const newPopulation = await runTransaction(db, async (transaction) => { diff --git a/snippets/firestore-next/test-firestore/update_delete_field.js b/snippets/firestore-next/test-firestore/update_delete_field.js index b5477302..7bff4444 100644 --- a/snippets/firestore-next/test-firestore/update_delete_field.js +++ b/snippets/firestore-next/test-firestore/update_delete_field.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START update_delete_field_modular] -import { doc, collection, updateDoc, deleteField } from "firebase/firestore"; +import { doc, updateDoc, deleteField } from "firebase/firestore"; -const cityRef = doc(collection(db, 'cities'), 'BJ'); +const cityRef = doc(db, 'cities', 'BJ'); // Remove the 'capital' field from the document await updateDoc(cityRef, { diff --git a/snippets/firestore-next/test-firestore/update_document.js b/snippets/firestore-next/test-firestore/update_document.js index 02c21f35..23488474 100644 --- a/snippets/firestore-next/test-firestore/update_document.js +++ b/snippets/firestore-next/test-firestore/update_document.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START update_document_modular] -import { collection, doc, updateDoc } from "firebase/firestore"; +import { doc, updateDoc } from "firebase/firestore"; -const washingtonRef = doc(collection(db, "cities"), "DC"); +const washingtonRef = doc(db, "cities", "DC"); // Set the "capital" field of the city 'DC' await updateDoc(washingtonRef, { diff --git a/snippets/firestore-next/test-firestore/update_document_array.js b/snippets/firestore-next/test-firestore/update_document_array.js index e2c07145..463e857d 100644 --- a/snippets/firestore-next/test-firestore/update_document_array.js +++ b/snippets/firestore-next/test-firestore/update_document_array.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START update_document_array_modular] -import { collection, doc, updateDoc, arrayUnion, arrayRemove } from "firebase/firestore"; +import { doc, updateDoc, arrayUnion, arrayRemove } from "firebase/firestore"; -const washingtonRef = doc(collection(db, "cities"), "DC"); +const washingtonRef = doc(db, "cities", "DC"); // Atomically add a new region to the "regions" array field. await updateDoc(washingtonRef, { diff --git a/snippets/firestore-next/test-firestore/update_document_increment.js b/snippets/firestore-next/test-firestore/update_document_increment.js index 5ad2bb6a..30258a6c 100644 --- a/snippets/firestore-next/test-firestore/update_document_increment.js +++ b/snippets/firestore-next/test-firestore/update_document_increment.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START update_document_increment_modular] -import { collection, doc, updateDoc, increment } from "firebase/firestore"; +import { doc, updateDoc, increment } from "firebase/firestore"; -const washingtonRef = doc(collection(db, "cities"), "DC"); +const washingtonRef = doc(db, "cities", "DC"); // Atomically increment the population of the city by 50. await updateDoc(washingtonRef, { diff --git a/snippets/firestore-next/test-firestore/update_document_nested.js b/snippets/firestore-next/test-firestore/update_document_nested.js index a1412018..d3c12533 100644 --- a/snippets/firestore-next/test-firestore/update_document_nested.js +++ b/snippets/firestore-next/test-firestore/update_document_nested.js @@ -4,10 +4,10 @@ // To make edits to the snippets in this file, please edit the source // [START update_document_nested_modular] -import { doc, collection, setDoc, updateDoc } from "firebase/firestore"; +import { doc, setDoc, updateDoc } from "firebase/firestore"; // Create an initial document to update. -const frankDocRef = doc(collection(db, "users"), "frank"); +const frankDocRef = doc(db, "users", "frank"); await setDoc(frankDocRef, { name: "Frank", favorites: { food: "Pizza", color: "Blue", subject: "recess" }, diff --git a/snippets/firestore-next/test-firestore/update_with_server_timestamp.js b/snippets/firestore-next/test-firestore/update_with_server_timestamp.js index 39cb4c94..e4e2f248 100644 --- a/snippets/firestore-next/test-firestore/update_with_server_timestamp.js +++ b/snippets/firestore-next/test-firestore/update_with_server_timestamp.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START update_with_server_timestamp_modular] -import { collection, updateDoc, serverTimestamp } from "firebase/firestore"; +import { updateDoc, serverTimestamp } from "firebase/firestore"; -const docRef = doc(collection(db, 'objects'), 'some-id'); +const docRef = doc(db, 'objects', 'some-id'); // Update the timestamp field with the value from the server const updateTimestamp = await updateDoc(docRef, { diff --git a/snippets/firestore-next/test-firestore/write_batch.js b/snippets/firestore-next/test-firestore/write_batch.js index 157d1bcf..42494f5a 100644 --- a/snippets/firestore-next/test-firestore/write_batch.js +++ b/snippets/firestore-next/test-firestore/write_batch.js @@ -4,21 +4,21 @@ // To make edits to the snippets in this file, please edit the source // [START write_batch_modular] -import { writeBatch, doc, collection } from "firebase/firestore"; +import { writeBatch, doc } from "firebase/firestore"; // Get a new write batch const batch = writeBatch(db); // Set the value of 'NYC' -const nycRef = doc(collection(db, "cities"), "NYC"); +const nycRef = doc(db, "cities", "NYC"); batch.set(nycRef, {name: "New York City"}); // Update the population of 'SF' -const sfRef = doc(collection(db, "cities"), "SF"); +const sfRef = doc(db, "cities", "SF"); batch.update(sfRef, {"population": 1000000}); // Delete the city 'LA' -const laRef = doc(collection(db, "cities"), "LA"); +const laRef = doc(db, "cities", "LA"); batch.delete(laRef); // Commit the batch diff --git a/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js b/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js index 7f820455..06b85efc 100644 --- a/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js +++ b/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js @@ -4,8 +4,8 @@ // To make edits to the snippets in this file, please edit the source // [START get_collection_ratings_modular] -import { collection, doc, getDocs } from "firebase/firestore"; +import { collection, getDocs } from "firebase/firestore"; -const ratingsRef = collection(doc(collection(db, "restaurants"), "arinell-pizza"), "ratings"); +const ratingsRef = collection(db, "restaurants", "arinell-pizza", "ratings"); const ratingsDocs = await getDocs(ratingsRef); // [END get_collection_ratings_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-solution-counters/create_counter.js b/snippets/firestore-next/test-solution-counters/create_counter.js index d69b00e6..738dd634 100644 --- a/snippets/firestore-next/test-solution-counters/create_counter.js +++ b/snippets/firestore-next/test-solution-counters/create_counter.js @@ -5,7 +5,7 @@ // [START create_counter_modular] function createCounter(ref, num_shards) { - import { collection, doc, writeBatch } from "firebase/firestore"; + import { doc, writeBatch } from "firebase/firestore"; const batch = writeBatch(db); @@ -14,7 +14,7 @@ function createCounter(ref, num_shards) { // Initialize each shard with count=0 for (let i = 0; i < num_shards; i++) { - const shardRef = doc(collection(ref, 'shards'), i.toString()); + const shardRef = doc(ref, 'shards', i.toString()); batch.set(shardRef, { count: 0 }); } diff --git a/snippets/firestore-next/test-solution-counters/increment_counter.js b/snippets/firestore-next/test-solution-counters/increment_counter.js index 278fea5f..37e94224 100644 --- a/snippets/firestore-next/test-solution-counters/increment_counter.js +++ b/snippets/firestore-next/test-solution-counters/increment_counter.js @@ -9,7 +9,7 @@ function incrementCounter(db, ref, num_shards) { // Select a shard of the counter at random const shardId = Math.floor(Math.random() * num_shards).toString(); - const shardRef = doc(collection(ref, 'shards'), shardId); + const shardRef = doc(ref, 'shards', shardId); // Update count return updateDoc(shardRef, "count", increment(1)); From 5e68f042a5531dd2f68528f3f52c3645ed442b43 Mon Sep 17 00:00:00 2001 From: Frank van Puffelen Date: Fri, 9 Apr 2021 14:42:33 -0700 Subject: [PATCH 057/170] Add RTDB increment snippet (#130) * Add RTDB increment snippets for both JS and vNext Add snippet showing how to do atomic increments with the `increment()` operator. --- .gitignore | 1 + database-next/read-and-write.js | 18 ++++++++++++++++++ database/read-and-write.js | 14 ++++++++++++++ .../rtdb_social_star_increment.js | 18 ++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 snippets/database-next/read-and-write/rtdb_social_star_increment.js diff --git a/.gitignore b/.gitignore index c3bf3b13..5759f295 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules tsconfig.json dist/ +.DS_Store diff --git a/database-next/read-and-write.js b/database-next/read-and-write.js index 717ddeae..2cbd5c5b 100644 --- a/database-next/read-and-write.js +++ b/database-next/read-and-write.js @@ -153,6 +153,24 @@ function toggleStar_wrapped() { // [END rtdb_social_star_transaction] } +/** + * @param {string} uid + * @param {string} key + */ +// [START rtdb_social_star_increment] +function addStar(uid, key) { + const { getDatabase, increment, ref, update } = require("firebase/database"); + const dbRef = ref(getDatabase()); + + const updates = {}; + updates[`posts/${key}/stars/${uid}`] = true; + updates[`posts/${key}/starCount`] = increment(1); + updates[`user-posts/${key}/stars/${uid}`] = true; + updates[`user-posts/${key}/starCount`] = increment(1); + update(dbRef, updates); +} +// [END rtdb_social_star_increment] + function readOnceWithGet(userId) { // [START rtdb_read_once_get] const { getDatabase, ref, child, get } = require("firebase/database"); diff --git a/database/read-and-write.js b/database/read-and-write.js index e14b741b..e5e5a629 100644 --- a/database/read-and-write.js +++ b/database/read-and-write.js @@ -124,6 +124,20 @@ function toggleStar(postRef, uid) { } // [END rtdb_social_star_transaction] +/** + * @param {string} uid + * @param {string} key + */ +// [START rtdb_social_star_increment] +function addStar(uid, key) { + const updates = {}; + updates[`posts/${key}/stars/${uid}`] = true; + updates[`posts/${key}/starCount`] = firebase.database.ServerValue.increment(1); + updates[`user-posts/${key}/stars/${uid}`] = true; + updates[`user-posts/${key}/starCount`] = firebase.database.ServerValue.increment(1); + firebase.database().ref().update(updates); +} + function readOnceWithGet(userId) { // [START rtdb_read_once_get] const dbRef = firebase.database().ref(); diff --git a/snippets/database-next/read-and-write/rtdb_social_star_increment.js b/snippets/database-next/read-and-write/rtdb_social_star_increment.js new file mode 100644 index 00000000..bb4f9d7e --- /dev/null +++ b/snippets/database-next/read-and-write/rtdb_social_star_increment.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./database-next/read-and-write.js +// +// To make edits to the snippets in this file, please edit the source + +// [START rtdb_social_star_increment_modular] +function addStar(uid, key) { + import { getDatabase, increment, ref, update } from "firebase/database"; + const dbRef = ref(getDatabase()); + + const updates = {}; + updates[`posts/${key}/stars/${uid}`] = true; + updates[`posts/${key}/starCount`] = increment(1); + updates[`user-posts/${key}/stars/${uid}`] = true; + updates[`user-posts/${key}/starCount`] = increment(1); + update(dbRef, updates); +} +// [END rtdb_social_star_increment_modular] \ No newline at end of file From 4b496235d2db433354ebb8084d59eba1263769a6 Mon Sep 17 00:00:00 2001 From: Frank van Puffelen Date: Fri, 9 Apr 2021 15:21:48 -0700 Subject: [PATCH 058/170] Add missing end region tag (#137) --- database/read-and-write.js | 1 + 1 file changed, 1 insertion(+) diff --git a/database/read-and-write.js b/database/read-and-write.js index e5e5a629..bcae4ccc 100644 --- a/database/read-and-write.js +++ b/database/read-and-write.js @@ -137,6 +137,7 @@ function addStar(uid, key) { updates[`user-posts/${key}/starCount`] = firebase.database.ServerValue.increment(1); firebase.database().ref().update(updates); } +// [END rtdb_social_star_increment] function readOnceWithGet(userId) { // [START rtdb_read_once_get] From 4b73641a1dd93c1497ff61956db8bac1e289b43e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 13 Apr 2021 02:44:02 -0700 Subject: [PATCH 059/170] Auto-update dependencies. (#155) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 3883772f..2fd8cc65 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/auth/package.json b/auth/package.json index bb6f53ad..d463785b 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.3", + "firebase": "^8.4.1", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 52076305..357a5df8 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 4e0c769f..d21f2634 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/firestore/package.json b/firestore/package.json index 788d5a65..90fd71c0 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3", + "firebase": "^8.4.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 68327016..f3662dba 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/installations/package.json b/installations/package.json index 2c2ac3bf..b5ac2b99 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/messaging/package.json b/messaging/package.json index c53fa8c6..63d99b74 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/perf/package.json b/perf/package.json index 3fda34fd..6ad0b16c 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 45a411e2..aa994346 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } diff --git a/storage/package.json b/storage/package.json index b777b198..22df3b5e 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.3.3" + "firebase": "^8.4.1" } } From 79331943860993df782238996c05fd281b36e13a Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 13 Apr 2021 05:22:04 -0700 Subject: [PATCH 060/170] Auto-update dependencies. (#156) Brought to you by your friendly [Repository Gardener](https://github.com/GoogleCloudPlatform/repository-gardener). --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index a9f82e88..cbc68fa3 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index ff88e29f..6e9b8519 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.3.3/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.3.3/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.4.1/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.4.1/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 3bd946fa08177660f925a4215f20cf6c53678c07 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Wed, 14 Apr 2021 11:51:33 -0400 Subject: [PATCH 061/170] vNext beta release (#158) --- analytics-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index 7b054b75..c2126ef1 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/auth-next/package.json b/auth-next/package.json index 058a14c8..db0a71f4 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/database-next/package.json b/database-next/package.json index 927237f7..df21d0a9 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index a3f38088..01aad6d2 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 8289e346..5f6c0a0d 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp", + "firebase": "9.0.0-beta.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index 85e91e5d..acb31ec3 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index c787b7ed..0ce83ae1 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/perf-next/package.json b/perf-next/package.json index 3a04b696..0069b847 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index 8977d454..a64c6243 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } diff --git a/storage-next/package.json b/storage-next/package.json index f21c67e0..9ec75d58 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "exp" + "firebase": "9.0.0-beta.1" } } From fd06c854d0efaa57cf05ad89a42f77bee9510eab Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 14 Apr 2021 17:00:49 +0100 Subject: [PATCH 062/170] Allow version range --- analytics-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index c2126ef1..c680a4f2 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/auth-next/package.json b/auth-next/package.json index db0a71f4..19e3cdd9 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/database-next/package.json b/database-next/package.json index df21d0a9..22ed471f 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 01aad6d2..0490b5e8 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 5f6c0a0d..929358a7 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1", + "firebase": "^9.0.0-beta.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index acb31ec3..c9ff1ffc 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 0ce83ae1..37d5e35a 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/perf-next/package.json b/perf-next/package.json index 0069b847..8865057a 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index a64c6243..54cfa5d9 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } diff --git a/storage-next/package.json b/storage-next/package.json index 9ec75d58..7777f2d0 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "9.0.0-beta.1" + "firebase": "^9.0.0-beta.1" } } From f1cd58ac448666cb40365d0325b7d55ee8cad6e1 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 26 Apr 2021 02:36:17 -0700 Subject: [PATCH 063/170] Auto-update dependencies. (#161) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index cbc68fa3..27897373 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 6e9b8519..dc011678 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.4.1/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.4.1/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.4.2/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.4.2/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From fda5ec6e2c7c38eb68482d40c9059645368ae206 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 26 Apr 2021 02:42:54 -0700 Subject: [PATCH 064/170] Auto-update dependencies. (#160) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 2fd8cc65..8c1e355a 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/auth/package.json b/auth/package.json index d463785b..3feb38f5 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.1", + "firebase": "^8.4.2", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 357a5df8..0613ac81 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index d21f2634..57f54180 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/firestore/package.json b/firestore/package.json index 90fd71c0..44f37d8d 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1", + "firebase": "^8.4.2", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index f3662dba..8642b7b7 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/installations/package.json b/installations/package.json index b5ac2b99..7128e9ce 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/messaging/package.json b/messaging/package.json index 63d99b74..993f52f6 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/perf/package.json b/perf/package.json index 6ad0b16c..2ff32514 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index aa994346..1389599f 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } diff --git a/storage/package.json b/storage/package.json index 22df3b5e..88891d05 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.1" + "firebase": "^8.4.2" } } From 91ddc32aa71b0caf38e8a0ff61e1b1a4be97eb75 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 30 Apr 2021 02:57:28 -0700 Subject: [PATCH 065/170] Auto-update dependencies. (#163) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 8c1e355a..2176f57c 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/auth/package.json b/auth/package.json index 3feb38f5..8dbb99b8 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.2", + "firebase": "^8.4.3", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 0613ac81..973143a7 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 57f54180..a72813ae 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/firestore/package.json b/firestore/package.json index 44f37d8d..9843abf3 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2", + "firebase": "^8.4.3", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 8642b7b7..68d09b40 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/installations/package.json b/installations/package.json index 7128e9ce..bcc06b53 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/messaging/package.json b/messaging/package.json index 993f52f6..1582241b 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/perf/package.json b/perf/package.json index 2ff32514..4b320f8b 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 1389599f..cd829ee8 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } diff --git a/storage/package.json b/storage/package.json index 88891d05..db31280c 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.2" + "firebase": "^8.4.3" } } From 12f71f2a94a46bbfe2c1ebac33189ddfc53a764e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 30 Apr 2021 06:08:36 -0700 Subject: [PATCH 066/170] Auto-update dependencies. (#164) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 27897373..990efa90 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index dc011678..227012bf 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.4.2/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.4.2/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.4.3/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.4.3/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 047d7a6317f833b9469f3bd881b3de80a428b5b9 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 6 May 2021 03:49:48 -0700 Subject: [PATCH 067/170] Auto-update dependencies. (#165) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 2176f57c..14fc1d13 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/auth/package.json b/auth/package.json index 8dbb99b8..2b11527a 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.3", + "firebase": "^8.5.0", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 973143a7..4dd01dde 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index a72813ae..89d85aef 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/firestore/package.json b/firestore/package.json index 9843abf3..2ddfc562 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3", + "firebase": "^8.5.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 68d09b40..8e32d6db 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/installations/package.json b/installations/package.json index bcc06b53..0df6ddbd 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/messaging/package.json b/messaging/package.json index 1582241b..81626c0e 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/perf/package.json b/perf/package.json index 4b320f8b..b3f57be0 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index cd829ee8..b3ef8837 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } diff --git a/storage/package.json b/storage/package.json index db31280c..913928c1 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.4.3" + "firebase": "^8.5.0" } } From 50abb592172c4de663301ac174d11f3a11c8235a Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 6 May 2021 06:04:57 -0700 Subject: [PATCH 068/170] Auto-update dependencies. (#166) * Auto-update dependencies. * Auto-update dependencies. --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 990efa90..13948c9e 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 227012bf..e881121d 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.4.3/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.4.3/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.5.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.5.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 8b919f5a49dd6b33dc61f8549933ff170ac05efc Mon Sep 17 00:00:00 2001 From: DPEBot Date: Wed, 12 May 2021 03:12:18 -0700 Subject: [PATCH 069/170] Auto-update dependencies. (#167) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 14fc1d13..1a8b60cc 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/auth/package.json b/auth/package.json index 2b11527a..6d6ba384 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.5.0", + "firebase": "^8.6.0", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 4dd01dde..3882cb78 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 89d85aef..01ec70bb 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/firestore/package.json b/firestore/package.json index 2ddfc562..d5c943fb 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0", + "firebase": "^8.6.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 8e32d6db..143e47bd 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/installations/package.json b/installations/package.json index 0df6ddbd..b125227a 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/messaging/package.json b/messaging/package.json index 81626c0e..ce2efdad 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/perf/package.json b/perf/package.json index b3f57be0..0ce74d47 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index b3ef8837..dd5fcfc7 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } diff --git a/storage/package.json b/storage/package.json index 913928c1..a3be871b 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.5.0" + "firebase": "^8.6.0" } } From 64e97a1fc4812052105c15f9ab2078c518526b69 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Wed, 12 May 2021 08:44:08 -0700 Subject: [PATCH 070/170] Auto-update dependencies. (#168) * Auto-update dependencies. * Auto-update dependencies. --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 13948c9e..16cc2cab 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index e881121d..f5dba578 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.5.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.5.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From c98e8a63eda12e1fc023f5c067c5acfa26b10c26 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 13 May 2021 02:35:13 -0700 Subject: [PATCH 071/170] Auto-update dependencies. (#169) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 1a8b60cc..89b8245e 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/auth/package.json b/auth/package.json index 6d6ba384..bbf42213 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.0", + "firebase": "^8.6.1", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 3882cb78..e4ff534e 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 01ec70bb..2064ca60 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/firestore/package.json b/firestore/package.json index d5c943fb..091e3bb3 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0", + "firebase": "^8.6.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 143e47bd..63bb4104 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/installations/package.json b/installations/package.json index b125227a..ebe93b9a 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/messaging/package.json b/messaging/package.json index ce2efdad..13b6147f 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/perf/package.json b/perf/package.json index 0ce74d47..14aa35d7 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index dd5fcfc7..8203d347 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } diff --git a/storage/package.json b/storage/package.json index a3be871b..47358cc6 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.0" + "firebase": "^8.6.1" } } From 435f622fea9cd723456684dc54e58266f46c052c Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 13 May 2021 06:13:20 -0700 Subject: [PATCH 072/170] Auto-update dependencies. (#170) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 16cc2cab..edb6dba7 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index f5dba578..ffe90bba 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.6.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.6.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.1/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 77de7288beb6819e2d1484d42e1d6cca23a04135 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 24 May 2021 04:20:37 -0700 Subject: [PATCH 073/170] Auto-update dependencies. (#173) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 89b8245e..24466723 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/auth/package.json b/auth/package.json index bbf42213..a290447c 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.1", + "firebase": "^8.6.2", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index e4ff534e..90c4cd48 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 2064ca60..8a383365 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/firestore/package.json b/firestore/package.json index 091e3bb3..cf9bca3d 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1", + "firebase": "^8.6.2", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 63bb4104..fafc55ba 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/installations/package.json b/installations/package.json index ebe93b9a..a4c47386 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/messaging/package.json b/messaging/package.json index 13b6147f..ff48e4e3 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/perf/package.json b/perf/package.json index 14aa35d7..8dd71652 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 8203d347..d1407f79 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } diff --git a/storage/package.json b/storage/package.json index 47358cc6..5cf74105 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.1" + "firebase": "^8.6.2" } } From e6875d81359a71ea27bf3e269db457583f2a20f7 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 24 May 2021 04:32:25 -0700 Subject: [PATCH 074/170] Auto-update dependencies. (#174) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index edb6dba7..1d18be34 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index ffe90bba..be1080e5 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.6.1/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.2/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.2/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 0430462594667080adc6c14800695260186af02e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 1 Jun 2021 02:37:40 -0700 Subject: [PATCH 075/170] Auto-update dependencies. (#175) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 24466723..24bab3c6 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/auth/package.json b/auth/package.json index a290447c..64ef6639 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.2", + "firebase": "^8.6.3", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 90c4cd48..c8e18cc9 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 8a383365..d0a7aeb0 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/firestore/package.json b/firestore/package.json index cf9bca3d..5d6159cb 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2", + "firebase": "^8.6.3", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index fafc55ba..335f1f64 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/installations/package.json b/installations/package.json index a4c47386..dc3cf92d 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/messaging/package.json b/messaging/package.json index ff48e4e3..26bb6a15 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/perf/package.json b/perf/package.json index 8dd71652..36a474ae 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index d1407f79..bc93566b 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } diff --git a/storage/package.json b/storage/package.json index 5cf74105..53a1828f 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.2" + "firebase": "^8.6.3" } } From ceaa80767e5b244fcb2f42dd4fe8889c9818d81a Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 1 Jun 2021 02:46:54 -0700 Subject: [PATCH 076/170] Auto-update dependencies. (#176) Co-authored-by: Sam Stern --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 1d18be34..6732a626 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index be1080e5..6216522a 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.6.2/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.6.2/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.3/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.3/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 7ce58263bec3424205c33f308e78d24400f322ad Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 8 Jun 2021 04:14:24 -0700 Subject: [PATCH 077/170] Auto-update dependencies. (#179) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 6732a626..38b866cc 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 6216522a..3a33e075 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.6.3/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.6.3/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.5/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.5/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 54afdf5549a8571a19e03f430e8fd86d5c944203 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 8 Jun 2021 04:20:02 -0700 Subject: [PATCH 078/170] Auto-update dependencies. (#177) Brought to you by your friendly [Repository Gardener](https://github.com/GoogleCloudPlatform/repository-gardener). --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 24bab3c6..b94f5885 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/auth/package.json b/auth/package.json index 64ef6639..d5183071 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.3", + "firebase": "^8.6.5", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index c8e18cc9..c247ac9e 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index d0a7aeb0..fc812865 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/firestore/package.json b/firestore/package.json index 5d6159cb..53ff7f4d 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3", + "firebase": "^8.6.5", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 335f1f64..d7e245c3 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/installations/package.json b/installations/package.json index dc3cf92d..bd991ac5 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/messaging/package.json b/messaging/package.json index 26bb6a15..91cf4f7c 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/perf/package.json b/perf/package.json index 36a474ae..fa22f5f1 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index bc93566b..1c4d08d4 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } diff --git a/storage/package.json b/storage/package.json index 53a1828f..4173cb9a 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.3" + "firebase": "^8.6.5" } } From 4fadb8758d103fbf1bd3f994a78a77b5d2f723f7 Mon Sep 17 00:00:00 2001 From: Dharmaraj <63334359+DharmarajX24@users.noreply.github.com> Date: Thu, 10 Jun 2021 16:11:56 +0530 Subject: [PATCH 079/170] Added updateProfile and updateEmail for modular SDK (#178) --- .gitignore | 1 + auth-next/manage.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 auth-next/manage.js diff --git a/.gitignore b/.gitignore index 5759f295..9d79b150 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules tsconfig.json dist/ .DS_Store +.idea diff --git a/auth-next/manage.js b/auth-next/manage.js new file mode 100644 index 00000000..37f4c734 --- /dev/null +++ b/auth-next/manage.js @@ -0,0 +1,29 @@ +function updateUserProfile() { + // [START auth_update_user_profile] + const { getAuth, updateProfile } = require("firebase/auth"); + const auth = getAuth(); + updateProfile(auth.currentUser, { + displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg" + }).then(() => { + // Profile updated! + }).catch((error) => { + const errorCode = error.code; + const errorMessage = error.message; + // .. + }); + // [END auth_update_user_profile] +} + +function updateUserEmail() { + // [START auth_update_user_email] + const { getAuth, updateEmail } = require("firebase/auth"); + const auth = getAuth(); + updateEmail(auth.currentUser, "user@example.com").then(() => { + // Email updated! + }).catch((error) => { + const errorCode = error.code; + const errorMessage = error.message; + // .. + }); + // [END auth_update_user_email] +} From 8185ab90e151ef75faf780e39759b22dcde6498e Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Thu, 10 Jun 2021 06:59:33 -0400 Subject: [PATCH 080/170] Auth manage snippets (#181) --- auth-next/manage.js | 91 ++++++++++++++----- auth/manage.js | 70 ++++++++++++++ .../auth-next/manage/auth_get_user_profile.js | 23 +++++ .../manage/auth_get_user_profile_provider.js | 21 +++++ .../manage/auth_update_user_email.js | 16 ++++ .../manage/auth_update_user_profile.js | 18 ++++ 6 files changed, 215 insertions(+), 24 deletions(-) create mode 100644 auth/manage.js create mode 100644 snippets/auth-next/manage/auth_get_user_profile.js create mode 100644 snippets/auth-next/manage/auth_get_user_profile_provider.js create mode 100644 snippets/auth-next/manage/auth_update_user_email.js create mode 100644 snippets/auth-next/manage/auth_update_user_profile.js diff --git a/auth-next/manage.js b/auth-next/manage.js index 37f4c734..442cfa0b 100644 --- a/auth-next/manage.js +++ b/auth-next/manage.js @@ -1,29 +1,72 @@ -function updateUserProfile() { - // [START auth_update_user_profile] - const { getAuth, updateProfile } = require("firebase/auth"); - const auth = getAuth(); - updateProfile(auth.currentUser, { - displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg" - }).then(() => { - // Profile updated! - }).catch((error) => { - const errorCode = error.code; - const errorMessage = error.message; - // .. +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function getUserProfile() { + // [START auth_get_user_profile] + const { getAuth } = require("firebase/auth"); + + const auth = getAuth(); + const user = auth.currentUser; + if (user !== null) { + // The user object has basic properties such as display name, email, etc. + const displayName = user.displayName; + const email = user.email; + const photoURL = user.photoURL; + const emailVerified = user.emailVerified; + + // The user's ID, unique to the Firebase project. Do NOT use + // this value to authenticate with your backend server, if + // you have one. Use User.getToken() instead. + const uid = user.uid; + } + // [END auth_get_user_profile] +} + +function getUserProfileProvider() { + // [START auth_get_user_profile_provider] + const { getAuth } = require("firebase/auth"); + + const auth = getAuth(); + const user = auth.currentUser; + + if (user !== null) { + user.providerData.forEach((profile) => { + console.log("Sign-in provider: " + profile.providerId); + console.log(" Provider-specific UID: " + profile.uid); + console.log(" Name: " + profile.displayName); + console.log(" Email: " + profile.email); + console.log(" Photo URL: " + profile.photoURL); }); - // [END auth_update_user_profile] + } + // [END auth_get_user_profile_provider] +} + +function updateUserProfile() { + // [START auth_update_user_profile] + const { getAuth, updateProfile } = require("firebase/auth"); + const auth = getAuth(); + updateProfile(auth.currentUser, { + displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg" + }).then(() => { + // Profile updated! + // ... + }).catch((error) => { + // An error occurred + // ... + }); + // [END auth_update_user_profile] } function updateUserEmail() { - // [START auth_update_user_email] - const { getAuth, updateEmail } = require("firebase/auth"); - const auth = getAuth(); - updateEmail(auth.currentUser, "user@example.com").then(() => { - // Email updated! - }).catch((error) => { - const errorCode = error.code; - const errorMessage = error.message; - // .. - }); - // [END auth_update_user_email] + // [START auth_update_user_email] + const { getAuth, updateEmail } = require("firebase/auth"); + const auth = getAuth(); + updateEmail(auth.currentUser, "user@example.com").then(() => { + // Email updated! + // ... + }).catch((error) => { + // An error occurred + // ... + }); + // [END auth_update_user_email] } diff --git a/auth/manage.js b/auth/manage.js new file mode 100644 index 00000000..ed451c1b --- /dev/null +++ b/auth/manage.js @@ -0,0 +1,70 @@ +// These samples are intended for Web so this import would normally be +// done in HTML however using modules here is more convenient for +// ensuring sample correctness offline. +import firebase from "firebase/app"; +import "firebase/auth"; + +function getUserProfile() { + // [START auth_get_user_profile] + const user = firebase.auth().currentUser; + if (user !== null) { + // The user object has basic properties such as display name, email, etc. + const displayName = user.displayName; + const email = user.email; + const photoURL = user.photoURL; + const emailVerified = user.emailVerified; + + // The user's ID, unique to the Firebase project. Do NOT use + // this value to authenticate with your backend server, if + // you have one. Use User.getToken() instead. + const uid = user.uid; + } + // [END auth_get_user_profile] +} + +function getUserProfileProvider() { + // [START auth_get_user_profile_provider] + const user = firebase.auth().currentUser; + + if (user !== null) { + user.providerData.forEach((profile) => { + console.log("Sign-in provider: " + profile.providerId); + console.log(" Provider-specific UID: " + profile.uid); + console.log(" Name: " + profile.displayName); + console.log(" Email: " + profile.email); + console.log(" Photo URL: " + profile.photoURL); + }); + } + // [END auth_get_user_profile_provider] +} + +function updateUserProfile() { + // [START auth_update_user_profile] + const user = firebase.auth().currentUser; + + user.updateProfile({ + displayName: "Jane Q. User", + photoURL: "https://example.com/jane-q-user/profile.jpg" + }).then(() => { + // Update successful + // ... + }).catch((error) => { + // An error occurred + // ... + }); + // [END auth_update_user_profile] +} + +function updateUserEmail() { + // [START auth_update_user_email] + const user = firebase.auth().currentUser; + + user.updateEmail("user@example.com").then(() => { + // Update successful + // ... + }).catch((error) => { + // An error occurred + // ... + }); + // [END auth_update_user_email] +} diff --git a/snippets/auth-next/manage/auth_get_user_profile.js b/snippets/auth-next/manage/auth_get_user_profile.js new file mode 100644 index 00000000..106104e8 --- /dev/null +++ b/snippets/auth-next/manage/auth_get_user_profile.js @@ -0,0 +1,23 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_get_user_profile_modular] +import { getAuth } from "firebase/auth"; + +const auth = getAuth(); +const user = auth.currentUser; +if (user !== null) { + // The user object has basic properties such as display name, email, etc. + const displayName = user.displayName; + const email = user.email; + const photoURL = user.photoURL; + const emailVerified = user.emailVerified; + + // The user's ID, unique to the Firebase project. Do NOT use + // this value to authenticate with your backend server, if + // you have one. Use User.getToken() instead. + const uid = user.uid; +} +// [END auth_get_user_profile_modular] \ No newline at end of file diff --git a/snippets/auth-next/manage/auth_get_user_profile_provider.js b/snippets/auth-next/manage/auth_get_user_profile_provider.js new file mode 100644 index 00000000..63e9654f --- /dev/null +++ b/snippets/auth-next/manage/auth_get_user_profile_provider.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_get_user_profile_provider_modular] +import { getAuth } from "firebase/auth"; + +const auth = getAuth(); +const user = auth.currentUser; + +if (user !== null) { + user.providerData.forEach((profile) => { + console.log("Sign-in provider: " + profile.providerId); + console.log(" Provider-specific UID: " + profile.uid); + console.log(" Name: " + profile.displayName); + console.log(" Email: " + profile.email); + console.log(" Photo URL: " + profile.photoURL); + }); +} +// [END auth_get_user_profile_provider_modular] \ No newline at end of file diff --git a/snippets/auth-next/manage/auth_update_user_email.js b/snippets/auth-next/manage/auth_update_user_email.js new file mode 100644 index 00000000..8e313ece --- /dev/null +++ b/snippets/auth-next/manage/auth_update_user_email.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_update_user_email_modular] +import { getAuth, updateEmail } from "firebase/auth"; +const auth = getAuth(); +updateEmail(auth.currentUser, "user@example.com").then(() => { + // Email updated! + // ... +}).catch((error) => { + // An error occurred + // ... +}); +// [END auth_update_user_email_modular] \ No newline at end of file diff --git a/snippets/auth-next/manage/auth_update_user_profile.js b/snippets/auth-next/manage/auth_update_user_profile.js new file mode 100644 index 00000000..9449474e --- /dev/null +++ b/snippets/auth-next/manage/auth_update_user_profile.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_update_user_profile_modular] +import { getAuth, updateProfile } from "firebase/auth"; +const auth = getAuth(); +updateProfile(auth.currentUser, { + displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg" +}).then(() => { + // Profile updated! + // ... +}).catch((error) => { + // An error occurred + // ... +}); +// [END auth_update_user_profile_modular] \ No newline at end of file From 01c3aa926b72c3441aa8c9ea32d52ec3234d8215 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 10 Jun 2021 13:00:50 +0100 Subject: [PATCH 081/170] Current user snippets --- auth-next/index.js | 17 +++++++++++++++++ auth/index.js | 14 ++++++++++++++ snippets/auth-next/index/auth_current_user.js | 19 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 snippets/auth-next/index/auth_current_user.js diff --git a/auth-next/index.js b/auth-next/index.js index 9c8168b8..73d33219 100644 --- a/auth-next/index.js +++ b/auth-next/index.js @@ -63,6 +63,23 @@ function authStateListener() { // [END auth_state_listener] } +function currentUser() { + // [START auth_current_user] + const { getAuth } = require("firebase/auth"); + + const auth = getAuth(); + const user = auth.currentUser; + + if (user) { + // User is signed in, see docs for a list of available properties + // https://firebase.google.com/docs/reference/js/firebase.User + // ... + } else { + // No user is signed in. + } + // [END auth_current_user] +} + function setLanguageCode() { // [START auth_set_language_code] const { getAuth } = require("firebase/auth"); diff --git a/auth/index.js b/auth/index.js index cae8831b..6ea5d587 100644 --- a/auth/index.js +++ b/auth/index.js @@ -54,6 +54,20 @@ function authStateListener() { // [END auth_state_listener] } +function currentUser() { + // [START auth_current_user] + const user = firebase.auth().currentUser; + + if (user) { + // User is signed in, see docs for a list of available properties + // https://firebase.google.com/docs/reference/js/firebase.User + // ... + } else { + // No user is signed in. + } + // [END auth_current_user] +} + function setLanguageCode() { // [START auth_set_language_code] firebase.auth().languageCode = 'it'; diff --git a/snippets/auth-next/index/auth_current_user.js b/snippets/auth-next/index/auth_current_user.js new file mode 100644 index 00000000..474f66bf --- /dev/null +++ b/snippets/auth-next/index/auth_current_user.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_current_user_modular] +import { getAuth } from "firebase/auth"; + +const auth = getAuth(); +const user = auth.currentUser; + +if (user) { + // User is signed in, see docs for a list of available properties + // https://firebase.google.com/docs/reference/js/firebase.User + // ... +} else { + // No user is signed in. +} +// [END auth_current_user_modular] \ No newline at end of file From 2f9922a96c240407ffaaa9d10b014bbd32b2002d Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 10 Jun 2021 13:16:45 +0100 Subject: [PATCH 082/170] Rest of the manage snippets --- auth-next/manage.js | 96 +++++++++++++++++++ auth/manage.js | 81 ++++++++++++++++ snippets/auth-next/manage/auth_delete_user.js | 18 ++++ .../manage/auth_send_password_reset.js | 18 ++++ .../auth-next/manage/auth_update_password.js | 20 ++++ .../manage/send_email_verification.js | 18 ++++ 6 files changed, 251 insertions(+) create mode 100644 snippets/auth-next/manage/auth_delete_user.js create mode 100644 snippets/auth-next/manage/auth_send_password_reset.js create mode 100644 snippets/auth-next/manage/auth_update_password.js create mode 100644 snippets/auth-next/manage/send_email_verification.js diff --git a/auth-next/manage.js b/auth-next/manage.js index 442cfa0b..49b21301 100644 --- a/auth-next/manage.js +++ b/auth-next/manage.js @@ -70,3 +70,99 @@ function updateUserEmail() { }); // [END auth_update_user_email] } + +function sendEmailVerification() { + // [START send_email_verification] + const { getAuth, sendEmailVerification } = require("firebase/auth"); + + const auth = getAuth(); + const user = auth.currentUser; + + sendEmailVerification(user).then(() => { + // Email sent. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END send_email_verification] +} + +function updatePassword() { + function getASecureRandomPassword() { + return "correcthorsebatterystaple"; + } + + // [START auth_update_password] + const { getAuth, updatePassword } = require("firebase/auth"); + + const auth = getAuth(); + + const user = auth.currentUser; + const newPassword = getASecureRandomPassword(); + + updatePassword(user, newPassword).then(() => { + // Update successful. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_update_password] +} + +function sendPasswordReset() { + // [START auth_send_password_reset] + const { getAuth, sendPasswordResetEmail } = require("firebase/auth"); + + const auth = getAuth(); + const emailAddress = "user@example.com"; + + sendPasswordResetEmail(auth, emailAddress).then(() => { + // Email sent. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_send_password_reset] +} + +function deleteUser() { + // [START auth_delete_user] + const { getAuth, deleteUser } = require("firebase/auth"); + + const auth = getAuth(); + const user = auth.currentUser; + + deleteUser(user).then(() => { + // User deleted. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_delete_user] +} + +function reauthenticateWithCredential() { + /** + * @returns {object} + */ + function promptForCredentials() { + return {}; + } + + // [START auth_reauth_with-credential] + const { getAuth, reauthenticateWithCredential } = require("firebase/auth"); + + const auth = getAuth(); + const user = auth.currentUser; + + // TODO(you): prompt the user to re-provide their sign-in credentials + const credential = promptForCredentials(); + + reauthenticateWithCredential(user, credential).then(() => { + // User re-authenticated. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_reauth_with-credential] +} diff --git a/auth/manage.js b/auth/manage.js index ed451c1b..71d6cd45 100644 --- a/auth/manage.js +++ b/auth/manage.js @@ -68,3 +68,84 @@ function updateUserEmail() { }); // [END auth_update_user_email] } + +function sendEmailVerification() { + // [START send_email_verification] + const user = firebase.auth().currentUser; + + user.sendEmailVerification().then(() => { + // Email sent. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END send_email_verification] +} + +function updatePassword() { + function getASecureRandomPassword() { + return "correcthorsebatterystaple"; + } + + // [START auth_update_password] + const user = firebase.auth().currentUser; + const newPassword = getASecureRandomPassword(); + + user.updatePassword(newPassword).then(() => { + // Update successful. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_update_password] +} + +function sendPasswordReset() { + // [START auth_send_password_reset] + const auth = firebase.auth(); + const emailAddress = "user@example.com"; + + auth.sendPasswordResetEmail(emailAddress).then(() => { + // Email sent. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_send_password_reset] +} + +function deleteUser() { + // [START auth_delete_user] + const user = firebase.auth().currentUser; + + user.delete().then(() => { + // User deleted. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_delete_user] +} + +function reauthenticateWithCredential() { + /** + * @returns {object} + */ + function promptForCredentials() { + return {}; + } + + // [START auth_reauth_with-credential] + const user = firebase.auth().currentUser; + + // TODO(you): prompt the user to re-provide their sign-in credentials + const credential = promptForCredentials(); + + user.reauthenticateWithCredential(credential).then(() => { + // User re-authenticated. + }).catch((error) => { + // An error ocurred + // ... + }); + // [END auth_reauth_with-credential] +} diff --git a/snippets/auth-next/manage/auth_delete_user.js b/snippets/auth-next/manage/auth_delete_user.js new file mode 100644 index 00000000..8d725aa4 --- /dev/null +++ b/snippets/auth-next/manage/auth_delete_user.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_delete_user_modular] +import { getAuth, deleteUser } from "firebase/auth"; + +const auth = getAuth(); +const user = auth.currentUser; + +deleteUser(user).then(() => { + // User deleted. +}).catch((error) => { + // An error ocurred + // ... +}); +// [END auth_delete_user_modular] \ No newline at end of file diff --git a/snippets/auth-next/manage/auth_send_password_reset.js b/snippets/auth-next/manage/auth_send_password_reset.js new file mode 100644 index 00000000..fa6118bb --- /dev/null +++ b/snippets/auth-next/manage/auth_send_password_reset.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_send_password_reset_modular] +import { getAuth, sendPasswordResetEmail } from "firebase/auth"; + +const auth = getAuth(); +const emailAddress = "user@example.com"; + +sendPasswordResetEmail(auth, emailAddress).then(() => { + // Email sent. +}).catch((error) => { + // An error ocurred + // ... +}); +// [END auth_send_password_reset_modular] \ No newline at end of file diff --git a/snippets/auth-next/manage/auth_update_password.js b/snippets/auth-next/manage/auth_update_password.js new file mode 100644 index 00000000..69543928 --- /dev/null +++ b/snippets/auth-next/manage/auth_update_password.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_update_password_modular] +import { getAuth, updatePassword } from "firebase/auth"; + +const auth = getAuth(); + +const user = auth.currentUser; +const newPassword = getASecureRandomPassword(); + +updatePassword(user, newPassword).then(() => { + // Update successful. +}).catch((error) => { + // An error ocurred + // ... +}); +// [END auth_update_password_modular] \ No newline at end of file diff --git a/snippets/auth-next/manage/send_email_verification.js b/snippets/auth-next/manage/send_email_verification.js new file mode 100644 index 00000000..82b0dcf9 --- /dev/null +++ b/snippets/auth-next/manage/send_email_verification.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START send_email_verification_modular] +import { getAuth, sendEmailVerification } from "firebase/auth"; + +const auth = getAuth(); +const user = auth.currentUser; + +sendEmailVerification(user).then(() => { + // Email sent. +}).catch((error) => { + // An error ocurred + // ... +}); +// [END send_email_verification_modular] \ No newline at end of file From 6fee4dc019264742d992e45293fe73cf714a5018 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 10 Jun 2021 13:32:51 +0100 Subject: [PATCH 083/170] Fix one tag --- auth-next/manage.js | 4 ++-- auth/manage.js | 4 ++-- .../manage/auth_reauth_with_credential.js | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 snippets/auth-next/manage/auth_reauth_with_credential.js diff --git a/auth-next/manage.js b/auth-next/manage.js index 49b21301..bf603ccc 100644 --- a/auth-next/manage.js +++ b/auth-next/manage.js @@ -149,7 +149,7 @@ function reauthenticateWithCredential() { return {}; } - // [START auth_reauth_with-credential] + // [START auth_reauth_with_credential] const { getAuth, reauthenticateWithCredential } = require("firebase/auth"); const auth = getAuth(); @@ -164,5 +164,5 @@ function reauthenticateWithCredential() { // An error ocurred // ... }); - // [END auth_reauth_with-credential] + // [END auth_reauth_with_credential] } diff --git a/auth/manage.js b/auth/manage.js index 71d6cd45..7163ef00 100644 --- a/auth/manage.js +++ b/auth/manage.js @@ -135,7 +135,7 @@ function reauthenticateWithCredential() { return {}; } - // [START auth_reauth_with-credential] + // [START auth_reauth_with_credential] const user = firebase.auth().currentUser; // TODO(you): prompt the user to re-provide their sign-in credentials @@ -147,5 +147,5 @@ function reauthenticateWithCredential() { // An error ocurred // ... }); - // [END auth_reauth_with-credential] + // [END auth_reauth_with_credential] } diff --git a/snippets/auth-next/manage/auth_reauth_with_credential.js b/snippets/auth-next/manage/auth_reauth_with_credential.js new file mode 100644 index 00000000..0b02de6c --- /dev/null +++ b/snippets/auth-next/manage/auth_reauth_with_credential.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/manage.js +// +// To make edits to the snippets in this file, please edit the source + +// [START auth_reauth_with_credential_modular] +import { getAuth, reauthenticateWithCredential } from "firebase/auth"; + +const auth = getAuth(); +const user = auth.currentUser; + +// TODO(you): prompt the user to re-provide their sign-in credentials +const credential = promptForCredentials(); + +reauthenticateWithCredential(user, credential).then(() => { + // User re-authenticated. +}).catch((error) => { + // An error ocurred + // ... +}); +// [END auth_reauth_with_credential_modular] \ No newline at end of file From d78b4d2f955b586d9ec0e125c3adfcc7742ed80a Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 11 Jun 2021 02:26:09 -0700 Subject: [PATCH 084/170] Auto-update dependencies. (#182) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index b94f5885..cc5fc126 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/auth/package.json b/auth/package.json index d5183071..c049b151 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.5", + "firebase": "^8.6.7", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index c247ac9e..e5c6e37c 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index fc812865..e7ab4fc6 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/firestore/package.json b/firestore/package.json index 53ff7f4d..1c3c4360 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5", + "firebase": "^8.6.7", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index d7e245c3..1119e0dc 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/installations/package.json b/installations/package.json index bd991ac5..f7f4edee 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/messaging/package.json b/messaging/package.json index 91cf4f7c..db8faba3 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/perf/package.json b/perf/package.json index fa22f5f1..5e300b1f 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 1c4d08d4..fc4287df 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } diff --git a/storage/package.json b/storage/package.json index 4173cb9a..d52a0fc9 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.5" + "firebase": "^8.6.7" } } From fccb4eb27619856d85f1fe5fd320bb23b7c1f31f Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 11 Jun 2021 05:32:01 -0700 Subject: [PATCH 085/170] Auto-update dependencies. (#183) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 38b866cc..43629560 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 3a33e075..83cdfa98 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.6.5/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.6.5/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.7/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.7/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From f38981820e0c0ac9f3cc57f425e34f76c629d2aa Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 11 Jun 2021 08:47:17 -0400 Subject: [PATCH 086/170] SDK v9.0.0-beta.3 (#184) --- analytics-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index c680a4f2..fc41c09e 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/auth-next/package.json b/auth-next/package.json index 19e3cdd9..628a59ca 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/database-next/package.json b/database-next/package.json index 22ed471f..b97354bb 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 0490b5e8..660b3a4a 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 929358a7..503db5bd 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1", + "firebase": "^9.0.0-beta.3", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index c9ff1ffc..a9de34b8 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 37d5e35a..785a3025 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/perf-next/package.json b/perf-next/package.json index 8865057a..f57ee6fe 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index 54cfa5d9..5295c660 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } diff --git a/storage-next/package.json b/storage-next/package.json index 7777f2d0..00ccd216 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.1" + "firebase": "^9.0.0-beta.3" } } From 6d42e4114a857c53f5c3fb49555d32b73521dccc Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 11 Jun 2021 09:11:48 -0400 Subject: [PATCH 087/170] Move to pnpm (#185) --- .github/workflows/test.yml | 6 ++--- .gitignore | 1 + analytics-next/ecommerce.js | 24 ++++++++--------- firestore-next/test.solution-arrays.js | 4 +-- firestore-next/test.solution-counters.js | 4 +-- lerna.json | 27 ------------------- package.json | 7 ++--- .../ecommerce/analytics_ecommerce_add_cart.js | 2 +- .../ecommerce/analytics_ecommerce_checkout.js | 2 +- .../analytics_ecommerce_payment_info.js | 2 +- .../analytics_ecommerce_promotions.js | 2 +- .../ecommerce/analytics_ecommerce_purchase.js | 2 +- .../ecommerce/analytics_ecommerce_refund.js | 2 +- .../analytics_ecommerce_remove_cart.js | 2 +- .../analytics_ecommerce_select_item.js | 2 +- .../analytics_ecommerce_shipping_info.js | 2 +- .../analytics_ecommerce_view_cart.js | 2 +- .../analytics_ecommerce_view_item_details.js | 2 +- .../analytics_ecommerce_view_item_list.js | 2 +- .../query_in_category_timestamp.js | 2 +- .../query_in_category_timestamp_invalid.js | 2 +- .../test-solution-counters/get_count.js | 2 +- .../increment_counter.js | 2 +- 23 files changed, 40 insertions(+), 65 deletions(-) delete mode 100644 lerna.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b619cd36..dbfa11d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: node-version: - - 10.x + - 12.x steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 @@ -29,13 +29,13 @@ jobs: - name: Install dependencies run: | npm install - npm run lerna-bootstrap + npm run bootstrap - name: Lint snippets run: npm run lint - name: Compile snippets - run: npm run lerna-compile + run: npm run compile - name: Check generated snippets run: | diff --git a/.gitignore b/.gitignore index 9d79b150..435f90ea 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tsconfig.json dist/ .DS_Store .idea +pnpm-lock.yaml diff --git a/analytics-next/ecommerce.js b/analytics-next/ecommerce.js index c4c7807c..081aad48 100644 --- a/analytics-next/ecommerce.js +++ b/analytics-next/ecommerce.js @@ -35,7 +35,7 @@ const item_socks = { function ecommerceViewItemList() { // [START analytics_ecommerce_view_item_list] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce params const params1 = { @@ -52,7 +52,7 @@ function ecommerceViewItemList() { function ecommerceSelectItem() { // [START analytics_ecommerce_select_item] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce event params const params2 = { @@ -69,7 +69,7 @@ function ecommerceSelectItem() { function ecommerceViewItemDetails() { // [START analytics_ecommerce_view_item_details] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce event params const params3 = { @@ -86,7 +86,7 @@ function ecommerceViewItemDetails() { function ecommerceAddCart() { // [START analytics_ecommerce_add_cart] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Specify order quantity const item_jeggings_quantity = { @@ -112,7 +112,7 @@ function ecommerceAddCart() { function ecommerceViewCart() { // [START analytics_ecommerce_view_cart] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Specify order quantity const item_jeggings_quantity = { @@ -140,7 +140,7 @@ function ecommerceViewCart() { function ecommerceRemoveCart() { // [START analytics_ecommerce_remove_cart] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce params const params6 = { @@ -157,7 +157,7 @@ function ecommerceRemoveCart() { function ecommerceCheckout() { // [START analytics_ecommerce_checkout] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce params const params7 = { @@ -175,7 +175,7 @@ function ecommerceCheckout() { function ecommerceShippingInfo() { // [START analytics_ecommerce_shipping_info] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce params const params8 = { @@ -194,7 +194,7 @@ function ecommerceShippingInfo() { function ecommercePaymentInfo() { // [START analytics_ecommerce_payment_info] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce params const params9 = { @@ -213,7 +213,7 @@ function ecommercePaymentInfo() { function ecommercePurchase() { // [START analytics_ecommerce_purchase] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce bundle const params10 = { @@ -235,7 +235,7 @@ function ecommercePurchase() { function ecommerceRefund() { // [START analytics_ecommerce_refund] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce params const params11 = { @@ -262,7 +262,7 @@ function ecommerceRefund() { function ecommercePromotions() { // [START analytics_ecommerce_promotions] - const { getAnalytics, logEvent } = require("@firebase/analytics"); + const { getAnalytics, logEvent } = require("firebase/analytics"); // Prepare ecommerce params const params12 = { diff --git a/firestore-next/test.solution-arrays.js b/firestore-next/test.solution-arrays.js index 7986ef6f..3ca186ac 100644 --- a/firestore-next/test.solution-arrays.js +++ b/firestore-next/test.solution-arrays.js @@ -78,7 +78,7 @@ describe("firestore-solution-arrays", () => { it("should query in a category by timestamp", () => { function queryOne() { // [START query_in_category_timestamp_invalid] - const { collection, query, where, orderBy, FirebaseFirestore } = require("@firebase/firestore"); + const { collection, query, where, orderBy, FirebaseFirestore } = require("firebase/firestore"); const q = query(collection(db, "posts"), where("categories.cats", "==", true), @@ -89,7 +89,7 @@ describe("firestore-solution-arrays", () => { function queryTwo() { // [START query_in_category_timestamp] - const { collection, query, where, orderBy } = require("@firebase/firestore"); + const { collection, query, where, orderBy } = require("firebase/firestore"); const q = query(collection(db, "posts"), where("categories.cats", ">", 0), diff --git a/firestore-next/test.solution-counters.js b/firestore-next/test.solution-counters.js index 2e00e8d9..ec671731 100644 --- a/firestore-next/test.solution-counters.js +++ b/firestore-next/test.solution-counters.js @@ -28,7 +28,7 @@ function createCounter(ref, num_shards) { // [START increment_counter] function incrementCounter(db, ref, num_shards) { - const { collection, doc, updateDoc, increment, FirebaseFirestore } = require("@firebase/firestore"); + const { doc, updateDoc, increment } = require("firebase/firestore"); // Select a shard of the counter at random const shardId = Math.floor(Math.random() * num_shards).toString(); @@ -41,7 +41,7 @@ function incrementCounter(db, ref, num_shards) { // [START get_count] async function getCount(ref) { - const { collection, getDocs } = require("@firebase/firestore"); + const { collection, getDocs } = require("firebase/firestore"); // Sum the count of each shard in the subcollection const snapshot = await getDocs(collection(ref, 'shards')); diff --git a/lerna.json b/lerna.json deleted file mode 100644 index a14444a4..00000000 --- a/lerna.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "lerna": "2.8.0", - "packages": [ - "analytics", - "analytics-next", - "auth", - "auth-next", - "database", - "database-next", - "firebaseapp", - "firebaseapp-next", - "firestore", - "firestore-next", - "functions", - "functions-next", - "installations", - "messaging", - "messaging-next", - "perf", - "perf-next", - "remoteconfig", - "remoteconfig-next", - "storage", - "storage-next" - ], - "version": "1.0.0" -} diff --git a/package.json b/package.json index 6eb29b72..e7621ce2 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,14 @@ "snippets": "rimraf snippets && ts-node scripts/separate-snippets.ts", "lint": "git ls-files | grep -v 'snippets/' | grep '.js$' | xargs npx eslint", "format": "npm run lint -- --fix", - "lerna-bootstrap": "lerna bootstrap --no-ci", - "lerna-compile": "lerna run compile" + "bootstrap": "pnpm recursive install", + "compile": "pnpm recursive run compile --workspace-concurrency=4" }, "license": "Apache-2.0", "devDependencies": { + "@types/node": "^15.12.2", "eslint": "^7.16.0", - "lerna": "^3.22.1", + "pnpm": "^6.7.4", "rimraf": "^3.0.2", "ts-node": "^9.0.0", "typescript": "^3.8.3" diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js index 0fc501d9..8d7f87cf 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_add_cart_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Specify order quantity const item_jeggings_quantity = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js index 0e369459..85611fb1 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_checkout_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce params const params7 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js index 17ea80d1..db328513 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_payment_info_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce params const params9 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js index a099a1ac..666241ee 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_promotions_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce params const params12 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js index ea589cb7..a5ba8c62 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_purchase_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce bundle const params10 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js index f7d1f8f8..fab84487 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_refund_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce params const params11 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js index 9bec3f7d..aa841d8f 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_remove_cart_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce params const params6 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js index a4e7ec58..74f3c8c2 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_select_item_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce event params const params2 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js index d2f2ccaa..09cd0f05 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_shipping_info_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce params const params8 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js index bfe02fd0..89ab04ec 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_view_cart_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Specify order quantity const item_jeggings_quantity = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js index ebd74763..920e2c18 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_view_item_details_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce event params const params3 = { diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js index c66f0d20..13eb197c 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START analytics_ecommerce_view_item_list_modular] -import { getAnalytics, logEvent } from "@firebase/analytics"; +import { getAnalytics, logEvent } from "firebase/analytics"; // Prepare ecommerce params const params1 = { diff --git a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js index 88477e12..31336fac 100644 --- a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js +++ b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START query_in_category_timestamp_modular] -import { collection, query, where, orderBy } from "@firebase/firestore"; +import { collection, query, where, orderBy } from "firebase/firestore"; const q = query(collection(db, "posts"), where("categories.cats", ">", 0), diff --git a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js index 65a84c9f..29c0a18c 100644 --- a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js +++ b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START query_in_category_timestamp_invalid_modular] -import { collection, query, where, orderBy, FirebaseFirestore } from "@firebase/firestore"; +import { collection, query, where, orderBy, FirebaseFirestore } from "firebase/firestore"; const q = query(collection(db, "posts"), where("categories.cats", "==", true), diff --git a/snippets/firestore-next/test-solution-counters/get_count.js b/snippets/firestore-next/test-solution-counters/get_count.js index 614173c9..2fc01217 100644 --- a/snippets/firestore-next/test-solution-counters/get_count.js +++ b/snippets/firestore-next/test-solution-counters/get_count.js @@ -5,7 +5,7 @@ // [START get_count_modular] async function getCount(ref) { - import { collection, getDocs } from "@firebase/firestore"; + import { collection, getDocs } from "firebase/firestore"; // Sum the count of each shard in the subcollection const snapshot = await getDocs(collection(ref, 'shards')); diff --git a/snippets/firestore-next/test-solution-counters/increment_counter.js b/snippets/firestore-next/test-solution-counters/increment_counter.js index 37e94224..c74ec711 100644 --- a/snippets/firestore-next/test-solution-counters/increment_counter.js +++ b/snippets/firestore-next/test-solution-counters/increment_counter.js @@ -5,7 +5,7 @@ // [START increment_counter_modular] function incrementCounter(db, ref, num_shards) { - import { collection, doc, updateDoc, increment, FirebaseFirestore } from "@firebase/firestore"; + import { doc, updateDoc, increment } from "firebase/firestore"; // Select a shard of the counter at random const shardId = Math.floor(Math.random() * num_shards).toString(); From 9d474d90b35260924574c0db5e3dc4f38e9e7dd1 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Thu, 17 Jun 2021 05:37:02 -0400 Subject: [PATCH 088/170] Clarify some query snippets See: https://github.com/firebase/snippets-web/issues/186 --- firestore/test.firestore.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/firestore/test.firestore.js b/firestore/test.firestore.js index 988a3c97..bccf10cd 100644 --- a/firestore/test.firestore.js +++ b/firestore/test.firestore.js @@ -856,9 +856,9 @@ describe("firestore", () => { it("should handle other wheres", () => { var citiesRef = db.collection("cities"); // [START example_filters] - citiesRef.where("state", "==", "CA"); - citiesRef.where("population", "<", 100000); - citiesRef.where("name", ">=", "San Francisco"); + const nameQuery = citiesRef.where("state", "==", "CA"); + const populationQuery = citiesRef.where("population", "<", 100000); + const nameQuery = citiesRef.where("name", ">=", "San Francisco"); // [END example_filters] // [START simple_query_not_equal] @@ -900,16 +900,16 @@ describe("firestore", () => { it("should handle compound queries", () => { var citiesRef = db.collection("cities"); // [START chain_filters] - citiesRef.where("state", "==", "CO").where("name", "==", "Denver"); - citiesRef.where("state", "==", "CA").where("population", "<", 1000000); + const q1 = citiesRef.where("state", "==", "CO").where("name", "==", "Denver"); + const q2 = citiesRef.where("state", "==", "CA").where("population", "<", 1000000); // [END chain_filters] }); it("should handle range filters on one field", () => { var citiesRef = db.collection("cities"); // [START valid_range_filters] - citiesRef.where("state", ">=", "CA").where("state", "<=", "IN"); - citiesRef.where("state", "==", "CA").where("population", ">", 1000000); + const q1 = citiesRef.where("state", ">=", "CA").where("state", "<=", "IN"); + const q2 = citiesRef.where("state", "==", "CA").where("population", ">", 1000000); // [END valid_range_filters] }); From cc780b4d760548050b37263a092c7b6fb85ab97d Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Thu, 17 Jun 2021 05:38:46 -0400 Subject: [PATCH 089/170] Clarify some query snippets See: https://github.com/firebase/snippets-web/issues/186 --- firestore-next/test.firestore.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 2a452e80..29983b26 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -851,13 +851,13 @@ describe("firestore", () => { const citiesRef = collection(db, "cities"); // [START example_filters] - const q1 = query(citiesRef, where("state", "==", "CA")); - const q2 = query(citiesRef, where("population", "<", 100000)); - const q3 = query(citiesRef, where("name", ">=", "San Francisco")); + const stateQuery = query(citiesRef, where("state", "==", "CA")); + const populationQuery = query(citiesRef, where("population", "<", 100000)); + const nameQuery = query(citiesRef, where("name", ">=", "San Francisco")); // [END example_filters] // [START simple_query_not_equal] - const q4 = query(citiesRef, where("capital", "!=", false)); + const notCapitalQuery = query(citiesRef, where("capital", "!=", false)); // [END simple_query_not_equal] }); From 97c3d88ffa57794babb50af2a2db26aa5465feae Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Thu, 17 Jun 2021 05:43:31 -0400 Subject: [PATCH 090/170] Update test.firestore.js --- firestore/test.firestore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firestore/test.firestore.js b/firestore/test.firestore.js index bccf10cd..2aadf8d5 100644 --- a/firestore/test.firestore.js +++ b/firestore/test.firestore.js @@ -856,7 +856,7 @@ describe("firestore", () => { it("should handle other wheres", () => { var citiesRef = db.collection("cities"); // [START example_filters] - const nameQuery = citiesRef.where("state", "==", "CA"); + const stateQuery = citiesRef.where("state", "==", "CA"); const populationQuery = citiesRef.where("population", "<", 100000); const nameQuery = citiesRef.where("name", ">=", "San Francisco"); // [END example_filters] From edd04c7201285d863794c21a5a50201c02a9aa55 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 17 Jun 2021 10:48:40 +0100 Subject: [PATCH 091/170] Regenerate snippets --- snippets/firestore-next/test-firestore/example_filters.js | 6 +++--- .../firestore-next/test-firestore/simple_query_not_equal.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/firestore-next/test-firestore/example_filters.js b/snippets/firestore-next/test-firestore/example_filters.js index ccadb811..b5f58a5c 100644 --- a/snippets/firestore-next/test-firestore/example_filters.js +++ b/snippets/firestore-next/test-firestore/example_filters.js @@ -4,7 +4,7 @@ // To make edits to the snippets in this file, please edit the source // [START example_filters_modular] -const q1 = query(citiesRef, where("state", "==", "CA")); -const q2 = query(citiesRef, where("population", "<", 100000)); -const q3 = query(citiesRef, where("name", ">=", "San Francisco")); +const stateQuery = query(citiesRef, where("state", "==", "CA")); +const populationQuery = query(citiesRef, where("population", "<", 100000)); +const nameQuery = query(citiesRef, where("name", ">=", "San Francisco")); // [END example_filters_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/simple_query_not_equal.js b/snippets/firestore-next/test-firestore/simple_query_not_equal.js index 0ddb5643..a9ca2690 100644 --- a/snippets/firestore-next/test-firestore/simple_query_not_equal.js +++ b/snippets/firestore-next/test-firestore/simple_query_not_equal.js @@ -4,5 +4,5 @@ // To make edits to the snippets in this file, please edit the source // [START simple_query_not_equal_modular] -const q4 = query(citiesRef, where("capital", "!=", false)); +const notCapitalQuery = query(citiesRef, where("capital", "!=", false)); // [END simple_query_not_equal_modular] \ No newline at end of file From edb656bdbd8549323bbb590c8d1aa250ee3874f3 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 18 Jun 2021 02:46:38 -0700 Subject: [PATCH 092/170] Auto-update dependencies. (#187) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index cc5fc126..6860d83d 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/auth/package.json b/auth/package.json index c049b151..c2417cc1 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.7", + "firebase": "^8.6.8", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index e5c6e37c..c9019f5a 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index e7ab4fc6..477a93b1 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/firestore/package.json b/firestore/package.json index 1c3c4360..c8c44a65 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7", + "firebase": "^8.6.8", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 1119e0dc..98a666fe 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/installations/package.json b/installations/package.json index f7f4edee..cfeb425a 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/messaging/package.json b/messaging/package.json index db8faba3..79655ec6 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/perf/package.json b/perf/package.json index 5e300b1f..98bf1569 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index fc4287df..fbe56615 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } diff --git a/storage/package.json b/storage/package.json index d52a0fc9..c2e6acd7 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.7" + "firebase": "^8.6.8" } } From 15e1160b5a0eef0198df0d6c6dd16d349cc9ee1b Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 18 Jun 2021 07:25:12 -0700 Subject: [PATCH 093/170] Auto-update dependencies. (#188) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 43629560..8326796b 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 83cdfa98..d3568384 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.6.7/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.6.7/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.8/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.6.8/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 26569c25020d706a2f5a3b9bc2d306c29a7e5bfc Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 21 Jun 2021 11:30:18 -0400 Subject: [PATCH 094/170] Version 9.0.0-beta.5 (#190) --- analytics-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index fc41c09e..7619d871 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/auth-next/package.json b/auth-next/package.json index 628a59ca..50a848dd 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/database-next/package.json b/database-next/package.json index b97354bb..8ca518b1 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 660b3a4a..3dbdc53c 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 503db5bd..5e80fc86 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3", + "firebase": "^9.0.0-beta.5", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index a9de34b8..3b9ba918 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 785a3025..9f079581 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/perf-next/package.json b/perf-next/package.json index f57ee6fe..715ad2c2 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index 5295c660..a006de29 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } diff --git a/storage-next/package.json b/storage-next/package.json index 00ccd216..a9fa5b59 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.3" + "firebase": "^9.0.0-beta.5" } } From f277c5669a45428236a9a480b736be55a6eb74ab Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 2 Jul 2021 09:18:58 +0000 Subject: [PATCH 095/170] Auto-update dependencies. (#193) --- analytics/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 6860d83d..606ce181 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/auth/package.json b/auth/package.json index c2417cc1..4f1aac94 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.8", + "firebase": "^8.7.0", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index c9019f5a..300c2819 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 477a93b1..94770adf 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/firestore/package.json b/firestore/package.json index c8c44a65..f7f5cad1 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8", + "firebase": "^8.7.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 98a666fe..38d4e438 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/installations/package.json b/installations/package.json index cfeb425a..0cf430e2 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/messaging/package.json b/messaging/package.json index 79655ec6..508df566 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/perf/package.json b/perf/package.json index 98bf1569..6e2069e1 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index fbe56615..97d84e71 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } diff --git a/storage/package.json b/storage/package.json index c2e6acd7..c24bbbc9 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.6.8" + "firebase": "^8.7.0" } } From 6f8eef6a604d236cda3db955ad3f8790eae7bd85 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 2 Jul 2021 11:41:48 +0100 Subject: [PATCH 096/170] Version 9.0.0-beta.6 (#194) --- analytics-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index 7619d871..8a016e7f 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/auth-next/package.json b/auth-next/package.json index 50a848dd..0faf9c39 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/database-next/package.json b/database-next/package.json index 8ca518b1..36e447be 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 3dbdc53c..8d8aeb5b 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 5e80fc86..2a6789f9 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5", + "firebase": "^9.0.0-beta.6", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index 3b9ba918..8af6456f 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 9f079581..7a515c8f 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/perf-next/package.json b/perf-next/package.json index 715ad2c2..ae90ad17 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index a006de29..f092772d 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } diff --git a/storage-next/package.json b/storage-next/package.json index a9fa5b59..e2e1edc8 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.5" + "firebase": "^9.0.0-beta.6" } } From 28ef8d3a13c9454b8f9da33200b1616dc935542a Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 2 Jul 2021 12:06:42 +0100 Subject: [PATCH 097/170] Add AppCheck snippets (#195) --- appcheck-next/index.js | 65 +++++++++++++++++++ appcheck-next/package.json | 11 ++++ appcheck/index.js | 55 ++++++++++++++++ appcheck/package.json | 11 ++++ .../index/appcheck_custom_provider.js | 29 +++++++++ .../index/appcheck_initialize.js | 19 ++++++ .../appcheck_initialize_custom_provider.js | 17 +++++ 7 files changed, 207 insertions(+) create mode 100644 appcheck-next/index.js create mode 100644 appcheck-next/package.json create mode 100644 appcheck/index.js create mode 100644 appcheck/package.json create mode 100644 snippets/appcheck-next/index/appcheck_custom_provider.js create mode 100644 snippets/appcheck-next/index/appcheck_initialize.js create mode 100644 snippets/appcheck-next/index/appcheck_initialize_custom_provider.js diff --git a/appcheck-next/index.js b/appcheck-next/index.js new file mode 100644 index 00000000..824cd3cb --- /dev/null +++ b/appcheck-next/index.js @@ -0,0 +1,65 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function initialize() { + // [START appcheck_initialize] + const { initializeApp } = require("firebase/app"); + const { initializeAppCheck, ReCaptchaV3Provider } = require("firebase/app-check"); + + const app = initializeApp({ + // Your firebase configuration object + }); + + // Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this + // key is the counterpart to the secret key you set in the Firebase console. + const appCheck = initializeAppCheck(app, { + provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd') + }); + // [END appcheck_initialize] +} + +function customProvider() { + // [START appcheck_custom_provider] + const { CustomProvider } = require("firebase/app-check"); + + const appCheckCustomProvider = new CustomProvider({ + getToken: () => { + return new Promise((resolve, _reject) => { + // TODO: Logic to exchange proof of authenticity for an App Check token and + // expiration time. + + // [START_EXCLUDE] + const tokenFromServer = "abc1234"; + const expirationFromServer = 1234; + // [END_EXCLUDE] + + const appCheckToken = { + token: tokenFromServer, + expireTimeMillis: expirationFromServer * 1000 + }; + + resolve(appCheckToken); + }); + } + }); + // [END appcheck_custom_provider] + + return appCheckCustomProvider; +} + +function initializeCustomProvider() { + const appCheckCustomProvider = customProvider(); + + // [START appcheck_initialize_custom_provider] + const { initializeApp } = require("firebase/app"); + const { initializeAppCheck } = require("firebase/app-check"); + + const app = initializeApp({ + // Your firebase configuration object + }); + + const appCheck = initializeAppCheck(app, { + provider: appCheckCustomProvider + }); + // [END appcheck_initialize_custom_provider] +} diff --git a/appcheck-next/package.json b/appcheck-next/package.json new file mode 100644 index 00000000..0514d1e8 --- /dev/null +++ b/appcheck-next/package.json @@ -0,0 +1,11 @@ +{ + "name": "appcheck-next", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "^9.0.0-beta.6" + } +} diff --git a/appcheck/index.js b/appcheck/index.js new file mode 100644 index 00000000..04282f4d --- /dev/null +++ b/appcheck/index.js @@ -0,0 +1,55 @@ +import firebase from "firebase/app"; +import "firebase/app-check"; + +function initialize() { + // [START appcheck_initialize] + firebase.initializeApp({ + // Your firebase configuration object + }); + + const appCheck = firebase.appCheck(); + // Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this + // key is the counterpart to the secret key you set in the Firebase console. + appCheck.activate('abcdefghijklmnopqrstuvwxy-1234567890abcd'); + // [END appcheck_initialize] +} + +function customProvider() { + // [START appcheck_custom_provider] + const appCheckCustomProvider = { + getToken: () => { + return new Promise((resolve, _reject) => { + // TODO: Logic to exchange proof of authenticity for an App Check token and + // expiration time. + + // [START_EXCLUDE] + const tokenFromServer = "abc1234"; + const expirationFromServer = 1234; + // [END_EXCLUDE] + + const appCheckToken = { + token: tokenFromServer, + expireTimeMillis: expirationFromServer * 1000 + }; + + resolve(appCheckToken); + }); + } + }; + // [END appcheck_custom_provider] + + return appCheckCustomProvider; +} + +function initializeCustomProvider() { + const appCheckCustomProvider = customProvider(); + + // [START appcheck_initialize_custom_provider] + firebase.initializeApp({ + // Your firebase configuration object + }); + + const appCheck = firebase.appCheck(); + appCheck.activate(appCheckCustomProvider); + // [END appcheck_initialize_custom_provider] +} diff --git a/appcheck/package.json b/appcheck/package.json new file mode 100644 index 00000000..f40d585d --- /dev/null +++ b/appcheck/package.json @@ -0,0 +1,11 @@ +{ + "name": "appcheck", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "^8.7.0" + } +} diff --git a/snippets/appcheck-next/index/appcheck_custom_provider.js b/snippets/appcheck-next/index/appcheck_custom_provider.js new file mode 100644 index 00000000..7bcb0452 --- /dev/null +++ b/snippets/appcheck-next/index/appcheck_custom_provider.js @@ -0,0 +1,29 @@ +// This snippet file was generated by processing the source file: +// ./appcheck-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START appcheck_custom_provider_modular] +import { CustomProvider } from "firebase/app-check"; + +const appCheckCustomProvider = new CustomProvider({ + getToken: () => { + return new Promise((resolve, _reject) => { + // TODO: Logic to exchange proof of authenticity for an App Check token and + // expiration time. + + // [START_EXCLUDE] + const tokenFromServer = "abc1234"; + const expirationFromServer = 1234; + // [END_EXCLUDE] + + const appCheckToken = { + token: tokenFromServer, + expireTimeMillis: expirationFromServer * 1000 + }; + + resolve(appCheckToken); + }); + } +}); +// [END appcheck_custom_provider_modular] \ No newline at end of file diff --git a/snippets/appcheck-next/index/appcheck_initialize.js b/snippets/appcheck-next/index/appcheck_initialize.js new file mode 100644 index 00000000..7aa91572 --- /dev/null +++ b/snippets/appcheck-next/index/appcheck_initialize.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./appcheck-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START appcheck_initialize_modular] +import { initializeApp } from "firebase/app"; +import { initializeAppCheck, ReCaptchaV3Provider } from "firebase/app-check"; + +const app = initializeApp({ + // Your firebase configuration object +}); + +// Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this +// key is the counterpart to the secret key you set in the Firebase console. +const appCheck = initializeAppCheck(app, { + provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd') +}); +// [END appcheck_initialize_modular] \ No newline at end of file diff --git a/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js b/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js new file mode 100644 index 00000000..ef721941 --- /dev/null +++ b/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js @@ -0,0 +1,17 @@ +// This snippet file was generated by processing the source file: +// ./appcheck-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START appcheck_initialize_custom_provider_modular] +import { initializeApp } from "firebase/app"; +import { initializeAppCheck } from "firebase/app-check"; + +const app = initializeApp({ + // Your firebase configuration object +}); + +const appCheck = initializeAppCheck(app, { + provider: appCheckCustomProvider +}); +// [END appcheck_initialize_custom_provider_modular] \ No newline at end of file From 4e2e1a25845917860fca1858aa3ca3c80dc9ff42 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 2 Jul 2021 12:21:30 +0000 Subject: [PATCH 098/170] Auto-update dependencies. (#196) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 8326796b..264fe1a3 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index d3568384..4ff1a19b 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.6.8/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.6.8/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.7.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.7.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From e48a146a0f89358c85e5f67aee3fa14047b63cbd Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 5 Jul 2021 10:06:32 +0100 Subject: [PATCH 099/170] Update transaction_promise.js (#198) --- firestore-next/test.firestore.js | 1 + snippets/firestore-next/test-firestore/transaction_promise.js | 1 + 2 files changed, 2 insertions(+) diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 29983b26..7dca3d0e 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -559,6 +559,7 @@ describe("firestore", () => { const newPop = sfDoc.data().population + 1; if (newPop <= 1000000) { transaction.update(sfDocRef, { population: newPop }); + return newPop; } else { return Promise.reject("Sorry! Population is too big"); } diff --git a/snippets/firestore-next/test-firestore/transaction_promise.js b/snippets/firestore-next/test-firestore/transaction_promise.js index cda47859..7646bb6d 100644 --- a/snippets/firestore-next/test-firestore/transaction_promise.js +++ b/snippets/firestore-next/test-firestore/transaction_promise.js @@ -19,6 +19,7 @@ try { const newPop = sfDoc.data().population + 1; if (newPop <= 1000000) { transaction.update(sfDocRef, { population: newPop }); + return newPop; } else { return Promise.reject("Sorry! Population is too big"); } From f063360468ed058d43e0ec8a2ff6a7d37ac23300 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Mon, 5 Jul 2021 11:35:31 +0100 Subject: [PATCH 100/170] Add messaging sw snippet (#199) --- messaging-next/service-worker.js | 17 ++++++++++++++++- .../messaging_on_background_message.js | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/messaging-next/service-worker.js b/messaging-next/service-worker.js index 25ee21db..ce0ac6b8 100644 --- a/messaging-next/service-worker.js +++ b/messaging-next/service-worker.js @@ -40,6 +40,21 @@ function initInSw() { function onBackgroundMessage() { // [START messaging_on_background_message] - // TODO(snippet): This snippet is not yet translated to the @exp SDK + const { getMessaging } = require("firebase/messaging"); + const { onBackgroundMessage } = require("firebase/messaging/sw"); + + const messaging = getMessaging(); + onBackgroundMessage(messaging, (payload) => { + console.log('[firebase-messaging-sw.js] Received background message ', payload); + // Customize notification here + const notificationTitle = 'Background Message Title'; + const notificationOptions = { + body: 'Background Message body.', + icon: '/firebase-logo.png' + }; + + self.registration.showNotification(notificationTitle, + notificationOptions); + }); // [END messaging_on_background_message] } diff --git a/snippets/messaging-next/service-worker/messaging_on_background_message.js b/snippets/messaging-next/service-worker/messaging_on_background_message.js index 2c55eab1..000ab312 100644 --- a/snippets/messaging-next/service-worker/messaging_on_background_message.js +++ b/snippets/messaging-next/service-worker/messaging_on_background_message.js @@ -4,5 +4,20 @@ // To make edits to the snippets in this file, please edit the source // [START messaging_on_background_message_modular] -// TODO(snippet): This snippet is not yet translated to the @exp SDK +import { getMessaging } from "firebase/messaging"; +import { onBackgroundMessage } from "firebase/messaging/sw"; + +const messaging = getMessaging(); +onBackgroundMessage(messaging, (payload) => { + console.log('[firebase-messaging-sw.js] Received background message ', payload); + // Customize notification here + const notificationTitle = 'Background Message Title'; + const notificationOptions = { + body: 'Background Message body.', + icon: '/firebase-logo.png' + }; + + self.registration.showNotification(notificationTitle, + notificationOptions); +}); // [END messaging_on_background_message_modular] \ No newline at end of file From 4af4eff5b6359647e95ee300a19ffbdec4f8e975 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 9 Jul 2021 10:51:24 +0000 Subject: [PATCH 101/170] Auto-update dependencies. (#200) --- analytics/package.json | 2 +- appcheck/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 606ce181..279e01b9 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/appcheck/package.json b/appcheck/package.json index f40d585d..1e3e3e4e 100644 --- a/appcheck/package.json +++ b/appcheck/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/auth/package.json b/auth/package.json index 4f1aac94..3b153e5f 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.7.0", + "firebase": "^8.7.1", "firebaseui": "^4.8.0" } } diff --git a/database/package.json b/database/package.json index 300c2819..6065a1e2 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 94770adf..9f37e03a 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/firestore/package.json b/firestore/package.json index f7f5cad1..eb8d249b 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0", + "firebase": "^8.7.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 38d4e438..03a0c953 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/installations/package.json b/installations/package.json index 0cf430e2..4e522a00 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/messaging/package.json b/messaging/package.json index 508df566..f431485c 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/perf/package.json b/perf/package.json index 6e2069e1..5b3cd047 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 97d84e71..c37579d2 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } diff --git a/storage/package.json b/storage/package.json index c24bbbc9..f38e0b00 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.0" + "firebase": "^8.7.1" } } From fcad62c049a656606546f2c3c1645a6153cbe59b Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 9 Jul 2021 12:59:55 +0000 Subject: [PATCH 102/170] Auto-update dependencies. (#201) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 264fe1a3..2cc69598 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 4ff1a19b..eb4175ca 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.7.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.7.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.7.1/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.7.1/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 9b05382e6bd01887c1d2636339b39c00b72e7dce Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Tue, 13 Jul 2021 15:49:38 +0100 Subject: [PATCH 103/170] Update cache hashing (#202) --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dbfa11d6..3eddc3bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: uses: actions/cache@v1 with: path: ~/.npm - key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }} - name: Install dependencies run: | From 9d1c8c51a6b7143605340490795caeea2d8f2e73 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 23 Jul 2021 09:07:01 +0000 Subject: [PATCH 104/170] Auto-update dependencies. (#204) Co-authored-by: Sam --- analytics-next/package.json | 2 +- analytics/package.json | 2 +- appcheck-next/package.json | 2 +- appcheck/package.json | 2 +- auth-next/emulator-suite.js | 4 ++-- auth-next/package.json | 2 +- auth/package.json | 4 ++-- database-next/emulator-suite.js | 4 ++-- database-next/package.json | 2 +- database/package.json | 2 +- firebaseapp-next/package.json | 2 +- firebaseapp/package.json | 2 +- firestore-next/emulator-suite.js | 4 ++-- firestore-next/package.json | 2 +- firestore/package.json | 2 +- functions-next/emulator-suite.js | 4 ++-- functions-next/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging-next/package.json | 2 +- messaging/package.json | 2 +- perf-next/package.json | 2 +- perf/package.json | 2 +- remoteconfig-next/package.json | 2 +- remoteconfig/package.json | 2 +- snippets/auth-next/emulator-suite/auth_emulator_connect.js | 4 ++-- .../database-next/emulator-suite/rtdb_emulator_connect.js | 4 ++-- snippets/firestore-next/emulator-suite/fs_emulator_connect.js | 4 ++-- .../emulator-suite/fb_functions_emulator_connect.js | 4 ++-- storage-next/package.json | 2 +- storage/package.json | 2 +- 31 files changed, 40 insertions(+), 40 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index 8a016e7f..b04876cb 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/analytics/package.json b/analytics/package.json index 279e01b9..57c16836 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/appcheck-next/package.json b/appcheck-next/package.json index 0514d1e8..8fc601eb 100644 --- a/appcheck-next/package.json +++ b/appcheck-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/appcheck/package.json b/appcheck/package.json index 1e3e3e4e..cf7d82b3 100644 --- a/appcheck/package.json +++ b/appcheck/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/auth-next/emulator-suite.js b/auth-next/emulator-suite.js index ed24e78b..84d57ed0 100644 --- a/auth-next/emulator-suite.js +++ b/auth-next/emulator-suite.js @@ -3,10 +3,10 @@ function emulatorConnect() { // [START auth_emulator_connect] - const { getAuth, useAuthEmulator } = require("firebase/auth"); + const { getAuth, connectAuthEmulator } = require("firebase/auth"); const auth = getAuth(); - useAuthEmulator(auth, "http://localhost:9099"); + connectAuthEmulator(auth, "http://localhost:9099"); // [END auth_emulator_connect] } diff --git a/auth-next/package.json b/auth-next/package.json index 0faf9c39..1a955b2a 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/auth/package.json b/auth/package.json index 3b153e5f..f8a0c4de 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.7.1", - "firebaseui": "^4.8.0" + "firebase": "^8.8.0", + "firebaseui": "^4.8.1" } } diff --git a/database-next/emulator-suite.js b/database-next/emulator-suite.js index 083fea80..ab86bf9b 100644 --- a/database-next/emulator-suite.js +++ b/database-next/emulator-suite.js @@ -3,12 +3,12 @@ function onDocumentReady() { // [START rtdb_emulator_connect] - const { getDatabase, useDatabaseEmulator } = require("firebase/database"); + const { getDatabase, connectDatabaseEmulator } = require("firebase/database"); const db = getDatabase(); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. - useDatabaseEmulator(db, "localhost", 9000); + connectDatabaseEmulator(db, "localhost", 9000); } // [END rtdb_emulator_connect] } diff --git a/database-next/package.json b/database-next/package.json index 36e447be..a6c12500 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/database/package.json b/database/package.json index 6065a1e2..d26b77fb 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 8d8aeb5b..daeaf862 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 9f37e03a..fd76176d 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/firestore-next/emulator-suite.js b/firestore-next/emulator-suite.js index 61463eee..30ad24eb 100644 --- a/firestore-next/emulator-suite.js +++ b/firestore-next/emulator-suite.js @@ -3,10 +3,10 @@ function onDocumentReady() { // [START fs_emulator_connect] - const { getFirestore, useFirestoreEmulator } = require("firebase/firestore"); + const { getFirestore, connectFirestoreEmulator } = require("firebase/firestore"); // firebaseApps previously initialized using initializeApp() const db = getFirestore(); - useFirestoreEmulator(db, 'localhost', 8080); + connectFirestoreEmulator(db, 'localhost', 8080); // [END fs_emulator_connect] } diff --git a/firestore-next/package.json b/firestore-next/package.json index 2a6789f9..fe0e5390 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6", + "firebase": "^9.0.0-beta.7", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/firestore/package.json b/firestore/package.json index eb8d249b..400d854f 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1", + "firebase": "^8.8.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/emulator-suite.js b/functions-next/emulator-suite.js index 1f519a2e..7a750fc4 100644 --- a/functions-next/emulator-suite.js +++ b/functions-next/emulator-suite.js @@ -12,10 +12,10 @@ initializeApp({ export function emulatorSettings() { // [START fb_functions_emulator_connect] const { getApp } = require("firebase/app"); - const { getFunctions, useFunctionsEmulator } = require("firebase/functions"); + const { getFunctions, connectFunctionsEmulator } = require("firebase/functions"); const functions = getFunctions(getApp()); - useFunctionsEmulator(functions, "localhost", 5001); + connectFunctionsEmulator(functions, "localhost", 5001); // [END fb_functions_emulator_connect] } diff --git a/functions-next/package.json b/functions-next/package.json index 8af6456f..38a60b6f 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/functions/package.json b/functions/package.json index 03a0c953..78ddd20e 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/installations/package.json b/installations/package.json index 4e522a00..948ad208 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 7a515c8f..cb9c10c3 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/messaging/package.json b/messaging/package.json index f431485c..3d9ea607 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/perf-next/package.json b/perf-next/package.json index ae90ad17..7ff11967 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/perf/package.json b/perf/package.json index 5b3cd047..c928467c 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index f092772d..eaa7272d 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index c37579d2..781f8363 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } diff --git a/snippets/auth-next/emulator-suite/auth_emulator_connect.js b/snippets/auth-next/emulator-suite/auth_emulator_connect.js index 99f222ff..7e4cf680 100644 --- a/snippets/auth-next/emulator-suite/auth_emulator_connect.js +++ b/snippets/auth-next/emulator-suite/auth_emulator_connect.js @@ -4,8 +4,8 @@ // To make edits to the snippets in this file, please edit the source // [START auth_emulator_connect_modular] -import { getAuth, useAuthEmulator } from "firebase/auth"; +import { getAuth, connectAuthEmulator } from "firebase/auth"; const auth = getAuth(); -useAuthEmulator(auth, "http://localhost:9099"); +connectAuthEmulator(auth, "http://localhost:9099"); // [END auth_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js index 0015f451..709fc10b 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js @@ -4,11 +4,11 @@ // To make edits to the snippets in this file, please edit the source // [START rtdb_emulator_connect_modular] -import { getDatabase, useDatabaseEmulator } from "firebase/database"; +import { getDatabase, connectDatabaseEmulator } from "firebase/database"; const db = getDatabase(); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. - useDatabaseEmulator(db, "localhost", 9000); + connectDatabaseEmulator(db, "localhost", 9000); } // [END rtdb_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js index 140f6a09..3754a2df 100644 --- a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js +++ b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js @@ -4,9 +4,9 @@ // To make edits to the snippets in this file, please edit the source // [START fs_emulator_connect_modular] -import { getFirestore, useFirestoreEmulator } from "firebase/firestore"; +import { getFirestore, connectFirestoreEmulator } from "firebase/firestore"; // firebaseApps previously initialized using initializeApp() const db = getFirestore(); -useFirestoreEmulator(db, 'localhost', 8080); +connectFirestoreEmulator(db, 'localhost', 8080); // [END fs_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js index 62fc3dd2..1a314acf 100644 --- a/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js +++ b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js @@ -5,8 +5,8 @@ // [START fb_functions_emulator_connect_modular] import { getApp } from "firebase/app"; -import { getFunctions, useFunctionsEmulator } from "firebase/functions"; +import { getFunctions, connectFunctionsEmulator } from "firebase/functions"; const functions = getFunctions(getApp()); -useFunctionsEmulator(functions, "localhost", 5001); +connectFunctionsEmulator(functions, "localhost", 5001); // [END fb_functions_emulator_connect_modular] \ No newline at end of file diff --git a/storage-next/package.json b/storage-next/package.json index e2e1edc8..a912d510 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.6" + "firebase": "^9.0.0-beta.7" } } diff --git a/storage/package.json b/storage/package.json index f38e0b00..9ab7fd82 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.7.1" + "firebase": "^8.8.0" } } From 9fcfc6425e99f0a4dba4807693eca8f86d0188a3 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 23 Jul 2021 12:05:27 +0100 Subject: [PATCH 105/170] Initialize functions snippet (#205) --- functions-next/callable.js | 17 +++++++++++++++++ functions/callable.js | 16 ++++++++++++++++ .../callable/fb_functions_initialize.js | 19 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 snippets/functions-next/callable/fb_functions_initialize.js diff --git a/functions-next/callable.js b/functions-next/callable.js index 70049563..5ebc03d9 100644 --- a/functions-next/callable.js +++ b/functions-next/callable.js @@ -1,6 +1,23 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] +export function initialize() { + // [START fb_functions_initialize] + const { initializeApp } = require("firebase/app"); + const { getFunctions } = require("firebase/functions"); + + initializeApp({ + // Your Firebase Web SDK configuration + // [START_EXCLUDE] + projectId: "", + apiKey: "", + // [END_EXCLUDE] + }); + + const functions = getFunctions(); + // [END fb_functions_initialize] +} + export function callAddMessage() { const messageText = "Hello, World!"; diff --git a/functions/callable.js b/functions/callable.js index 2b605ae1..66b576d5 100644 --- a/functions/callable.js +++ b/functions/callable.js @@ -1,5 +1,21 @@ +// [START fb_functions_imports] import firebase from "firebase/app"; import "firebase/functions"; +// [END fb_functions_imports] + +function initialize() { + // [START fb_functions_initialize] + firebase.initializeApp({ + // Your Firebase Web SDK configuration + // [START_EXCLUDE] + projectId: "", + apiKey: "", + // [END_EXCLUDE] + }); + + const functions = firebase.functions(); + // [END fb_functions_initialize] +} function callAddMessage() { const messageText = "Hello, World!"; diff --git a/snippets/functions-next/callable/fb_functions_initialize.js b/snippets/functions-next/callable/fb_functions_initialize.js new file mode 100644 index 00000000..7c8e4d49 --- /dev/null +++ b/snippets/functions-next/callable/fb_functions_initialize.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./functions-next/callable.js +// +// To make edits to the snippets in this file, please edit the source + +// [START fb_functions_initialize_modular] +import { initializeApp } from "firebase/app"; +import { getFunctions } from "firebase/functions"; + +initializeApp({ + // Your Firebase Web SDK configuration + // [START_EXCLUDE] + projectId: "", + apiKey: "", + // [END_EXCLUDE] +}); + +const functions = getFunctions(); +// [END fb_functions_initialize_modular] \ No newline at end of file From f29550c38f02bad94cfd87c15d3cd1cba36ece9a Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 23 Jul 2021 12:46:38 +0000 Subject: [PATCH 106/170] Auto-update dependencies. (#206) * Auto-update dependencies. * Auto-update dependencies. --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 2cc69598..81809b77 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index eb4175ca..7877457c 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.7.1/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.7.1/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.8.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.8.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From da7abdba24bff614c2c5ef0eb6ce836480d82dd5 Mon Sep 17 00:00:00 2001 From: Kevin Cheung Date: Tue, 27 Jul 2021 12:54:13 -0700 Subject: [PATCH 107/170] Add App Check non-Firebase resource snippets (#207) * Add App Check non-Firebase resource snippets * Pass lint * npm run snippet * more lint fixes * npm run snippets again --- appcheck-next/index.js | 37 +++++++++++++++++++ appcheck/index.js | 21 +++++++++++ .../index/appcheck_nonfirebase.js | 32 ++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 snippets/appcheck-next/index/appcheck_nonfirebase.js diff --git a/appcheck-next/index.js b/appcheck-next/index.js index 824cd3cb..b2faba28 100644 --- a/appcheck-next/index.js +++ b/appcheck-next/index.js @@ -63,3 +63,40 @@ function initializeCustomProvider() { }); // [END appcheck_initialize_custom_provider] } + +function nonFirebase() { + const { initializeApp } = require("firebase/app"); + const app = initializeApp({ + // Your firebase configuration object + }); + const { ReCaptchaV3Provider } = require('firebase/app-check'); + const provider = new ReCaptchaV3Provider(''); + + // [START appcheck_nonfirebase] + const { initializeAppCheck, getToken } = require('firebase/app-check'); + + const appCheck = initializeAppCheck( + app, + { provider: provider } // ReCaptchaV3Provider or CustomProvider + ); + + const callApiWithAppCheckExample = async () => { + let appCheckTokenResponse; + try { + appCheckTokenResponse = await getToken(appCheck, /* forceRefresh= */ false); + } catch (err) { + // Handle any errors if the token was not retrieved. + return; + } + + // Include the App Check token with requests to your server. + const apiResponse = await fetch('https://yourbackend.example.com/yourApiEndpoint', { + headers: { + 'X-Firebase-AppCheck': appCheckTokenResponse.token, + } + }); + + // Handle response from your backend. + }; + // [END appcheck_nonfirebase] +} diff --git a/appcheck/index.js b/appcheck/index.js index 04282f4d..6ad5079a 100644 --- a/appcheck/index.js +++ b/appcheck/index.js @@ -53,3 +53,24 @@ function initializeCustomProvider() { appCheck.activate(appCheckCustomProvider); // [END appcheck_initialize_custom_provider] } + +// [START appcheck_nonfirebase] +const callApiWithAppCheckExample = async () => { + let appCheckTokenResponse; + try { + appCheckTokenResponse = await firebase.appCheck().getToken(/* forceRefresh= */ false); + } catch (err) { + // Handle any errors if the token was not retrieved. + return; + } + + // Include the App Check token with requests to your server. + const apiResponse = await fetch('https://yourbackend.example.com/yourApiEndpoint', { + headers: { + 'X-Firebase-AppCheck': appCheckTokenResponse.token, + } + }); + + // Handle response from your backend. +}; +// [END appcheck_nonfirebase] diff --git a/snippets/appcheck-next/index/appcheck_nonfirebase.js b/snippets/appcheck-next/index/appcheck_nonfirebase.js new file mode 100644 index 00000000..e1d8dc87 --- /dev/null +++ b/snippets/appcheck-next/index/appcheck_nonfirebase.js @@ -0,0 +1,32 @@ +// This snippet file was generated by processing the source file: +// ./appcheck-next/index.js +// +// To make edits to the snippets in this file, please edit the source + +// [START appcheck_nonfirebase_modular] +import { initializeAppCheck, getToken } from 'firebase/app-check'; + +const appCheck = initializeAppCheck( + app, + { provider: provider } // ReCaptchaV3Provider or CustomProvider +); + +const callApiWithAppCheckExample = async () => { + let appCheckTokenResponse; + try { + appCheckTokenResponse = await getToken(appCheck, /* forceRefresh= */ false); + } catch (err) { + // Handle any errors if the token was not retrieved. + return; + } + + // Include the App Check token with requests to your server. + const apiResponse = await fetch('https://yourbackend.example.com/yourApiEndpoint', { + headers: { + 'X-Firebase-AppCheck': appCheckTokenResponse.token, + } + }); + + // Handle response from your backend. +}; +// [END appcheck_nonfirebase_modular] \ No newline at end of file From 74b104c98c9312132d690617fa17248212bc52ed Mon Sep 17 00:00:00 2001 From: Kevin Cheung Date: Wed, 28 Jul 2021 16:03:21 -0700 Subject: [PATCH 108/170] Show isTokenAutoRefreshEnabled in App Check (#208) * Show isTokenAutoRefreshEnabled in App Check * npm run snippets --- appcheck-next/index.js | 12 ++++++++++-- appcheck/index.js | 14 ++++++++++++-- .../appcheck-next/index/appcheck_initialize.js | 6 +++++- .../index/appcheck_initialize_custom_provider.js | 6 +++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/appcheck-next/index.js b/appcheck-next/index.js index b2faba28..f5598ebd 100644 --- a/appcheck-next/index.js +++ b/appcheck-next/index.js @@ -13,7 +13,11 @@ function initialize() { // Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this // key is the counterpart to the secret key you set in the Firebase console. const appCheck = initializeAppCheck(app, { - provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd') + provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd'), + + // Optional argument. If true, the SDK automatically refreshes App Check + // tokens as needed. + isTokenAutoRefreshEnabled: true }); // [END appcheck_initialize] } @@ -59,7 +63,11 @@ function initializeCustomProvider() { }); const appCheck = initializeAppCheck(app, { - provider: appCheckCustomProvider + provider: appCheckCustomProvider, + + // Optional argument. If true, the SDK automatically refreshes App Check + // tokens as needed. + isTokenAutoRefreshEnabled: true }); // [END appcheck_initialize_custom_provider] } diff --git a/appcheck/index.js b/appcheck/index.js index 6ad5079a..3721b16c 100644 --- a/appcheck/index.js +++ b/appcheck/index.js @@ -10,7 +10,12 @@ function initialize() { const appCheck = firebase.appCheck(); // Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this // key is the counterpart to the secret key you set in the Firebase console. - appCheck.activate('abcdefghijklmnopqrstuvwxy-1234567890abcd'); + appCheck.activate( + 'abcdefghijklmnopqrstuvwxy-1234567890abcd', + + // Optional argument. If true, the SDK automatically refreshes App Check + // tokens as needed. + true); // [END appcheck_initialize] } @@ -50,7 +55,12 @@ function initializeCustomProvider() { }); const appCheck = firebase.appCheck(); - appCheck.activate(appCheckCustomProvider); + appCheck.activate( + appCheckCustomProvider, + + // Optional argument. If true, the SDK automatically refreshes App Check + // tokens as needed. + true); // [END appcheck_initialize_custom_provider] } diff --git a/snippets/appcheck-next/index/appcheck_initialize.js b/snippets/appcheck-next/index/appcheck_initialize.js index 7aa91572..54074768 100644 --- a/snippets/appcheck-next/index/appcheck_initialize.js +++ b/snippets/appcheck-next/index/appcheck_initialize.js @@ -14,6 +14,10 @@ const app = initializeApp({ // Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this // key is the counterpart to the secret key you set in the Firebase console. const appCheck = initializeAppCheck(app, { - provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd') + provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd'), + + // Optional argument. If true, the SDK automatically refreshes App Check + // tokens as needed. + isTokenAutoRefreshEnabled: true }); // [END appcheck_initialize_modular] \ No newline at end of file diff --git a/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js b/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js index ef721941..787e13a0 100644 --- a/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js +++ b/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js @@ -12,6 +12,10 @@ const app = initializeApp({ }); const appCheck = initializeAppCheck(app, { - provider: appCheckCustomProvider + provider: appCheckCustomProvider, + + // Optional argument. If true, the SDK automatically refreshes App Check + // tokens as needed. + isTokenAutoRefreshEnabled: true }); // [END appcheck_initialize_custom_provider_modular] \ No newline at end of file From ae2d5c7ba741f18f3f213b269cac36424be4eb6d Mon Sep 17 00:00:00 2001 From: Kevin Cheung Date: Thu, 29 Jul 2021 01:29:42 -0700 Subject: [PATCH 109/170] Say how to generate separated snippets (#210) --- scripts/separate-snippets.ts | 3 ++- .../analytics-next/ecommerce/analytics_ecommerce_add_cart.js | 3 ++- .../analytics-next/ecommerce/analytics_ecommerce_checkout.js | 3 ++- snippets/analytics-next/ecommerce/analytics_ecommerce_items.js | 3 ++- .../ecommerce/analytics_ecommerce_payment_info.js | 3 ++- .../analytics-next/ecommerce/analytics_ecommerce_promotions.js | 3 ++- .../analytics-next/ecommerce/analytics_ecommerce_purchase.js | 3 ++- .../analytics-next/ecommerce/analytics_ecommerce_refund.js | 3 ++- .../ecommerce/analytics_ecommerce_remove_cart.js | 3 ++- .../ecommerce/analytics_ecommerce_select_item.js | 3 ++- .../ecommerce/analytics_ecommerce_shipping_info.js | 3 ++- .../analytics-next/ecommerce/analytics_ecommerce_view_cart.js | 3 ++- .../ecommerce/analytics_ecommerce_view_item_details.js | 3 ++- .../ecommerce/analytics_ecommerce_view_item_list.js | 3 ++- snippets/analytics-next/index/analytics_initialize.js | 3 ++- snippets/analytics-next/index/analytics_log_event.js | 3 ++- .../analytics-next/index/analytics_log_event_custom_params.js | 3 ++- snippets/analytics-next/index/analytics_log_event_params.js | 3 ++- snippets/analytics-next/index/analytics_set_user_properties.js | 3 ++- snippets/appcheck-next/index/appcheck_custom_provider.js | 3 ++- snippets/appcheck-next/index/appcheck_initialize.js | 3 ++- .../appcheck-next/index/appcheck_initialize_custom_provider.js | 3 ++- snippets/appcheck-next/index/appcheck_nonfirebase.js | 3 ++- snippets/auth-next/anonymous/auth_anon_sign_in.js | 3 ++- snippets/auth-next/apple/auth_apple_link_facebook.js | 3 ++- snippets/auth-next/apple/auth_apple_nonce_node.js | 3 ++- snippets/auth-next/apple/auth_apple_provider_create.js | 3 ++- snippets/auth-next/apple/auth_apple_provider_params.js | 3 ++- snippets/auth-next/apple/auth_apple_provider_scopes.js | 3 ++- snippets/auth-next/apple/auth_apple_reauthenticate_popup.js | 3 ++- snippets/auth-next/apple/auth_apple_signin_nonce.js | 3 ++- snippets/auth-next/apple/auth_apple_signin_popup.js | 3 ++- snippets/auth-next/apple/auth_apple_signin_redirect.js | 3 ++- snippets/auth-next/apple/auth_apple_signin_redirect_result.js | 3 ++- .../auth-state-persistence/auth_set_persistence_none.js | 3 ++- .../auth-state-persistence/auth_set_persistence_session.js | 3 ++- snippets/auth-next/cordova/auth_cordova_redirect_result.js | 3 ++- snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js | 3 ++- snippets/auth-next/cordova/auth_create_google_provider.js | 3 ++- .../custom-email-handler/auth_handle_mgmt_query_params.js | 3 ++- .../custom-email-handler/auth_handle_recover_email.js | 3 ++- .../custom-email-handler/auth_handle_reset_password.js | 3 ++- .../auth-next/custom-email-handler/auth_handle_verify_email.js | 3 ++- snippets/auth-next/custom/auth_sign_in_custom.js | 3 ++- .../email-link-auth/auth_email_link_actioncode_settings.js | 3 ++- snippets/auth-next/email-link-auth/auth_email_link_link.js | 3 ++- snippets/auth-next/email-link-auth/auth_email_link_reauth.js | 3 ++- snippets/auth-next/email-link-auth/auth_email_link_send.js | 3 ++- snippets/auth-next/email-link-auth/email_link_complete.js | 3 ++- snippets/auth-next/email-link-auth/email_link_diferentiate.js | 3 ++- snippets/auth-next/email/auth_send_email_verification.js | 3 ++- snippets/auth-next/email/auth_send_password_reset.js | 3 ++- snippets/auth-next/email/auth_signin_password.js | 3 ++- snippets/auth-next/email/auth_signup_password.js | 3 ++- snippets/auth-next/emulator-suite/auth_emulator_connect.js | 3 ++- snippets/auth-next/facebook/auth_facebook_callback.js | 3 ++- snippets/auth-next/facebook/auth_facebook_checksameuser.js | 3 ++- snippets/auth-next/facebook/auth_facebook_provider_create.js | 3 ++- snippets/auth-next/facebook/auth_facebook_provider_params.js | 3 ++- snippets/auth-next/facebook/auth_facebook_provider_scopes.js | 3 ++- snippets/auth-next/facebook/auth_facebook_signin_credential.js | 3 ++- snippets/auth-next/facebook/auth_facebook_signin_popup.js | 3 ++- .../auth-next/facebook/auth_facebook_signin_redirect_result.js | 3 ++- snippets/auth-next/github/auth_github_provider_create.js | 3 ++- snippets/auth-next/github/auth_github_provider_credential.js | 3 ++- snippets/auth-next/github/auth_github_provider_params.js | 3 ++- snippets/auth-next/github/auth_github_provider_scopes.js | 3 ++- snippets/auth-next/github/auth_github_signin_popup.js | 3 ++- .../auth-next/github/auth_github_signin_redirect_result.js | 3 ++- snippets/auth-next/google-signin/auth_google_build_signin.js | 3 ++- snippets/auth-next/google-signin/auth_google_callback.js | 3 ++- snippets/auth-next/google-signin/auth_google_checksameuser.js | 3 ++- .../auth-next/google-signin/auth_google_provider_create.js | 3 ++- .../auth-next/google-signin/auth_google_provider_params.js | 3 ++- .../auth-next/google-signin/auth_google_provider_scopes.js | 3 ++- .../auth-next/google-signin/auth_google_signin_credential.js | 3 ++- snippets/auth-next/google-signin/auth_google_signin_popup.js | 3 ++- .../google-signin/auth_google_signin_redirect_result.js | 3 ++- snippets/auth-next/index/auth_current_user.js | 3 ++- snippets/auth-next/index/auth_make_email_credential.js | 3 ++- snippets/auth-next/index/auth_make_facebook_credential.js | 3 ++- snippets/auth-next/index/auth_make_google_credential.js | 3 ++- snippets/auth-next/index/auth_set_language_code.js | 3 ++- snippets/auth-next/index/auth_sign_out.js | 3 ++- snippets/auth-next/index/auth_signin_credential.js | 3 ++- snippets/auth-next/index/auth_signin_redirect.js | 3 ++- snippets/auth-next/index/auth_state_listener.js | 3 ++- .../auth-next/link-multiple-accounts/auth_anonymous_link.js | 3 ++- .../auth-next/link-multiple-accounts/auth_get_providers.js | 3 ++- .../link-multiple-accounts/auth_get_redirect_result.js | 3 ++- .../auth-next/link-multiple-accounts/auth_link_with_popup.js | 3 ++- .../link-multiple-accounts/auth_link_with_redirect.js | 3 ++- .../link-multiple-accounts/auth_make_email_credential.js | 3 ++- .../auth-next/link-multiple-accounts/auth_merge_accounts.js | 3 ++- snippets/auth-next/link-multiple-accounts/auth_simple_link.js | 3 ++- .../auth-next/link-multiple-accounts/auth_unlink_provider.js | 3 ++- snippets/auth-next/manage/auth_delete_user.js | 3 ++- snippets/auth-next/manage/auth_get_user_profile.js | 3 ++- snippets/auth-next/manage/auth_get_user_profile_provider.js | 3 ++- snippets/auth-next/manage/auth_reauth_with_credential.js | 3 ++- snippets/auth-next/manage/auth_send_password_reset.js | 3 ++- snippets/auth-next/manage/auth_update_password.js | 3 ++- snippets/auth-next/manage/auth_update_user_email.js | 3 ++- snippets/auth-next/manage/auth_update_user_profile.js | 3 ++- snippets/auth-next/manage/send_email_verification.js | 3 ++- .../auth-next/microsoft-oauth/auth_msft_create_provider.js | 3 ++- snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js | 3 ++- .../auth-next/microsoft-oauth/auth_msft_provider_params.js | 3 ++- .../microsoft-oauth/auth_msft_provider_params_tenant.js | 3 ++- .../auth-next/microsoft-oauth/auth_msft_provider_scopes.js | 3 ++- snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js | 3 ++- snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js | 3 ++- .../auth-next/microsoft-oauth/auth_msft_signin_redirect.js | 3 ++- .../microsoft-oauth/auth_msft_signin_redirect_result.js | 3 ++- snippets/auth-next/phone-auth/auth_get_recaptcha_response.js | 3 ++- snippets/auth-next/phone-auth/auth_phone_recaptcha_render.js | 3 ++- .../phone-auth/auth_phone_recaptcha_verifier_invisible.js | 3 ++- .../phone-auth/auth_phone_recaptcha_verifier_simple.js | 3 ++- .../phone-auth/auth_phone_recaptcha_verifier_visible.js | 3 ++- snippets/auth-next/phone-auth/auth_phone_signin.js | 3 ++- snippets/auth-next/phone-auth/auth_phone_verify_code.js | 3 ++- .../auth-next/service-worker-sessions/auth_svc_get_idtoken.js | 3 ++- .../auth-next/service-worker-sessions/auth_svc_intercept.js | 3 ++- .../service-worker-sessions/auth_svc_listen_activate.js | 3 ++- .../auth-next/service-worker-sessions/auth_svc_register.js | 3 ++- .../service-worker-sessions/auth_svc_sign_in_email.js | 3 ++- .../auth-next/service-worker-sessions/auth_svc_subscribe.js | 3 ++- snippets/auth-next/twitter/auth_twitter_provider_create.js | 3 ++- snippets/auth-next/twitter/auth_twitter_provider_params.js | 3 ++- snippets/auth-next/twitter/auth_twitter_signin_popup.js | 3 ++- .../auth-next/twitter/auth_twitter_signin_redirect_result.js | 3 ++- snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js | 3 ++- snippets/auth-next/yahoo-oauth/auth_yahoo_provider_create.js | 3 ++- snippets/auth-next/yahoo-oauth/auth_yahoo_provider_params.js | 3 ++- snippets/auth-next/yahoo-oauth/auth_yahoo_provider_scopes.js | 3 ++- snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js | 3 ++- snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js | 3 ++- snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js | 3 ++- .../auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js | 3 ++- snippets/database-next/emulator-suite/rtdb_emulator_connect.js | 3 ++- snippets/database-next/emulator-suite/rtdb_emulator_flush.js | 3 ++- snippets/database-next/index/rtdb_get_reference.js | 3 ++- .../database-next/lists-of-data/rtdb_social_listen_children.js | 3 ++- .../database-next/lists-of-data/rtdb_social_listen_value.js | 3 ++- .../database-next/lists-of-data/rtdb_social_most_starred.js | 3 ++- .../database-next/lists-of-data/rtdb_social_most_viewed.js | 3 ++- snippets/database-next/lists-of-data/rtdb_social_push.js | 3 ++- snippets/database-next/lists-of-data/rtdb_social_recent.js | 3 ++- snippets/database-next/offline/rtdb_detect_connection_state.js | 3 ++- snippets/database-next/offline/rtdb_estimate_clock_skew.js | 3 ++- snippets/database-next/offline/rtdb_ondisconnect_callback.js | 3 ++- snippets/database-next/offline/rtdb_ondisconnect_cancel.js | 3 ++- snippets/database-next/offline/rtdb_ondisconnect_simple.js | 3 ++- snippets/database-next/offline/rtdb_sample_presence_app.js | 3 ++- snippets/database-next/offline/rtdb_set_server_timestamp.js | 3 ++- snippets/database-next/read-and-write/rtdb_read_once_get.js | 3 ++- .../read-and-write/rtdb_social_completion_callback.js | 3 ++- .../read-and-write/rtdb_social_listen_star_count.js | 3 ++- .../read-and-write/rtdb_social_single_value_read.js | 3 ++- .../database-next/read-and-write/rtdb_social_star_increment.js | 3 ++- .../read-and-write/rtdb_social_star_transaction.js | 3 ++- .../database-next/read-and-write/rtdb_social_write_fan_out.js | 3 ++- snippets/database-next/read-and-write/rtdb_write_new_user.js | 3 ++- .../read-and-write/rtdb_write_new_user_completion.js | 3 ++- snippets/database-next/sharding/rtdb_multiple_instances.js | 3 ++- snippets/firebaseapp-next/firebaseapp/firebase_options.js | 3 ++- snippets/firebaseapp-next/firebaseapp/firebase_secondary.js | 3 ++- snippets/firestore-next/emulator-suite/fs_emulator_connect.js | 3 ++- snippets/firestore-next/test-firestore/add_ada_lovelace.js | 3 ++- snippets/firestore-next/test-firestore/add_alan_turing.js | 3 ++- snippets/firestore-next/test-firestore/add_document.js | 3 ++- .../firestore-next/test-firestore/add_rating_transaction.js | 3 ++- .../firestore-next/test-firestore/array_contains_any_filter.js | 3 ++- .../firestore-next/test-firestore/array_contains_filter.js | 3 ++- snippets/firestore-next/test-firestore/chain_filters.js | 3 ++- snippets/firestore-next/test-firestore/cities_document_set.js | 3 ++- snippets/firestore-next/test-firestore/city_custom_object.js | 3 ++- snippets/firestore-next/test-firestore/collection_reference.js | 3 ++- snippets/firestore-next/test-firestore/data_types.js | 3 ++- snippets/firestore-next/test-firestore/delete_collection.js | 3 ++- snippets/firestore-next/test-firestore/delete_document.js | 3 ++- snippets/firestore-next/test-firestore/detach_listener.js | 3 ++- snippets/firestore-next/test-firestore/disable_network.js | 3 ++- snippets/firestore-next/test-firestore/doc_reference.js | 3 ++- .../firestore-next/test-firestore/doc_reference_alternative.js | 3 ++- snippets/firestore-next/test-firestore/enable_network.js | 3 ++- snippets/firestore-next/test-firestore/example_data.js | 3 ++- snippets/firestore-next/test-firestore/example_filters.js | 3 ++- snippets/firestore-next/test-firestore/filter_and_order.js | 3 ++- .../firestore-next/test-firestore/fs_collection_group_query.js | 3 ++- .../test-firestore/fs_collection_group_query_data_setup.js | 3 ++- snippets/firestore-next/test-firestore/fs_setup_cache.js | 3 ++- snippets/firestore-next/test-firestore/get_all_users.js | 3 ++- snippets/firestore-next/test-firestore/get_custom_object.js | 3 ++- snippets/firestore-next/test-firestore/get_document.js | 3 ++- snippets/firestore-next/test-firestore/get_document_options.js | 3 ++- snippets/firestore-next/test-firestore/get_multiple.js | 3 ++- snippets/firestore-next/test-firestore/get_multiple_all.js | 3 ++- snippets/firestore-next/test-firestore/handle_listen_errors.js | 3 ++- snippets/firestore-next/test-firestore/in_filter.js | 3 ++- snippets/firestore-next/test-firestore/in_filter_with_array.js | 3 ++- .../firestore-next/test-firestore/initialize_persistence.js | 3 ++- .../firestore-next/test-firestore/invalid_filter_and_order.js | 3 ++- .../firestore-next/test-firestore/invalid_range_filters.js | 3 ++- snippets/firestore-next/test-firestore/listen_diffs.js | 3 ++- snippets/firestore-next/test-firestore/listen_document.js | 3 ++- .../firestore-next/test-firestore/listen_document_local.js | 3 ++- snippets/firestore-next/test-firestore/listen_for_users.js | 3 ++- snippets/firestore-next/test-firestore/listen_multiple.js | 3 ++- snippets/firestore-next/test-firestore/listen_with_metadata.js | 3 ++- snippets/firestore-next/test-firestore/new_document.js | 3 ++- snippets/firestore-next/test-firestore/not_in_filter.js | 3 ++- snippets/firestore-next/test-firestore/order_and_end.js | 3 ++- snippets/firestore-next/test-firestore/order_and_limit.js | 3 ++- snippets/firestore-next/test-firestore/order_and_limit_desc.js | 3 ++- snippets/firestore-next/test-firestore/order_and_start.js | 3 ++- snippets/firestore-next/test-firestore/order_multiple.js | 3 ++- snippets/firestore-next/test-firestore/paginate.js | 3 ++- .../test-firestore/server_timestamp_resolution_options.js | 3 ++- snippets/firestore-next/test-firestore/set_custom_object.js | 3 ++- snippets/firestore-next/test-firestore/set_document.js | 3 ++- snippets/firestore-next/test-firestore/set_with_merge.js | 3 ++- snippets/firestore-next/test-firestore/simple_queries.js | 3 ++- snippets/firestore-next/test-firestore/simple_queries_again.js | 3 ++- .../firestore-next/test-firestore/simple_query_not_equal.js | 3 ++- snippets/firestore-next/test-firestore/start_doc.js | 3 ++- .../firestore-next/test-firestore/start_multiple_orderby.js | 3 ++- .../firestore-next/test-firestore/subcollection_reference.js | 3 ++- snippets/firestore-next/test-firestore/transaction.js | 3 ++- snippets/firestore-next/test-firestore/transaction_promise.js | 3 ++- snippets/firestore-next/test-firestore/update_delete_field.js | 3 ++- snippets/firestore-next/test-firestore/update_document.js | 3 ++- .../firestore-next/test-firestore/update_document_array.js | 3 ++- .../firestore-next/test-firestore/update_document_increment.js | 3 ++- .../firestore-next/test-firestore/update_document_nested.js | 3 ++- .../test-firestore/update_with_server_timestamp.js | 3 ++- snippets/firestore-next/test-firestore/use_from_cache.js | 3 ++- .../firestore-next/test-firestore/valid_filter_and_order.js | 3 ++- snippets/firestore-next/test-firestore/valid_range_filters.js | 3 ++- snippets/firestore-next/test-firestore/write_batch.js | 3 ++- .../test-solution-aggregation/get_collection_ratings.js | 3 ++- .../firestore-next/test-solution-aggregation/sample_doc.js | 3 ++- .../firestore-next/test-solution-arrays/post_with_array.js | 3 ++- snippets/firestore-next/test-solution-arrays/post_with_map.js | 3 ++- .../test-solution-arrays/post_with_map_advanced.js | 3 ++- .../firestore-next/test-solution-arrays/query_in_category.js | 3 ++- .../test-solution-arrays/query_in_category_timestamp.js | 3 ++- .../query_in_category_timestamp_invalid.js | 3 ++- .../firestore-next/test-solution-bundles/fs_bundle_load.js | 3 ++- .../firestore-next/test-solution-counters/create_counter.js | 3 ++- snippets/firestore-next/test-solution-counters/get_count.js | 3 ++- .../firestore-next/test-solution-counters/increment_counter.js | 3 ++- .../firestore-next/test-solution-geoqueries/fs_geo_add_hash.js | 3 ++- .../test-solution-geoqueries/fs_geo_query_hashes.js | 3 ++- .../functions-next/callable/fb_functions_call_add_message.js | 3 ++- .../callable/fb_functions_call_add_message_error.js | 3 ++- snippets/functions-next/callable/fb_functions_initialize.js | 3 ++- .../emulator-suite/fb_functions_callable_call.js | 3 ++- .../emulator-suite/fb_functions_emulator_connect.js | 3 ++- snippets/messaging-next/index/messaging_delete_token.js | 3 ++- .../messaging-next/index/messaging_get_messaging_object.js | 3 ++- snippets/messaging-next/index/messaging_get_token.js | 3 ++- snippets/messaging-next/index/messaging_receive_message.js | 3 ++- snippets/messaging-next/index/messaging_request_permission.js | 3 ++- snippets/messaging-next/service-worker/messaging_init_in_sw.js | 3 ++- .../service-worker/messaging_on_background_message.js | 3 ++- snippets/perf-next/index/perf_add_custom_attributes.js | 3 ++- snippets/perf-next/index/perf_add_custom_metrics.js | 3 ++- snippets/perf-next/index/perf_add_custom_trace.js | 3 ++- snippets/perf-next/index/perf_get_instance.js | 3 ++- snippets/perf-next/index/perf_initialize.js | 3 ++- snippets/perf-next/index/perf_user_timing_marks.js | 3 ++- snippets/placeholder/coming_soon.js | 3 ++- snippets/remoteconfig-next/index/rc_fetch_config_callback.js | 3 ++- snippets/remoteconfig-next/index/rc_get_instance.js | 3 ++- snippets/remoteconfig-next/index/rc_get_values.js | 3 ++- snippets/remoteconfig-next/index/rc_set_default_values.js | 3 ++- snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js | 3 ++- snippets/storage-next/create-reference/storage_create_ref.js | 3 ++- .../storage-next/create-reference/storage_create_ref_child.js | 3 ++- snippets/storage-next/create-reference/storage_navigate_ref.js | 3 ++- .../create-reference/storage_navigate_ref_chain.js | 3 ++- .../storage-next/create-reference/storage_ref_full_example.js | 3 ++- .../storage-next/create-reference/storage_ref_properties.js | 3 ++- snippets/storage-next/delete-files/storage_delete_file.js | 3 ++- .../storage-next/download-files/storage_download_create_ref.js | 3 ++- .../download-files/storage_download_full_example.js | 3 ++- .../storage-next/download-files/storage_download_via_url.js | 3 ++- snippets/storage-next/file-metadata/storage_custom_metadata.js | 3 ++- snippets/storage-next/file-metadata/storage_delete_metadata.js | 3 ++- snippets/storage-next/file-metadata/storage_get_metadata.js | 3 ++- snippets/storage-next/file-metadata/storage_update_metadata.js | 3 ++- snippets/storage-next/index/storage_custom_app.js | 3 ++- snippets/storage-next/index/storage_initialize.js | 3 ++- snippets/storage-next/index/storage_multiple_buckets.js | 3 ++- snippets/storage-next/index/storage_on_complete.js | 3 ++- snippets/storage-next/list-files/storage_list_all.js | 3 ++- snippets/storage-next/list-files/storage_list_paginate.js | 3 ++- snippets/storage-next/upload-files/storage_manage_uploads.js | 3 ++- snippets/storage-next/upload-files/storage_monitor_upload.js | 3 ++- snippets/storage-next/upload-files/storage_upload_blob.js | 3 ++- snippets/storage-next/upload-files/storage_upload_bytes.js | 3 ++- .../storage-next/upload-files/storage_upload_handle_error.js | 3 ++- snippets/storage-next/upload-files/storage_upload_metadata.js | 3 ++- snippets/storage-next/upload-files/storage_upload_ref.js | 3 ++- snippets/storage-next/upload-files/storage_upload_string.js | 3 ++- 306 files changed, 612 insertions(+), 306 deletions(-) diff --git a/scripts/separate-snippets.ts b/scripts/separate-snippets.ts index dbc89c52..86821383 100644 --- a/scripts/separate-snippets.ts +++ b/scripts/separate-snippets.ts @@ -125,7 +125,8 @@ function processSnippet( `// This snippet file was generated by processing the source file:`, `// ${sourceFile}`, `//`, - `// To make edits to the snippets in this file, please edit the source`, + `// To update the snippets in this file, edit the source and then run`, + `// 'npm run snippets'.`, ``, ]; const content = [...preambleLines, ...outputLines].join("\n"); diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js index 8d7f87cf..8f0e68bd 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_add_cart.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_add_cart_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js index 85611fb1..beaae722 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_checkout.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_checkout_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_items.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_items.js index e3ad7cbe..03b27b47 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_items.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_items.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_items_modular] // A pair of jeggings diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js index db328513..048ad5da 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_payment_info.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_payment_info_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js index 666241ee..d0577a18 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_promotions.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_promotions_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js index a5ba8c62..12b6d02d 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_purchase.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_purchase_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js index fab84487..706e1d7d 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_refund.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_refund_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js index aa841d8f..1ad9790f 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_remove_cart.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_remove_cart_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js index 74f3c8c2..d4eda55c 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_select_item.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_select_item_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js index 09cd0f05..a4f43cbe 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_shipping_info.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_shipping_info_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js index 89ab04ec..cc2359dc 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_cart.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_view_cart_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js index 920e2c18..83f3474e 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_details.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_view_item_details_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js index 13eb197c..fb2fec01 100644 --- a/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js +++ b/snippets/analytics-next/ecommerce/analytics_ecommerce_view_item_list.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/ecommerce.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_ecommerce_view_item_list_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/index/analytics_initialize.js b/snippets/analytics-next/index/analytics_initialize.js index 4fb42cb3..42a9578d 100644 --- a/snippets/analytics-next/index/analytics_initialize.js +++ b/snippets/analytics-next/index/analytics_initialize.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_initialize_modular] import { getAnalytics } from "firebase/analytics"; diff --git a/snippets/analytics-next/index/analytics_log_event.js b/snippets/analytics-next/index/analytics_log_event.js index c5537b5b..7bd74243 100644 --- a/snippets/analytics-next/index/analytics_log_event.js +++ b/snippets/analytics-next/index/analytics_log_event.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_log_event_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/index/analytics_log_event_custom_params.js b/snippets/analytics-next/index/analytics_log_event_custom_params.js index 122d94d1..7d76b3f5 100644 --- a/snippets/analytics-next/index/analytics_log_event_custom_params.js +++ b/snippets/analytics-next/index/analytics_log_event_custom_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_log_event_custom_params_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/index/analytics_log_event_params.js b/snippets/analytics-next/index/analytics_log_event_params.js index 86831dbd..27e6528d 100644 --- a/snippets/analytics-next/index/analytics_log_event_params.js +++ b/snippets/analytics-next/index/analytics_log_event_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_log_event_params_modular] import { getAnalytics, logEvent } from "firebase/analytics"; diff --git a/snippets/analytics-next/index/analytics_set_user_properties.js b/snippets/analytics-next/index/analytics_set_user_properties.js index b064cdbf..f432e5bf 100644 --- a/snippets/analytics-next/index/analytics_set_user_properties.js +++ b/snippets/analytics-next/index/analytics_set_user_properties.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./analytics-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START analytics_set_user_properties_modular] import { getAnalytics, setUserProperties } from "firebase/analytics"; diff --git a/snippets/appcheck-next/index/appcheck_custom_provider.js b/snippets/appcheck-next/index/appcheck_custom_provider.js index 7bcb0452..35c7bc99 100644 --- a/snippets/appcheck-next/index/appcheck_custom_provider.js +++ b/snippets/appcheck-next/index/appcheck_custom_provider.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./appcheck-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START appcheck_custom_provider_modular] import { CustomProvider } from "firebase/app-check"; diff --git a/snippets/appcheck-next/index/appcheck_initialize.js b/snippets/appcheck-next/index/appcheck_initialize.js index 54074768..f7763562 100644 --- a/snippets/appcheck-next/index/appcheck_initialize.js +++ b/snippets/appcheck-next/index/appcheck_initialize.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./appcheck-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START appcheck_initialize_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js b/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js index 787e13a0..03f2baa8 100644 --- a/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js +++ b/snippets/appcheck-next/index/appcheck_initialize_custom_provider.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./appcheck-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START appcheck_initialize_custom_provider_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/appcheck-next/index/appcheck_nonfirebase.js b/snippets/appcheck-next/index/appcheck_nonfirebase.js index e1d8dc87..275891f8 100644 --- a/snippets/appcheck-next/index/appcheck_nonfirebase.js +++ b/snippets/appcheck-next/index/appcheck_nonfirebase.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./appcheck-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START appcheck_nonfirebase_modular] import { initializeAppCheck, getToken } from 'firebase/app-check'; diff --git a/snippets/auth-next/anonymous/auth_anon_sign_in.js b/snippets/auth-next/anonymous/auth_anon_sign_in.js index b495ec28..3db81772 100644 --- a/snippets/auth-next/anonymous/auth_anon_sign_in.js +++ b/snippets/auth-next/anonymous/auth_anon_sign_in.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/anonymous.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_anon_sign_in_modular] import { getAuth, signInAnonymously } from "firebase/auth"; diff --git a/snippets/auth-next/apple/auth_apple_link_facebook.js b/snippets/auth-next/apple/auth_apple_link_facebook.js index a9f116ad..1ed9d764 100644 --- a/snippets/auth-next/apple/auth_apple_link_facebook.js +++ b/snippets/auth-next/apple/auth_apple_link_facebook.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_link_facebook_modular] import { getAuth, linkWithPopup, FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/apple/auth_apple_nonce_node.js b/snippets/auth-next/apple/auth_apple_nonce_node.js index 27b08552..26bb2ef0 100644 --- a/snippets/auth-next/apple/auth_apple_nonce_node.js +++ b/snippets/auth-next/apple/auth_apple_nonce_node.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_nonce_node_modular] const crypto = require("crypto"); diff --git a/snippets/auth-next/apple/auth_apple_provider_create.js b/snippets/auth-next/apple/auth_apple_provider_create.js index 9612b2c3..b6c0aefd 100644 --- a/snippets/auth-next/apple/auth_apple_provider_create.js +++ b/snippets/auth-next/apple/auth_apple_provider_create.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_provider_create_modular] import { OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/apple/auth_apple_provider_params.js b/snippets/auth-next/apple/auth_apple_provider_params.js index f0f914a2..775ab94b 100644 --- a/snippets/auth-next/apple/auth_apple_provider_params.js +++ b/snippets/auth-next/apple/auth_apple_provider_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_provider_params_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/apple/auth_apple_provider_scopes.js b/snippets/auth-next/apple/auth_apple_provider_scopes.js index 306853bd..86da8bbc 100644 --- a/snippets/auth-next/apple/auth_apple_provider_scopes.js +++ b/snippets/auth-next/apple/auth_apple_provider_scopes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_provider_scopes_modular] provider.addScope('email'); diff --git a/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js b/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js index 5d1b9257..129fe920 100644 --- a/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js +++ b/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_reauthenticate_popup_modular] import { getAuth, reauthenticateWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/apple/auth_apple_signin_nonce.js b/snippets/auth-next/apple/auth_apple_signin_nonce.js index 36962b8f..ffa3a3d2 100644 --- a/snippets/auth-next/apple/auth_apple_signin_nonce.js +++ b/snippets/auth-next/apple/auth_apple_signin_nonce.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_signin_nonce_modular] import { getAuth, signInWithCredential, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/apple/auth_apple_signin_popup.js b/snippets/auth-next/apple/auth_apple_signin_popup.js index 3fb9436c..2db09607 100644 --- a/snippets/auth-next/apple/auth_apple_signin_popup.js +++ b/snippets/auth-next/apple/auth_apple_signin_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_signin_popup_modular] import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/apple/auth_apple_signin_redirect.js b/snippets/auth-next/apple/auth_apple_signin_redirect.js index 9b97a683..f000195d 100644 --- a/snippets/auth-next/apple/auth_apple_signin_redirect.js +++ b/snippets/auth-next/apple/auth_apple_signin_redirect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; diff --git a/snippets/auth-next/apple/auth_apple_signin_redirect_result.js b/snippets/auth-next/apple/auth_apple_signin_redirect_result.js index f0b2d64c..68dba4ab 100644 --- a/snippets/auth-next/apple/auth_apple_signin_redirect_result.js +++ b/snippets/auth-next/apple/auth_apple_signin_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/apple.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_apple_signin_redirect_result_modular] import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js b/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js index 88b579f9..5224cc21 100644 --- a/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js +++ b/snippets/auth-next/auth-state-persistence/auth_set_persistence_none.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/auth-state-persistence.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_set_persistence_none_modular] import { getAuth, setPersistence, signInWithRedirect, inMemoryPersistence, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js b/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js index 6644370d..d21183ff 100644 --- a/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js +++ b/snippets/auth-next/auth-state-persistence/auth_set_persistence_session.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/auth-state-persistence.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_set_persistence_session_modular] import { getAuth, setPersistence, signInWithEmailAndPassword, browserSessionPersistence } from "firebase/auth"; diff --git a/snippets/auth-next/cordova/auth_cordova_redirect_result.js b/snippets/auth-next/cordova/auth_cordova_redirect_result.js index f4794507..7bcc69a3 100644 --- a/snippets/auth-next/cordova/auth_cordova_redirect_result.js +++ b/snippets/auth-next/cordova/auth_cordova_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/cordova.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_cordova_redirect_result_modular] import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js b/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js index 14084a12..5aaee22d 100644 --- a/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js +++ b/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/cordova.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_cordova_sign_in_redirect_modular] import { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/cordova/auth_create_google_provider.js b/snippets/auth-next/cordova/auth_create_google_provider.js index 7fb88bc9..aab60312 100644 --- a/snippets/auth-next/cordova/auth_create_google_provider.js +++ b/snippets/auth-next/cordova/auth_create_google_provider.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/cordova.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_create_google_provider_modular] import { GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js b/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js index 8810372f..6dec3399 100644 --- a/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js +++ b/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/custom-email-handler.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_handle_mgmt_query_params_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/auth-next/custom-email-handler/auth_handle_recover_email.js b/snippets/auth-next/custom-email-handler/auth_handle_recover_email.js index db2bdea8..a4351a50 100644 --- a/snippets/auth-next/custom-email-handler/auth_handle_recover_email.js +++ b/snippets/auth-next/custom-email-handler/auth_handle_recover_email.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/custom-email-handler.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_handle_recover_email_modular] import { checkActionCode, applyActionCode, sendPasswordResetEmail } from "firebase/auth"; diff --git a/snippets/auth-next/custom-email-handler/auth_handle_reset_password.js b/snippets/auth-next/custom-email-handler/auth_handle_reset_password.js index 85f32168..95a3faea 100644 --- a/snippets/auth-next/custom-email-handler/auth_handle_reset_password.js +++ b/snippets/auth-next/custom-email-handler/auth_handle_reset_password.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/custom-email-handler.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_handle_reset_password_modular] import { verifyPasswordResetCode, confirmPasswordReset } from "firebase/auth"; diff --git a/snippets/auth-next/custom-email-handler/auth_handle_verify_email.js b/snippets/auth-next/custom-email-handler/auth_handle_verify_email.js index ca0089f0..730d4601 100644 --- a/snippets/auth-next/custom-email-handler/auth_handle_verify_email.js +++ b/snippets/auth-next/custom-email-handler/auth_handle_verify_email.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/custom-email-handler.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_handle_verify_email_modular] function handleVerifyEmail(auth, actionCode, continueUrl, lang) { diff --git a/snippets/auth-next/custom/auth_sign_in_custom.js b/snippets/auth-next/custom/auth_sign_in_custom.js index 3500d6d9..c345c0ce 100644 --- a/snippets/auth-next/custom/auth_sign_in_custom.js +++ b/snippets/auth-next/custom/auth_sign_in_custom.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/custom.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_sign_in_custom_modular] import { getAuth, signInWithCustomToken } from "firebase/auth"; diff --git a/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js b/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js index dd6f4de2..a1480a11 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email-link-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_email_link_actioncode_settings_modular] const actionCodeSettings = { diff --git a/snippets/auth-next/email-link-auth/auth_email_link_link.js b/snippets/auth-next/email-link-auth/auth_email_link_link.js index 07abe3c8..a49b979f 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_link.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_link.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email-link-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_email_link_link_modular] import { getAuth, linkWithCredential, EmailAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/email-link-auth/auth_email_link_reauth.js b/snippets/auth-next/email-link-auth/auth_email_link_reauth.js index f6c57144..128650cb 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_reauth.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_reauth.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email-link-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_email_link_reauth_modular] import { getAuth, reauthenticateWithCredential, EmailAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/email-link-auth/auth_email_link_send.js b/snippets/auth-next/email-link-auth/auth_email_link_send.js index 8a3065c8..5b97d87f 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_send.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_send.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email-link-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_email_link_send_modular] import { getAuth, sendSignInLinkToEmail } from "firebase/auth"; diff --git a/snippets/auth-next/email-link-auth/email_link_complete.js b/snippets/auth-next/email-link-auth/email_link_complete.js index b0da2093..b42b9af9 100644 --- a/snippets/auth-next/email-link-auth/email_link_complete.js +++ b/snippets/auth-next/email-link-auth/email_link_complete.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email-link-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START email_link_complete_modular] import { getAuth, isSignInWithEmailLink, signInWithEmailLink } from "firebase/auth"; diff --git a/snippets/auth-next/email-link-auth/email_link_diferentiate.js b/snippets/auth-next/email-link-auth/email_link_diferentiate.js index cbbe0e57..4fc06b41 100644 --- a/snippets/auth-next/email-link-auth/email_link_diferentiate.js +++ b/snippets/auth-next/email-link-auth/email_link_diferentiate.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email-link-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START email_link_diferentiate_modular] import { getAuth, fetchSignInMethodsForEmail, EmailAuthProvider} from "firebase/auth"; diff --git a/snippets/auth-next/email/auth_send_email_verification.js b/snippets/auth-next/email/auth_send_email_verification.js index ef0c64b8..9290a421 100644 --- a/snippets/auth-next/email/auth_send_email_verification.js +++ b/snippets/auth-next/email/auth_send_email_verification.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_send_email_verification_modular] import { getAuth, sendEmailVerification } from "firebase/auth"; diff --git a/snippets/auth-next/email/auth_send_password_reset.js b/snippets/auth-next/email/auth_send_password_reset.js index 1b195344..e8e18a58 100644 --- a/snippets/auth-next/email/auth_send_password_reset.js +++ b/snippets/auth-next/email/auth_send_password_reset.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_send_password_reset_modular] import { getAuth, sendPasswordResetEmail } from "firebase/auth"; diff --git a/snippets/auth-next/email/auth_signin_password.js b/snippets/auth-next/email/auth_signin_password.js index 2652af74..f0a211d5 100644 --- a/snippets/auth-next/email/auth_signin_password.js +++ b/snippets/auth-next/email/auth_signin_password.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_signin_password_modular] import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; diff --git a/snippets/auth-next/email/auth_signup_password.js b/snippets/auth-next/email/auth_signup_password.js index 679bfbb0..00aa9bd5 100644 --- a/snippets/auth-next/email/auth_signup_password.js +++ b/snippets/auth-next/email/auth_signup_password.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/email.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_signup_password_modular] import { getAuth, createUserWithEmailAndPassword } from "firebase/auth"; diff --git a/snippets/auth-next/emulator-suite/auth_emulator_connect.js b/snippets/auth-next/emulator-suite/auth_emulator_connect.js index 7e4cf680..dd0b2e37 100644 --- a/snippets/auth-next/emulator-suite/auth_emulator_connect.js +++ b/snippets/auth-next/emulator-suite/auth_emulator_connect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/emulator-suite.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_emulator_connect_modular] import { getAuth, connectAuthEmulator } from "firebase/auth"; diff --git a/snippets/auth-next/facebook/auth_facebook_callback.js b/snippets/auth-next/facebook/auth_facebook_callback.js index 144928d8..8596bb68 100644 --- a/snippets/auth-next/facebook/auth_facebook_callback.js +++ b/snippets/auth-next/facebook/auth_facebook_callback.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_facebook_callback_modular] import { getAuth, onAuthStateChanged, signInWithCredential, signOut, FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/facebook/auth_facebook_checksameuser.js b/snippets/auth-next/facebook/auth_facebook_checksameuser.js index e4ed4845..0b1d170b 100644 --- a/snippets/auth-next/facebook/auth_facebook_checksameuser.js +++ b/snippets/auth-next/facebook/auth_facebook_checksameuser.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_facebook_checksameuser_modular] import { FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/facebook/auth_facebook_provider_create.js b/snippets/auth-next/facebook/auth_facebook_provider_create.js index 93913be7..403abcd2 100644 --- a/snippets/auth-next/facebook/auth_facebook_provider_create.js +++ b/snippets/auth-next/facebook/auth_facebook_provider_create.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_facebook_provider_create_modular] import { FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/facebook/auth_facebook_provider_params.js b/snippets/auth-next/facebook/auth_facebook_provider_params.js index 04c8532b..308fadd4 100644 --- a/snippets/auth-next/facebook/auth_facebook_provider_params.js +++ b/snippets/auth-next/facebook/auth_facebook_provider_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_facebook_provider_params_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/facebook/auth_facebook_provider_scopes.js b/snippets/auth-next/facebook/auth_facebook_provider_scopes.js index ba67a6f3..06386449 100644 --- a/snippets/auth-next/facebook/auth_facebook_provider_scopes.js +++ b/snippets/auth-next/facebook/auth_facebook_provider_scopes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // / [START auth_facebook_provider_scopes_modular] provider.addScope('user_birthday'); diff --git a/snippets/auth-next/facebook/auth_facebook_signin_credential.js b/snippets/auth-next/facebook/auth_facebook_signin_credential.js index 84ce9612..dcd42c7e 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_credential.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_facebook_signin_credential_modular] import { getAuth, signInWithCredential, FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/facebook/auth_facebook_signin_popup.js b/snippets/auth-next/facebook/auth_facebook_signin_popup.js index 164948a2..2bc014ed 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_popup.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_facebook_signin_popup_modular] import { getAuth, signInWithPopup, FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js index 9c2d5e30..49f3a494 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/facebook.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_facebook_signin_redirect_result_modular] import { getAuth, getRedirectResult, FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/github/auth_github_provider_create.js b/snippets/auth-next/github/auth_github_provider_create.js index eb5250d9..92cc4171 100644 --- a/snippets/auth-next/github/auth_github_provider_create.js +++ b/snippets/auth-next/github/auth_github_provider_create.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/github.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_github_provider_create_modular] import { GithubAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/github/auth_github_provider_credential.js b/snippets/auth-next/github/auth_github_provider_credential.js index ee159180..ca122a35 100644 --- a/snippets/auth-next/github/auth_github_provider_credential.js +++ b/snippets/auth-next/github/auth_github_provider_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/github.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_github_provider_credential_modular] import { GithubAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/github/auth_github_provider_params.js b/snippets/auth-next/github/auth_github_provider_params.js index 159dcd8c..e2d4f341 100644 --- a/snippets/auth-next/github/auth_github_provider_params.js +++ b/snippets/auth-next/github/auth_github_provider_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/github.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_github_provider_params_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/github/auth_github_provider_scopes.js b/snippets/auth-next/github/auth_github_provider_scopes.js index 09f26298..b9237208 100644 --- a/snippets/auth-next/github/auth_github_provider_scopes.js +++ b/snippets/auth-next/github/auth_github_provider_scopes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/github.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_github_provider_scopes_modular] provider.addScope('repo'); diff --git a/snippets/auth-next/github/auth_github_signin_popup.js b/snippets/auth-next/github/auth_github_signin_popup.js index 5b7a78b1..74e76cc9 100644 --- a/snippets/auth-next/github/auth_github_signin_popup.js +++ b/snippets/auth-next/github/auth_github_signin_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/github.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_github_signin_popup_modular] import { getAuth, signInWithPopup, GithubAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/github/auth_github_signin_redirect_result.js b/snippets/auth-next/github/auth_github_signin_redirect_result.js index 6884ed36..6147d9de 100644 --- a/snippets/auth-next/github/auth_github_signin_redirect_result.js +++ b/snippets/auth-next/github/auth_github_signin_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/github.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_github_signin_redirect_result_modular] import { getAuth, getRedirectResult, GithubAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/google-signin/auth_google_build_signin.js b/snippets/auth-next/google-signin/auth_google_build_signin.js index b6f4bbb9..6df84e3e 100644 --- a/snippets/auth-next/google-signin/auth_google_build_signin.js +++ b/snippets/auth-next/google-signin/auth_google_build_signin.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_build_signin_modular] import { getAuth, signInWithCredential, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/google-signin/auth_google_callback.js b/snippets/auth-next/google-signin/auth_google_callback.js index 2c23aa69..27aa8dc6 100644 --- a/snippets/auth-next/google-signin/auth_google_callback.js +++ b/snippets/auth-next/google-signin/auth_google_callback.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_callback_modular] import { getAuth, onAuthStateChanged, signInWithCredential, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/google-signin/auth_google_checksameuser.js b/snippets/auth-next/google-signin/auth_google_checksameuser.js index e2a7cad9..cc451991 100644 --- a/snippets/auth-next/google-signin/auth_google_checksameuser.js +++ b/snippets/auth-next/google-signin/auth_google_checksameuser.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_checksameuser_modular] import { GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/google-signin/auth_google_provider_create.js b/snippets/auth-next/google-signin/auth_google_provider_create.js index 6d696d21..76b356d6 100644 --- a/snippets/auth-next/google-signin/auth_google_provider_create.js +++ b/snippets/auth-next/google-signin/auth_google_provider_create.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_provider_create_modular] import { GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/google-signin/auth_google_provider_params.js b/snippets/auth-next/google-signin/auth_google_provider_params.js index 4799da72..25f1ea99 100644 --- a/snippets/auth-next/google-signin/auth_google_provider_params.js +++ b/snippets/auth-next/google-signin/auth_google_provider_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_provider_params_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/google-signin/auth_google_provider_scopes.js b/snippets/auth-next/google-signin/auth_google_provider_scopes.js index f370a854..346b6432 100644 --- a/snippets/auth-next/google-signin/auth_google_provider_scopes.js +++ b/snippets/auth-next/google-signin/auth_google_provider_scopes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_provider_scopes_modular] provider.addScope('https://www.googleapis.com/auth/contacts.readonly'); diff --git a/snippets/auth-next/google-signin/auth_google_signin_credential.js b/snippets/auth-next/google-signin/auth_google_signin_credential.js index 6c8a5641..a3a8808e 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_credential.js +++ b/snippets/auth-next/google-signin/auth_google_signin_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_signin_credential_modular] signInWithCredential(auth, credential).catch((error) => { diff --git a/snippets/auth-next/google-signin/auth_google_signin_popup.js b/snippets/auth-next/google-signin/auth_google_signin_popup.js index f74b800d..55c46488 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_popup.js +++ b/snippets/auth-next/google-signin/auth_google_signin_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_signin_popup_modular] import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js index 2e91c4c6..a64977bb 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js +++ b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/google-signin.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_google_signin_redirect_result_modular] import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_current_user.js b/snippets/auth-next/index/auth_current_user.js index 474f66bf..c094a464 100644 --- a/snippets/auth-next/index/auth_current_user.js +++ b/snippets/auth-next/index/auth_current_user.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_current_user_modular] import { getAuth } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_make_email_credential.js b/snippets/auth-next/index/auth_make_email_credential.js index 7009633b..6487fe62 100644 --- a/snippets/auth-next/index/auth_make_email_credential.js +++ b/snippets/auth-next/index/auth_make_email_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_make_email_credential_modular] import { EmailAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_make_facebook_credential.js b/snippets/auth-next/index/auth_make_facebook_credential.js index 7a68e3b7..91f5ae63 100644 --- a/snippets/auth-next/index/auth_make_facebook_credential.js +++ b/snippets/auth-next/index/auth_make_facebook_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_make_facebook_credential_modular] import { FacebookAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_make_google_credential.js b/snippets/auth-next/index/auth_make_google_credential.js index 007bb7eb..2640d101 100644 --- a/snippets/auth-next/index/auth_make_google_credential.js +++ b/snippets/auth-next/index/auth_make_google_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_make_google_credential_modular] import { GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_set_language_code.js b/snippets/auth-next/index/auth_set_language_code.js index 6d4126f9..47e78295 100644 --- a/snippets/auth-next/index/auth_set_language_code.js +++ b/snippets/auth-next/index/auth_set_language_code.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_set_language_code_modular] import { getAuth } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_sign_out.js b/snippets/auth-next/index/auth_sign_out.js index 7360528c..4cef4757 100644 --- a/snippets/auth-next/index/auth_sign_out.js +++ b/snippets/auth-next/index/auth_sign_out.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_sign_out_modular] import { getAuth, signOut } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_signin_credential.js b/snippets/auth-next/index/auth_signin_credential.js index eccad4e6..ba2db6b8 100644 --- a/snippets/auth-next/index/auth_signin_credential.js +++ b/snippets/auth-next/index/auth_signin_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_signin_credential_modular] import { getAuth, signInWithCredential } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_signin_redirect.js b/snippets/auth-next/index/auth_signin_redirect.js index f5187cb3..49c95513 100644 --- a/snippets/auth-next/index/auth_signin_redirect.js +++ b/snippets/auth-next/index/auth_signin_redirect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; diff --git a/snippets/auth-next/index/auth_state_listener.js b/snippets/auth-next/index/auth_state_listener.js index 4764642b..aebe6818 100644 --- a/snippets/auth-next/index/auth_state_listener.js +++ b/snippets/auth-next/index/auth_state_listener.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_state_listener_modular] import { getAuth, onAuthStateChanged } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js b/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js index fb3cc1a8..3bf9ab56 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js +++ b/snippets/auth-next/link-multiple-accounts/auth_anonymous_link.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_anonymous_link_modular] import { getAuth, linkWithCredential } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_get_providers.js b/snippets/auth-next/link-multiple-accounts/auth_get_providers.js index 2550bdd7..0f1ebbc1 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_get_providers.js +++ b/snippets/auth-next/link-multiple-accounts/auth_get_providers.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_get_providers_modular] import { GoogleAuthProvider, FacebookAuthProvider, TwitterAuthProvider, GithubAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_get_redirect_result.js b/snippets/auth-next/link-multiple-accounts/auth_get_redirect_result.js index 2118d9ba..1608a933 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_get_redirect_result.js +++ b/snippets/auth-next/link-multiple-accounts/auth_get_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_get_redirect_result_modular] import { getRedirectResult } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js b/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js index b531cbc6..b6619cad 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js +++ b/snippets/auth-next/link-multiple-accounts/auth_link_with_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_link_with_popup_modular] import { getAuth, linkWithPopup, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js b/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js index fc06ec47..1e496f42 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js +++ b/snippets/auth-next/link-multiple-accounts/auth_link_with_redirect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_link_with_redirect_modular] import { getAuth, linkWithRedirect, GoogleAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_make_email_credential.js b/snippets/auth-next/link-multiple-accounts/auth_make_email_credential.js index e78c54e1..861d77e8 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_make_email_credential.js +++ b/snippets/auth-next/link-multiple-accounts/auth_make_email_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_make_email_credential_modular] import { EmailAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js b/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js index 2525d20a..f7cc113c 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js +++ b/snippets/auth-next/link-multiple-accounts/auth_merge_accounts.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_merge_accounts_modular] import { getAuth, signInWithCredential, linkWithCredential, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_simple_link.js b/snippets/auth-next/link-multiple-accounts/auth_simple_link.js index ca360976..15c434a2 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_simple_link.js +++ b/snippets/auth-next/link-multiple-accounts/auth_simple_link.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_simple_link_modular] import { getAuth, linkWithCredential } from "firebase/auth"; diff --git a/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js b/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js index 7818cb06..46617b26 100644 --- a/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js +++ b/snippets/auth-next/link-multiple-accounts/auth_unlink_provider.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/link-multiple-accounts.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_unlink_provider_modular] import { getAuth, unlink } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_delete_user.js b/snippets/auth-next/manage/auth_delete_user.js index 8d725aa4..389a0852 100644 --- a/snippets/auth-next/manage/auth_delete_user.js +++ b/snippets/auth-next/manage/auth_delete_user.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_delete_user_modular] import { getAuth, deleteUser } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_get_user_profile.js b/snippets/auth-next/manage/auth_get_user_profile.js index 106104e8..9dce7fdc 100644 --- a/snippets/auth-next/manage/auth_get_user_profile.js +++ b/snippets/auth-next/manage/auth_get_user_profile.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_get_user_profile_modular] import { getAuth } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_get_user_profile_provider.js b/snippets/auth-next/manage/auth_get_user_profile_provider.js index 63e9654f..1d165d49 100644 --- a/snippets/auth-next/manage/auth_get_user_profile_provider.js +++ b/snippets/auth-next/manage/auth_get_user_profile_provider.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_get_user_profile_provider_modular] import { getAuth } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_reauth_with_credential.js b/snippets/auth-next/manage/auth_reauth_with_credential.js index 0b02de6c..74e84732 100644 --- a/snippets/auth-next/manage/auth_reauth_with_credential.js +++ b/snippets/auth-next/manage/auth_reauth_with_credential.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_reauth_with_credential_modular] import { getAuth, reauthenticateWithCredential } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_send_password_reset.js b/snippets/auth-next/manage/auth_send_password_reset.js index fa6118bb..9e8f2c3c 100644 --- a/snippets/auth-next/manage/auth_send_password_reset.js +++ b/snippets/auth-next/manage/auth_send_password_reset.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_send_password_reset_modular] import { getAuth, sendPasswordResetEmail } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_update_password.js b/snippets/auth-next/manage/auth_update_password.js index 69543928..56e578b9 100644 --- a/snippets/auth-next/manage/auth_update_password.js +++ b/snippets/auth-next/manage/auth_update_password.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_update_password_modular] import { getAuth, updatePassword } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_update_user_email.js b/snippets/auth-next/manage/auth_update_user_email.js index 8e313ece..d3607f75 100644 --- a/snippets/auth-next/manage/auth_update_user_email.js +++ b/snippets/auth-next/manage/auth_update_user_email.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_update_user_email_modular] import { getAuth, updateEmail } from "firebase/auth"; diff --git a/snippets/auth-next/manage/auth_update_user_profile.js b/snippets/auth-next/manage/auth_update_user_profile.js index 9449474e..2af9185a 100644 --- a/snippets/auth-next/manage/auth_update_user_profile.js +++ b/snippets/auth-next/manage/auth_update_user_profile.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_update_user_profile_modular] import { getAuth, updateProfile } from "firebase/auth"; diff --git a/snippets/auth-next/manage/send_email_verification.js b/snippets/auth-next/manage/send_email_verification.js index 82b0dcf9..34f06fdb 100644 --- a/snippets/auth-next/manage/send_email_verification.js +++ b/snippets/auth-next/manage/send_email_verification.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/manage.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START send_email_verification_modular] import { getAuth, sendEmailVerification } from "firebase/auth"; diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_create_provider.js b/snippets/auth-next/microsoft-oauth/auth_msft_create_provider.js index bbde8267..c0a9039c 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_create_provider.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_create_provider.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_create_provider_modular] import { OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js b/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js index 8e4da503..1a029c7e 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_link_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_link_popup_modular] import { getAuth, linkWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_provider_params.js b/snippets/auth-next/microsoft-oauth/auth_msft_provider_params.js index dea75ee7..007ae646 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_provider_params.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_provider_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_provider_params_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_provider_params_tenant.js b/snippets/auth-next/microsoft-oauth/auth_msft_provider_params_tenant.js index 82abfe9b..341ff1f1 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_provider_params_tenant.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_provider_params_tenant.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_provider_params_tenant_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_provider_scopes.js b/snippets/auth-next/microsoft-oauth/auth_msft_provider_scopes.js index 6c4d2fed..ad86ac6e 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_provider_scopes.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_provider_scopes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_provider_scopes_modular] provider.addScope('mail.read'); diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js b/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js index b257ec88..1d222fba 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_reauth_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_reauth_popup_modular] import { getAuth, reauthenticateWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js b/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js index 2b1fffa9..a19e598d 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_signin_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_signin_popup_modular] import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js index 7e04a832..c020dcf5 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; diff --git a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js index 3992a4d1..e1249de1 100644 --- a/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js +++ b/snippets/auth-next/microsoft-oauth/auth_msft_signin_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/microsoft-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_msft_signin_redirect_result_modular] import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/phone-auth/auth_get_recaptcha_response.js b/snippets/auth-next/phone-auth/auth_get_recaptcha_response.js index 83a31ed1..f19a93e6 100644 --- a/snippets/auth-next/phone-auth/auth_get_recaptcha_response.js +++ b/snippets/auth-next/phone-auth/auth_get_recaptcha_response.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/phone-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_get_recaptcha_response_modular] const recaptchaResponse = grecaptcha.getResponse(recaptchaWidgetId); diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_render.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_render.js index 0bbceb0d..27e9d8c9 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_render.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_render.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/phone-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_phone_recaptcha_render_modular] recaptchaVerifier.render().then((widgetId) => { diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js index 2ee43e7c..f6b6893f 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/phone-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_phone_recaptcha_verifier_invisible_modular] import { getAuth, RecaptchaVerifier } from "firebase/auth"; diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js index 5a318bce..ed56fe99 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/phone-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_phone_recaptcha_verifier_simple_modular] import { getAuth, RecaptchaVerifier } from "firebase/auth"; diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js index 4b987ee7..c91e6041 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/phone-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_phone_recaptcha_verifier_visible_modular] import { getAuth, RecaptchaVerifier } from "firebase/auth"; diff --git a/snippets/auth-next/phone-auth/auth_phone_signin.js b/snippets/auth-next/phone-auth/auth_phone_signin.js index a7a3f0af..31c3d248 100644 --- a/snippets/auth-next/phone-auth/auth_phone_signin.js +++ b/snippets/auth-next/phone-auth/auth_phone_signin.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/phone-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_phone_signin_modular] import { getAuth, signInWithPhoneNumber } from "firebase/auth"; diff --git a/snippets/auth-next/phone-auth/auth_phone_verify_code.js b/snippets/auth-next/phone-auth/auth_phone_verify_code.js index 51265141..299f8cf3 100644 --- a/snippets/auth-next/phone-auth/auth_phone_verify_code.js +++ b/snippets/auth-next/phone-auth/auth_phone_verify_code.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/phone-auth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_phone_verify_code_modular] const code = getCodeFromUserInput(); diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js b/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js index e3a61d07..dd78ada8 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_get_idtoken.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/service-worker-sessions.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_svc_get_idtoken_modular] import { getAuth, getIdToken } from "firebase/auth"; diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_intercept.js b/snippets/auth-next/service-worker-sessions/auth_svc_intercept.js index b14ccbed..419614ff 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_intercept.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_intercept.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/service-worker-sessions.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_svc_intercept_modular] const getOriginFromUrl = (url) => { diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_listen_activate.js b/snippets/auth-next/service-worker-sessions/auth_svc_listen_activate.js index a51cfedb..0337fc83 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_listen_activate.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_listen_activate.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/service-worker-sessions.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_svc_listen_activate_modular] self.addEventListener('activate', (event) => { diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_register.js b/snippets/auth-next/service-worker-sessions/auth_svc_register.js index 1b0b19c1..0cb36be3 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_register.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_register.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/service-worker-sessions.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_svc_register_modular] // Install servicerWorker if supported on sign-in/sign-up page. diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js b/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js index a7d6e30b..02e3a62a 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_sign_in_email.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/service-worker-sessions.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_svc_sign_in_email_modular] import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; diff --git a/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js b/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js index a3bb5c2a..76448570 100644 --- a/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js +++ b/snippets/auth-next/service-worker-sessions/auth_svc_subscribe.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/service-worker-sessions.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_svc_subscribe_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/auth-next/twitter/auth_twitter_provider_create.js b/snippets/auth-next/twitter/auth_twitter_provider_create.js index 496ae5f5..7fb82507 100644 --- a/snippets/auth-next/twitter/auth_twitter_provider_create.js +++ b/snippets/auth-next/twitter/auth_twitter_provider_create.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/twitter.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_twitter_provider_create_modular] import { TwitterAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/twitter/auth_twitter_provider_params.js b/snippets/auth-next/twitter/auth_twitter_provider_params.js index cb7c7a39..14d457f0 100644 --- a/snippets/auth-next/twitter/auth_twitter_provider_params.js +++ b/snippets/auth-next/twitter/auth_twitter_provider_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/twitter.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_twitter_provider_params_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/twitter/auth_twitter_signin_popup.js b/snippets/auth-next/twitter/auth_twitter_signin_popup.js index be2b7f57..a5fb5a95 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_popup.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/twitter.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_twitter_signin_popup_modular] import { getAuth, signInWithPopup, TwitterAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js index cfecf9cc..53b42c85 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/twitter.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_twitter_signin_redirect_result_modular] import { getAuth, getRedirectResult, TwitterAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js index 8f672f6b..1a921bce 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_link_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_link_popup_modular] import { getAuth, linkWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_create.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_create.js index c30a64f0..c26cd5fd 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_create.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_create.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_provider_create_modular] import { OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_params.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_params.js index 7bd28592..f8d918f9 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_params.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_params.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_provider_params_modular] provider.setCustomParameters({ diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_scopes.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_scopes.js index 24e059c8..8a02ff7b 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_scopes.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_provider_scopes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_provider_scopes_modular] // Request access to Yahoo Mail API. diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js index b35e162d..57243f05 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_reauth_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_reauth_popup_modular] import { getAuth, reauthenticateWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js index 8c8c2713..91c04abc 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_popup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_signin_popup_modular] import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth"; diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js index 5acb5687..f16cac73 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_signin_redirect_modular] import { getAuth, signInWithRedirect } from "firebase/auth"; diff --git a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js index 73f69951..61709b2c 100644 --- a/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js +++ b/snippets/auth-next/yahoo-oauth/auth_yahoo_signin_redirect_result.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./auth-next/yahoo-oauth.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START auth_yahoo_signin_redirect_result_modular] import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth"; diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js index 709fc10b..4cc268e7 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/emulator-suite.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_emulator_connect_modular] import { getDatabase, connectDatabaseEmulator } from "firebase/database"; diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_flush.js b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js index 0476a256..3e17ef9a 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_flush.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_flush.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/emulator-suite.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_emulator_flush_modular] import { getDatabase, ref, set } from "firebase/database"; diff --git a/snippets/database-next/index/rtdb_get_reference.js b/snippets/database-next/index/rtdb_get_reference.js index fe16c855..ee87937e 100644 --- a/snippets/database-next/index/rtdb_get_reference.js +++ b/snippets/database-next/index/rtdb_get_reference.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_get_reference_modular] import { getDatabase } from "firebase/database"; diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_children.js b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js index 644c0334..78f90ff2 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_listen_children.js +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_children.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/lists-of-data.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_listen_children_modular] import { getDatabase, ref, onChildAdded, onChildChanged, onChildRemoved } from "firebase/database"; diff --git a/snippets/database-next/lists-of-data/rtdb_social_listen_value.js b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js index 938308ad..d234eeea 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_listen_value.js +++ b/snippets/database-next/lists-of-data/rtdb_social_listen_value.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/lists-of-data.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_listen_value_modular] import { getDatabase, ref, onValue } from "firebase/database"; diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_starred.js b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js index 5c364682..63237fdf 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_most_starred.js +++ b/snippets/database-next/lists-of-data/rtdb_social_most_starred.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/lists-of-data.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_most_starred_modular] import { getDatabase, ref, query, orderByChild } from "firebase/database"; diff --git a/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js index 784df41e..1ebe7edc 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js +++ b/snippets/database-next/lists-of-data/rtdb_social_most_viewed.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/lists-of-data.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_most_viewed_modular] import { getDatabase, ref, query, orderByChild } from "firebase/database"; diff --git a/snippets/database-next/lists-of-data/rtdb_social_push.js b/snippets/database-next/lists-of-data/rtdb_social_push.js index c62c0a0a..ec366352 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_push.js +++ b/snippets/database-next/lists-of-data/rtdb_social_push.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/lists-of-data.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_push_modular] import { getDatabase, ref, push, set } from "firebase/database"; diff --git a/snippets/database-next/lists-of-data/rtdb_social_recent.js b/snippets/database-next/lists-of-data/rtdb_social_recent.js index 0f26c486..8b35d6e6 100644 --- a/snippets/database-next/lists-of-data/rtdb_social_recent.js +++ b/snippets/database-next/lists-of-data/rtdb_social_recent.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/lists-of-data.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_recent_modular] import { getDatabase, ref, query, limitToLast } from "firebase/database"; diff --git a/snippets/database-next/offline/rtdb_detect_connection_state.js b/snippets/database-next/offline/rtdb_detect_connection_state.js index e37375d2..313af6ee 100644 --- a/snippets/database-next/offline/rtdb_detect_connection_state.js +++ b/snippets/database-next/offline/rtdb_detect_connection_state.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/offline.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_detect_connection_state_modular] import { getDatabase, ref, onValue } from "firebase/database"; diff --git a/snippets/database-next/offline/rtdb_estimate_clock_skew.js b/snippets/database-next/offline/rtdb_estimate_clock_skew.js index 9e4b6f5d..e1a92581 100644 --- a/snippets/database-next/offline/rtdb_estimate_clock_skew.js +++ b/snippets/database-next/offline/rtdb_estimate_clock_skew.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/offline.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_estimate_clock_skew_modular] import { getDatabase, ref, onValue } from "firebase/database"; diff --git a/snippets/database-next/offline/rtdb_ondisconnect_callback.js b/snippets/database-next/offline/rtdb_ondisconnect_callback.js index 6b7f2950..16071828 100644 --- a/snippets/database-next/offline/rtdb_ondisconnect_callback.js +++ b/snippets/database-next/offline/rtdb_ondisconnect_callback.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/offline.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_ondisconnect_callback_modular] onDisconnect(presenceRef).remove().catch((err) => { diff --git a/snippets/database-next/offline/rtdb_ondisconnect_cancel.js b/snippets/database-next/offline/rtdb_ondisconnect_cancel.js index f5c3c972..f18cab8e 100644 --- a/snippets/database-next/offline/rtdb_ondisconnect_cancel.js +++ b/snippets/database-next/offline/rtdb_ondisconnect_cancel.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/offline.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_ondisconnect_cancel_modular] const onDisconnectRef = onDisconnect(presenceRef); diff --git a/snippets/database-next/offline/rtdb_ondisconnect_simple.js b/snippets/database-next/offline/rtdb_ondisconnect_simple.js index da1fdf4f..340e3fe5 100644 --- a/snippets/database-next/offline/rtdb_ondisconnect_simple.js +++ b/snippets/database-next/offline/rtdb_ondisconnect_simple.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/offline.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_ondisconnect_simple_modular] import { getDatabase, ref, onDisconnect } from "firebase/database"; diff --git a/snippets/database-next/offline/rtdb_sample_presence_app.js b/snippets/database-next/offline/rtdb_sample_presence_app.js index 504f396f..394e64e6 100644 --- a/snippets/database-next/offline/rtdb_sample_presence_app.js +++ b/snippets/database-next/offline/rtdb_sample_presence_app.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/offline.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_sample_presence_app_modular] import { getDatabase, ref, onValue, push, onDisconnect, set, serverTimestamp } from "firebase/database"; diff --git a/snippets/database-next/offline/rtdb_set_server_timestamp.js b/snippets/database-next/offline/rtdb_set_server_timestamp.js index 4a1a219b..8a9d2e8a 100644 --- a/snippets/database-next/offline/rtdb_set_server_timestamp.js +++ b/snippets/database-next/offline/rtdb_set_server_timestamp.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/offline.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_set_server_timestamp_modular] import { getDatabase, ref, onDisconnect, serverTimestamp } from "firebase/database"; diff --git a/snippets/database-next/read-and-write/rtdb_read_once_get.js b/snippets/database-next/read-and-write/rtdb_read_once_get.js index ec618da0..a0cf77a5 100644 --- a/snippets/database-next/read-and-write/rtdb_read_once_get.js +++ b/snippets/database-next/read-and-write/rtdb_read_once_get.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_read_once_get_modular] import { getDatabase, ref, child, get } from "firebase/database"; diff --git a/snippets/database-next/read-and-write/rtdb_social_completion_callback.js b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js index 483dd962..b1ab42a1 100644 --- a/snippets/database-next/read-and-write/rtdb_social_completion_callback.js +++ b/snippets/database-next/read-and-write/rtdb_social_completion_callback.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_completion_callback_modular] import { getDatabase, ref, set } from "firebase/database"; diff --git a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js index 3f7f498b..ab520ce6 100644 --- a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js +++ b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_listen_star_count_modular] import { getDatabase, ref, onValue} from "firebase/database"; diff --git a/snippets/database-next/read-and-write/rtdb_social_single_value_read.js b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js index 276bdfd3..3debb5e5 100644 --- a/snippets/database-next/read-and-write/rtdb_social_single_value_read.js +++ b/snippets/database-next/read-and-write/rtdb_social_single_value_read.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_single_value_read_modular] import { getDatabase, ref, onValue } from "firebase/database"; diff --git a/snippets/database-next/read-and-write/rtdb_social_star_increment.js b/snippets/database-next/read-and-write/rtdb_social_star_increment.js index bb4f9d7e..dce5e8a9 100644 --- a/snippets/database-next/read-and-write/rtdb_social_star_increment.js +++ b/snippets/database-next/read-and-write/rtdb_social_star_increment.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_star_increment_modular] function addStar(uid, key) { diff --git a/snippets/database-next/read-and-write/rtdb_social_star_transaction.js b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js index af817f0c..bf837c92 100644 --- a/snippets/database-next/read-and-write/rtdb_social_star_transaction.js +++ b/snippets/database-next/read-and-write/rtdb_social_star_transaction.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_star_transaction_modular] import { getDatabase, ref, runTransaction } from "firebase/database"; diff --git a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js index a87824e9..f787d4bd 100644 --- a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js +++ b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_social_write_fan_out_modular] function writeNewPost(uid, username, picture, title, body) { diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user.js b/snippets/database-next/read-and-write/rtdb_write_new_user.js index 85ecc9f4..eef24086 100644 --- a/snippets/database-next/read-and-write/rtdb_write_new_user.js +++ b/snippets/database-next/read-and-write/rtdb_write_new_user.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_write_new_user_modular] import { getDatabase, ref, set } from "firebase/database"; diff --git a/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js index b6e0dacb..8bb5878e 100644 --- a/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js +++ b/snippets/database-next/read-and-write/rtdb_write_new_user_completion.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/read-and-write.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_write_new_user_completion_modular] import { getDatabase, ref, set } from "firebase/database"; diff --git a/snippets/database-next/sharding/rtdb_multiple_instances.js b/snippets/database-next/sharding/rtdb_multiple_instances.js index cd40b918..fe66cbc8 100644 --- a/snippets/database-next/sharding/rtdb_multiple_instances.js +++ b/snippets/database-next/sharding/rtdb_multiple_instances.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./database-next/sharding.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rtdb_multiple_instances_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/firebaseapp-next/firebaseapp/firebase_options.js b/snippets/firebaseapp-next/firebaseapp/firebase_options.js index 76a420e9..f951d4d7 100644 --- a/snippets/firebaseapp-next/firebaseapp/firebase_options.js +++ b/snippets/firebaseapp-next/firebaseapp/firebase_options.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firebaseapp-next/firebaseapp.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START firebase_options_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/firebaseapp-next/firebaseapp/firebase_secondary.js b/snippets/firebaseapp-next/firebaseapp/firebase_secondary.js index c78f2b3f..2dd04f0f 100644 --- a/snippets/firebaseapp-next/firebaseapp/firebase_secondary.js +++ b/snippets/firebaseapp-next/firebaseapp/firebase_secondary.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firebaseapp-next/firebaseapp.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START firebase_secondary_modular] // Initialize another app with a different config diff --git a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js index 3754a2df..7e31fcfd 100644 --- a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js +++ b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/emulator-suite.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fs_emulator_connect_modular] import { getFirestore, connectFirestoreEmulator } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/add_ada_lovelace.js b/snippets/firestore-next/test-firestore/add_ada_lovelace.js index 7e9a0516..ae9e168a 100644 --- a/snippets/firestore-next/test-firestore/add_ada_lovelace.js +++ b/snippets/firestore-next/test-firestore/add_ada_lovelace.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START add_ada_lovelace_modular] import { collection, addDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/add_alan_turing.js b/snippets/firestore-next/test-firestore/add_alan_turing.js index 6ea96265..0c7abaaf 100644 --- a/snippets/firestore-next/test-firestore/add_alan_turing.js +++ b/snippets/firestore-next/test-firestore/add_alan_turing.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START add_alan_turing_modular] // Add a second document with a generated ID. diff --git a/snippets/firestore-next/test-firestore/add_document.js b/snippets/firestore-next/test-firestore/add_document.js index 2ecb5c36..ddfea007 100644 --- a/snippets/firestore-next/test-firestore/add_document.js +++ b/snippets/firestore-next/test-firestore/add_document.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START add_document_modular] import { collection, addDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/add_rating_transaction.js b/snippets/firestore-next/test-firestore/add_rating_transaction.js index e5c279a9..7d698806 100644 --- a/snippets/firestore-next/test-firestore/add_rating_transaction.js +++ b/snippets/firestore-next/test-firestore/add_rating_transaction.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START add_rating_transaction_modular] import { collection, doc, runTransaction } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/array_contains_any_filter.js b/snippets/firestore-next/test-firestore/array_contains_any_filter.js index 72c550f8..3ee6e4d9 100644 --- a/snippets/firestore-next/test-firestore/array_contains_any_filter.js +++ b/snippets/firestore-next/test-firestore/array_contains_any_filter.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START array_contains_any_filter_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/array_contains_filter.js b/snippets/firestore-next/test-firestore/array_contains_filter.js index 9a9fcdb3..4576a193 100644 --- a/snippets/firestore-next/test-firestore/array_contains_filter.js +++ b/snippets/firestore-next/test-firestore/array_contains_filter.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START array_contains_filter_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/chain_filters.js b/snippets/firestore-next/test-firestore/chain_filters.js index b13640b4..cbf3322f 100644 --- a/snippets/firestore-next/test-firestore/chain_filters.js +++ b/snippets/firestore-next/test-firestore/chain_filters.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START chain_filters_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/cities_document_set.js b/snippets/firestore-next/test-firestore/cities_document_set.js index 793c4a8e..4b85b25d 100644 --- a/snippets/firestore-next/test-firestore/cities_document_set.js +++ b/snippets/firestore-next/test-firestore/cities_document_set.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START cities_document_set_modular] import { doc, setDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/city_custom_object.js b/snippets/firestore-next/test-firestore/city_custom_object.js index 2b9f2c02..c8e4b80c 100644 --- a/snippets/firestore-next/test-firestore/city_custom_object.js +++ b/snippets/firestore-next/test-firestore/city_custom_object.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START city_custom_object_modular] class City { diff --git a/snippets/firestore-next/test-firestore/collection_reference.js b/snippets/firestore-next/test-firestore/collection_reference.js index 2b43362d..d69f17e4 100644 --- a/snippets/firestore-next/test-firestore/collection_reference.js +++ b/snippets/firestore-next/test-firestore/collection_reference.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START collection_reference_modular] import { collection } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/data_types.js b/snippets/firestore-next/test-firestore/data_types.js index 9aa46b2b..9218ae6b 100644 --- a/snippets/firestore-next/test-firestore/data_types.js +++ b/snippets/firestore-next/test-firestore/data_types.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START data_types_modular] import { doc, setDoc, Timestamp } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/delete_collection.js b/snippets/firestore-next/test-firestore/delete_collection.js index 758e653e..4adef6f8 100644 --- a/snippets/firestore-next/test-firestore/delete_collection.js +++ b/snippets/firestore-next/test-firestore/delete_collection.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START delete_collection_modular] /** diff --git a/snippets/firestore-next/test-firestore/delete_document.js b/snippets/firestore-next/test-firestore/delete_document.js index 0933d311..b00ae490 100644 --- a/snippets/firestore-next/test-firestore/delete_document.js +++ b/snippets/firestore-next/test-firestore/delete_document.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START delete_document_modular] import { doc, deleteDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/detach_listener.js b/snippets/firestore-next/test-firestore/detach_listener.js index 24848db2..cd921018 100644 --- a/snippets/firestore-next/test-firestore/detach_listener.js +++ b/snippets/firestore-next/test-firestore/detach_listener.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START detach_listener_modular] import { collection, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/disable_network.js b/snippets/firestore-next/test-firestore/disable_network.js index 095e6090..efa1fc27 100644 --- a/snippets/firestore-next/test-firestore/disable_network.js +++ b/snippets/firestore-next/test-firestore/disable_network.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START disable_network_modular] import { disableNetwork } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/doc_reference.js b/snippets/firestore-next/test-firestore/doc_reference.js index 10b96445..c5380539 100644 --- a/snippets/firestore-next/test-firestore/doc_reference.js +++ b/snippets/firestore-next/test-firestore/doc_reference.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START doc_reference_modular] import { doc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/doc_reference_alternative.js b/snippets/firestore-next/test-firestore/doc_reference_alternative.js index 8b60f4de..c88294a9 100644 --- a/snippets/firestore-next/test-firestore/doc_reference_alternative.js +++ b/snippets/firestore-next/test-firestore/doc_reference_alternative.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START doc_reference_alternative_modular] import { doc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/enable_network.js b/snippets/firestore-next/test-firestore/enable_network.js index e6d59889..2df9171b 100644 --- a/snippets/firestore-next/test-firestore/enable_network.js +++ b/snippets/firestore-next/test-firestore/enable_network.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START enable_network_modular] import { enableNetwork } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/example_data.js b/snippets/firestore-next/test-firestore/example_data.js index 52204078..cb7e92aa 100644 --- a/snippets/firestore-next/test-firestore/example_data.js +++ b/snippets/firestore-next/test-firestore/example_data.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START example_data_modular] import { collection, doc, setDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/example_filters.js b/snippets/firestore-next/test-firestore/example_filters.js index b5f58a5c..b481e5a8 100644 --- a/snippets/firestore-next/test-firestore/example_filters.js +++ b/snippets/firestore-next/test-firestore/example_filters.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START example_filters_modular] const stateQuery = query(citiesRef, where("state", "==", "CA")); diff --git a/snippets/firestore-next/test-firestore/filter_and_order.js b/snippets/firestore-next/test-firestore/filter_and_order.js index 13e31c0a..b8c03705 100644 --- a/snippets/firestore-next/test-firestore/filter_and_order.js +++ b/snippets/firestore-next/test-firestore/filter_and_order.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START filter_and_order_modular] import { query, where, orderBy, limit } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/fs_collection_group_query.js b/snippets/firestore-next/test-firestore/fs_collection_group_query.js index 96a2d735..3468017b 100644 --- a/snippets/firestore-next/test-firestore/fs_collection_group_query.js +++ b/snippets/firestore-next/test-firestore/fs_collection_group_query.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fs_collection_group_query_modular] import { collectionGroup, query, where, getDocs } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js b/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js index a4e07952..f4f62178 100644 --- a/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js +++ b/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fs_collection_group_query_data_setup_modular] import { collection, doc, setDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/fs_setup_cache.js b/snippets/firestore-next/test-firestore/fs_setup_cache.js index 3085eb65..8429da4c 100644 --- a/snippets/firestore-next/test-firestore/fs_setup_cache.js +++ b/snippets/firestore-next/test-firestore/fs_setup_cache.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fs_setup_cache_modular] import { initializeFirestore, CACHE_SIZE_UNLIMITED } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/get_all_users.js b/snippets/firestore-next/test-firestore/get_all_users.js index c8c86b5d..59dd760a 100644 --- a/snippets/firestore-next/test-firestore/get_all_users.js +++ b/snippets/firestore-next/test-firestore/get_all_users.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_all_users_modular] import { collection, getDocs } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/get_custom_object.js b/snippets/firestore-next/test-firestore/get_custom_object.js index 3e39eafa..e20a6839 100644 --- a/snippets/firestore-next/test-firestore/get_custom_object.js +++ b/snippets/firestore-next/test-firestore/get_custom_object.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_custom_object_modular] import { doc, getDoc} from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/get_document.js b/snippets/firestore-next/test-firestore/get_document.js index 1ca4787d..4cfbaaf6 100644 --- a/snippets/firestore-next/test-firestore/get_document.js +++ b/snippets/firestore-next/test-firestore/get_document.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_document_modular] import { doc, getDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/get_document_options.js b/snippets/firestore-next/test-firestore/get_document_options.js index 8b161b27..3a708a0d 100644 --- a/snippets/firestore-next/test-firestore/get_document_options.js +++ b/snippets/firestore-next/test-firestore/get_document_options.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_document_options_modular] import { doc, getDocFromCache } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/get_multiple.js b/snippets/firestore-next/test-firestore/get_multiple.js index 9b1616c2..59f8f9c3 100644 --- a/snippets/firestore-next/test-firestore/get_multiple.js +++ b/snippets/firestore-next/test-firestore/get_multiple.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_multiple_modular] import { collection, query, where, getDocs } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/get_multiple_all.js b/snippets/firestore-next/test-firestore/get_multiple_all.js index c61ec1ad..721f222e 100644 --- a/snippets/firestore-next/test-firestore/get_multiple_all.js +++ b/snippets/firestore-next/test-firestore/get_multiple_all.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_multiple_all_modular] import { collection, getDocs } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/handle_listen_errors.js b/snippets/firestore-next/test-firestore/handle_listen_errors.js index bb59c7d5..c330b67b 100644 --- a/snippets/firestore-next/test-firestore/handle_listen_errors.js +++ b/snippets/firestore-next/test-firestore/handle_listen_errors.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START handle_listen_errors_modular] import { collection, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/in_filter.js b/snippets/firestore-next/test-firestore/in_filter.js index 55f0a0a7..4a041397 100644 --- a/snippets/firestore-next/test-firestore/in_filter.js +++ b/snippets/firestore-next/test-firestore/in_filter.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START in_filter_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/in_filter_with_array.js b/snippets/firestore-next/test-firestore/in_filter_with_array.js index 722b11aa..ebe6f18b 100644 --- a/snippets/firestore-next/test-firestore/in_filter_with_array.js +++ b/snippets/firestore-next/test-firestore/in_filter_with_array.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START in_filter_with_array_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/initialize_persistence.js b/snippets/firestore-next/test-firestore/initialize_persistence.js index 97936466..acd5e988 100644 --- a/snippets/firestore-next/test-firestore/initialize_persistence.js +++ b/snippets/firestore-next/test-firestore/initialize_persistence.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START initialize_persistence_modular] import { enableIndexedDbPersistence } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/invalid_filter_and_order.js b/snippets/firestore-next/test-firestore/invalid_filter_and_order.js index 5d8e73e6..708c9cd1 100644 --- a/snippets/firestore-next/test-firestore/invalid_filter_and_order.js +++ b/snippets/firestore-next/test-firestore/invalid_filter_and_order.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START invalid_filter_and_order_modular] import { query, where, orderBy } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/invalid_range_filters.js b/snippets/firestore-next/test-firestore/invalid_range_filters.js index 9ebde4ef..b6236824 100644 --- a/snippets/firestore-next/test-firestore/invalid_range_filters.js +++ b/snippets/firestore-next/test-firestore/invalid_range_filters.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START invalid_range_filters_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/listen_diffs.js b/snippets/firestore-next/test-firestore/listen_diffs.js index 0ef32dff..531c6f1e 100644 --- a/snippets/firestore-next/test-firestore/listen_diffs.js +++ b/snippets/firestore-next/test-firestore/listen_diffs.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START listen_diffs_modular] import { collection, query, where, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/listen_document.js b/snippets/firestore-next/test-firestore/listen_document.js index 9b6507fc..47b65229 100644 --- a/snippets/firestore-next/test-firestore/listen_document.js +++ b/snippets/firestore-next/test-firestore/listen_document.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START listen_document_modular] import { doc, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/listen_document_local.js b/snippets/firestore-next/test-firestore/listen_document_local.js index 08041a3f..cdb4e63b 100644 --- a/snippets/firestore-next/test-firestore/listen_document_local.js +++ b/snippets/firestore-next/test-firestore/listen_document_local.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START listen_document_local_modular] import { doc, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/listen_for_users.js b/snippets/firestore-next/test-firestore/listen_for_users.js index 3c42287a..5a519349 100644 --- a/snippets/firestore-next/test-firestore/listen_for_users.js +++ b/snippets/firestore-next/test-firestore/listen_for_users.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START listen_for_users_modular] import { collection, where, query, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/listen_multiple.js b/snippets/firestore-next/test-firestore/listen_multiple.js index 0c7f9d46..cf30c178 100644 --- a/snippets/firestore-next/test-firestore/listen_multiple.js +++ b/snippets/firestore-next/test-firestore/listen_multiple.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START listen_multiple_modular] import { collection, query, where, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/listen_with_metadata.js b/snippets/firestore-next/test-firestore/listen_with_metadata.js index 42848f62..693c1dc1 100644 --- a/snippets/firestore-next/test-firestore/listen_with_metadata.js +++ b/snippets/firestore-next/test-firestore/listen_with_metadata.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START listen_with_metadata_modular] import { doc, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/new_document.js b/snippets/firestore-next/test-firestore/new_document.js index c83e4aa6..219efce7 100644 --- a/snippets/firestore-next/test-firestore/new_document.js +++ b/snippets/firestore-next/test-firestore/new_document.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START new_document_modular] import { collection, doc, setDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/not_in_filter.js b/snippets/firestore-next/test-firestore/not_in_filter.js index c880cb02..70e82480 100644 --- a/snippets/firestore-next/test-firestore/not_in_filter.js +++ b/snippets/firestore-next/test-firestore/not_in_filter.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START not_in_filter_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/order_and_end.js b/snippets/firestore-next/test-firestore/order_and_end.js index d543ea06..7c68047f 100644 --- a/snippets/firestore-next/test-firestore/order_and_end.js +++ b/snippets/firestore-next/test-firestore/order_and_end.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START order_and_end_modular] import { query, orderBy, endAt } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/order_and_limit.js b/snippets/firestore-next/test-firestore/order_and_limit.js index 6979b518..6ff03737 100644 --- a/snippets/firestore-next/test-firestore/order_and_limit.js +++ b/snippets/firestore-next/test-firestore/order_and_limit.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START order_and_limit_modular] import { query, orderBy, limit } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/order_and_limit_desc.js b/snippets/firestore-next/test-firestore/order_and_limit_desc.js index ed61d2ab..725983de 100644 --- a/snippets/firestore-next/test-firestore/order_and_limit_desc.js +++ b/snippets/firestore-next/test-firestore/order_and_limit_desc.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START order_and_limit_desc_modular] import { query, orderBy, limit } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/order_and_start.js b/snippets/firestore-next/test-firestore/order_and_start.js index 20587a90..35cccc84 100644 --- a/snippets/firestore-next/test-firestore/order_and_start.js +++ b/snippets/firestore-next/test-firestore/order_and_start.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START order_and_start_modular] import { query, orderBy, startAt } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/order_multiple.js b/snippets/firestore-next/test-firestore/order_multiple.js index c0991c8c..7e6e5ad6 100644 --- a/snippets/firestore-next/test-firestore/order_multiple.js +++ b/snippets/firestore-next/test-firestore/order_multiple.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START order_multiple_modular] import { query, orderBy } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/paginate.js b/snippets/firestore-next/test-firestore/paginate.js index 26a7325b..cdc146ca 100644 --- a/snippets/firestore-next/test-firestore/paginate.js +++ b/snippets/firestore-next/test-firestore/paginate.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START paginate_modular] import { collection, query, orderBy, startAfter, limit, getDocs } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js b/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js index 9fab8f77..ac0ce5cb 100644 --- a/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js +++ b/snippets/firestore-next/test-firestore/server_timestamp_resolution_options.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START server_timestamp_resolution_options_modular] import { doc, updateDoc, serverTimestamp, onSnapshot } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/set_custom_object.js b/snippets/firestore-next/test-firestore/set_custom_object.js index 54febc9f..e27d3dd4 100644 --- a/snippets/firestore-next/test-firestore/set_custom_object.js +++ b/snippets/firestore-next/test-firestore/set_custom_object.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START set_custom_object_modular] import { doc, setDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/set_document.js b/snippets/firestore-next/test-firestore/set_document.js index 94a562af..a4c9bdb4 100644 --- a/snippets/firestore-next/test-firestore/set_document.js +++ b/snippets/firestore-next/test-firestore/set_document.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START set_document_modular] import { doc, setDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/set_with_merge.js b/snippets/firestore-next/test-firestore/set_with_merge.js index ca0fd3b6..f33def30 100644 --- a/snippets/firestore-next/test-firestore/set_with_merge.js +++ b/snippets/firestore-next/test-firestore/set_with_merge.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START set_with_merge_modular] import { doc, setDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/simple_queries.js b/snippets/firestore-next/test-firestore/simple_queries.js index 348cd4e6..9eede831 100644 --- a/snippets/firestore-next/test-firestore/simple_queries.js +++ b/snippets/firestore-next/test-firestore/simple_queries.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START simple_queries_modular] // Create a reference to the cities collection diff --git a/snippets/firestore-next/test-firestore/simple_queries_again.js b/snippets/firestore-next/test-firestore/simple_queries_again.js index f6256baf..bb2ebc83 100644 --- a/snippets/firestore-next/test-firestore/simple_queries_again.js +++ b/snippets/firestore-next/test-firestore/simple_queries_again.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START simple_queries_again_modular] import { collection, query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/simple_query_not_equal.js b/snippets/firestore-next/test-firestore/simple_query_not_equal.js index a9ca2690..d2bef734 100644 --- a/snippets/firestore-next/test-firestore/simple_query_not_equal.js +++ b/snippets/firestore-next/test-firestore/simple_query_not_equal.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START simple_query_not_equal_modular] const notCapitalQuery = query(citiesRef, where("capital", "!=", false)); diff --git a/snippets/firestore-next/test-firestore/start_doc.js b/snippets/firestore-next/test-firestore/start_doc.js index 23f38e63..e75c7984 100644 --- a/snippets/firestore-next/test-firestore/start_doc.js +++ b/snippets/firestore-next/test-firestore/start_doc.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START start_doc_modular] import { collection, doc, getDoc, query, orderBy, startAt } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/start_multiple_orderby.js b/snippets/firestore-next/test-firestore/start_multiple_orderby.js index f0faaec0..88133d16 100644 --- a/snippets/firestore-next/test-firestore/start_multiple_orderby.js +++ b/snippets/firestore-next/test-firestore/start_multiple_orderby.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START start_multiple_orderby_modular] // Will return all Springfields diff --git a/snippets/firestore-next/test-firestore/subcollection_reference.js b/snippets/firestore-next/test-firestore/subcollection_reference.js index 7b42af67..997714f1 100644 --- a/snippets/firestore-next/test-firestore/subcollection_reference.js +++ b/snippets/firestore-next/test-firestore/subcollection_reference.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START subcollection_reference_modular] import { doc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/transaction.js b/snippets/firestore-next/test-firestore/transaction.js index 27b84264..727c5f41 100644 --- a/snippets/firestore-next/test-firestore/transaction.js +++ b/snippets/firestore-next/test-firestore/transaction.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START transaction_modular] import { runTransaction } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/transaction_promise.js b/snippets/firestore-next/test-firestore/transaction_promise.js index 7646bb6d..94792933 100644 --- a/snippets/firestore-next/test-firestore/transaction_promise.js +++ b/snippets/firestore-next/test-firestore/transaction_promise.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START transaction_promise_modular] import { doc, runTransaction } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/update_delete_field.js b/snippets/firestore-next/test-firestore/update_delete_field.js index 7bff4444..fc6f1f94 100644 --- a/snippets/firestore-next/test-firestore/update_delete_field.js +++ b/snippets/firestore-next/test-firestore/update_delete_field.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START update_delete_field_modular] import { doc, updateDoc, deleteField } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/update_document.js b/snippets/firestore-next/test-firestore/update_document.js index 23488474..1073482a 100644 --- a/snippets/firestore-next/test-firestore/update_document.js +++ b/snippets/firestore-next/test-firestore/update_document.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START update_document_modular] import { doc, updateDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/update_document_array.js b/snippets/firestore-next/test-firestore/update_document_array.js index 463e857d..29a5c04e 100644 --- a/snippets/firestore-next/test-firestore/update_document_array.js +++ b/snippets/firestore-next/test-firestore/update_document_array.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START update_document_array_modular] import { doc, updateDoc, arrayUnion, arrayRemove } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/update_document_increment.js b/snippets/firestore-next/test-firestore/update_document_increment.js index 30258a6c..b8555bcf 100644 --- a/snippets/firestore-next/test-firestore/update_document_increment.js +++ b/snippets/firestore-next/test-firestore/update_document_increment.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START update_document_increment_modular] import { doc, updateDoc, increment } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/update_document_nested.js b/snippets/firestore-next/test-firestore/update_document_nested.js index d3c12533..be66b031 100644 --- a/snippets/firestore-next/test-firestore/update_document_nested.js +++ b/snippets/firestore-next/test-firestore/update_document_nested.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START update_document_nested_modular] import { doc, setDoc, updateDoc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/update_with_server_timestamp.js b/snippets/firestore-next/test-firestore/update_with_server_timestamp.js index e4e2f248..e761f11f 100644 --- a/snippets/firestore-next/test-firestore/update_with_server_timestamp.js +++ b/snippets/firestore-next/test-firestore/update_with_server_timestamp.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START update_with_server_timestamp_modular] import { updateDoc, serverTimestamp } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/use_from_cache.js b/snippets/firestore-next/test-firestore/use_from_cache.js index 9f125e6c..e9f257da 100644 --- a/snippets/firestore-next/test-firestore/use_from_cache.js +++ b/snippets/firestore-next/test-firestore/use_from_cache.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START use_from_cache_modular] import { collection, onSnapshot, where, query } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/valid_filter_and_order.js b/snippets/firestore-next/test-firestore/valid_filter_and_order.js index ae2519d0..d75524e9 100644 --- a/snippets/firestore-next/test-firestore/valid_filter_and_order.js +++ b/snippets/firestore-next/test-firestore/valid_filter_and_order.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START valid_filter_and_order_modular] import { query, where, orderBy } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/valid_range_filters.js b/snippets/firestore-next/test-firestore/valid_range_filters.js index cd559456..9a7f5350 100644 --- a/snippets/firestore-next/test-firestore/valid_range_filters.js +++ b/snippets/firestore-next/test-firestore/valid_range_filters.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START valid_range_filters_modular] import { query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-firestore/write_batch.js b/snippets/firestore-next/test-firestore/write_batch.js index 42494f5a..38f41f47 100644 --- a/snippets/firestore-next/test-firestore/write_batch.js +++ b/snippets/firestore-next/test-firestore/write_batch.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.firestore.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START write_batch_modular] import { writeBatch, doc } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js b/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js index 06b85efc..bc83cf8b 100644 --- a/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js +++ b/snippets/firestore-next/test-solution-aggregation/get_collection_ratings.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-aggregation.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_collection_ratings_modular] import { collection, getDocs } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-solution-aggregation/sample_doc.js b/snippets/firestore-next/test-solution-aggregation/sample_doc.js index 651b4d37..4cec6773 100644 --- a/snippets/firestore-next/test-solution-aggregation/sample_doc.js +++ b/snippets/firestore-next/test-solution-aggregation/sample_doc.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-aggregation.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START sample_doc_modular] const arinellDoc = { diff --git a/snippets/firestore-next/test-solution-arrays/post_with_array.js b/snippets/firestore-next/test-solution-arrays/post_with_array.js index da070d3d..eb336d14 100644 --- a/snippets/firestore-next/test-solution-arrays/post_with_array.js +++ b/snippets/firestore-next/test-solution-arrays/post_with_array.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-arrays.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START post_with_array_modular] // Sample document in the 'posts' collection. diff --git a/snippets/firestore-next/test-solution-arrays/post_with_map.js b/snippets/firestore-next/test-solution-arrays/post_with_map.js index 36ce26cc..16313ace 100644 --- a/snippets/firestore-next/test-solution-arrays/post_with_map.js +++ b/snippets/firestore-next/test-solution-arrays/post_with_map.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-arrays.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START post_with_map_modular] // Sample document in the 'posts' collection diff --git a/snippets/firestore-next/test-solution-arrays/post_with_map_advanced.js b/snippets/firestore-next/test-solution-arrays/post_with_map_advanced.js index b5b40eca..4cb176db 100644 --- a/snippets/firestore-next/test-solution-arrays/post_with_map_advanced.js +++ b/snippets/firestore-next/test-solution-arrays/post_with_map_advanced.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-arrays.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START post_with_map_advanced_modular] // The value of each entry in 'categories' is a unix timestamp diff --git a/snippets/firestore-next/test-solution-arrays/query_in_category.js b/snippets/firestore-next/test-solution-arrays/query_in_category.js index 212ef92b..3a13d2cf 100644 --- a/snippets/firestore-next/test-solution-arrays/query_in_category.js +++ b/snippets/firestore-next/test-solution-arrays/query_in_category.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-arrays.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START query_in_category_modular] import { collection, getDocs, query, where } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js index 31336fac..87dd9c6f 100644 --- a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js +++ b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-arrays.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START query_in_category_timestamp_modular] import { collection, query, where, orderBy } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js index 29c0a18c..c387ac2d 100644 --- a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js +++ b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-arrays.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START query_in_category_timestamp_invalid_modular] import { collection, query, where, orderBy, FirebaseFirestore } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-solution-bundles/fs_bundle_load.js b/snippets/firestore-next/test-solution-bundles/fs_bundle_load.js index 9aa8f430..e61315d2 100644 --- a/snippets/firestore-next/test-solution-bundles/fs_bundle_load.js +++ b/snippets/firestore-next/test-solution-bundles/fs_bundle_load.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-bundles.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fs_bundle_load_modular] import { loadBundle, namedQuery, getDocsFromCache } from "firebase/firestore"; diff --git a/snippets/firestore-next/test-solution-counters/create_counter.js b/snippets/firestore-next/test-solution-counters/create_counter.js index 738dd634..11dfb3d8 100644 --- a/snippets/firestore-next/test-solution-counters/create_counter.js +++ b/snippets/firestore-next/test-solution-counters/create_counter.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-counters.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START create_counter_modular] function createCounter(ref, num_shards) { diff --git a/snippets/firestore-next/test-solution-counters/get_count.js b/snippets/firestore-next/test-solution-counters/get_count.js index 2fc01217..7dec78f1 100644 --- a/snippets/firestore-next/test-solution-counters/get_count.js +++ b/snippets/firestore-next/test-solution-counters/get_count.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-counters.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START get_count_modular] async function getCount(ref) { diff --git a/snippets/firestore-next/test-solution-counters/increment_counter.js b/snippets/firestore-next/test-solution-counters/increment_counter.js index c74ec711..22defe9c 100644 --- a/snippets/firestore-next/test-solution-counters/increment_counter.js +++ b/snippets/firestore-next/test-solution-counters/increment_counter.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-counters.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START increment_counter_modular] function incrementCounter(db, ref, num_shards) { diff --git a/snippets/firestore-next/test-solution-geoqueries/fs_geo_add_hash.js b/snippets/firestore-next/test-solution-geoqueries/fs_geo_add_hash.js index f50ab477..29caa3d5 100644 --- a/snippets/firestore-next/test-solution-geoqueries/fs_geo_add_hash.js +++ b/snippets/firestore-next/test-solution-geoqueries/fs_geo_add_hash.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-geoqueries.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fs_geo_add_hash_modular] import { doc, updateDoc } from 'firebase/firestore'; diff --git a/snippets/firestore-next/test-solution-geoqueries/fs_geo_query_hashes.js b/snippets/firestore-next/test-solution-geoqueries/fs_geo_query_hashes.js index 1230a989..95a8863c 100644 --- a/snippets/firestore-next/test-solution-geoqueries/fs_geo_query_hashes.js +++ b/snippets/firestore-next/test-solution-geoqueries/fs_geo_query_hashes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./firestore-next/test.solution-geoqueries.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fs_geo_query_hashes_modular] import { collection, query, orderBy, startAt, endAt, getDocs } from 'firebase/firestore'; diff --git a/snippets/functions-next/callable/fb_functions_call_add_message.js b/snippets/functions-next/callable/fb_functions_call_add_message.js index 12d4d242..67c01eff 100644 --- a/snippets/functions-next/callable/fb_functions_call_add_message.js +++ b/snippets/functions-next/callable/fb_functions_call_add_message.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./functions-next/callable.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fb_functions_call_add_message_modular] import { getFunctions, httpsCallable } from "firebase/functions"; diff --git a/snippets/functions-next/callable/fb_functions_call_add_message_error.js b/snippets/functions-next/callable/fb_functions_call_add_message_error.js index 3a34c845..e87afbdd 100644 --- a/snippets/functions-next/callable/fb_functions_call_add_message_error.js +++ b/snippets/functions-next/callable/fb_functions_call_add_message_error.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./functions-next/callable.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fb_functions_call_add_message_error_modular] import { getFunctions, httpsCallable } from "firebase/functions"; diff --git a/snippets/functions-next/callable/fb_functions_initialize.js b/snippets/functions-next/callable/fb_functions_initialize.js index 7c8e4d49..d03268c8 100644 --- a/snippets/functions-next/callable/fb_functions_initialize.js +++ b/snippets/functions-next/callable/fb_functions_initialize.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./functions-next/callable.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fb_functions_initialize_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/functions-next/emulator-suite/fb_functions_callable_call.js b/snippets/functions-next/emulator-suite/fb_functions_callable_call.js index 2619806b..e547c3d3 100644 --- a/snippets/functions-next/emulator-suite/fb_functions_callable_call.js +++ b/snippets/functions-next/emulator-suite/fb_functions_callable_call.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./functions-next/emulator-suite.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fb_functions_callable_call_modular] import { getApp } from "firebase/app"; diff --git a/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js index 1a314acf..9b186fc2 100644 --- a/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js +++ b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./functions-next/emulator-suite.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START fb_functions_emulator_connect_modular] import { getApp } from "firebase/app"; diff --git a/snippets/messaging-next/index/messaging_delete_token.js b/snippets/messaging-next/index/messaging_delete_token.js index f8d6ef63..2e27ab2a 100644 --- a/snippets/messaging-next/index/messaging_delete_token.js +++ b/snippets/messaging-next/index/messaging_delete_token.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./messaging-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START messaging_delete_token_modular] import { getMessaging, deleteToken } from "firebase/messaging"; diff --git a/snippets/messaging-next/index/messaging_get_messaging_object.js b/snippets/messaging-next/index/messaging_get_messaging_object.js index 5dc88c68..1768bdd2 100644 --- a/snippets/messaging-next/index/messaging_get_messaging_object.js +++ b/snippets/messaging-next/index/messaging_get_messaging_object.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./messaging-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START messaging_get_messaging_object_modular] import { getMessaging } from "firebase/messaging"; diff --git a/snippets/messaging-next/index/messaging_get_token.js b/snippets/messaging-next/index/messaging_get_token.js index f1f4b3aa..fe571340 100644 --- a/snippets/messaging-next/index/messaging_get_token.js +++ b/snippets/messaging-next/index/messaging_get_token.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./messaging-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START messaging_get_token_modular] import { getMessaging, getToken } from "firebase/messaging"; diff --git a/snippets/messaging-next/index/messaging_receive_message.js b/snippets/messaging-next/index/messaging_receive_message.js index 94c3864d..63825c00 100644 --- a/snippets/messaging-next/index/messaging_receive_message.js +++ b/snippets/messaging-next/index/messaging_receive_message.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./messaging-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START messaging_receive_message_modular] // Handle incoming messages. Called when: diff --git a/snippets/messaging-next/index/messaging_request_permission.js b/snippets/messaging-next/index/messaging_request_permission.js index 77e2d311..c6653037 100644 --- a/snippets/messaging-next/index/messaging_request_permission.js +++ b/snippets/messaging-next/index/messaging_request_permission.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./messaging-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START messaging_request_permission_modular] Notification.requestPermission().then((permission) => { diff --git a/snippets/messaging-next/service-worker/messaging_init_in_sw.js b/snippets/messaging-next/service-worker/messaging_init_in_sw.js index 703e687d..abce8e1d 100644 --- a/snippets/messaging-next/service-worker/messaging_init_in_sw.js +++ b/snippets/messaging-next/service-worker/messaging_init_in_sw.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./messaging-next/service-worker.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START messaging_init_in_sw_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/messaging-next/service-worker/messaging_on_background_message.js b/snippets/messaging-next/service-worker/messaging_on_background_message.js index 000ab312..b7f65b53 100644 --- a/snippets/messaging-next/service-worker/messaging_on_background_message.js +++ b/snippets/messaging-next/service-worker/messaging_on_background_message.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./messaging-next/service-worker.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START messaging_on_background_message_modular] import { getMessaging } from "firebase/messaging"; diff --git a/snippets/perf-next/index/perf_add_custom_attributes.js b/snippets/perf-next/index/perf_add_custom_attributes.js index 42639c63..a1a7b13d 100644 --- a/snippets/perf-next/index/perf_add_custom_attributes.js +++ b/snippets/perf-next/index/perf_add_custom_attributes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./perf-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START perf_add_custom_attributes_modular] import { trace } from "firebase/performance"; diff --git a/snippets/perf-next/index/perf_add_custom_metrics.js b/snippets/perf-next/index/perf_add_custom_metrics.js index ad8ef48c..86dd674b 100644 --- a/snippets/perf-next/index/perf_add_custom_metrics.js +++ b/snippets/perf-next/index/perf_add_custom_metrics.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./perf-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START perf_add_custom_metrics_modular] import { trace } from "firebase/performance"; diff --git a/snippets/perf-next/index/perf_add_custom_trace.js b/snippets/perf-next/index/perf_add_custom_trace.js index 004ecda2..6fd54e49 100644 --- a/snippets/perf-next/index/perf_add_custom_trace.js +++ b/snippets/perf-next/index/perf_add_custom_trace.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./perf-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START perf_add_custom_trace_modular] import { trace } from "firebase/performance"; diff --git a/snippets/perf-next/index/perf_get_instance.js b/snippets/perf-next/index/perf_get_instance.js index cbee11e6..8b62eb72 100644 --- a/snippets/perf-next/index/perf_get_instance.js +++ b/snippets/perf-next/index/perf_get_instance.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./perf-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START perf_get_instance_modular] import { getPerformance } from "firebase/performance"; diff --git a/snippets/perf-next/index/perf_initialize.js b/snippets/perf-next/index/perf_initialize.js index c4802566..3b87e9c8 100644 --- a/snippets/perf-next/index/perf_initialize.js +++ b/snippets/perf-next/index/perf_initialize.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./perf-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START perf_initialize_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/perf-next/index/perf_user_timing_marks.js b/snippets/perf-next/index/perf_user_timing_marks.js index 5854f85c..8450370f 100644 --- a/snippets/perf-next/index/perf_user_timing_marks.js +++ b/snippets/perf-next/index/perf_user_timing_marks.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./perf-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START perf_user_timing_marks_modular] const performance = window.performance; diff --git a/snippets/placeholder/coming_soon.js b/snippets/placeholder/coming_soon.js index 715d6a3d..0477645f 100644 --- a/snippets/placeholder/coming_soon.js +++ b/snippets/placeholder/coming_soon.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./placeholder.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START coming_soon_modular] // TODO: Snippet coming soon! diff --git a/snippets/remoteconfig-next/index/rc_fetch_config_callback.js b/snippets/remoteconfig-next/index/rc_fetch_config_callback.js index 3975befd..3cb39de0 100644 --- a/snippets/remoteconfig-next/index/rc_fetch_config_callback.js +++ b/snippets/remoteconfig-next/index/rc_fetch_config_callback.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./remoteconfig-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rc_fetch_config_callback_modular] import { fetchAndActivate } from "firebase/remote-config"; diff --git a/snippets/remoteconfig-next/index/rc_get_instance.js b/snippets/remoteconfig-next/index/rc_get_instance.js index 7d59bf9d..0bf952b8 100644 --- a/snippets/remoteconfig-next/index/rc_get_instance.js +++ b/snippets/remoteconfig-next/index/rc_get_instance.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./remoteconfig-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rc_get_instance_modular] import { getRemoteConfig } from "firebase/remote-config"; diff --git a/snippets/remoteconfig-next/index/rc_get_values.js b/snippets/remoteconfig-next/index/rc_get_values.js index 1266cfe9..67018e3b 100644 --- a/snippets/remoteconfig-next/index/rc_get_values.js +++ b/snippets/remoteconfig-next/index/rc_get_values.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./remoteconfig-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rc_get_values_modular] import { getValue } from "firebase/remote-config"; diff --git a/snippets/remoteconfig-next/index/rc_set_default_values.js b/snippets/remoteconfig-next/index/rc_set_default_values.js index 6db33c0d..80e0e8c2 100644 --- a/snippets/remoteconfig-next/index/rc_set_default_values.js +++ b/snippets/remoteconfig-next/index/rc_set_default_values.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./remoteconfig-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rc_set_default_values_modular] remoteConfig.defaultConfig = { diff --git a/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js b/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js index 77a442f9..131976c5 100644 --- a/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js +++ b/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./remoteconfig-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START rc_set_minimum_fetch_time_modular] remoteConfig.settings.minimumFetchIntervalMillis = 3600000; diff --git a/snippets/storage-next/create-reference/storage_create_ref.js b/snippets/storage-next/create-reference/storage_create_ref.js index eb27bacb..761a634a 100644 --- a/snippets/storage-next/create-reference/storage_create_ref.js +++ b/snippets/storage-next/create-reference/storage_create_ref.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/create-reference.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_create_ref_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/create-reference/storage_create_ref_child.js b/snippets/storage-next/create-reference/storage_create_ref_child.js index 53b6834c..5e16407a 100644 --- a/snippets/storage-next/create-reference/storage_create_ref_child.js +++ b/snippets/storage-next/create-reference/storage_create_ref_child.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/create-reference.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_create_ref_child_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/create-reference/storage_navigate_ref.js b/snippets/storage-next/create-reference/storage_navigate_ref.js index 00a9e53f..ee279c72 100644 --- a/snippets/storage-next/create-reference/storage_navigate_ref.js +++ b/snippets/storage-next/create-reference/storage_navigate_ref.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/create-reference.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_navigate_ref_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/create-reference/storage_navigate_ref_chain.js b/snippets/storage-next/create-reference/storage_navigate_ref_chain.js index e0f2a056..d5e13752 100644 --- a/snippets/storage-next/create-reference/storage_navigate_ref_chain.js +++ b/snippets/storage-next/create-reference/storage_navigate_ref_chain.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/create-reference.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_navigate_ref_chain_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/create-reference/storage_ref_full_example.js b/snippets/storage-next/create-reference/storage_ref_full_example.js index 3c9f94c6..e61f4594 100644 --- a/snippets/storage-next/create-reference/storage_ref_full_example.js +++ b/snippets/storage-next/create-reference/storage_ref_full_example.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/create-reference.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_ref_full_example_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/create-reference/storage_ref_properties.js b/snippets/storage-next/create-reference/storage_ref_properties.js index 494817ea..c95a5b13 100644 --- a/snippets/storage-next/create-reference/storage_ref_properties.js +++ b/snippets/storage-next/create-reference/storage_ref_properties.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/create-reference.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_ref_properties_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/delete-files/storage_delete_file.js b/snippets/storage-next/delete-files/storage_delete_file.js index 86520968..c851c447 100644 --- a/snippets/storage-next/delete-files/storage_delete_file.js +++ b/snippets/storage-next/delete-files/storage_delete_file.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/delete-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_delete_file_modular] import { getStorage, ref, deleteObject } from "firebase/storage"; diff --git a/snippets/storage-next/download-files/storage_download_create_ref.js b/snippets/storage-next/download-files/storage_download_create_ref.js index bf12aaa9..8b1345b7 100644 --- a/snippets/storage-next/download-files/storage_download_create_ref.js +++ b/snippets/storage-next/download-files/storage_download_create_ref.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/download-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_download_create_ref_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/download-files/storage_download_full_example.js b/snippets/storage-next/download-files/storage_download_full_example.js index 4b66880e..cdd12166 100644 --- a/snippets/storage-next/download-files/storage_download_full_example.js +++ b/snippets/storage-next/download-files/storage_download_full_example.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/download-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_download_full_example_modular] import { getStorage, ref, getDownloadURL } from "firebase/storage"; diff --git a/snippets/storage-next/download-files/storage_download_via_url.js b/snippets/storage-next/download-files/storage_download_via_url.js index 0e45cada..c90e235c 100644 --- a/snippets/storage-next/download-files/storage_download_via_url.js +++ b/snippets/storage-next/download-files/storage_download_via_url.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/download-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_download_via_url_modular] import { getStorage, ref, getDownloadURL } from "firebase/storage"; diff --git a/snippets/storage-next/file-metadata/storage_custom_metadata.js b/snippets/storage-next/file-metadata/storage_custom_metadata.js index 7674c7d4..d6fb5ab4 100644 --- a/snippets/storage-next/file-metadata/storage_custom_metadata.js +++ b/snippets/storage-next/file-metadata/storage_custom_metadata.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/file-metadata.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_custom_metadata_modular] const metadata = { diff --git a/snippets/storage-next/file-metadata/storage_delete_metadata.js b/snippets/storage-next/file-metadata/storage_delete_metadata.js index c6b2ece3..71db946e 100644 --- a/snippets/storage-next/file-metadata/storage_delete_metadata.js +++ b/snippets/storage-next/file-metadata/storage_delete_metadata.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/file-metadata.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_delete_metadata_modular] import { getStorage, ref, updateMetadata } from "firebase/storage"; diff --git a/snippets/storage-next/file-metadata/storage_get_metadata.js b/snippets/storage-next/file-metadata/storage_get_metadata.js index e77444db..b2c96f1a 100644 --- a/snippets/storage-next/file-metadata/storage_get_metadata.js +++ b/snippets/storage-next/file-metadata/storage_get_metadata.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/file-metadata.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_get_metadata_modular] import { getStorage, ref, getMetadata } from "firebase/storage"; diff --git a/snippets/storage-next/file-metadata/storage_update_metadata.js b/snippets/storage-next/file-metadata/storage_update_metadata.js index fd9d6183..2435983b 100644 --- a/snippets/storage-next/file-metadata/storage_update_metadata.js +++ b/snippets/storage-next/file-metadata/storage_update_metadata.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/file-metadata.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_update_metadata_modular] import { getStorage, ref, updateMetadata } from "firebase/storage"; diff --git a/snippets/storage-next/index/storage_custom_app.js b/snippets/storage-next/index/storage_custom_app.js index 0c4f26fe..7196c252 100644 --- a/snippets/storage-next/index/storage_custom_app.js +++ b/snippets/storage-next/index/storage_custom_app.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_custom_app_modular] import { getStorage } from "firebase/storage"; diff --git a/snippets/storage-next/index/storage_initialize.js b/snippets/storage-next/index/storage_initialize.js index 61ad21be..422df3dd 100644 --- a/snippets/storage-next/index/storage_initialize.js +++ b/snippets/storage-next/index/storage_initialize.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_initialize_modular] import { initializeApp } from "firebase/app"; diff --git a/snippets/storage-next/index/storage_multiple_buckets.js b/snippets/storage-next/index/storage_multiple_buckets.js index 1022299b..426dd4f4 100644 --- a/snippets/storage-next/index/storage_multiple_buckets.js +++ b/snippets/storage-next/index/storage_multiple_buckets.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_multiple_buckets_modular] import { getApp } from "firebase/app"; diff --git a/snippets/storage-next/index/storage_on_complete.js b/snippets/storage-next/index/storage_on_complete.js index aa3edca8..e5d792f3 100644 --- a/snippets/storage-next/index/storage_on_complete.js +++ b/snippets/storage-next/index/storage_on_complete.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/index.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_on_complete_modular] import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; diff --git a/snippets/storage-next/list-files/storage_list_all.js b/snippets/storage-next/list-files/storage_list_all.js index 1adf935a..11e72e9e 100644 --- a/snippets/storage-next/list-files/storage_list_all.js +++ b/snippets/storage-next/list-files/storage_list_all.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/list-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_list_all_modular] import { getStorage, ref, listAll } from "firebase/storage"; diff --git a/snippets/storage-next/list-files/storage_list_paginate.js b/snippets/storage-next/list-files/storage_list_paginate.js index d04cd1d3..c7dd314e 100644 --- a/snippets/storage-next/list-files/storage_list_paginate.js +++ b/snippets/storage-next/list-files/storage_list_paginate.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/list-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_list_paginate_modular] import { getStorage, ref, list } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_manage_uploads.js b/snippets/storage-next/upload-files/storage_manage_uploads.js index 2623e8a1..0eaf008a 100644 --- a/snippets/storage-next/upload-files/storage_manage_uploads.js +++ b/snippets/storage-next/upload-files/storage_manage_uploads.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_manage_uploads_modular] import { getStorage, ref, uploadBytesResumable } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_monitor_upload.js b/snippets/storage-next/upload-files/storage_monitor_upload.js index 101f509a..cf035832 100644 --- a/snippets/storage-next/upload-files/storage_monitor_upload.js +++ b/snippets/storage-next/upload-files/storage_monitor_upload.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_monitor_upload_modular] import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_upload_blob.js b/snippets/storage-next/upload-files/storage_upload_blob.js index c33593cb..5ad22f8e 100644 --- a/snippets/storage-next/upload-files/storage_upload_blob.js +++ b/snippets/storage-next/upload-files/storage_upload_blob.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_upload_blob_modular] import { getStorage, ref, uploadBytes } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_upload_bytes.js b/snippets/storage-next/upload-files/storage_upload_bytes.js index ebf12e66..82acac25 100644 --- a/snippets/storage-next/upload-files/storage_upload_bytes.js +++ b/snippets/storage-next/upload-files/storage_upload_bytes.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_upload_bytes_modular] import { getStorage, ref, uploadBytes } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_upload_handle_error.js b/snippets/storage-next/upload-files/storage_upload_handle_error.js index 434fc230..bf50c6b5 100644 --- a/snippets/storage-next/upload-files/storage_upload_handle_error.js +++ b/snippets/storage-next/upload-files/storage_upload_handle_error.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_upload_handle_error_modular] import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_upload_metadata.js b/snippets/storage-next/upload-files/storage_upload_metadata.js index 1ac39783..3dd304b4 100644 --- a/snippets/storage-next/upload-files/storage_upload_metadata.js +++ b/snippets/storage-next/upload-files/storage_upload_metadata.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_upload_metadata_modular] import { getStorage, ref, uploadBytes } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_upload_ref.js b/snippets/storage-next/upload-files/storage_upload_ref.js index e776120d..ef565bf2 100644 --- a/snippets/storage-next/upload-files/storage_upload_ref.js +++ b/snippets/storage-next/upload-files/storage_upload_ref.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_upload_ref_modular] import { getStorage, ref } from "firebase/storage"; diff --git a/snippets/storage-next/upload-files/storage_upload_string.js b/snippets/storage-next/upload-files/storage_upload_string.js index ce0d4736..6450a566 100644 --- a/snippets/storage-next/upload-files/storage_upload_string.js +++ b/snippets/storage-next/upload-files/storage_upload_string.js @@ -1,7 +1,8 @@ // This snippet file was generated by processing the source file: // ./storage-next/upload-files.js // -// To make edits to the snippets in this file, please edit the source +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. // [START storage_upload_string_modular] import { getStorage, ref, uploadString } from "firebase/storage"; From ccf43903c930d121980e3f9ec2208160318d6dca Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 30 Jul 2021 09:01:37 +0000 Subject: [PATCH 110/170] Auto-update dependencies. (#211) --- analytics/package.json | 2 +- appcheck/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 57c16836..78c425e7 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/appcheck/package.json b/appcheck/package.json index cf7d82b3..7208eddf 100644 --- a/appcheck/package.json +++ b/appcheck/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/auth/package.json b/auth/package.json index f8a0c4de..95ed84c2 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.8.0", + "firebase": "^8.8.1", "firebaseui": "^4.8.1" } } diff --git a/database/package.json b/database/package.json index d26b77fb..356597c4 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index fd76176d..65e8ce77 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/firestore/package.json b/firestore/package.json index 400d854f..b831157a 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0", + "firebase": "^8.8.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 78ddd20e..c2ad0aa1 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/installations/package.json b/installations/package.json index 948ad208..412aade6 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/messaging/package.json b/messaging/package.json index 3d9ea607..35a95be2 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/perf/package.json b/perf/package.json index c928467c..d6f57401 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 781f8363..8d5f02f8 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } diff --git a/storage/package.json b/storage/package.json index 9ab7fd82..18190f7a 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.0" + "firebase": "^8.8.1" } } From 3c57ca857d15e079ffe20a800bc3612e855849a0 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Fri, 30 Jul 2021 14:18:39 +0000 Subject: [PATCH 111/170] Auto-update dependencies. (#212) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 81809b77..107339fc 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 7877457c..65f0aa01 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.8.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.8.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.8.1/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 4126f18e92092c07f8eef2d78314da27822c20f0 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Tue, 3 Aug 2021 13:30:49 +0100 Subject: [PATCH 112/170] Add snippet for Auth Emulator + Google Credential (#213) --- auth-next/emulator-suite.js | 12 ++++++++++++ auth/emulator-suite.js | 11 ++++++++++- .../auth_emulator_google_credential.js | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 snippets/auth-next/emulator-suite/auth_emulator_google_credential.js diff --git a/auth-next/emulator-suite.js b/auth-next/emulator-suite.js index 84d57ed0..66507de3 100644 --- a/auth-next/emulator-suite.js +++ b/auth-next/emulator-suite.js @@ -10,3 +10,15 @@ function emulatorConnect() { // [END auth_emulator_connect] } +function emulatorGoogleCredential() { + // [START auth_emulator_google_credential] + const { getAuth, signInWithCredential, GoogleAuthProvider } = require("firebase/auth"); + + const auth = getAuth(); + signInWithCredential(auth, GoogleAuthProvider.credential( + '{"sub": "abc123", "email": "foo@example.com", "email_verified": true}' + )); + // [END auth_emulator_google_credential] +} + + diff --git a/auth/emulator-suite.js b/auth/emulator-suite.js index 044795a7..b14a72db 100644 --- a/auth/emulator-suite.js +++ b/auth/emulator-suite.js @@ -3,7 +3,16 @@ import "firebase/auth"; function emulatorConnect() { // [START auth_emulator_connect] - var auth = firebase.auth(); + const auth = firebase.auth(); auth.useEmulator("http://localhost:9099"); // [END auth_emulator_connect] } + +function emulatorGoogleCredential() { + // [START auth_emulator_google_credential] + const auth = firebase.auth(); + auth.signInWithCredential(firebase.auth.GoogleAuthProvider.credential( + '{"sub": "abc123", "email": "foo@example.com", "email_verified": true}' + )); + // [END auth_emulator_google_credential] +} diff --git a/snippets/auth-next/emulator-suite/auth_emulator_google_credential.js b/snippets/auth-next/emulator-suite/auth_emulator_google_credential.js new file mode 100644 index 00000000..d3683bb0 --- /dev/null +++ b/snippets/auth-next/emulator-suite/auth_emulator_google_credential.js @@ -0,0 +1,14 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/emulator-suite.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_emulator_google_credential_modular] +import { getAuth, signInWithCredential, GoogleAuthProvider } from "firebase/auth"; + +const auth = getAuth(); +signInWithCredential(auth, GoogleAuthProvider.credential( + '{"sub": "abc123", "email": "foo@example.com", "email_verified": true}' +)); +// [END auth_emulator_google_credential_modular] \ No newline at end of file From eee411f0580eb061e4c6eeabf9b4fd8aac9b49ab Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Tue, 3 Aug 2021 13:42:34 +0100 Subject: [PATCH 113/170] Update to vNext Beta 8 (#214) --- analytics-next/package.json | 2 +- appcheck-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- firestore-next/test.firestore.js | 4 ++-- firestore-next/test.solution-aggregation.js | 4 ++-- firestore-next/test.solution-arrays.js | 6 +++--- firestore-next/test.solution-bundles.js | 4 ++-- firestore-next/test.solution-counters.js | 4 ++-- firestore-next/test.solution-geoqueries.js | 4 ++-- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- .../query_in_category_timestamp_invalid.js | 2 +- storage-next/package.json | 2 +- 18 files changed, 25 insertions(+), 25 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index b04876cb..94d9a07e 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/appcheck-next/package.json b/appcheck-next/package.json index 8fc601eb..9a7a71bb 100644 --- a/appcheck-next/package.json +++ b/appcheck-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/auth-next/package.json b/auth-next/package.json index 1a955b2a..68d38869 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/database-next/package.json b/database-next/package.json index a6c12500..1c21a0e6 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index daeaf862..4eec0161 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index fe0e5390..f15f2ed0 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7", + "firebase": "^9.0.0-beta.8", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 7dca3d0e..71c54b95 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -32,9 +32,9 @@ const cityConverter = { // [END city_custom_object] describe("firestore", () => { - const { FirebaseFirestore } = require("firebase/firestore"); + const { Firestore } = require("firebase/firestore"); - /** @type {FirebaseFirestore} */ + /** @type {Firestore} */ let db; let app; diff --git a/firestore-next/test.solution-aggregation.js b/firestore-next/test.solution-aggregation.js index c0a825b5..7106a0c9 100644 --- a/firestore-next/test.solution-aggregation.js +++ b/firestore-next/test.solution-aggregation.js @@ -10,9 +10,9 @@ const arinellDoc = { // [END sample_doc] describe("firestore-solution-arrays", () => { - const { FirebaseFirestore } = require("firebase/firestore"); + const { Firestore } = require("firebase/firestore"); - /** @type {FirebaseFirestore} */ + /** @type {Firestore} */ let db; before(async () => { diff --git a/firestore-next/test.solution-arrays.js b/firestore-next/test.solution-arrays.js index 3ca186ac..3746a8d1 100644 --- a/firestore-next/test.solution-arrays.js +++ b/firestore-next/test.solution-arrays.js @@ -44,9 +44,9 @@ const postsWithMapAdvanced = [ ]; describe("firestore-solution-arrays", () => { - const { FirebaseFirestore } = require("firebase/firestore"); + const { Firestore } = require("firebase/firestore"); - /** @type {FirebaseFirestore} */ + /** @type {Firestore} */ let db; before(() => { @@ -78,7 +78,7 @@ describe("firestore-solution-arrays", () => { it("should query in a category by timestamp", () => { function queryOne() { // [START query_in_category_timestamp_invalid] - const { collection, query, where, orderBy, FirebaseFirestore } = require("firebase/firestore"); + const { collection, query, where, orderBy, Firestore } = require("firebase/firestore"); const q = query(collection(db, "posts"), where("categories.cats", "==", true), diff --git a/firestore-next/test.solution-bundles.js b/firestore-next/test.solution-bundles.js index 400aeeb8..94bf7ff2 100644 --- a/firestore-next/test.solution-bundles.js +++ b/firestore-next/test.solution-bundles.js @@ -1,10 +1,10 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -const { FirebaseFirestore } = require('firebase/firestore'); +const { Firestore } = require('firebase/firestore'); /** - * @type FirebaseFirestore + * @type Firestore */ var db; diff --git a/firestore-next/test.solution-counters.js b/firestore-next/test.solution-counters.js index ec671731..da854797 100644 --- a/firestore-next/test.solution-counters.js +++ b/firestore-next/test.solution-counters.js @@ -1,9 +1,9 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -const { FirebaseFirestore } = require('firebase/firestore'); +const { Firestore } = require('firebase/firestore'); -/** @type {FirebaseFirestore} */ +/** @type {Firestore} */ let db; // [START create_counter] diff --git a/firestore-next/test.solution-geoqueries.js b/firestore-next/test.solution-geoqueries.js index 1293229e..507c6178 100644 --- a/firestore-next/test.solution-geoqueries.js +++ b/firestore-next/test.solution-geoqueries.js @@ -1,11 +1,11 @@ // [SNIPPET_REGISTRY disabled] // [SNIPPETS_SEPARATION enabled] -const { FirebaseFirestore } = require('firebase/firestore'); +const { Firestore } = require('firebase/firestore'); const geofire = require('geofire-common'); -/** @type {FirebaseFirestore} */ +/** @type {Firestore} */ let db; async function addHash(done) { diff --git a/functions-next/package.json b/functions-next/package.json index 38a60b6f..8e0e6422 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index cb9c10c3..2137e3e2 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/perf-next/package.json b/perf-next/package.json index 7ff11967..9321e3c8 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index eaa7272d..6f8e1636 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } diff --git a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js index c387ac2d..f50dc17c 100644 --- a/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js +++ b/snippets/firestore-next/test-solution-arrays/query_in_category_timestamp_invalid.js @@ -5,7 +5,7 @@ // 'npm run snippets'. // [START query_in_category_timestamp_invalid_modular] -import { collection, query, where, orderBy, FirebaseFirestore } from "firebase/firestore"; +import { collection, query, where, orderBy, Firestore } from "firebase/firestore"; const q = query(collection(db, "posts"), where("categories.cats", "==", true), diff --git a/storage-next/package.json b/storage-next/package.json index a912d510..6aca1112 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.7" + "firebase": "^9.0.0-beta.8" } } From dc5474c6b5375edc700485e1d49a007e9605be7b Mon Sep 17 00:00:00 2001 From: ochui princewill patrick Date: Mon, 9 Aug 2021 13:35:57 +0100 Subject: [PATCH 114/170] Fix broken link (#217) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b6f50ee..b45ac156 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repository holds code snippets used in Web documentation on [firebase.google.com](https://firebase.google.com/docs/). -These snippets are part of our documentation and best read in the context of a documentation page rather than used directly. If you're looking to get started with the Firebase Web SDK the best place to start is [quicstart-web](https://github.com/firebase/quickstart-web). +These snippets are part of our documentation and best read in the context of a documentation page rather than used directly. If you're looking to get started with the Firebase Web SDK the best place to start is [quickstart-js](https://github.com/firebase/quickstart-js). ## Example From 981c7a5040fd42cd5b1c87e3035d4748b6e8f62e Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 10 Aug 2021 11:09:49 -0700 Subject: [PATCH 115/170] Auto-update dependencies. (#215) --- analytics/package.json | 2 +- appcheck/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 78c425e7..9f18a1f0 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/appcheck/package.json b/appcheck/package.json index 7208eddf..d1f53982 100644 --- a/appcheck/package.json +++ b/appcheck/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/auth/package.json b/auth/package.json index 95ed84c2..d8178118 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.8.1", + "firebase": "^8.9.1", "firebaseui": "^4.8.1" } } diff --git a/database/package.json b/database/package.json index 356597c4..728b0f7a 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index 65e8ce77..dfe2745d 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/firestore/package.json b/firestore/package.json index b831157a..e91ee858 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1", + "firebase": "^8.9.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index c2ad0aa1..9861def8 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/installations/package.json b/installations/package.json index 412aade6..c8cb6019 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/messaging/package.json b/messaging/package.json index 35a95be2..a20a9ff1 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/perf/package.json b/perf/package.json index d6f57401..c30e4855 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 8d5f02f8..1d1da529 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } diff --git a/storage/package.json b/storage/package.json index 18190f7a..76392f55 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.8.1" + "firebase": "^8.9.1" } } From 955170d907dab12502a8e50967a698f93caa1705 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Tue, 10 Aug 2021 11:12:51 -0700 Subject: [PATCH 116/170] Auto-update dependencies. (#216) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 107339fc..bc24d2b8 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 65f0aa01..9b768ff4 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.8.1/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.9.1/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.9.1/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 91b44d995445cbe69c0c38e78afcfa9f38a2db39 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Tue, 10 Aug 2021 19:16:48 +0100 Subject: [PATCH 117/170] Analytics screenView snippet (#191) --- analytics-next/index.js | 15 +++++++++++++++ analytics/index.js | 12 ++++++++++++ .../index/analytics_record_screen_view.js | 15 +++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 snippets/analytics-next/index/analytics_record_screen_view.js diff --git a/analytics-next/index.js b/analytics-next/index.js index a93de88a..510fa758 100644 --- a/analytics-next/index.js +++ b/analytics-next/index.js @@ -50,3 +50,18 @@ function setUserProperties() { setUserProperties(analytics, { favorite_food: 'apples' }); // [END analytics_set_user_properties] } + +function recordScreenView() { + const screenName = ''; + const screenClass = ''; + + // [START analytics_record_screen_view] + const { getAnalytics, logEvent } = require("firebase/analytics"); + + const analytics = getAnalytics(); + logEvent(analytics, 'screen_view', { + firebase_screen: screenName, + firebase_screen_class: screenClass + }); + // [END analytics_record_screen_view] +} diff --git a/analytics/index.js b/analytics/index.js index f8a0e856..76d2c289 100644 --- a/analytics/index.js +++ b/analytics/index.js @@ -38,3 +38,15 @@ function setUserProperties() { firebase.analytics().setUserProperties({favorite_food: 'apples'}); // [END analytics_set_user_properties] } + +function recordScreenView() { + const screenName = ''; + const screenClass = ''; + + // [START analytics_record_screen_view] + firebase.analytics().logEvent('screen_view', { + firebase_screen: screenName, + firebase_screen_class: screenClass + }); + // [END analytics_record_screen_view] +} diff --git a/snippets/analytics-next/index/analytics_record_screen_view.js b/snippets/analytics-next/index/analytics_record_screen_view.js new file mode 100644 index 00000000..2eef20b3 --- /dev/null +++ b/snippets/analytics-next/index/analytics_record_screen_view.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./analytics-next/index.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START analytics_record_screen_view_modular] +import { getAnalytics, logEvent } from "firebase/analytics"; + +const analytics = getAnalytics(); +logEvent(analytics, 'screen_view', { + firebase_screen: screenName, + firebase_screen_class: screenClass +}); +// [END analytics_record_screen_view_modular] \ No newline at end of file From c5bfca32e881d7a40002285384a784749f973c35 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Thu, 12 Aug 2021 17:57:59 +0100 Subject: [PATCH 118/170] Perf initialize snippets (#219) --- perf-next/index.js | 4 +++- perf/index.js | 2 ++ snippets/perf-next/index/perf_imports.js | 10 ++++++++++ snippets/perf-next/index/perf_initialize.js | 3 --- 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 snippets/perf-next/index/perf_imports.js diff --git a/perf-next/index.js b/perf-next/index.js index 20f9b4f4..892f2b7e 100644 --- a/perf-next/index.js +++ b/perf-next/index.js @@ -4,10 +4,12 @@ const perf = getInstance(); function intialize() { - // [START perf_initialize] + // [START perf_imports] const { initializeApp } = require("firebase/app"); const { getPerformance } = require("firebase/performance"); + // [END perf_imports] + // [START perf_initialize] // TODO: Replace the following with your app's Firebase project configuration // See: https://firebase.google.com/docs/web/setup#config-object const firebaseConfig = { diff --git a/perf/index.js b/perf/index.js index 6d512e32..e4b46286 100644 --- a/perf/index.js +++ b/perf/index.js @@ -1,5 +1,7 @@ +// [START perf_imports] import firebase from "firebase/app"; import "firebase/performance"; +// [END perf_imports] const perf = firebase.performance(); diff --git a/snippets/perf-next/index/perf_imports.js b/snippets/perf-next/index/perf_imports.js new file mode 100644 index 00000000..83e0205f --- /dev/null +++ b/snippets/perf-next/index/perf_imports.js @@ -0,0 +1,10 @@ +// This snippet file was generated by processing the source file: +// ./perf-next/index.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START perf_imports_modular] +import { initializeApp } from "firebase/app"; +import { getPerformance } from "firebase/performance"; +// [END perf_imports_modular] \ No newline at end of file diff --git a/snippets/perf-next/index/perf_initialize.js b/snippets/perf-next/index/perf_initialize.js index 3b87e9c8..6d0e6657 100644 --- a/snippets/perf-next/index/perf_initialize.js +++ b/snippets/perf-next/index/perf_initialize.js @@ -5,9 +5,6 @@ // 'npm run snippets'. // [START perf_initialize_modular] -import { initializeApp } from "firebase/app"; -import { getPerformance } from "firebase/performance"; - // TODO: Replace the following with your app's Firebase project configuration // See: https://firebase.google.com/docs/web/setup#config-object const firebaseConfig = { From 0f582bcff452ee6312a42127e1138153d0e351e8 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Tue, 17 Aug 2021 19:28:17 +0100 Subject: [PATCH 119/170] Granular perf initialization snippets (#223) --- perf-next/index.js | 16 ++++++++++------ perf/index.js | 16 ++++++++++------ .../index/{perf_imports.js => perf_import.js} | 5 ++--- snippets/perf-next/index/perf_import_app.js | 9 +++++++++ ...perf_initialize.js => perf_initialize_app.js} | 9 +++------ snippets/perf-next/index/perf_singleton.js | 10 ++++++++++ 6 files changed, 44 insertions(+), 21 deletions(-) rename snippets/perf-next/index/{perf_imports.js => perf_import.js} (69%) create mode 100644 snippets/perf-next/index/perf_import_app.js rename snippets/perf-next/index/{perf_initialize.js => perf_initialize_app.js} (64%) create mode 100644 snippets/perf-next/index/perf_singleton.js diff --git a/perf-next/index.js b/perf-next/index.js index 892f2b7e..83fce95c 100644 --- a/perf-next/index.js +++ b/perf-next/index.js @@ -4,12 +4,14 @@ const perf = getInstance(); function intialize() { - // [START perf_imports] + // [START perf_import_app] const { initializeApp } = require("firebase/app"); + // [END perf_import_app] + // [START perf_import] const { getPerformance } = require("firebase/performance"); - // [END perf_imports] + // [END perf_import] - // [START perf_initialize] + // [START perf_initialize_app] // TODO: Replace the following with your app's Firebase project configuration // See: https://firebase.google.com/docs/web/setup#config-object const firebaseConfig = { @@ -17,11 +19,13 @@ function intialize() { }; // Initialize Firebase - const app = initializeApp(firebaseConfig); + initializeApp(firebaseConfig); + // [END perf_initialize_app] + // [START perf_singleton] // Initialize Performance Monitoring and get a reference to the service - const perf = getPerformance(app); - // [END perf_initialize] + const perf = getPerformance(); + // [END perf_singleton] } export function getInstance() { diff --git a/perf/index.js b/perf/index.js index e4b46286..d1d61202 100644 --- a/perf/index.js +++ b/perf/index.js @@ -1,24 +1,28 @@ -// [START perf_imports] +// [START perf_import_app] import firebase from "firebase/app"; +// [END perf_import_app] +// [START perf_import] import "firebase/performance"; -// [END perf_imports] +// [END perf_import] const perf = firebase.performance(); function intialize() { - // [START perf_initialize] + // [START perf_initialize_app] // TODO: Replace the following with your app's Firebase project configuration // See: https://firebase.google.com/docs/web/setup#config-object - var firebaseConfig = { + const firebaseConfig = { // ... }; // Initialize Firebase firebase.initializeApp(firebaseConfig); + // [END perf_initialize_app] + // [START perf_singleton] // Initialize Performance Monitoring and get a reference to the service - var perf = firebase.performance(); - // [END perf_initialize] + const perf = firebase.performance(); + // [END perf_singleton] } function addCustomTrace() { diff --git a/snippets/perf-next/index/perf_imports.js b/snippets/perf-next/index/perf_import.js similarity index 69% rename from snippets/perf-next/index/perf_imports.js rename to snippets/perf-next/index/perf_import.js index 83e0205f..326afe91 100644 --- a/snippets/perf-next/index/perf_imports.js +++ b/snippets/perf-next/index/perf_import.js @@ -4,7 +4,6 @@ // To update the snippets in this file, edit the source and then run // 'npm run snippets'. -// [START perf_imports_modular] -import { initializeApp } from "firebase/app"; +// [START perf_import_modular] import { getPerformance } from "firebase/performance"; -// [END perf_imports_modular] \ No newline at end of file +// [END perf_import_modular] \ No newline at end of file diff --git a/snippets/perf-next/index/perf_import_app.js b/snippets/perf-next/index/perf_import_app.js new file mode 100644 index 00000000..c2b640b9 --- /dev/null +++ b/snippets/perf-next/index/perf_import_app.js @@ -0,0 +1,9 @@ +// This snippet file was generated by processing the source file: +// ./perf-next/index.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START perf_import_app_modular] +import { initializeApp } from "firebase/app"; +// [END perf_import_app_modular] \ No newline at end of file diff --git a/snippets/perf-next/index/perf_initialize.js b/snippets/perf-next/index/perf_initialize_app.js similarity index 64% rename from snippets/perf-next/index/perf_initialize.js rename to snippets/perf-next/index/perf_initialize_app.js index 6d0e6657..74f23a66 100644 --- a/snippets/perf-next/index/perf_initialize.js +++ b/snippets/perf-next/index/perf_initialize_app.js @@ -4,7 +4,7 @@ // To update the snippets in this file, edit the source and then run // 'npm run snippets'. -// [START perf_initialize_modular] +// [START perf_initialize_app_modular] // TODO: Replace the following with your app's Firebase project configuration // See: https://firebase.google.com/docs/web/setup#config-object const firebaseConfig = { @@ -12,8 +12,5 @@ const firebaseConfig = { }; // Initialize Firebase -const app = initializeApp(firebaseConfig); - -// Initialize Performance Monitoring and get a reference to the service -const perf = getPerformance(app); -// [END perf_initialize_modular] \ No newline at end of file +initializeApp(firebaseConfig); +// [END perf_initialize_app_modular] \ No newline at end of file diff --git a/snippets/perf-next/index/perf_singleton.js b/snippets/perf-next/index/perf_singleton.js new file mode 100644 index 00000000..38ccb439 --- /dev/null +++ b/snippets/perf-next/index/perf_singleton.js @@ -0,0 +1,10 @@ +// This snippet file was generated by processing the source file: +// ./perf-next/index.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START perf_singleton_modular] +// Initialize Performance Monitoring and get a reference to the service +const perf = getPerformance(); +// [END perf_singleton_modular] \ No newline at end of file From 3b929e7ac15a1cb6d363a7fe85f2ba2bb09fae87 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 19 Aug 2021 07:38:34 -0700 Subject: [PATCH 120/170] Auto-update dependencies. (#225) --- auth/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/package.json b/auth/package.json index d8178118..3dddb07e 100644 --- a/auth/package.json +++ b/auth/package.json @@ -7,6 +7,6 @@ "license": "Apache 2.0", "dependencies": { "firebase": "^8.9.1", - "firebaseui": "^4.8.1" + "firebaseui": "^5.0.0" } } From 17620db63cdef986b41b020fccc7bb98f9890858 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Fri, 20 Aug 2021 20:40:05 +0100 Subject: [PATCH 121/170] Multiproject snippets (#228) --- firebaseapp-next/firebaseapp.js | 58 +++++++++++++++++++ firebaseapp/firebaseapp.js | 54 ++++++++++++++++- .../firebaseapp/app_default_init_options.js | 24 ++++++++ .../app_multi_project_init_options.js | 28 +++++++++ 4 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 snippets/firebaseapp-next/firebaseapp/app_default_init_options.js create mode 100644 snippets/firebaseapp-next/firebaseapp/app_multi_project_init_options.js diff --git a/firebaseapp-next/firebaseapp.js b/firebaseapp-next/firebaseapp.js index 8bd6838f..54aa3137 100644 --- a/firebaseapp-next/firebaseapp.js +++ b/firebaseapp-next/firebaseapp.js @@ -25,3 +25,61 @@ function multpleFirebaseApps() { // getDatabase(secondaryApp) // [END firebase_secondary] } + +function defaultInitOptions() { + const firebaseConfig = { + // ... + }; + + // [START app_default_init_options] + const { initializeApp } = require("firebase/app"); + const { getStorage } = require("firebase/storage"); + const { getFirestore } = require("firebase/firestore"); + + // Initialize Firebase with a "default" Firebase project + const defaultProject = initializeApp(firebaseConfig); + + console.log(defaultProject.name); // "[DEFAULT]" + + // Option 1: Access Firebase services via the defaultProject variable + let defaultStorage = getStorage(defaultProject); + let defaultFirestore = getFirestore(defaultProject); + + // Option 2: Access Firebase services using shorthand notation + defaultStorage = getStorage(); + defaultFirestore = getFirestore(); + // [END app_default_init_options] +} + +function multiProjectInitOptions() { + const firebaseConfig = { + // ... + }; + + const otherProjectFirebaseConfig = { + // ... + }; + + // [START app_multi_project_init_options] + const { initializeApp, getApp } = require("firebase/app"); + const { getStorage } = require("firebase/storage"); + const { getFirestore } = require("firebase/firestore"); + + // Initialize Firebase with a default Firebase project + initializeApp(firebaseConfig); + + // Initialize Firebase with a second Firebase project + const otherProject = initializeApp(otherProjectFirebaseConfig, "other"); + + console.log(getApp().name); // "[DEFAULT]" + console.log(otherProject.name); // "otherProject" + + // Use the shorthand notation to access the default project's Firebase services + const defaultStorage = getStorage(); + const defaultFirestore = getFirestore(); + + // Use the otherProject variable to access the second project's Firebase services + const otherStorage = getStorage(otherProject); + const otherFirestore = getFirestore(otherProject); + // [END app_multi_project_init_options] +} diff --git a/firebaseapp/firebaseapp.js b/firebaseapp/firebaseapp.js index 88eedd46..e030583f 100644 --- a/firebaseapp/firebaseapp.js +++ b/firebaseapp/firebaseapp.js @@ -6,7 +6,7 @@ function multpleFirebaseApps() { // - Project ID // - App ID // - API Key - var secondaryAppConfig = { + const secondaryAppConfig = { projectId: "", appId: "", apiKey: "", @@ -17,8 +17,58 @@ function multpleFirebaseApps() { // [START firebase_secondary] // Initialize another app with a different config - var secondaryApp = firebase.initializeApp(secondaryAppConfig, "secondary"); + const secondaryApp = firebase.initializeApp(secondaryAppConfig, "secondary"); // Access services, such as the Realtime Database // secondaryApp.database(); // [END firebase_secondary] } + +function defaultInitOptions() { + const firebaseConfig = { + // ... + }; + + // [START app_default_init_options] + // Initialize Firebase with a "default" Firebase project + const defaultProject = firebase.initializeApp(firebaseConfig); + + console.log(defaultProject.name); // "[DEFAULT]" + + // Option 1: Access Firebase services via the defaultProject variable + let defaultStorage = defaultProject.storage(); + let defaultFirestore = defaultProject.firestore(); + + // Option 2: Access Firebase services using shorthand notation + defaultStorage = firebase.storage(); + defaultFirestore = firebase.firestore(); + // [END app_default_init_options] +} + +function multiProjectInitOptions() { + const firebaseConfig = { + // ... + }; + + const otherProjectFirebaseConfig = { + // ... + }; + + // [START app_multi_project_init_options] + // Initialize Firebase with a default Firebase project + firebase.initializeApp(firebaseConfig); + + // Initialize Firebase with a second Firebase project + const otherProject = firebase.initializeApp(otherProjectFirebaseConfig, "other"); + + console.log(firebase.app().name); // "[DEFAULT]" + console.log(otherProject.name); // "otherProject" + + // Use the shorthand notation to access the default project's Firebase services + const defaultStorage = firebase.storage(); + const defaultFirestore = firebase.firestore(); + + // Use the otherProject variable to access the second project's Firebase services + const otherStorage = otherProject.storage(); + const otherFirestore = otherProject.firestore(); + // [END app_multi_project_init_options] +} diff --git a/snippets/firebaseapp-next/firebaseapp/app_default_init_options.js b/snippets/firebaseapp-next/firebaseapp/app_default_init_options.js new file mode 100644 index 00000000..7cebaaf3 --- /dev/null +++ b/snippets/firebaseapp-next/firebaseapp/app_default_init_options.js @@ -0,0 +1,24 @@ +// This snippet file was generated by processing the source file: +// ./firebaseapp-next/firebaseapp.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START app_default_init_options_modular] +import { initializeApp } from "firebase/app"; +import { getStorage } from "firebase/storage"; +import { getFirestore } from "firebase/firestore"; + +// Initialize Firebase with a "default" Firebase project +const defaultProject = initializeApp(firebaseConfig); + +console.log(defaultProject.name); // "[DEFAULT]" + +// Option 1: Access Firebase services via the defaultProject variable +let defaultStorage = getStorage(defaultProject); +let defaultFirestore = getFirestore(defaultProject); + +// Option 2: Access Firebase services using shorthand notation +defaultStorage = getStorage(); +defaultFirestore = getFirestore(); +// [END app_default_init_options_modular] \ No newline at end of file diff --git a/snippets/firebaseapp-next/firebaseapp/app_multi_project_init_options.js b/snippets/firebaseapp-next/firebaseapp/app_multi_project_init_options.js new file mode 100644 index 00000000..415f8813 --- /dev/null +++ b/snippets/firebaseapp-next/firebaseapp/app_multi_project_init_options.js @@ -0,0 +1,28 @@ +// This snippet file was generated by processing the source file: +// ./firebaseapp-next/firebaseapp.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START app_multi_project_init_options_modular] +import { initializeApp, getApp } from "firebase/app"; +import { getStorage } from "firebase/storage"; +import { getFirestore } from "firebase/firestore"; + +// Initialize Firebase with a default Firebase project +initializeApp(firebaseConfig); + +// Initialize Firebase with a second Firebase project +const otherProject = initializeApp(otherProjectFirebaseConfig, "other"); + +console.log(getApp().name); // "[DEFAULT]" +console.log(otherProject.name); // "otherProject" + +// Use the shorthand notation to access the default project's Firebase services +const defaultStorage = getStorage(); +const defaultFirestore = getFirestore(); + +// Use the otherProject variable to access the second project's Firebase services +const otherStorage = getStorage(otherProject); +const otherFirestore = getFirestore(otherProject); +// [END app_multi_project_init_options_modular] \ No newline at end of file From c14985f96b28797b53c8b4ac09da9e34666b2279 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 23 Aug 2021 06:41:39 -0700 Subject: [PATCH 122/170] Auto-update dependencies. (#226) --- analytics/package.json | 2 +- appcheck/package.json | 2 +- auth/package.json | 2 +- database/package.json | 2 +- firebaseapp/package.json | 2 +- firestore/package.json | 2 +- functions/package.json | 2 +- installations/package.json | 2 +- messaging/package.json | 2 +- perf/package.json | 2 +- remoteconfig/package.json | 2 +- storage/package.json | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 9f18a1f0..b344a8a6 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/appcheck/package.json b/appcheck/package.json index d1f53982..d9d819fa 100644 --- a/appcheck/package.json +++ b/appcheck/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/auth/package.json b/auth/package.json index 3dddb07e..a6827027 100644 --- a/auth/package.json +++ b/auth/package.json @@ -6,7 +6,7 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.9.1", + "firebase": "^8.10.0", "firebaseui": "^5.0.0" } } diff --git a/database/package.json b/database/package.json index 728b0f7a..ea21b973 100644 --- a/database/package.json +++ b/database/package.json @@ -6,6 +6,6 @@ }, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/firebaseapp/package.json b/firebaseapp/package.json index dfe2745d..5226e2a0 100644 --- a/firebaseapp/package.json +++ b/firebaseapp/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/firestore/package.json b/firestore/package.json index e91ee858..73bbb88c 100644 --- a/firestore/package.json +++ b/firestore/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1", + "firebase": "^8.10.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions/package.json b/functions/package.json index 9861def8..653086c9 100644 --- a/functions/package.json +++ b/functions/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/installations/package.json b/installations/package.json index c8cb6019..1395fca3 100644 --- a/installations/package.json +++ b/installations/package.json @@ -4,6 +4,6 @@ "scripts": {}, "license": "Apache 2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/messaging/package.json b/messaging/package.json index a20a9ff1..96a5720d 100644 --- a/messaging/package.json +++ b/messaging/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/perf/package.json b/perf/package.json index c30e4855..61906b8e 100644 --- a/perf/package.json +++ b/perf/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/remoteconfig/package.json b/remoteconfig/package.json index 1d1da529..8437cbd2 100644 --- a/remoteconfig/package.json +++ b/remoteconfig/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } diff --git a/storage/package.json b/storage/package.json index 76392f55..e27166e7 100644 --- a/storage/package.json +++ b/storage/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^8.9.1" + "firebase": "^8.10.0" } } From b9d79df57c4add61ad92995e6e73ba744280af28 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 23 Aug 2021 06:44:47 -0700 Subject: [PATCH 123/170] Auto-update dependencies. (#227) --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index bc24d2b8..ddc3c44d 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 9b768ff4..3b2f7de0 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.9.1/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.9.1/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 81fcf30888909936d4898421e858da809f8cf595 Mon Sep 17 00:00:00 2001 From: rachelsaunders <52258509+rachelsaunders@users.noreply.github.com> Date: Mon, 23 Aug 2021 17:07:10 -0400 Subject: [PATCH 124/170] [perf] make initialize & get singleton lines more explicit for vNext (#229) --- perf-next/index.js | 6 +++--- perf/index.js | 2 +- snippets/perf-next/index/perf_initialize_app.js | 4 ++-- snippets/perf-next/index/perf_singleton.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/perf-next/index.js b/perf-next/index.js index 83fce95c..e41aa1b0 100644 --- a/perf-next/index.js +++ b/perf-next/index.js @@ -13,18 +13,18 @@ function intialize() { // [START perf_initialize_app] // TODO: Replace the following with your app's Firebase project configuration - // See: https://firebase.google.com/docs/web/setup#config-object + // See: https://firebase.google.com/docs/web/learn-more#config-object const firebaseConfig = { // ... }; // Initialize Firebase - initializeApp(firebaseConfig); + const app = initializeApp(firebaseConfig); // [END perf_initialize_app] // [START perf_singleton] // Initialize Performance Monitoring and get a reference to the service - const perf = getPerformance(); + const perf = getPerformance(app); // [END perf_singleton] } diff --git a/perf/index.js b/perf/index.js index d1d61202..c5ae8b22 100644 --- a/perf/index.js +++ b/perf/index.js @@ -10,7 +10,7 @@ const perf = firebase.performance(); function intialize() { // [START perf_initialize_app] // TODO: Replace the following with your app's Firebase project configuration - // See: https://firebase.google.com/docs/web/setup#config-object + // See: https://firebase.google.com/docs/web/learn-more#config-object const firebaseConfig = { // ... }; diff --git a/snippets/perf-next/index/perf_initialize_app.js b/snippets/perf-next/index/perf_initialize_app.js index 74f23a66..94e0c966 100644 --- a/snippets/perf-next/index/perf_initialize_app.js +++ b/snippets/perf-next/index/perf_initialize_app.js @@ -6,11 +6,11 @@ // [START perf_initialize_app_modular] // TODO: Replace the following with your app's Firebase project configuration -// See: https://firebase.google.com/docs/web/setup#config-object +// See: https://firebase.google.com/docs/web/learn-more#config-object const firebaseConfig = { // ... }; // Initialize Firebase -initializeApp(firebaseConfig); +const app = initializeApp(firebaseConfig); // [END perf_initialize_app_modular] \ No newline at end of file diff --git a/snippets/perf-next/index/perf_singleton.js b/snippets/perf-next/index/perf_singleton.js index 38ccb439..e070b52b 100644 --- a/snippets/perf-next/index/perf_singleton.js +++ b/snippets/perf-next/index/perf_singleton.js @@ -6,5 +6,5 @@ // [START perf_singleton_modular] // Initialize Performance Monitoring and get a reference to the service -const perf = getPerformance(); +const perf = getPerformance(app); // [END perf_singleton_modular] \ No newline at end of file From 5371e900366afbd9fae7352f4be05250ab95966c Mon Sep 17 00:00:00 2001 From: Jeff <3759507+jhuleatt@users.noreply.github.com> Date: Tue, 7 Sep 2021 14:13:52 -0400 Subject: [PATCH 125/170] Update build tools and upgrade CI to node 14 (#237) --- .github/workflows/test.yml | 2 +- package.json | 10 +++++----- scripts/separate-snippets.ts | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3eddc3bd..ee2c87f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: node-version: - - 12.x + - 14.x steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 diff --git a/package.json b/package.json index e7621ce2..cb7d9157 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ }, "license": "Apache-2.0", "devDependencies": { - "@types/node": "^15.12.2", - "eslint": "^7.16.0", - "pnpm": "^6.7.4", + "@types/node": "^16.7.10", + "eslint": "^7.32.0", + "pnpm": "^6.14.6", "rimraf": "^3.0.2", - "ts-node": "^9.0.0", - "typescript": "^3.8.3" + "ts-node": "^10.2.1", + "typescript": "^4.4.2" } } diff --git a/scripts/separate-snippets.ts b/scripts/separate-snippets.ts index 86821383..ff93a58f 100644 --- a/scripts/separate-snippets.ts +++ b/scripts/separate-snippets.ts @@ -171,12 +171,15 @@ function collectSnippets(filePath: string): SnippetsConfig { const suffixLine = lines.find((l) => !!l.match(RE_SNIPPETS_SUFFIX)); if (suffixLine) { const m = suffixLine.match(RE_SNIPPETS_SUFFIX); - config.suffix = m[1]; + + if (m && m[1]) { + config.suffix = m[1]; + } } // A temporary array holding the names of snippets we're currently within. // This allows for handling nested snippets. - let inSnippetNames = []; + let inSnippetNames: string[] = []; for (const line of lines) { const startMatch = line.match(RE_START_SNIPPET); From ea048bf1d3b845f9497fdddca82e4db8eee99d81 Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Tue, 7 Sep 2021 19:17:08 +0100 Subject: [PATCH 126/170] Move to v9 stable release (#234) --- analytics-next/package.json | 2 +- appcheck-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index 94d9a07e..6dd68b8a 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/appcheck-next/package.json b/appcheck-next/package.json index 9a7a71bb..ad511f74 100644 --- a/appcheck-next/package.json +++ b/appcheck-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/auth-next/package.json b/auth-next/package.json index 68d38869..4f5685b2 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/database-next/package.json b/database-next/package.json index 1c21a0e6..47fb5f09 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 4eec0161..d4426033 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index f15f2ed0..38b07b6d 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8", + "firebase": "^9.0.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index 8e0e6422..73194f1c 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 2137e3e2..b4ad1c0f 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/perf-next/package.json b/perf-next/package.json index 9321e3c8..70f81332 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index 6f8e1636..2f3e3350 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } diff --git a/storage-next/package.json b/storage-next/package.json index 6aca1112..3032a7e9 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0-beta.8" + "firebase": "^9.0.0" } } From 2b9c3212d3844d394f8d98f30cadc03fdef8c2f5 Mon Sep 17 00:00:00 2001 From: Jeff <3759507+jhuleatt@users.noreply.github.com> Date: Tue, 7 Sep 2021 14:23:21 -0400 Subject: [PATCH 127/170] [messaging] Change import in service worker (#224) --- messaging-next/service-worker.js | 2 +- snippets/messaging-next/service-worker/messaging_init_in_sw.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/messaging-next/service-worker.js b/messaging-next/service-worker.js index ce0ac6b8..a81a7c18 100644 --- a/messaging-next/service-worker.js +++ b/messaging-next/service-worker.js @@ -16,7 +16,7 @@ let self; function initInSw() { // [START messaging_init_in_sw] const { initializeApp } = require("firebase/app"); - const { getMessaging } = require("firebase/messaging"); + const { getMessaging } = require("firebase/messaging/sw"); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. diff --git a/snippets/messaging-next/service-worker/messaging_init_in_sw.js b/snippets/messaging-next/service-worker/messaging_init_in_sw.js index abce8e1d..42f0f526 100644 --- a/snippets/messaging-next/service-worker/messaging_init_in_sw.js +++ b/snippets/messaging-next/service-worker/messaging_init_in_sw.js @@ -6,7 +6,7 @@ // [START messaging_init_in_sw_modular] import { initializeApp } from "firebase/app"; -import { getMessaging } from "firebase/messaging"; +import { getMessaging } from "firebase/messaging/sw"; // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 1e8f41c904d557f486cdab2a1401ec5f6033dc39 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Wed, 22 Sep 2021 05:19:15 -0700 Subject: [PATCH 128/170] Auto-update dependencies. (#232) * Auto-update dependencies. * switch to compat Co-authored-by: Jeff <3759507+jhuleatt@users.noreply.github.com> --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index ddc3c44d..34d7708d 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 3b2f7de0..38628112 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/9.0.2/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From d5241e7ae8b9c015a03f2822c490bfe8b107d2f2 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 30 Sep 2021 13:00:16 -0700 Subject: [PATCH 129/170] Auto-update dependencies. (#239) * Auto-update dependencies. * move legacy back to v8 Co-authored-by: Jeff <3759507+jhuleatt@users.noreply.github.com> --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index 34d7708d..ddc3c44d 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 38628112..3b2f7de0 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/9.0.2/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 50d5bdce71c1495104199f18d83a03c13f4bf190 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 30 Sep 2021 13:06:16 -0700 Subject: [PATCH 130/170] Auto-update dependencies. (#231) * Auto-update dependencies. * keep all non-next folders on 8 Co-authored-by: Jeff <3759507+jhuleatt@users.noreply.github.com> --- analytics-next/package.json | 2 +- appcheck-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index 6dd68b8a..d0955d16 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/appcheck-next/package.json b/appcheck-next/package.json index ad511f74..7c84b7df 100644 --- a/appcheck-next/package.json +++ b/appcheck-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/auth-next/package.json b/auth-next/package.json index 4f5685b2..53d964a2 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/database-next/package.json b/database-next/package.json index 47fb5f09..175d6c63 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index d4426033..88dd8954 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 38b07b6d..2c95f580 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0", + "firebase": "^9.1.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index 73194f1c..4ddfe8c3 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index b4ad1c0f..fe28f50e 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/perf-next/package.json b/perf-next/package.json index 70f81332..69cf753b 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index 2f3e3350..8a072847 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } diff --git a/storage-next/package.json b/storage-next/package.json index 3032a7e9..fbce56ec 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.0.0" + "firebase": "^9.1.0" } } From dc8dcdd5148aa14cf59c8fbcb3c1c2476f7a3643 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 1 Oct 2021 12:27:04 -0700 Subject: [PATCH 131/170] Add snippets for custom dependencies doc (#243) * Snippets for custom dependencies doc * Add app dependency --- auth-next/custom-dependencies.js | 58 +++++++++++++++++++ .../auth_get_auth_equivalent.js | 16 +++++ .../auth_only_browser_local.js | 16 +++++ .../auth_only_indexed_db.js | 16 +++++ .../auth_sign_in_redirect_manual_deps.js | 18 ++++++ 5 files changed, 124 insertions(+) create mode 100644 auth-next/custom-dependencies.js create mode 100644 snippets/auth-next/custom-dependencies/auth_get_auth_equivalent.js create mode 100644 snippets/auth-next/custom-dependencies/auth_only_browser_local.js create mode 100644 snippets/auth-next/custom-dependencies/auth_only_indexed_db.js create mode 100644 snippets/auth-next/custom-dependencies/auth_sign_in_redirect_manual_deps.js diff --git a/auth-next/custom-dependencies.js b/auth-next/custom-dependencies.js new file mode 100644 index 00000000..209b6767 --- /dev/null +++ b/auth-next/custom-dependencies.js @@ -0,0 +1,58 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +// Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/custom-dependencies.md + +function getAuthEquivalent() { + // [START auth_get_auth_equivalent] + const {initializeAuth, browserLocalPersistence, browserPopupRedirectResolver, browserSessionPersistence, indexedDBLocalPersistence} = require("firebase/auth"); + const {initializeApp} = require("firebase/app"); + + const app = initializeApp({/** Your app config */}); + const auth = initializeAuth(app, { + persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence], + popupRedirectResolver: browserPopupRedirectResolver, + }); + // [END auth_get_auth_equivalent] +} + +function onlyBrowserLocal() { + // [START auth_only_browser_local] + const {initializeAuth, browserLocalPersistence} = require("firebase/auth"); + const {initializeApp} = require("firebase/app"); + + const app = initializeApp({/** Your app config */}); + const auth = initializeAuth(app, { + persistence: browserLocalPersistence, + // No popupRedirectResolver defined + }); + // [END auth_only_browser_local] +} + +function onlyIndexedDB() { + // [START auth_only_indexed_db] + const {initializeAuth, indexedDBLocalPersistence} = require("firebase/auth"); + const {initializeApp} = require("firebase/app"); + + const app = initializeApp({/** Your app config */}); + const auth = initializeAuth(app, { + persistence: indexedDBLocalPersistence, + // No popupRedirectResolver defined + }); + // [END auth_only_indexed_db] +} + +function signInRedirectManualDeps() { + // [START auth_sign_in_redirect_manual_deps] + const {initializeAuth, browserLocalPersistence, browserPopupRedirectResolver, indexedDBLocalPersistence, signInWithRedirect, GoogleAuthProvider} = require("firebase/auth"); + const {initializeApp} = require("firebase/app"); + + const app = initializeApp({/** Your app config */}); + const auth = initializeAuth(app, { + persistence: [indexedDBLocalPersistence, browserLocalPersistence], + }); + + // Later + signInWithRedirect(auth, new GoogleAuthProvider(), browserPopupRedirectResolver); + // [END auth_sign_in_redirect_manual_deps] +} \ No newline at end of file diff --git a/snippets/auth-next/custom-dependencies/auth_get_auth_equivalent.js b/snippets/auth-next/custom-dependencies/auth_get_auth_equivalent.js new file mode 100644 index 00000000..37292487 --- /dev/null +++ b/snippets/auth-next/custom-dependencies/auth_get_auth_equivalent.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/custom-dependencies.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_get_auth_equivalent_modular] +import {initializeAuth, browserLocalPersistence, browserPopupRedirectResolver, browserSessionPersistence, indexedDBLocalPersistence} from "firebase/auth"; +import {initializeApp} from "firebase/app"; + +const app = initializeApp({/** Your app config */}); +const auth = initializeAuth(app, { + persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence], + popupRedirectResolver: browserPopupRedirectResolver, +}); +// [END auth_get_auth_equivalent_modular] \ No newline at end of file diff --git a/snippets/auth-next/custom-dependencies/auth_only_browser_local.js b/snippets/auth-next/custom-dependencies/auth_only_browser_local.js new file mode 100644 index 00000000..549307ac --- /dev/null +++ b/snippets/auth-next/custom-dependencies/auth_only_browser_local.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/custom-dependencies.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_only_browser_local_modular] +import {initializeAuth, browserLocalPersistence} from "firebase/auth"; +import {initializeApp} from "firebase/app"; + +const app = initializeApp({/** Your app config */}); +const auth = initializeAuth(app, { + persistence: browserLocalPersistence, + // No popupRedirectResolver defined +}); +// [END auth_only_browser_local_modular] \ No newline at end of file diff --git a/snippets/auth-next/custom-dependencies/auth_only_indexed_db.js b/snippets/auth-next/custom-dependencies/auth_only_indexed_db.js new file mode 100644 index 00000000..1427ae6b --- /dev/null +++ b/snippets/auth-next/custom-dependencies/auth_only_indexed_db.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/custom-dependencies.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_only_indexed_db_modular] +import {initializeAuth, indexedDBLocalPersistence} from "firebase/auth"; +import {initializeApp} from "firebase/app"; + +const app = initializeApp({/** Your app config */}); +const auth = initializeAuth(app, { + persistence: indexedDBLocalPersistence, + // No popupRedirectResolver defined +}); +// [END auth_only_indexed_db_modular] \ No newline at end of file diff --git a/snippets/auth-next/custom-dependencies/auth_sign_in_redirect_manual_deps.js b/snippets/auth-next/custom-dependencies/auth_sign_in_redirect_manual_deps.js new file mode 100644 index 00000000..75fd0d5d --- /dev/null +++ b/snippets/auth-next/custom-dependencies/auth_sign_in_redirect_manual_deps.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/custom-dependencies.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_sign_in_redirect_manual_deps_modular] +import {initializeAuth, browserLocalPersistence, browserPopupRedirectResolver, indexedDBLocalPersistence, signInWithRedirect, GoogleAuthProvider} from "firebase/auth"; +import {initializeApp} from "firebase/app"; + +const app = initializeApp({/** Your app config */}); +const auth = initializeAuth(app, { + persistence: [indexedDBLocalPersistence, browserLocalPersistence], +}); + +// Later +signInWithRedirect(auth, new GoogleAuthProvider(), browserPopupRedirectResolver); +// [END auth_sign_in_redirect_manual_deps_modular] \ No newline at end of file From fdc51dd76f7c8f31d107b2dc27100c28e0318431 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 5 Oct 2021 10:51:03 -0700 Subject: [PATCH 132/170] Fix import path for Cordova (#240) --- auth-next/cordova.js | 6 +++--- snippets/auth-next/cordova/auth_cordova_redirect_result.js | 2 +- snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js | 2 +- snippets/auth-next/cordova/auth_create_google_provider.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/auth-next/cordova.js b/auth-next/cordova.js index 1823b33c..ff91dfcc 100644 --- a/auth-next/cordova.js +++ b/auth-next/cordova.js @@ -5,7 +5,7 @@ function createGoogleProvider() { // [START auth_create_google_provider] - const { GoogleAuthProvider } = require("firebase/auth"); + const { GoogleAuthProvider } = require("firebase/auth/cordova"); const provider = new GoogleAuthProvider(); // [END auth_create_google_provider] @@ -13,7 +13,7 @@ function createGoogleProvider() { function cordovaSignInRedirect() { // [START auth_cordova_sign_in_redirect] - const { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } = require("firebase/auth"); + const { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } = require("firebase/auth/cordova"); const auth = getAuth(); signInWithRedirect(auth, new GoogleAuthProvider()) @@ -40,7 +40,7 @@ function cordovaSignInRedirect() { function cordovaRedirectResult() { // [START auth_cordova_redirect_result] - const { getAuth, getRedirectResult, GoogleAuthProvider } = require("firebase/auth"); + const { getAuth, getRedirectResult, GoogleAuthProvider } = require("firebase/auth/cordova"); const auth = getAuth(); getRedirectResult(auth) diff --git a/snippets/auth-next/cordova/auth_cordova_redirect_result.js b/snippets/auth-next/cordova/auth_cordova_redirect_result.js index 7bcc69a3..f1c87596 100644 --- a/snippets/auth-next/cordova/auth_cordova_redirect_result.js +++ b/snippets/auth-next/cordova/auth_cordova_redirect_result.js @@ -5,7 +5,7 @@ // 'npm run snippets'. // [START auth_cordova_redirect_result_modular] -import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; +import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth/cordova"; const auth = getAuth(); getRedirectResult(auth) diff --git a/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js b/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js index 5aaee22d..ed3cc8d1 100644 --- a/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js +++ b/snippets/auth-next/cordova/auth_cordova_sign_in_redirect.js @@ -5,7 +5,7 @@ // 'npm run snippets'. // [START auth_cordova_sign_in_redirect_modular] -import { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; +import { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } from "firebase/auth/cordova"; const auth = getAuth(); signInWithRedirect(auth, new GoogleAuthProvider()) diff --git a/snippets/auth-next/cordova/auth_create_google_provider.js b/snippets/auth-next/cordova/auth_create_google_provider.js index aab60312..fcf96401 100644 --- a/snippets/auth-next/cordova/auth_create_google_provider.js +++ b/snippets/auth-next/cordova/auth_create_google_provider.js @@ -5,7 +5,7 @@ // 'npm run snippets'. // [START auth_create_google_provider_modular] -import { GoogleAuthProvider } from "firebase/auth"; +import { GoogleAuthProvider } from "firebase/auth/cordova"; const provider = new GoogleAuthProvider(); // [END auth_create_google_provider_modular] \ No newline at end of file From 5062c76ac28473ed47e87abf9369590c979ef088 Mon Sep 17 00:00:00 2001 From: Ian Tay Date: Fri, 15 Oct 2021 12:01:07 -0700 Subject: [PATCH 133/170] Add SAML provider snippets. (#246) * Add SAML provider snippets. This is a Google Cloud Identity Platform provider. * Add OIDC provider snippets. This is a Google Cloud Identity Platform provider. * add generated snippets --- auth-next/oidc.js | 96 +++++++++++++++++++ auth-next/saml.js | 68 +++++++++++++ auth/oidc.js | 71 ++++++++++++++ auth/saml.js | 56 +++++++++++ .../oidc/auth_oidc_direct_sign_in.js | 31 ++++++ .../oidc/auth_oidc_provider_create.js | 11 +++ .../auth-next/oidc/auth_oidc_signin_popup.js | 27 ++++++ .../oidc/auth_oidc_signin_redirect.js | 12 +++ .../oidc/auth_oidc_signin_redirect_result.js | 28 ++++++ .../saml/auth_saml_provider_create.js | 11 +++ .../auth-next/saml/auth_saml_signin_popup.js | 27 ++++++ .../saml/auth_saml_signin_redirect.js | 12 +++ .../saml/auth_saml_signin_redirect_result.js | 28 ++++++ .../auth/oidc/auth_oidc_direct_sign_in.js | 19 ++++ .../auth/oidc/auth_oidc_provider_create.js | 9 ++ snippets/auth/oidc/auth_oidc_signin_popup.js | 18 ++++ .../auth/oidc/auth_oidc_signin_redirect.js | 11 +++ .../oidc/auth_oidc_signin_redirect_result.js | 20 ++++ .../auth/saml/auth_saml_provider_create.js | 9 ++ snippets/auth/saml/auth_saml_signin_popup.js | 21 ++++ .../auth/saml/auth_saml_signin_redirect.js | 9 ++ .../saml/auth_saml_signin_redirect_result.js | 20 ++++ 22 files changed, 614 insertions(+) create mode 100644 auth-next/oidc.js create mode 100644 auth-next/saml.js create mode 100644 auth/oidc.js create mode 100644 auth/saml.js create mode 100644 snippets/auth-next/oidc/auth_oidc_direct_sign_in.js create mode 100644 snippets/auth-next/oidc/auth_oidc_provider_create.js create mode 100644 snippets/auth-next/oidc/auth_oidc_signin_popup.js create mode 100644 snippets/auth-next/oidc/auth_oidc_signin_redirect.js create mode 100644 snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js create mode 100644 snippets/auth-next/saml/auth_saml_provider_create.js create mode 100644 snippets/auth-next/saml/auth_saml_signin_popup.js create mode 100644 snippets/auth-next/saml/auth_saml_signin_redirect.js create mode 100644 snippets/auth-next/saml/auth_saml_signin_redirect_result.js create mode 100644 snippets/auth/oidc/auth_oidc_direct_sign_in.js create mode 100644 snippets/auth/oidc/auth_oidc_provider_create.js create mode 100644 snippets/auth/oidc/auth_oidc_signin_popup.js create mode 100644 snippets/auth/oidc/auth_oidc_signin_redirect.js create mode 100644 snippets/auth/oidc/auth_oidc_signin_redirect_result.js create mode 100644 snippets/auth/saml/auth_saml_provider_create.js create mode 100644 snippets/auth/saml/auth_saml_signin_popup.js create mode 100644 snippets/auth/saml/auth_saml_signin_redirect.js create mode 100644 snippets/auth/saml/auth_saml_signin_redirect_result.js diff --git a/auth-next/oidc.js b/auth-next/oidc.js new file mode 100644 index 00000000..5dc20e81 --- /dev/null +++ b/auth-next/oidc.js @@ -0,0 +1,96 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function oidcProvider() { + // [START auth_oidc_provider_create] + const { OAuthProvider } = require("firebase/auth"); + + const provider = new OAuthProvider("oidc.myProvider"); + // [END auth_oidc_provider_create] +} + +function oidcSignInPopup(provider) { + // [START auth_oidc_signin_popup] + const { getAuth, signInWithPopup, OAuthProvider } = require("firebase/auth"); + + const auth = getAuth(); + signInWithPopup(auth, provider) + .then((result) => { + // User is signed in. + const credential = OAuthProvider.credentialFromResult(result); + // This gives you an access token for the OIDC provider. You can use it to directly interact with that provider + }).catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = OAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); + // [END auth_oidc_signin_popup] +} + +function oidcSignInRedirect(provider) { + // [START auth_oidc_signin_redirect] + const { getAuth, signInWithRedirect } = require("firebase/auth"); + + const auth = getAuth(); + signInWithRedirect(auth, provider); + // [END auth_oidc_signin_redirect] +} + +function oidcSignInRedirectResult(provider) { + // [START auth_oidc_signin_redirect_result] + const { getAuth, getRedirectResult, OAuthProvider } = require("firebase/auth"); + + const auth = getAuth(); + getRedirectResult(auth) + .then((result) => { + // User is signed in. + const credential = OAuthProvider.credentialFromResult(result); + // This gives you an access token for the OIDC provider. You can use it to directly interact with that provider + }) + .catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = OAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); + // [END auth_oidc_signin_redirect_result] +} + +function oidcDirectSignIn(provider, oidcIdToken) { + // [START auth_oidc_direct_sign_in] + const { getAuth, OAuthProvider, signInWithCredential } = require("firebase/auth"); + + const auth = getAuth(); + const credential = provider.credential({ + idToken: oidcIdToken, + }); + signInWithCredential(auth, credential) + .then((result) => { + // User is signed in. + const newCredential = OAuthProvider.credentialFromResult(result); + // This gives you a new access token for the OIDC provider. You can use it to directly interact with that provider. + }) + .catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = OAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); + // [END auth_oidc_direct_sign_in] +} \ No newline at end of file diff --git a/auth-next/saml.js b/auth-next/saml.js new file mode 100644 index 00000000..9a5683d9 --- /dev/null +++ b/auth-next/saml.js @@ -0,0 +1,68 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function samlProvider() { + // [START auth_saml_provider_create] + const { SAMLAuthProvider } = require("firebase/auth"); + + const provider = new SAMLAuthProvider("saml.myProvider"); + // [END auth_saml_provider_create] +} + +function samlSignInPopup(provider) { + // [START auth_saml_signin_popup] + const { getAuth, signInWithPopup, SAMLAuthProvider } = require("firebase/auth"); + + const auth = getAuth(); + signInWithPopup(auth, provider) + .then((result) => { + // User is signed in. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }).catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = SAMLAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); + // [END auth_saml_signin_popup] +} + +function samlSignInRedirect(provider) { + // [START auth_saml_signin_redirect] + const { getAuth, signInWithRedirect } = require("firebase/auth"); + + const auth = getAuth(); + signInWithRedirect(auth, provider); + // [END auth_saml_signin_redirect] +} + +function samlSignInRedirectResult(provider) { + // [START auth_saml_signin_redirect_result] + const { getAuth, getRedirectResult, SAMLAuthProvider } = require("firebase/auth"); + + const auth = getAuth(); + getRedirectResult(auth) + .then((result) => { + // User is signed in. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }) + .catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = SAMLAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); + // [END auth_saml_signin_redirect_result] +} \ No newline at end of file diff --git a/auth/oidc.js b/auth/oidc.js new file mode 100644 index 00000000..4c056e52 --- /dev/null +++ b/auth/oidc.js @@ -0,0 +1,71 @@ +// These samples are intended for Web so this import would normally be +// done in HTML however using modules here is more convenient for +// ensuring sample correctness offline. +import firebase from "firebase/app"; +import "firebase/auth"; + +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function oidcProvider() { + // [START auth_oidc_provider_create] + const provider = new firebase.auth.OAuthProvider('oidc.myProvider'); + // [END auth_oidc_provider_create] +} + +function oidcSignInPopup(provider) { + // [START auth_oidc_signin_popup] + firebase.auth().signInWithPopup(provider) + .then((result) => { + // User is signed in. + // result.credential is a firebase.auth().OAuthCredential object. + // result.credential.providerId is equal to 'oidc.myProvider'. + // result.credential.idToken is the OIDC provider's ID token. + }) + .catch((error) => { + // Handle error. + }); + // [END auth_oidc_signin_popup] +} + +function oidcSignInRedirect(provider) { + // [START auth_oidc_signin_redirect] + firebase.auth().signInWithRedirect(provider).catch((error) => { + // Handle error. + }); + // [END auth_oidc_signin_redirect] +} + +function oidcSignInRedirectResult(provider) { + // [START auth_oidc_signin_redirect_result] + // On return. + firebase.auth().getRedirectResult() + .then((result) => { + // User is signed in. + // result.credential is a firebase.auth().OAuthCredential object. + // result.credential.providerId is equal to 'oidc.myProvider'. + // result.credential.idToken is the OIDC provider's ID token. + }) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END auth_oidc_signin_redirect_result] +} + +function oidcDirectSignIn(provider, oidcIdToken) { + // [START auth_oidc_direct_sign_in] + const credential = provider.credential(oidcIdToken, null); + + firebase.auth().signInWithCredential(credential) + .then((result) => { + // User is signed in. + // User now has a odic.myProvider UserInfo in providerData. + }) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END auth_oidc_direct_sign_in] +} + diff --git a/auth/saml.js b/auth/saml.js new file mode 100644 index 00000000..a55b691c --- /dev/null +++ b/auth/saml.js @@ -0,0 +1,56 @@ +// These samples are intended for Web so this import would normally be +// done in HTML however using modules here is more convenient for +// ensuring sample correctness offline. +import firebase from "firebase/app"; +import "firebase/auth"; + +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function samlProvider() { + // [START auth_saml_provider_create] + const provider = new firebase.auth.SAMLAuthProvider('saml.myProvider'); + // [END auth_saml_provider_create] +} + +function samlSignInPopup(provider) { + // [START auth_saml_signin_popup] + firebase.auth().signInWithPopup(provider) + .then((result) => { + // User is signed in. + // Identity provider data available in result.additionalUserInfo.profile, + // or from the user's ID token obtained from result.user.getIdToken() + // as an object in the firebase.sign_in_attributes custom claim + // This is also available from result.user.getIdTokenResult() + // idTokenResult.claims.firebase.sign_in_attributes. + }) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END auth_saml_signin_popup] +} + +function samlSignInRedirect(provider) { + // [START auth_saml_signin_redirect] + firebase.auth().signInWithRedirect(provider); + // [END auth_saml_signin_redirect] +} + +function samlSignInRedirectResult(provider) { + // [START auth_saml_signin_redirect_result] + firebase.auth().getRedirectResult() + .then((result) => { + // User is signed in. + // Provider data available in result.additionalUserInfo.profile, + // or from the user's ID token obtained from result.user.getIdToken() + // as an object in the firebase.sign_in_attributes custom claim + // This is also available from result.user.getIdTokenResult() + // idTokenResult.claims.firebase.sign_in_attributes. + }).catch((error) => { + // Handle / display error. + // ... + }); + // [END auth_saml_signin_redirect_result] +} + diff --git a/snippets/auth-next/oidc/auth_oidc_direct_sign_in.js b/snippets/auth-next/oidc/auth_oidc_direct_sign_in.js new file mode 100644 index 00000000..65f693a6 --- /dev/null +++ b/snippets/auth-next/oidc/auth_oidc_direct_sign_in.js @@ -0,0 +1,31 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_direct_sign_in_modular] +import { getAuth, OAuthProvider, signInWithCredential } from "firebase/auth"; + +const auth = getAuth(); +const credential = provider.credential({ + idToken: oidcIdToken, +}); +signInWithCredential(auth, credential) + .then((result) => { + // User is signed in. + const newCredential = OAuthProvider.credentialFromResult(result); + // This gives you a new access token for the OIDC provider. You can use it to directly interact with that provider. + }) + .catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = OAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); +// [END auth_oidc_direct_sign_in_modular] \ No newline at end of file diff --git a/snippets/auth-next/oidc/auth_oidc_provider_create.js b/snippets/auth-next/oidc/auth_oidc_provider_create.js new file mode 100644 index 00000000..ce1846b9 --- /dev/null +++ b/snippets/auth-next/oidc/auth_oidc_provider_create.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_provider_create_modular] +import { OAuthProvider } from "firebase/auth"; + +const provider = new OAuthProvider("oidc.myProvider"); +// [END auth_oidc_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth-next/oidc/auth_oidc_signin_popup.js b/snippets/auth-next/oidc/auth_oidc_signin_popup.js new file mode 100644 index 00000000..76b01b1d --- /dev/null +++ b/snippets/auth-next/oidc/auth_oidc_signin_popup.js @@ -0,0 +1,27 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_signin_popup_modular] +import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth"; + +const auth = getAuth(); +signInWithPopup(auth, provider) + .then((result) => { + // User is signed in. + const credential = OAuthProvider.credentialFromResult(result); + // This gives you an access token for the OIDC provider. You can use it to directly interact with that provider + }).catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = OAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); +// [END auth_oidc_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth-next/oidc/auth_oidc_signin_redirect.js b/snippets/auth-next/oidc/auth_oidc_signin_redirect.js new file mode 100644 index 00000000..2038d116 --- /dev/null +++ b/snippets/auth-next/oidc/auth_oidc_signin_redirect.js @@ -0,0 +1,12 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_signin_redirect_modular] +import { getAuth, signInWithRedirect } from "firebase/auth"; + +const auth = getAuth(); +signInWithRedirect(auth, provider); +// [END auth_oidc_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js b/snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js new file mode 100644 index 00000000..ae5a441d --- /dev/null +++ b/snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js @@ -0,0 +1,28 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_signin_redirect_result_modular] +import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth"; + +const auth = getAuth(); +getRedirectResult(auth) + .then((result) => { + // User is signed in. + const credential = OAuthProvider.credentialFromResult(result); + // This gives you an access token for the OIDC provider. You can use it to directly interact with that provider + }) + .catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = OAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); +// [END auth_oidc_signin_redirect_result_modular] \ No newline at end of file diff --git a/snippets/auth-next/saml/auth_saml_provider_create.js b/snippets/auth-next/saml/auth_saml_provider_create.js new file mode 100644 index 00000000..e492d490 --- /dev/null +++ b/snippets/auth-next/saml/auth_saml_provider_create.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_provider_create_modular] +import { SAMLAuthProvider } from "firebase/auth"; + +const provider = new SAMLAuthProvider("saml.myProvider"); +// [END auth_saml_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth-next/saml/auth_saml_signin_popup.js b/snippets/auth-next/saml/auth_saml_signin_popup.js new file mode 100644 index 00000000..8010a17b --- /dev/null +++ b/snippets/auth-next/saml/auth_saml_signin_popup.js @@ -0,0 +1,27 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_signin_popup_modular] +import { getAuth, signInWithPopup, SAMLAuthProvider } from "firebase/auth"; + +const auth = getAuth(); +signInWithPopup(auth, provider) + .then((result) => { + // User is signed in. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }).catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = SAMLAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); +// [END auth_saml_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth-next/saml/auth_saml_signin_redirect.js b/snippets/auth-next/saml/auth_saml_signin_redirect.js new file mode 100644 index 00000000..619af67f --- /dev/null +++ b/snippets/auth-next/saml/auth_saml_signin_redirect.js @@ -0,0 +1,12 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_signin_redirect_modular] +import { getAuth, signInWithRedirect } from "firebase/auth"; + +const auth = getAuth(); +signInWithRedirect(auth, provider); +// [END auth_saml_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/saml/auth_saml_signin_redirect_result.js b/snippets/auth-next/saml/auth_saml_signin_redirect_result.js new file mode 100644 index 00000000..4e4d4260 --- /dev/null +++ b/snippets/auth-next/saml/auth_saml_signin_redirect_result.js @@ -0,0 +1,28 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_signin_redirect_result_modular] +import { getAuth, getRedirectResult, SAMLAuthProvider } from "firebase/auth"; + +const auth = getAuth(); +getRedirectResult(auth) + .then((result) => { + // User is signed in. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }) + .catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // The email of the user's account used. + const email = error.email; + // The AuthCredential type that was used. + const credential = SAMLAuthProvider.credentialFromError(error); + // Handle / display error. + // ... + }); +// [END auth_saml_signin_redirect_result_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_direct_sign_in.js b/snippets/auth/oidc/auth_oidc_direct_sign_in.js new file mode 100644 index 00000000..5a0c629d --- /dev/null +++ b/snippets/auth/oidc/auth_oidc_direct_sign_in.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./auth/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_direct_sign_in_modular] +const credential = provider.credential(oidcIdToken, null); + +firebase.auth().signInWithCredential(credential) + .then((result) => { + // User is signed in. + // User now has a odic.myProvider UserInfo in providerData. + }) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END auth_oidc_direct_sign_in_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_provider_create.js b/snippets/auth/oidc/auth_oidc_provider_create.js new file mode 100644 index 00000000..09e08ad8 --- /dev/null +++ b/snippets/auth/oidc/auth_oidc_provider_create.js @@ -0,0 +1,9 @@ +// This snippet file was generated by processing the source file: +// ./auth/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_provider_create_modular] +const provider = new firebase.auth.OAuthProvider('oidc.myProvider'); +// [END auth_oidc_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_popup.js b/snippets/auth/oidc/auth_oidc_signin_popup.js new file mode 100644 index 00000000..c5ff4afa --- /dev/null +++ b/snippets/auth/oidc/auth_oidc_signin_popup.js @@ -0,0 +1,18 @@ +// This snippet file was generated by processing the source file: +// ./auth/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_signin_popup_modular] +firebase.auth().signInWithPopup(provider) + .then((result) => { + // User is signed in. + // result.credential is a firebase.auth().OAuthCredential object. + // result.credential.providerId is equal to 'oidc.myProvider'. + // result.credential.idToken is the OIDC provider's ID token. + }) + .catch((error) => { + // Handle error. + }); +// [END auth_oidc_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_redirect.js b/snippets/auth/oidc/auth_oidc_signin_redirect.js new file mode 100644 index 00000000..4951c4bf --- /dev/null +++ b/snippets/auth/oidc/auth_oidc_signin_redirect.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./auth/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_signin_redirect_modular] +firebase.auth().signInWithRedirect(provider).catch((error) => { + // Handle error. +}); +// [END auth_oidc_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_redirect_result.js b/snippets/auth/oidc/auth_oidc_signin_redirect_result.js new file mode 100644 index 00000000..2cd0eaa7 --- /dev/null +++ b/snippets/auth/oidc/auth_oidc_signin_redirect_result.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./auth/oidc.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_oidc_signin_redirect_result_modular] +// On return. +firebase.auth().getRedirectResult() + .then((result) => { + // User is signed in. + // result.credential is a firebase.auth().OAuthCredential object. + // result.credential.providerId is equal to 'oidc.myProvider'. + // result.credential.idToken is the OIDC provider's ID token. + }) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END auth_oidc_signin_redirect_result_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_provider_create.js b/snippets/auth/saml/auth_saml_provider_create.js new file mode 100644 index 00000000..a9765e5e --- /dev/null +++ b/snippets/auth/saml/auth_saml_provider_create.js @@ -0,0 +1,9 @@ +// This snippet file was generated by processing the source file: +// ./auth/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_provider_create_modular] +const provider = new firebase.auth.SAMLAuthProvider('saml.myProvider'); +// [END auth_saml_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_popup.js b/snippets/auth/saml/auth_saml_signin_popup.js new file mode 100644 index 00000000..1fb3b4f6 --- /dev/null +++ b/snippets/auth/saml/auth_saml_signin_popup.js @@ -0,0 +1,21 @@ +// This snippet file was generated by processing the source file: +// ./auth/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_signin_popup_modular] +firebase.auth().signInWithPopup(provider) + .then((result) => { + // User is signed in. + // Identity provider data available in result.additionalUserInfo.profile, + // or from the user's ID token obtained from result.user.getIdToken() + // as an object in the firebase.sign_in_attributes custom claim + // This is also available from result.user.getIdTokenResult() + // idTokenResult.claims.firebase.sign_in_attributes. + }) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END auth_saml_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_redirect.js b/snippets/auth/saml/auth_saml_signin_redirect.js new file mode 100644 index 00000000..bd328a57 --- /dev/null +++ b/snippets/auth/saml/auth_saml_signin_redirect.js @@ -0,0 +1,9 @@ +// This snippet file was generated by processing the source file: +// ./auth/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_signin_redirect_modular] +firebase.auth().signInWithRedirect(provider); +// [END auth_saml_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_redirect_result.js b/snippets/auth/saml/auth_saml_signin_redirect_result.js new file mode 100644 index 00000000..65a9f38b --- /dev/null +++ b/snippets/auth/saml/auth_saml_signin_redirect_result.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./auth/saml.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_saml_signin_redirect_result_modular] +firebase.auth().getRedirectResult() + .then((result) => { + // User is signed in. + // Provider data available in result.additionalUserInfo.profile, + // or from the user's ID token obtained from result.user.getIdToken() + // as an object in the firebase.sign_in_attributes custom claim + // This is also available from result.user.getIdTokenResult() + // idTokenResult.claims.firebase.sign_in_attributes. + }).catch((error) => { + // Handle / display error. + // ... + }); +// [END auth_saml_signin_redirect_result_modular] \ No newline at end of file From 20d5d980c84eb7f59547b3007dfb518098877248 Mon Sep 17 00:00:00 2001 From: Ian Tay Date: Fri, 15 Oct 2021 13:33:07 -0700 Subject: [PATCH 134/170] add initialization with custom domain code (#247) remove wrong tags (supposed to be for auth-next) --- auth-next/index.js | 16 +++++++++++++- auth/index.js | 11 ++++++++++ auth/oidc.js | 3 --- auth/saml.js | 3 --- .../index/auth_init_custom_domain.js | 17 +++++++++++++++ .../auth/oidc/auth_oidc_direct_sign_in.js | 19 ----------------- .../auth/oidc/auth_oidc_provider_create.js | 9 -------- snippets/auth/oidc/auth_oidc_signin_popup.js | 18 ---------------- .../auth/oidc/auth_oidc_signin_redirect.js | 11 ---------- .../oidc/auth_oidc_signin_redirect_result.js | 20 ------------------ .../auth/saml/auth_saml_provider_create.js | 9 -------- snippets/auth/saml/auth_saml_signin_popup.js | 21 ------------------- .../auth/saml/auth_saml_signin_redirect.js | 9 -------- .../saml/auth_saml_signin_redirect_result.js | 20 ------------------ 14 files changed, 43 insertions(+), 143 deletions(-) create mode 100644 snippets/auth-next/index/auth_init_custom_domain.js delete mode 100644 snippets/auth/oidc/auth_oidc_direct_sign_in.js delete mode 100644 snippets/auth/oidc/auth_oidc_provider_create.js delete mode 100644 snippets/auth/oidc/auth_oidc_signin_popup.js delete mode 100644 snippets/auth/oidc/auth_oidc_signin_redirect.js delete mode 100644 snippets/auth/oidc/auth_oidc_signin_redirect_result.js delete mode 100644 snippets/auth/saml/auth_saml_provider_create.js delete mode 100644 snippets/auth/saml/auth_saml_signin_popup.js delete mode 100644 snippets/auth/saml/auth_saml_signin_redirect.js delete mode 100644 snippets/auth/saml/auth_saml_signin_redirect_result.js diff --git a/auth-next/index.js b/auth-next/index.js index 73d33219..c4dadfe0 100644 --- a/auth-next/index.js +++ b/auth-next/index.js @@ -26,7 +26,7 @@ function makeFacebookCredential(response) { function makeEmailCredential(email, password) { // [START auth_make_email_credential] const { EmailAuthProvider } = require("firebase/auth"); - + const credential = EmailAuthProvider.credential(email, password); // [END auth_make_email_credential] } @@ -121,3 +121,17 @@ function signInRedirect(provider) { signInWithRedirect(auth, provider); // [END auth_signin_redirect] } + +function initializeWithCustomDomain() { + // [START auth_init_custom_domain] + const { initializeApp } = require("firebase/app"); + + const firebaseConfig = { + apiKey: "...", + // By default, authDomain is '[YOUR_APP].firebaseapp.com'. + // You may replace it with a custom domain. + authDomain: '[YOUR_CUSTOM_DOMAIN]' + }; + const firebaseApp = initializeApp(firebaseConfig); + // [END auth_init_custom_domain] +} diff --git a/auth/index.js b/auth/index.js index 6ea5d587..6567c030 100644 --- a/auth/index.js +++ b/auth/index.js @@ -101,3 +101,14 @@ function signInRedirect(provider) { firebase.auth().signInWithRedirect(provider); // [END auth_signin_redirect] } + +function initializeWithCustomDomain() { + // [START auth_init_custom_domain] + firebase.initializeApp({ + apiKey: '...', + // By default, authDomain is '[YOUR_APP].firebaseapp.com'. + // You may replace it with a custom domain. + authDomain: '[YOUR_CUSTOM_DOMAIN]' + }); + // [END auth_init_custom_domain] +} diff --git a/auth/oidc.js b/auth/oidc.js index 4c056e52..e3a3e01e 100644 --- a/auth/oidc.js +++ b/auth/oidc.js @@ -4,9 +4,6 @@ import firebase from "firebase/app"; import "firebase/auth"; -// [SNIPPET_REGISTRY disabled] -// [SNIPPETS_SEPARATION enabled] - function oidcProvider() { // [START auth_oidc_provider_create] const provider = new firebase.auth.OAuthProvider('oidc.myProvider'); diff --git a/auth/saml.js b/auth/saml.js index a55b691c..e3a99cde 100644 --- a/auth/saml.js +++ b/auth/saml.js @@ -4,9 +4,6 @@ import firebase from "firebase/app"; import "firebase/auth"; -// [SNIPPET_REGISTRY disabled] -// [SNIPPETS_SEPARATION enabled] - function samlProvider() { // [START auth_saml_provider_create] const provider = new firebase.auth.SAMLAuthProvider('saml.myProvider'); diff --git a/snippets/auth-next/index/auth_init_custom_domain.js b/snippets/auth-next/index/auth_init_custom_domain.js new file mode 100644 index 00000000..971e5c56 --- /dev/null +++ b/snippets/auth-next/index/auth_init_custom_domain.js @@ -0,0 +1,17 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/index.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_init_custom_domain_modular] +import { initializeApp } from "firebase/app"; + +const firebaseConfig = { + apiKey: "...", + // By default, authDomain is '[YOUR_APP].firebaseapp.com'. + // You may replace it with a custom domain. + authDomain: '[YOUR_CUSTOM_DOMAIN]' +}; +const firebaseApp = initializeApp(firebaseConfig); +// [END auth_init_custom_domain_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_direct_sign_in.js b/snippets/auth/oidc/auth_oidc_direct_sign_in.js deleted file mode 100644 index 5a0c629d..00000000 --- a/snippets/auth/oidc/auth_oidc_direct_sign_in.js +++ /dev/null @@ -1,19 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_direct_sign_in_modular] -const credential = provider.credential(oidcIdToken, null); - -firebase.auth().signInWithCredential(credential) - .then((result) => { - // User is signed in. - // User now has a odic.myProvider UserInfo in providerData. - }) - .catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_oidc_direct_sign_in_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_provider_create.js b/snippets/auth/oidc/auth_oidc_provider_create.js deleted file mode 100644 index 09e08ad8..00000000 --- a/snippets/auth/oidc/auth_oidc_provider_create.js +++ /dev/null @@ -1,9 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_provider_create_modular] -const provider = new firebase.auth.OAuthProvider('oidc.myProvider'); -// [END auth_oidc_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_popup.js b/snippets/auth/oidc/auth_oidc_signin_popup.js deleted file mode 100644 index c5ff4afa..00000000 --- a/snippets/auth/oidc/auth_oidc_signin_popup.js +++ /dev/null @@ -1,18 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_signin_popup_modular] -firebase.auth().signInWithPopup(provider) - .then((result) => { - // User is signed in. - // result.credential is a firebase.auth().OAuthCredential object. - // result.credential.providerId is equal to 'oidc.myProvider'. - // result.credential.idToken is the OIDC provider's ID token. - }) - .catch((error) => { - // Handle error. - }); -// [END auth_oidc_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_redirect.js b/snippets/auth/oidc/auth_oidc_signin_redirect.js deleted file mode 100644 index 4951c4bf..00000000 --- a/snippets/auth/oidc/auth_oidc_signin_redirect.js +++ /dev/null @@ -1,11 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_signin_redirect_modular] -firebase.auth().signInWithRedirect(provider).catch((error) => { - // Handle error. -}); -// [END auth_oidc_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_redirect_result.js b/snippets/auth/oidc/auth_oidc_signin_redirect_result.js deleted file mode 100644 index 2cd0eaa7..00000000 --- a/snippets/auth/oidc/auth_oidc_signin_redirect_result.js +++ /dev/null @@ -1,20 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_signin_redirect_result_modular] -// On return. -firebase.auth().getRedirectResult() - .then((result) => { - // User is signed in. - // result.credential is a firebase.auth().OAuthCredential object. - // result.credential.providerId is equal to 'oidc.myProvider'. - // result.credential.idToken is the OIDC provider's ID token. - }) - .catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_oidc_signin_redirect_result_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_provider_create.js b/snippets/auth/saml/auth_saml_provider_create.js deleted file mode 100644 index a9765e5e..00000000 --- a/snippets/auth/saml/auth_saml_provider_create.js +++ /dev/null @@ -1,9 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_provider_create_modular] -const provider = new firebase.auth.SAMLAuthProvider('saml.myProvider'); -// [END auth_saml_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_popup.js b/snippets/auth/saml/auth_saml_signin_popup.js deleted file mode 100644 index 1fb3b4f6..00000000 --- a/snippets/auth/saml/auth_saml_signin_popup.js +++ /dev/null @@ -1,21 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_signin_popup_modular] -firebase.auth().signInWithPopup(provider) - .then((result) => { - // User is signed in. - // Identity provider data available in result.additionalUserInfo.profile, - // or from the user's ID token obtained from result.user.getIdToken() - // as an object in the firebase.sign_in_attributes custom claim - // This is also available from result.user.getIdTokenResult() - // idTokenResult.claims.firebase.sign_in_attributes. - }) - .catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_saml_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_redirect.js b/snippets/auth/saml/auth_saml_signin_redirect.js deleted file mode 100644 index bd328a57..00000000 --- a/snippets/auth/saml/auth_saml_signin_redirect.js +++ /dev/null @@ -1,9 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_signin_redirect_modular] -firebase.auth().signInWithRedirect(provider); -// [END auth_saml_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_redirect_result.js b/snippets/auth/saml/auth_saml_signin_redirect_result.js deleted file mode 100644 index 65a9f38b..00000000 --- a/snippets/auth/saml/auth_saml_signin_redirect_result.js +++ /dev/null @@ -1,20 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_signin_redirect_result_modular] -firebase.auth().getRedirectResult() - .then((result) => { - // User is signed in. - // Provider data available in result.additionalUserInfo.profile, - // or from the user's ID token obtained from result.user.getIdToken() - // as an object in the firebase.sign_in_attributes custom claim - // This is also available from result.user.getIdTokenResult() - // idTokenResult.claims.firebase.sign_in_attributes. - }).catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_saml_signin_redirect_result_modular] \ No newline at end of file From e2a9d336d42add89bc3f504e4143300adea25685 Mon Sep 17 00:00:00 2001 From: Ian Tay Date: Mon, 18 Oct 2021 16:51:42 -0700 Subject: [PATCH 135/170] add multi-tenancy snippets (#250) --- auth-next/multi-tenancy.js | 347 ++++++++++++++++++ auth/multi-tenancy.js | 312 ++++++++++++++++ .../multitenant_account_exists_popup.js | 44 +++ .../multitenant_account_exists_redirect.js | 51 +++ .../multitenant_account_linking.js | 34 ++ .../multitenant_create_custom_token.js | 20 + .../multitenant_send_emaillink.js | 23 ++ .../multi-tenancy/multitenant_set_tenant.js | 12 + .../multitenant_signin_custom_token.js | 16 + .../multitenant_signin_emaillink.js | 29 ++ .../multitenant_signin_password.js | 19 + .../multitenant_signin_password_demo.js | 33 ++ .../multitenant_signin_saml_popup.js | 25 ++ .../multitenant_signin_saml_redirect.js | 29 ++ .../multitenant_signup_password.js | 19 + .../multitenant_switch_tenant.js | 15 + ...multitenant_switch_tenant_multiinstance.js | 19 + 17 files changed, 1047 insertions(+) create mode 100644 auth-next/multi-tenancy.js create mode 100644 auth/multi-tenancy.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_account_linking.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_create_custom_token.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_send_emaillink.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_set_tenant.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_signin_custom_token.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_signin_emaillink.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_signin_password.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_signin_password_demo.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_signin_saml_popup.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_signin_saml_redirect.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_signup_password.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_switch_tenant.js create mode 100644 snippets/auth-next/multi-tenancy/multitenant_switch_tenant_multiinstance.js diff --git a/auth-next/multi-tenancy.js b/auth-next/multi-tenancy.js new file mode 100644 index 00000000..c0c86662 --- /dev/null +++ b/auth-next/multi-tenancy.js @@ -0,0 +1,347 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function setTenant() { + // [START multitenant_set_tenant] + const { getAuth } = require("firebase/auth"); + const auth = getAuth(); + const tenantId = "TENANT_ID1"; + auth.tenantId = tenantId; + // [END multitenant_set_tenant] +} + +function switchTenantSingleAuth(auth) { + // [START multitenant_switch_tenant] + // One Auth instance + // Switch to tenant1 + auth.tenantId = "TENANT_ID1"; + // Switch to tenant2 + auth.tenantId = "TENANT_ID2"; + // Switch back to project level IdPs + auth.tenantId = null; + // [END multitenant_switch_tenant] +} + +function switchTenantMultiAuth(firebaseConfig1, firebaseConfig2) { + // [START multitenant_switch_tenant_multiinstance] + // Multiple Auth instances + const { initializeApp } = require("firebase/app"); + const { getAuth } = require("firebase/auth"); + const firebaseApp1 = initializeApp(firebaseConfig1, 'app1_for_tenantId1'); + const firebaseApp2 = initializeApp(firebaseConfig2, 'app2_for_tenantId2'); + + const auth1 = getAuth(firebaseApp1); + const auth2 = getAuth(firebaseApp2); + + auth1.tenantId = "TENANT_ID1"; + auth2.tenantId = "TENANT_ID2"; + // [END multitenant_switch_tenant_multiinstance] +} + +function passwordSignInWithTenantDemo(auth, email, password) { + // [START multitenant_signin_password_demo] + const { signInWithEmailAndPassword, onAuthStateChanged } = require("firebase/auth"); + // Switch to TENANT_ID1 + auth.tenantId = 'TENANT_ID1'; + + // Sign in with tenant + signInWithEmailAndPassword(auth, email, password) + .then((userCredential) => { + // User is signed in. + const user = userCredential.user; + // user.tenantId is set to 'TENANT_ID1'. + // Switch to 'TENANT_ID2'. + auth.tenantId = 'TENANT_ID2'; + // auth.currentUser still points to the user. + // auth.currentUser.tenantId is 'TENANT_ID1'. + }); + + // You could also get the current user from Auth state observer. + onAuthStateChanged(auth, (user) => { + if (user) { + // User is signed in. + // user.tenantId is set to 'TENANT_ID1'. + } else { + // No user is signed in. + } + }); + // [END multitenant_signin_password_demo] +} + +function signUpWithTenant(auth, email, password) { + // [START multitenant_signup_password] + const { createUserWithEmailAndPassword } = require("firebase/auth"); + auth.tenantId = 'TENANT_ID'; + + createUserWithEmailAndPassword(auth, email, password) + .then((userCredential) => { + // User is signed in. + // userCredential.user.tenantId is 'TENANT_ID'. + }).catch((error) => { + // Handle / display error. + // ... + }); + // [END multitenant_signup_password] +} + + +function passwordSignInWithTenant(auth, email, password) { + // [START multitenant_signin_password] + const { signInWithEmailAndPassword } = require("firebase/auth"); + auth.tenantId = 'TENANT_ID'; + + signInWithEmailAndPassword(auth, email, password) + .then((userCredential) => { + // User is signed in. + // userCredential.user.tenantId is 'TENANT_ID'. + }).catch((error) => { + // Handle / display error. + // ... + }); + // [END multitenant_signin_password] +} + +function samlSignInPopupTenant(auth, provider) { + // [START multitenant_signin_saml_popup] + const { signInWithPopup } = require("firebase/auth"); + // Switch to TENANT_ID1. + auth.tenantId = 'TENANT_ID1'; + + // Sign-in with popup. + signInWithPopup(auth, provider) + .then((userCredential) => { + // User is signed in. + const user = userCredential.user; + // user.tenantId is set to 'TENANT_ID1'. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END multitenant_signin_saml_popup] +} + +function samlSignInRedirectTenant(auth, provider) { + // [START multitenant_signin_saml_redirect] + const { signInWithRedirect, getRedirectResult } = require("firebase/auth"); + // Switch to TENANT_ID1. + auth.tenantId = 'TENANT_ID1'; + + // Sign-in with redirect. + signInWithRedirect(auth, provider); + + // After the user completes sign-in and returns to the app, you can get + // the sign-in result by calling getRedirectResult. However, if they sign out + // and sign in again with an IdP, no tenant is used. + getRedirectResult(auth) + .then((result) => { + // User is signed in. + // The tenant ID available in result.user.tenantId. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END multitenant_signin_saml_redirect] +} + +function sendSignInLinkToEmailTenant(auth, email, actionCodeSettings) { + // [START multitenant_send_emaillink] + const { sendSignInLinkToEmail } = require("firebase/auth"); + // Switch to TENANT_ID1 + auth.tenantId = 'TENANT_ID1'; + + sendSignInLinkToEmail(auth, email, actionCodeSettings) + .then(() => { + // The link was successfully sent. Inform the user. + // Save the email locally so you don't need to ask the user for it again + // if they open the link on the same device. + window.localStorage.setItem('emailForSignIn', email); + }) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END multitenant_send_emaillink] +} + +function signInWithEmailLinkTenant(auth) { + // [START multitenant_signin_emaillink] + const { isSignInWithEmailLink, parseActionCodeURL, signInWithEmailLink } = require("firebase/auth"); + if (isSignInWithEmailLink(auth, window.location.href)) { + const actionCodeUrl = parseActionCodeURL(window.location.href); + if (actionCodeUrl.tenantId) { + auth.tenantId = actionCodeUrl.tenantId; + } + let email = window.localStorage.getItem('emailForSignIn'); + if (!email) { + // User opened the link on a different device. To prevent session fixation + // attacks, ask the user to provide the associated email again. For example: + email = window.prompt('Please provide your email for confirmation'); + } + // The client SDK will parse the code from the link for you. + signInWithEmailLink(auth, email, window.location.href) + .then((result) => { + // User is signed in. + // tenant ID available in result.user.tenantId. + // Clear email from storage. + window.localStorage.removeItem('emailForSignIn'); + }); + } + // [END multitenant_signin_emaillink] +} + +// Same as the code in auth/ since this is the admin SDK. +function createCustomTokenTenant(admin, uid) { + // [START multitenant_create_custom_token] + // Ensure you're using a tenant-aware auth instance + const tenantManager = admin.auth().tenantManager(); + const tenantAuth = tenantManager.authForTenant('TENANT_ID1'); + + // Create a custom token in the usual manner + tenantAuth.createCustomToken(uid) + .then((customToken) => { + // Send token back to client + }) + .catch((error) => { + console.log('Error creating custom token:', error); + }); + // [END multitenant_create_custom_token] +} + +function signInWithCustomTokenTenant(auth, token) { + // [START multitenant_signin_custom_token] + const { signInWithCustomToken } = require("firebase/auth"); + auth.tenantId = 'TENANT_ID1'; + + signInWithCustomToken(auth, token) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END multitenant_signin_custom_token] +} + +function linkAccountTenant(auth, provider, email, password) { + // [START multitenant_account_linking] + const { signInWithPopup, EmailAuthProvider, linkWithCredential, SAMLAuthProvider, signInWithCredential } = require("firebase/auth"); + // Switch to TENANT_ID1 + auth.tenantId = 'TENANT_ID1'; + + // Sign-in with popup + signInWithPopup(auth, provider) + .then((userCredential) => { + // Existing user with e.g. SAML provider. + const prevUser = userCredential.user; + const emailCredential = + EmailAuthProvider.credential(email, password); + return linkWithCredential(prevUser, emailCredential) + .then((linkResult) => { + // Sign in with the newly linked credential + const linkCredential = SAMLAuthProvider.credentialFromResult(linkResult); + return signInWithCredential(auth, linkCredential); + }) + .then((signInResult) => { + // Handle sign in of merged user + // ... + }); + }) + .catch((error) => { + // Handle / display error. + // ... + }); + // [END multitenant_account_linking] +} + +function accountExistsPopupTenant(auth, samlProvider, googleProvider, goToApp) { + // [START multitenant_account_exists_popup] + const { signInWithPopup, fetchSignInMethodsForEmail, linkWithCredential } = require("firebase/auth"); + // Step 1. + // User tries to sign in to the SAML provider in that tenant. + auth.tenantId = 'TENANT_ID'; + signInWithPopup(auth, samlProvider) + .catch((error) => { + // An error happened. + if (error.code === 'auth/account-exists-with-different-credential') { + // Step 2. + // User's email already exists. + // The pending SAML credential. + const pendingCred = error.credential; + // The credential's tenantId if needed: error.tenantId + // The provider account's email address. + const email = error.email; + // Get sign-in methods for this email. + fetchSignInMethodsForEmail(email, auth) + .then((methods) => { + // Step 3. + // Ask the user to sign in with existing Google account. + if (methods[0] == 'google.com') { + signInWithPopup(auth, googleProvider) + .then((result) => { + // Step 4 + // Link the SAML AuthCredential to the existing user. + linkWithCredential(result.user, pendingCred) + .then((linkResult) => { + // SAML account successfully linked to the existing + // user. + goToApp(); + }); + }); + } + }); + } + }); + // [END multitenant_account_exists_popup] +} + +function accountExistsRedirectTenant(auth, samlProvider, googleProvider, goToApp) { + // [START multitenant_account_exists_redirect] + const { signInWithRedirect, getRedirectResult, fetchSignInMethodsForEmail, linkWithCredential } = require("firebase/auth"); + // Step 1. + // User tries to sign in to SAML provider. + auth.tenantId = 'TENANT_ID'; + signInWithRedirect(auth, samlProvider); + var pendingCred; + // Redirect back from SAML IDP. auth.tenantId is null after redirecting. + getRedirectResult(auth).catch((error) => { + if (error.code === 'auth/account-exists-with-different-credential') { + // Step 2. + // User's email already exists. + const tenantId = error.tenantId; + // The pending SAML credential. + pendingCred = error.credential; + // The provider account's email address. + const email = error.email; + // Need to set the tenant ID again as the page was reloaded and the + // previous setting was reset. + auth.tenantId = tenantId; + // Get sign-in methods for this email. + fetchSignInMethodsForEmail(auth, email) + .then((methods) => { + // Step 3. + // Ask the user to sign in with existing Google account. + if (methods[0] == 'google.com') { + signInWithRedirect(auth, googleProvider); + } + }); + } + }); + + // Redirect back from Google. auth.tenantId is null after redirecting. + getRedirectResult(auth).then((result) => { + // Step 4 + // Link the SAML AuthCredential to the existing user. + // result.user.tenantId is 'TENANT_ID'. + linkWithCredential(result.user, pendingCred) + .then((linkResult) => { + // SAML account successfully linked to the existing + // user. + goToApp(); + }); + }); + // [END multitenant_account_exists_redirect] +} \ No newline at end of file diff --git a/auth/multi-tenancy.js b/auth/multi-tenancy.js new file mode 100644 index 00000000..8afc1a5c --- /dev/null +++ b/auth/multi-tenancy.js @@ -0,0 +1,312 @@ +// These samples are intended for Web so this import would normally be +// done in HTML however using modules here is more convenient for +// ensuring sample correctness offline. +import firebase from "firebase/app"; +import "firebase/auth"; + +function setTenant() { + // [START multitenant_set_tenant] + const tenantId = "TENANT_ID1"; + firebase.auth().tenantId = tenantId; + // [END multitenant_set_tenant] +} + +function switchTenantSingleAuth() { + // [START multitenant_switch_tenant] + // One Auth instance + // Switch to tenant1 + firebase.auth().tenantId = "TENANT_ID1"; + // Switch to tenant2 + firebase.auth().tenantId = "TENANT_ID2"; + // Switch back to project level IdPs + firebase.auth().tenantId = null; + // [END multitenant_switch_tenant] +} + +function switchTenantMultiAuthInstance(config) { + // [START multitenant_switch_tenant_multiinstance] + // Multiple Auth instances + firebase.initializeApp(config, 'app1_for_tenantId1'); + firebase.initializeApp(config, 'app2_for_tenantId2'); + + const auth1 = firebase.app('app1').auth(); + const auth2 = firebase.app('app2').auth(); + + auth1.tenantId = "TENANT_ID1"; + auth2.tenantId = "TENANT_ID2"; + // [END multitenant_switch_tenant_multiinstance] +} + +function passwordSignInWithTenantDemo(email, password) { + // [START multitenant_signin_password_demo] + // Switch to TENANT_ID1 + firebase.auth().tenantId = 'TENANT_ID1'; + + // Sign in with tenant + firebase.auth().signInWithEmailAndPassword(email, password) + .then((result) => { + const user = result.user; + // user.tenantId is set to 'TENANT_ID1'. + // Switch to 'TENANT_ID2'. + firebase.auth().tenantId = 'TENANT_ID2'; + // firebase.auth().currentUser still point to the user. + // firebase.auth().currentUser.tenantId is 'TENANT_ID1'. + }); + + // You could also get the current user from Auth state observer. + firebase.auth().onAuthStateChanged((user) => { + if (user) { + // User is signed in. + // user.tenantId is set to 'TENANT_ID1'. + } else { + // No user is signed in. + } + }); + // [END multitenant_signin_password_demo] +} + +function signUpWithTenant(email, password) { + // [START multitenant_signup_password] + firebase.auth().tenantId = 'TENANT_ID'; + + firebase.auth().createUserWithEmailAndPassword(email, password) + .then((result) => { + // result.user.tenantId is 'TENANT_ID'. + }).catch((error) => { + // Handle error. + }); + // [END multitenant_signup_password] +} + + +function passwordSignInWithTenant(email, password) { + // [START multitenant_signin_password] + firebase.auth().tenantId = 'TENANT_ID'; + + firebase.auth().signInWithEmailAndPassword(email, password) + .then((result) => { + // result.user.tenantId is 'TENANT_ID'. + }).catch((error) => { + // Handle error. + }); + // [END multitenant_signin_password] +} + +function samlSignInPopupTenant(provider) { + // [START multitenant_signin_saml_popup] + // Switch to TENANT_ID1. + firebase.auth().tenantId = 'TENANT_ID1'; + + // Sign-in with popup. + firebase.auth().signInWithPopup(provider) + .then((result) => { + // User is signed in. + // tenant ID is available in result.user.tenantId. + // Identity provider data is available in result.additionalUserInfo.profile. + }) + .catch((error) => { + // Handle error. + }); + // [END multitenant_signin_saml_popup] +} + +function samlSignInRedirectTenant(provider) { + // [START multitenant_signin_saml_redirect] + // Switch to TENANT_ID1. + firebase.auth().tenantId = 'TENANT_ID1'; + + // Sign-in with redirect. + firebase.auth().signInWithRedirect(provider); + + // After the user completes sign-in and returns to the app, you can get + // the sign-in result by calling getRedirectResult. However, if they sign out + // and sign in again with an IdP, no tenant is used. + firebase.auth().getRedirectResult() + .then((result) => { + // User is signed in. + // The tenant ID available in result.user.tenantId. + // Identity provider data is available in result.additionalUserInfo.profile. + }) + .catch((error) => { + // Handle error. + }); + // [END multitenant_signin_saml_redirect] +} + +function sendSignInLinkToEmailTenant(email, actionCodeSettings) { + // [START multitenant_send_emaillink] + // Switch to TENANT_ID1 + firebase.auth().tenantId = 'TENANT_ID1'; + + firebase.auth().sendSignInLinkToEmail(email, actionCodeSettings) + .then(() => { + // The link was successfully sent. Inform the user. + // Save the email locally so you don't need to ask the user for it again + // if they open the link on the same device. + window.localStorage.setItem('emailForSignIn', email); + }) + .catch((error) => { + // Some error occurred, you can inspect the code: error.code + }); + // [END multitenant_send_emaillink] +} + +function signInWithEmailLinkTenant() { + // [START multitenant_signin_emaillink] + if (firebase.auth().isSignInWithEmailLink(window.location.href)) { + const actionCodeUrl = firebase.auth.ActionCodeURL.parseLink(window.location.href); + if (actionCodeUrl.tenantId) { + firebase.auth().tenantId = actionCodeUrl.tenantId; + } + let email = window.localStorage.getItem('emailForSignIn'); + if (!email) { + // User opened the link on a different device. To prevent session fixation + // attacks, ask the user to provide the associated email again. For example: + email = window.prompt('Please provide your email for confirmation'); + } + firebase.auth().signInWithEmailLink(email, window.location.href) + .then((result) => { + // User is signed in. + // tenant ID available in result.user.tenantId. + }); + } + // [END multitenant_signin_emaillink] +} + +function createCustomTokenTenant(admin, uid) { + // [START multitenant_create_custom_token] + // Ensure you're using a tenant-aware auth instance + const tenantManager = admin.auth().tenantManager(); + const tenantAuth = tenantManager.authForTenant('TENANT_ID1'); + + // Create a custom token in the usual manner + tenantAuth.createCustomToken(uid) + .then((customToken) => { + // Send token back to client + }) + .catch((error) => { + console.log('Error creating custom token:', error); + }); + // [END multitenant_create_custom_token] +} + +function signInWithCustomTokenTenant(token) { + // [START multitenant_signin_custom_token] + firebase.auth().tenantId = 'TENANT_ID1'; + + firebase.auth().signInWithCustomToken(token) + .catch((error) => { + // Handle Errors here. + const errorCode = error.code; + const errorMessage = error.message; + // ... + }); + // [END multitenant_signin_custom_token] +} + +function linkAccountTenant(provider, email, password) { + // [START multitenant_account_linking] + // Switch to TENANT_ID1 + firebase.auth().tenantId = 'TENANT_ID1'; + + // Sign-in with popup + firebase.auth().signInWithPopup(provider) + .then((result) => { + // Existing user with e.g. SAML provider. + const user = result.user; + const emailCredential = + firebase.auth.EmailAuthProvider.credential(email, password); + return user.linkWithCredential(emailCredential); + }) + .then((linkResult) => { + // The user can sign in with both SAML and email/password now. + }); + // [END multitenant_account_linking] +} + +function accountExistsPopupTenant(samlProvider, googleProvider, goToApp) { + // [START multitenant_account_exists_popup] + // Step 1. + // User tries to sign in to the SAML provider in that tenant. + firebase.auth().tenantId = 'TENANT_ID'; + firebase.auth().signInWithPopup(samlProvider) + .catch((error) => { + // An error happened. + if (error.code === 'auth/account-exists-with-different-credential') { + // Step 2. + // User's email already exists. + // The pending SAML credential. + const pendingCred = error.credential; + // The credential's tenantId if needed: error.tenantId + // The provider account's email address. + const email = error.email; + // Get sign-in methods for this email. + firebase.auth().fetchSignInMethodsForEmail(email) + .then((methods) => { + // Step 3. + // Ask the user to sign in with existing Google account. + if (methods[0] == 'google.com') { + firebase.auth().signInWithPopup(googleProvider) + .then((result) => { + // Step 4 + // Link the SAML AuthCredential to the existing user. + result.user.linkWithCredential(pendingCred) + .then((linkResult) => { + // SAML account successfully linked to the existing + // user. + goToApp(); + }); + }); + } + }); + } + }); + // [END multitenant_account_exists_popup] +} + +function accountExistsRedirectTenant(samlProvider, googleProvider, goToApp) { + // [START multitenant_account_exists_redirect] + // Step 1. + // User tries to sign in to SAML provider. + firebase.auth().tenantId = 'TENANT_ID'; + firebase.auth().signInWithRedirect(samlProvider); + var pendingCred; + // Redirect back from SAML IDP. auth.tenantId is null after redirecting. + firebase.auth().getRedirectResult().catch((error) => { + if (error.code === 'auth/account-exists-with-different-credential') { + // Step 2. + // User's email already exists. + const tenantId = error.tenantId; + // The pending SAML credential. + pendingCred = error.credential; + // The provider account's email address. + const email = error.email; + // Need to set the tenant ID again as the page was reloaded and the + // previous setting was reset. + firebase.auth().tenantId = tenantId; + // Get sign-in methods for this email. + firebase.auth().fetchSignInMethodsForEmail(email) + .then((methods) => { + // Step 3. + // Ask the user to sign in with existing Google account. + if (methods[0] == 'google.com') { + firebase.auth().signInWithRedirect(googleProvider); + } + }); + } + }); + + // Redirect back from Google. auth.tenantId is null after redirecting. + firebase.auth().getRedirectResult().then((result) => { + // Step 4 + // Link the SAML AuthCredential to the existing user. + // result.user.tenantId is 'TENANT_ID'. + result.user.linkWithCredential(pendingCred) + .then((linkResult) => { + // SAML account successfully linked to the existing + // user. + goToApp(); + }); + }); + // [END multitenant_account_exists_redirect] +} \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js b/snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js new file mode 100644 index 00000000..43734616 --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js @@ -0,0 +1,44 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_account_exists_popup_modular] +import { signInWithPopup, fetchSignInMethodsForEmail, linkWithCredential } from "firebase/auth"; +// Step 1. +// User tries to sign in to the SAML provider in that tenant. +auth.tenantId = 'TENANT_ID'; +signInWithPopup(auth, samlProvider) + .catch((error) => { + // An error happened. + if (error.code === 'auth/account-exists-with-different-credential') { + // Step 2. + // User's email already exists. + // The pending SAML credential. + const pendingCred = error.credential; + // The credential's tenantId if needed: error.tenantId + // The provider account's email address. + const email = error.email; + // Get sign-in methods for this email. + fetchSignInMethodsForEmail(email, auth) + .then((methods) => { + // Step 3. + // Ask the user to sign in with existing Google account. + if (methods[0] == 'google.com') { + signInWithPopup(auth, googleProvider) + .then((result) => { + // Step 4 + // Link the SAML AuthCredential to the existing user. + linkWithCredential(result.user, pendingCred) + .then((linkResult) => { + // SAML account successfully linked to the existing + // user. + goToApp(); + }); + }); + } + }); + } + }); +// [END multitenant_account_exists_popup_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js b/snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js new file mode 100644 index 00000000..f8a3942d --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js @@ -0,0 +1,51 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_account_exists_redirect_modular] +import { signInWithRedirect, getRedirectResult, fetchSignInMethodsForEmail, linkWithCredential } from "firebase/auth"; +// Step 1. +// User tries to sign in to SAML provider. +auth.tenantId = 'TENANT_ID'; +signInWithRedirect(auth, samlProvider); +var pendingCred; +// Redirect back from SAML IDP. auth.tenantId is null after redirecting. +getRedirectResult(auth).catch((error) => { + if (error.code === 'auth/account-exists-with-different-credential') { + // Step 2. + // User's email already exists. + const tenantId = error.tenantId; + // The pending SAML credential. + pendingCred = error.credential; + // The provider account's email address. + const email = error.email; + // Need to set the tenant ID again as the page was reloaded and the + // previous setting was reset. + auth.tenantId = tenantId; + // Get sign-in methods for this email. + fetchSignInMethodsForEmail(auth, email) + .then((methods) => { + // Step 3. + // Ask the user to sign in with existing Google account. + if (methods[0] == 'google.com') { + signInWithRedirect(auth, googleProvider); + } + }); + } +}); + +// Redirect back from Google. auth.tenantId is null after redirecting. +getRedirectResult(auth).then((result) => { + // Step 4 + // Link the SAML AuthCredential to the existing user. + // result.user.tenantId is 'TENANT_ID'. + linkWithCredential(result.user, pendingCred) + .then((linkResult) => { + // SAML account successfully linked to the existing + // user. + goToApp(); + }); +}); +// [END multitenant_account_exists_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_account_linking.js b/snippets/auth-next/multi-tenancy/multitenant_account_linking.js new file mode 100644 index 00000000..c43ff90d --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_account_linking.js @@ -0,0 +1,34 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_account_linking_modular] +import { signInWithPopup, EmailAuthProvider, linkWithCredential, SAMLAuthProvider, signInWithCredential } from "firebase/auth"; +// Switch to TENANT_ID1 +auth.tenantId = 'TENANT_ID1'; + +// Sign-in with popup +signInWithPopup(auth, provider) + .then((userCredential) => { + // Existing user with e.g. SAML provider. + const prevUser = userCredential.user; + const emailCredential = + EmailAuthProvider.credential(email, password); + return linkWithCredential(prevUser, emailCredential) + .then((linkResult) => { + // Sign in with the newly linked credential + const linkCredential = SAMLAuthProvider.credentialFromResult(linkResult); + return signInWithCredential(auth, linkCredential); + }) + .then((signInResult) => { + // Handle sign in of merged user + // ... + }); + }) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END multitenant_account_linking_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_create_custom_token.js b/snippets/auth-next/multi-tenancy/multitenant_create_custom_token.js new file mode 100644 index 00000000..1426cf8a --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_create_custom_token.js @@ -0,0 +1,20 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_create_custom_token_modular] +// Ensure you're using a tenant-aware auth instance +const tenantManager = admin.auth().tenantManager(); +const tenantAuth = tenantManager.authForTenant('TENANT_ID1'); + +// Create a custom token in the usual manner +tenantAuth.createCustomToken(uid) + .then((customToken) => { + // Send token back to client + }) + .catch((error) => { + console.log('Error creating custom token:', error); + }); +// [END multitenant_create_custom_token_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_send_emaillink.js b/snippets/auth-next/multi-tenancy/multitenant_send_emaillink.js new file mode 100644 index 00000000..4c4d95c5 --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_send_emaillink.js @@ -0,0 +1,23 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_send_emaillink_modular] +import { sendSignInLinkToEmail } from "firebase/auth"; +// Switch to TENANT_ID1 +auth.tenantId = 'TENANT_ID1'; + +sendSignInLinkToEmail(auth, email, actionCodeSettings) + .then(() => { + // The link was successfully sent. Inform the user. + // Save the email locally so you don't need to ask the user for it again + // if they open the link on the same device. + window.localStorage.setItem('emailForSignIn', email); + }) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END multitenant_send_emaillink_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_set_tenant.js b/snippets/auth-next/multi-tenancy/multitenant_set_tenant.js new file mode 100644 index 00000000..9510bc5e --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_set_tenant.js @@ -0,0 +1,12 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_set_tenant_modular] +import { getAuth } from "firebase/auth"; +const auth = getAuth(); +const tenantId = "TENANT_ID1"; +auth.tenantId = tenantId; +// [END multitenant_set_tenant_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_signin_custom_token.js b/snippets/auth-next/multi-tenancy/multitenant_signin_custom_token.js new file mode 100644 index 00000000..b9fa9c58 --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_signin_custom_token.js @@ -0,0 +1,16 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_signin_custom_token_modular] +import { signInWithCustomToken } from "firebase/auth"; +auth.tenantId = 'TENANT_ID1'; + +signInWithCustomToken(auth, token) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END multitenant_signin_custom_token_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_signin_emaillink.js b/snippets/auth-next/multi-tenancy/multitenant_signin_emaillink.js new file mode 100644 index 00000000..0032af1c --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_signin_emaillink.js @@ -0,0 +1,29 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_signin_emaillink_modular] +import { isSignInWithEmailLink, parseActionCodeURL, signInWithEmailLink } from "firebase/auth"; +if (isSignInWithEmailLink(auth, window.location.href)) { + const actionCodeUrl = parseActionCodeURL(window.location.href); + if (actionCodeUrl.tenantId) { + auth.tenantId = actionCodeUrl.tenantId; + } + let email = window.localStorage.getItem('emailForSignIn'); + if (!email) { + // User opened the link on a different device. To prevent session fixation + // attacks, ask the user to provide the associated email again. For example: + email = window.prompt('Please provide your email for confirmation'); + } + // The client SDK will parse the code from the link for you. + signInWithEmailLink(auth, email, window.location.href) + .then((result) => { + // User is signed in. + // tenant ID available in result.user.tenantId. + // Clear email from storage. + window.localStorage.removeItem('emailForSignIn'); + }); +} +// [END multitenant_signin_emaillink_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_signin_password.js b/snippets/auth-next/multi-tenancy/multitenant_signin_password.js new file mode 100644 index 00000000..73642a8d --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_signin_password.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_signin_password_modular] +import { signInWithEmailAndPassword } from "firebase/auth"; +auth.tenantId = 'TENANT_ID'; + +signInWithEmailAndPassword(auth, email, password) + .then((userCredential) => { + // User is signed in. + // userCredential.user.tenantId is 'TENANT_ID'. + }).catch((error) => { + // Handle / display error. + // ... + }); +// [END multitenant_signin_password_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_signin_password_demo.js b/snippets/auth-next/multi-tenancy/multitenant_signin_password_demo.js new file mode 100644 index 00000000..87882773 --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_signin_password_demo.js @@ -0,0 +1,33 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_signin_password_demo_modular] +import { signInWithEmailAndPassword, onAuthStateChanged } from "firebase/auth"; +// Switch to TENANT_ID1 +auth.tenantId = 'TENANT_ID1'; + +// Sign in with tenant +signInWithEmailAndPassword(auth, email, password) + .then((userCredential) => { + // User is signed in. + const user = userCredential.user; + // user.tenantId is set to 'TENANT_ID1'. + // Switch to 'TENANT_ID2'. + auth.tenantId = 'TENANT_ID2'; + // auth.currentUser still points to the user. + // auth.currentUser.tenantId is 'TENANT_ID1'. + }); + +// You could also get the current user from Auth state observer. +onAuthStateChanged(auth, (user) => { + if (user) { + // User is signed in. + // user.tenantId is set to 'TENANT_ID1'. + } else { + // No user is signed in. + } +}); +// [END multitenant_signin_password_demo_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_signin_saml_popup.js b/snippets/auth-next/multi-tenancy/multitenant_signin_saml_popup.js new file mode 100644 index 00000000..6aa90550 --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_signin_saml_popup.js @@ -0,0 +1,25 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_signin_saml_popup_modular] +import { signInWithPopup } from "firebase/auth"; +// Switch to TENANT_ID1. +auth.tenantId = 'TENANT_ID1'; + +// Sign-in with popup. +signInWithPopup(auth, provider) + .then((userCredential) => { + // User is signed in. + const user = userCredential.user; + // user.tenantId is set to 'TENANT_ID1'. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END multitenant_signin_saml_popup_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_signin_saml_redirect.js b/snippets/auth-next/multi-tenancy/multitenant_signin_saml_redirect.js new file mode 100644 index 00000000..d3552a56 --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_signin_saml_redirect.js @@ -0,0 +1,29 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_signin_saml_redirect_modular] +import { signInWithRedirect, getRedirectResult } from "firebase/auth"; +// Switch to TENANT_ID1. +auth.tenantId = 'TENANT_ID1'; + +// Sign-in with redirect. +signInWithRedirect(auth, provider); + +// After the user completes sign-in and returns to the app, you can get +// the sign-in result by calling getRedirectResult. However, if they sign out +// and sign in again with an IdP, no tenant is used. +getRedirectResult(auth) + .then((result) => { + // User is signed in. + // The tenant ID available in result.user.tenantId. + // Provider data available from the result.user.getIdToken() + // or from result.user.providerData + }) + .catch((error) => { + // Handle / display error. + // ... + }); +// [END multitenant_signin_saml_redirect_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_signup_password.js b/snippets/auth-next/multi-tenancy/multitenant_signup_password.js new file mode 100644 index 00000000..d89d5edf --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_signup_password.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_signup_password_modular] +import { createUserWithEmailAndPassword } from "firebase/auth"; +auth.tenantId = 'TENANT_ID'; + +createUserWithEmailAndPassword(auth, email, password) + .then((userCredential) => { + // User is signed in. + // userCredential.user.tenantId is 'TENANT_ID'. + }).catch((error) => { + // Handle / display error. + // ... + }); +// [END multitenant_signup_password_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_switch_tenant.js b/snippets/auth-next/multi-tenancy/multitenant_switch_tenant.js new file mode 100644 index 00000000..455e4e3b --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_switch_tenant.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_switch_tenant_modular] +// One Auth instance +// Switch to tenant1 +auth.tenantId = "TENANT_ID1"; +// Switch to tenant2 +auth.tenantId = "TENANT_ID2"; +// Switch back to project level IdPs +auth.tenantId = null; +// [END multitenant_switch_tenant_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_switch_tenant_multiinstance.js b/snippets/auth-next/multi-tenancy/multitenant_switch_tenant_multiinstance.js new file mode 100644 index 00000000..72550493 --- /dev/null +++ b/snippets/auth-next/multi-tenancy/multitenant_switch_tenant_multiinstance.js @@ -0,0 +1,19 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/multi-tenancy.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START multitenant_switch_tenant_multiinstance_modular] +// Multiple Auth instances +import { initializeApp } from "firebase/app"; +import { getAuth } from "firebase/auth"; +const firebaseApp1 = initializeApp(firebaseConfig1, 'app1_for_tenantId1'); +const firebaseApp2 = initializeApp(firebaseConfig2, 'app2_for_tenantId2'); + +const auth1 = getAuth(firebaseApp1); +const auth2 = getAuth(firebaseApp2); + +auth1.tenantId = "TENANT_ID1"; +auth2.tenantId = "TENANT_ID2"; +// [END multitenant_switch_tenant_multiinstance_modular] \ No newline at end of file From 1c4c6834f310bf53a98b3fa3c2e2191396cacd69 Mon Sep 17 00:00:00 2001 From: Ian Tay Date: Thu, 21 Oct 2021 10:38:57 -0700 Subject: [PATCH 136/170] add provider_credential snippets for the social Idps that don't have it. (#253) --- auth-next/facebook.js | 9 +++++++++ auth-next/google-signin.js | 9 +++++++++ auth-next/twitter.js | 7 +++++++ auth/facebook.js | 6 ++++++ auth/google-signin.js | 6 ++++++ auth/initialization.txt | 9 +++++++++ auth/multi-tenancy.js | 2 +- auth/twitter.js | 6 ++++++ .../facebook/auth_facebook_provider_credential.js | 11 +++++++++++ .../google-signin/auth_google_provider_credential.js | 11 +++++++++++ .../twitter/auth_twitter_provider_credential.js | 11 +++++++++++ 11 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 auth/initialization.txt create mode 100644 snippets/auth-next/facebook/auth_facebook_provider_credential.js create mode 100644 snippets/auth-next/google-signin/auth_google_provider_credential.js create mode 100644 snippets/auth-next/twitter/auth_twitter_provider_credential.js diff --git a/auth-next/facebook.js b/auth-next/facebook.js index 4b61f4be..90414d7e 100644 --- a/auth-next/facebook.js +++ b/auth-next/facebook.js @@ -163,3 +163,12 @@ function authWithCredential(credential) { }); // [END auth_facebook_signin_credential] } + +function facebookProviderCredential(accessToken) { + // [START auth_facebook_provider_credential] + const { FacebookAuthProvider } = require("firebase/auth"); + + const credential = FacebookAuthProvider.credential(accessToken); + // [END auth_facebook_provider_credential] +} + diff --git a/auth-next/google-signin.js b/auth-next/google-signin.js index 78b79a61..1e1cee59 100644 --- a/auth-next/google-signin.js +++ b/auth-next/google-signin.js @@ -157,4 +157,13 @@ function isUserEqual_wrapper() { // [END auth_google_checksameuser] } +function googleProviderCredential(idToken) { + // [START auth_google_provider_credential] + const { GoogleAuthProvider } = require("firebase/auth"); + + const credential = GoogleAuthProvider.credential(idToken); + // [END auth_google_provider_credential] +} + + diff --git a/auth-next/twitter.js b/auth-next/twitter.js index 8024bbe5..57416b03 100644 --- a/auth-next/twitter.js +++ b/auth-next/twitter.js @@ -73,3 +73,10 @@ function twitterSignInRedirectResult() { // [END auth_twitter_signin_redirect_result] } +function twitterProviderCredential(accessToken, secret) { + // [START auth_twitter_provider_credential] + const { TwitterAuthProvider } = require("firebase/auth"); + + const credential = TwitterAuthProvider.credential(accessToken, secret); + // [END auth_twitter_provider_credential] +} \ No newline at end of file diff --git a/auth/facebook.js b/auth/facebook.js index 3e5c5b14..4259960d 100644 --- a/auth/facebook.js +++ b/auth/facebook.js @@ -151,3 +151,9 @@ function authWithCredential(credential) { }); // [END auth_facebook_signin_credential] } + +function facebookProviderCredential(accessToken) { + // [START auth_facebook_provider_credential] + var credential = firebase.auth.FacebookAuthProvider.credential(accessToken); + // [END auth_facebook_provider_credential] +} diff --git a/auth/google-signin.js b/auth/google-signin.js index 908a32e1..fcc32dc8 100644 --- a/auth/google-signin.js +++ b/auth/google-signin.js @@ -142,3 +142,9 @@ function isUserEqual(googleUser, firebaseUser) { return false; } // [END auth_google_checksameuser] + +function googleProviderCredential(idToken) { + // [START auth_google_provider_credential] + var credential = firebase.auth.GoogleAuthProvider.credential(idToken); + // [END auth_google_provider_credential] +} diff --git a/auth/initialization.txt b/auth/initialization.txt new file mode 100644 index 00000000..bccb0571 --- /dev/null +++ b/auth/initialization.txt @@ -0,0 +1,9 @@ + + \ No newline at end of file diff --git a/auth/multi-tenancy.js b/auth/multi-tenancy.js index 8afc1a5c..8b31e145 100644 --- a/auth/multi-tenancy.js +++ b/auth/multi-tenancy.js @@ -23,7 +23,7 @@ function switchTenantSingleAuth() { // [END multitenant_switch_tenant] } -function switchTenantMultiAuthInstance(config) { +function switchTenantMultiAuth(config) { // [START multitenant_switch_tenant_multiinstance] // Multiple Auth instances firebase.initializeApp(config, 'app1_for_tenantId1'); diff --git a/auth/twitter.js b/auth/twitter.js index b1ca2581..a78370b7 100644 --- a/auth/twitter.js +++ b/auth/twitter.js @@ -76,3 +76,9 @@ function twitterSignInRedirectResult() { }); // [END auth_twitter_signin_redirect_result] } + +function twitterProviderCredential(accessToken, secret) { + // [START auth_twitter_provider_credential] + var credential = firebase.auth.TwitterAuthProvider.credential(accessToken, secret); + // [END auth_twitter_provider_credential] +} \ No newline at end of file diff --git a/snippets/auth-next/facebook/auth_facebook_provider_credential.js b/snippets/auth-next/facebook/auth_facebook_provider_credential.js new file mode 100644 index 00000000..b7bbca25 --- /dev/null +++ b/snippets/auth-next/facebook/auth_facebook_provider_credential.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/facebook.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_facebook_provider_credential_modular] +import { FacebookAuthProvider } from "firebase/auth"; + +const credential = FacebookAuthProvider.credential(accessToken); +// [END auth_facebook_provider_credential_modular] \ No newline at end of file diff --git a/snippets/auth-next/google-signin/auth_google_provider_credential.js b/snippets/auth-next/google-signin/auth_google_provider_credential.js new file mode 100644 index 00000000..924aa167 --- /dev/null +++ b/snippets/auth-next/google-signin/auth_google_provider_credential.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/google-signin.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_google_provider_credential_modular] +import { GoogleAuthProvider } from "firebase/auth"; + +const credential = GoogleAuthProvider.credential(idToken); +// [END auth_google_provider_credential_modular] \ No newline at end of file diff --git a/snippets/auth-next/twitter/auth_twitter_provider_credential.js b/snippets/auth-next/twitter/auth_twitter_provider_credential.js new file mode 100644 index 00000000..e25b369c --- /dev/null +++ b/snippets/auth-next/twitter/auth_twitter_provider_credential.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/twitter.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_twitter_provider_credential_modular] +import { TwitterAuthProvider } from "firebase/auth"; + +const credential = TwitterAuthProvider.credential(accessToken, secret); +// [END auth_twitter_provider_credential_modular] \ No newline at end of file From 509769a817d7437616bcfcb816f783b29aaca843 Mon Sep 17 00:00:00 2001 From: Ersin Ertan <4809853+ersin-ertan@users.noreply.github.com> Date: Fri, 21 Jan 2022 16:18:29 -0500 Subject: [PATCH 137/170] Update method in comment for getting the id token (#262) Sources - https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/model/user.ts#L85 - https://firebase.google.com/docs/reference/js/v8/firebase.User#getidtoken - https://firebase.google.com/docs/reference/js/auth.user.md#usergetidtoken - https://firebase.google.com/docs/auth/web/manage-users#get_a_users_profile --- auth/manage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/manage.js b/auth/manage.js index 7163ef00..217199f2 100644 --- a/auth/manage.js +++ b/auth/manage.js @@ -16,7 +16,7 @@ function getUserProfile() { // The user's ID, unique to the Firebase project. Do NOT use // this value to authenticate with your backend server, if - // you have one. Use User.getToken() instead. + // you have one. Use User.getIdToken() instead. const uid = user.uid; } // [END auth_get_user_profile] From 9bdf357b4b667c71b0914f4af9fa6210b4a953d5 Mon Sep 17 00:00:00 2001 From: Yarego Brozek <78966160+devkiloton@users.noreply.github.com> Date: Thu, 21 Apr 2022 11:31:19 -0300 Subject: [PATCH 138/170] adding missing code in a snippet (#288) --- database-next/read-and-write.js | 2 +- .../database-next/read-and-write/rtdb_social_write_fan_out.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/database-next/read-and-write.js b/database-next/read-and-write.js index 2cbd5c5b..4196c0d7 100644 --- a/database-next/read-and-write.js +++ b/database-next/read-and-write.js @@ -74,9 +74,9 @@ function socialSingleValueRead() { } function writeNewPost_wrapped() { + // [START rtdb_social_write_fan_out] const { getDatabase, ref, child, push, update } = require("firebase/database"); - // [START rtdb_social_write_fan_out] function writeNewPost(uid, username, picture, title, body) { const db = getDatabase(); diff --git a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js index f787d4bd..783eca2b 100644 --- a/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js +++ b/snippets/database-next/read-and-write/rtdb_social_write_fan_out.js @@ -5,6 +5,8 @@ // 'npm run snippets'. // [START rtdb_social_write_fan_out_modular] +import { getDatabase, ref, child, push, update } from "firebase/database"; + function writeNewPost(uid, username, picture, title, body) { const db = getDatabase(); From 69c85abdc7cd6990618720cd33aa0d1ee357c652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ros=C3=A1rio=20Pereira=20Fernandes?= Date: Thu, 19 May 2022 13:37:24 +0100 Subject: [PATCH 139/170] fix error handling on v9 auth snippets (#289) --- auth-next/apple.js | 6 +++--- auth-next/facebook.js | 8 ++++---- auth-next/github.js | 4 ++-- auth-next/google-signin.js | 8 ++++---- auth-next/index.js | 2 +- auth-next/multi-tenancy.js | 4 ++-- auth-next/oidc.js | 6 +++--- auth-next/saml.js | 4 ++-- auth-next/twitter.js | 4 ++-- .../auth-next/apple/auth_apple_reauthenticate_popup.js | 2 +- snippets/auth-next/apple/auth_apple_signin_popup.js | 2 +- .../auth-next/apple/auth_apple_signin_redirect_result.js | 2 +- snippets/auth-next/facebook/auth_facebook_callback.js | 2 +- .../auth-next/facebook/auth_facebook_signin_credential.js | 2 +- snippets/auth-next/facebook/auth_facebook_signin_popup.js | 2 +- .../facebook/auth_facebook_signin_redirect_result.js | 2 +- snippets/auth-next/github/auth_github_signin_popup.js | 2 +- .../github/auth_github_signin_redirect_result.js | 2 +- .../auth-next/google-signin/auth_google_build_signin.js | 2 +- snippets/auth-next/google-signin/auth_google_callback.js | 2 +- .../google-signin/auth_google_signin_credential.js | 2 +- .../auth-next/google-signin/auth_google_signin_popup.js | 2 +- .../google-signin/auth_google_signin_redirect_result.js | 2 +- snippets/auth-next/index/auth_signin_credential.js | 2 +- .../multi-tenancy/multitenant_account_exists_popup.js | 2 +- .../multi-tenancy/multitenant_account_exists_redirect.js | 2 +- snippets/auth-next/oidc/auth_oidc_direct_sign_in.js | 2 +- snippets/auth-next/oidc/auth_oidc_signin_popup.js | 2 +- .../auth-next/oidc/auth_oidc_signin_redirect_result.js | 2 +- snippets/auth-next/saml/auth_saml_signin_popup.js | 2 +- .../auth-next/saml/auth_saml_signin_redirect_result.js | 2 +- snippets/auth-next/twitter/auth_twitter_signin_popup.js | 2 +- .../twitter/auth_twitter_signin_redirect_result.js | 2 +- 33 files changed, 47 insertions(+), 47 deletions(-) diff --git a/auth-next/apple.js b/auth-next/apple.js index 29a33dea..7cffca8b 100644 --- a/auth-next/apple.js +++ b/auth-next/apple.js @@ -45,7 +45,7 @@ function appleSignInPopup(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = OAuthProvider.credentialFromError(error); @@ -85,7 +85,7 @@ function appleSignInRedirectResult() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = OAuthProvider.credentialFromError(error); @@ -123,7 +123,7 @@ function appleReauthenticatePopup() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = OAuthProvider.credentialFromError(error); diff --git a/auth-next/facebook.js b/auth-next/facebook.js index 90414d7e..67b397f2 100644 --- a/auth-next/facebook.js +++ b/auth-next/facebook.js @@ -40,7 +40,7 @@ function facebookSignInPopup(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); @@ -66,7 +66,7 @@ function facebookSignInRedirectResult() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); // ... @@ -102,7 +102,7 @@ function checkLoginState_wrapper() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); // ... @@ -156,7 +156,7 @@ function authWithCredential(credential) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); // ... diff --git a/auth-next/github.js b/auth-next/github.js index 941a9047..babfd1ee 100644 --- a/auth-next/github.js +++ b/auth-next/github.js @@ -46,7 +46,7 @@ function githubSignInPopup(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GithubAuthProvider.credentialFromError(error); // ... @@ -75,7 +75,7 @@ function githubSignInRedirectResult() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GithubAuthProvider.credentialFromError(error); // ... diff --git a/auth-next/google-signin.js b/auth-next/google-signin.js index 1e1cee59..136c26b5 100644 --- a/auth-next/google-signin.js +++ b/auth-next/google-signin.js @@ -39,7 +39,7 @@ function googleSignInPopup(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... @@ -65,7 +65,7 @@ function googleSignInRedirectResult() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... @@ -87,7 +87,7 @@ function googleBuildAndSignIn(id_token) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... @@ -123,7 +123,7 @@ function onSignIn_wrapper() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... diff --git a/auth-next/index.js b/auth-next/index.js index c4dadfe0..b4a17903 100644 --- a/auth-next/index.js +++ b/auth-next/index.js @@ -107,7 +107,7 @@ function authWithCredential(credential) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // ... }); // [END auth_signin_credential] diff --git a/auth-next/multi-tenancy.js b/auth-next/multi-tenancy.js index c0c86662..d7577f34 100644 --- a/auth-next/multi-tenancy.js +++ b/auth-next/multi-tenancy.js @@ -273,7 +273,7 @@ function accountExistsPopupTenant(auth, samlProvider, googleProvider, goToApp) { const pendingCred = error.credential; // The credential's tenantId if needed: error.tenantId // The provider account's email address. - const email = error.email; + const email = error.customData.email; // Get sign-in methods for this email. fetchSignInMethodsForEmail(email, auth) .then((methods) => { @@ -315,7 +315,7 @@ function accountExistsRedirectTenant(auth, samlProvider, googleProvider, goToApp // The pending SAML credential. pendingCred = error.credential; // The provider account's email address. - const email = error.email; + const email = error.customData.email; // Need to set the tenant ID again as the page was reloaded and the // previous setting was reset. auth.tenantId = tenantId; diff --git a/auth-next/oidc.js b/auth-next/oidc.js index 5dc20e81..dae69fe9 100644 --- a/auth-next/oidc.js +++ b/auth-next/oidc.js @@ -24,7 +24,7 @@ function oidcSignInPopup(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = OAuthProvider.credentialFromError(error); // Handle / display error. @@ -58,7 +58,7 @@ function oidcSignInRedirectResult(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = OAuthProvider.credentialFromError(error); // Handle / display error. @@ -86,7 +86,7 @@ function oidcDirectSignIn(provider, oidcIdToken) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = OAuthProvider.credentialFromError(error); // Handle / display error. diff --git a/auth-next/saml.js b/auth-next/saml.js index 9a5683d9..cdecce56 100644 --- a/auth-next/saml.js +++ b/auth-next/saml.js @@ -24,7 +24,7 @@ function samlSignInPopup(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = SAMLAuthProvider.credentialFromError(error); // Handle / display error. @@ -58,7 +58,7 @@ function samlSignInRedirectResult(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = SAMLAuthProvider.credentialFromError(error); // Handle / display error. diff --git a/auth-next/twitter.js b/auth-next/twitter.js index 57416b03..a386e4ab 100644 --- a/auth-next/twitter.js +++ b/auth-next/twitter.js @@ -36,7 +36,7 @@ function twitterSignInPopup(provider) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = TwitterAuthProvider.credentialFromError(error); // ... @@ -65,7 +65,7 @@ function twitterSignInRedirectResult() { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = TwitterAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js b/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js index 129fe920..cd40151d 100644 --- a/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js +++ b/snippets/auth-next/apple/auth_apple_reauthenticate_popup.js @@ -32,7 +32,7 @@ reauthenticateWithPopup(auth.currentUser, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = OAuthProvider.credentialFromError(error); diff --git a/snippets/auth-next/apple/auth_apple_signin_popup.js b/snippets/auth-next/apple/auth_apple_signin_popup.js index 2db09607..c2a392cf 100644 --- a/snippets/auth-next/apple/auth_apple_signin_popup.js +++ b/snippets/auth-next/apple/auth_apple_signin_popup.js @@ -25,7 +25,7 @@ signInWithPopup(auth, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = OAuthProvider.credentialFromError(error); diff --git a/snippets/auth-next/apple/auth_apple_signin_redirect_result.js b/snippets/auth-next/apple/auth_apple_signin_redirect_result.js index 68dba4ab..654f95e5 100644 --- a/snippets/auth-next/apple/auth_apple_signin_redirect_result.js +++ b/snippets/auth-next/apple/auth_apple_signin_redirect_result.js @@ -25,7 +25,7 @@ getRedirectResult(auth) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = OAuthProvider.credentialFromError(error); diff --git a/snippets/auth-next/facebook/auth_facebook_callback.js b/snippets/auth-next/facebook/auth_facebook_callback.js index 8596bb68..63106871 100644 --- a/snippets/auth-next/facebook/auth_facebook_callback.js +++ b/snippets/auth-next/facebook/auth_facebook_callback.js @@ -26,7 +26,7 @@ function checkLoginState(response) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/facebook/auth_facebook_signin_credential.js b/snippets/auth-next/facebook/auth_facebook_signin_credential.js index dcd42c7e..3b784f24 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_credential.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_credential.js @@ -19,7 +19,7 @@ signInWithCredential(auth, credential) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/facebook/auth_facebook_signin_popup.js b/snippets/auth-next/facebook/auth_facebook_signin_popup.js index 2bc014ed..7d35aaf2 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_popup.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_popup.js @@ -24,7 +24,7 @@ signInWithPopup(auth, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); diff --git a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js index 49f3a494..eb6cdb30 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js @@ -20,7 +20,7 @@ getRedirectResult(auth) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // AuthCredential type that was used. const credential = FacebookAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/github/auth_github_signin_popup.js b/snippets/auth-next/github/auth_github_signin_popup.js index 74e76cc9..e1b4768e 100644 --- a/snippets/auth-next/github/auth_github_signin_popup.js +++ b/snippets/auth-next/github/auth_github_signin_popup.js @@ -22,7 +22,7 @@ signInWithPopup(auth, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GithubAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/github/auth_github_signin_redirect_result.js b/snippets/auth-next/github/auth_github_signin_redirect_result.js index 6147d9de..b3d31d0a 100644 --- a/snippets/auth-next/github/auth_github_signin_redirect_result.js +++ b/snippets/auth-next/github/auth_github_signin_redirect_result.js @@ -24,7 +24,7 @@ getRedirectResult(auth) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GithubAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/google-signin/auth_google_build_signin.js b/snippets/auth-next/google-signin/auth_google_build_signin.js index 6df84e3e..98f35eb2 100644 --- a/snippets/auth-next/google-signin/auth_google_build_signin.js +++ b/snippets/auth-next/google-signin/auth_google_build_signin.js @@ -17,7 +17,7 @@ signInWithCredential(auth, credential).catch((error) => { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/google-signin/auth_google_callback.js b/snippets/auth-next/google-signin/auth_google_callback.js index 27aa8dc6..873778dd 100644 --- a/snippets/auth-next/google-signin/auth_google_callback.js +++ b/snippets/auth-next/google-signin/auth_google_callback.js @@ -25,7 +25,7 @@ function onSignIn(googleUser) { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/google-signin/auth_google_signin_credential.js b/snippets/auth-next/google-signin/auth_google_signin_credential.js index a3a8808e..25c6f3ba 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_credential.js +++ b/snippets/auth-next/google-signin/auth_google_signin_credential.js @@ -10,7 +10,7 @@ signInWithCredential(auth, credential).catch((error) => { const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The credential that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/google-signin/auth_google_signin_popup.js b/snippets/auth-next/google-signin/auth_google_signin_popup.js index 55c46488..d6c70eb9 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_popup.js +++ b/snippets/auth-next/google-signin/auth_google_signin_popup.js @@ -21,7 +21,7 @@ signInWithPopup(auth, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js index a64977bb..50c4aded 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js +++ b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js @@ -21,7 +21,7 @@ getRedirectResult(auth) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = GoogleAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/index/auth_signin_credential.js b/snippets/auth-next/index/auth_signin_credential.js index ba2db6b8..c2b027a3 100644 --- a/snippets/auth-next/index/auth_signin_credential.js +++ b/snippets/auth-next/index/auth_signin_credential.js @@ -19,7 +19,7 @@ signInWithCredential(auth, credential) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // ... }); // [END auth_signin_credential_modular] \ No newline at end of file diff --git a/snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js b/snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js index 43734616..7bf33262 100644 --- a/snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js +++ b/snippets/auth-next/multi-tenancy/multitenant_account_exists_popup.js @@ -19,7 +19,7 @@ signInWithPopup(auth, samlProvider) const pendingCred = error.credential; // The credential's tenantId if needed: error.tenantId // The provider account's email address. - const email = error.email; + const email = error.customData.email; // Get sign-in methods for this email. fetchSignInMethodsForEmail(email, auth) .then((methods) => { diff --git a/snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js b/snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js index f8a3942d..a81617dd 100644 --- a/snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js +++ b/snippets/auth-next/multi-tenancy/multitenant_account_exists_redirect.js @@ -20,7 +20,7 @@ getRedirectResult(auth).catch((error) => { // The pending SAML credential. pendingCred = error.credential; // The provider account's email address. - const email = error.email; + const email = error.customData.email; // Need to set the tenant ID again as the page was reloaded and the // previous setting was reset. auth.tenantId = tenantId; diff --git a/snippets/auth-next/oidc/auth_oidc_direct_sign_in.js b/snippets/auth-next/oidc/auth_oidc_direct_sign_in.js index 65f693a6..558fd915 100644 --- a/snippets/auth-next/oidc/auth_oidc_direct_sign_in.js +++ b/snippets/auth-next/oidc/auth_oidc_direct_sign_in.js @@ -22,7 +22,7 @@ signInWithCredential(auth, credential) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = OAuthProvider.credentialFromError(error); // Handle / display error. diff --git a/snippets/auth-next/oidc/auth_oidc_signin_popup.js b/snippets/auth-next/oidc/auth_oidc_signin_popup.js index 76b01b1d..130d617e 100644 --- a/snippets/auth-next/oidc/auth_oidc_signin_popup.js +++ b/snippets/auth-next/oidc/auth_oidc_signin_popup.js @@ -18,7 +18,7 @@ signInWithPopup(auth, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = OAuthProvider.credentialFromError(error); // Handle / display error. diff --git a/snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js b/snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js index ae5a441d..bc76a620 100644 --- a/snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js +++ b/snippets/auth-next/oidc/auth_oidc_signin_redirect_result.js @@ -19,7 +19,7 @@ getRedirectResult(auth) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = OAuthProvider.credentialFromError(error); // Handle / display error. diff --git a/snippets/auth-next/saml/auth_saml_signin_popup.js b/snippets/auth-next/saml/auth_saml_signin_popup.js index 8010a17b..3a922a9a 100644 --- a/snippets/auth-next/saml/auth_saml_signin_popup.js +++ b/snippets/auth-next/saml/auth_saml_signin_popup.js @@ -18,7 +18,7 @@ signInWithPopup(auth, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = SAMLAuthProvider.credentialFromError(error); // Handle / display error. diff --git a/snippets/auth-next/saml/auth_saml_signin_redirect_result.js b/snippets/auth-next/saml/auth_saml_signin_redirect_result.js index 4e4d4260..e4bf73de 100644 --- a/snippets/auth-next/saml/auth_saml_signin_redirect_result.js +++ b/snippets/auth-next/saml/auth_saml_signin_redirect_result.js @@ -19,7 +19,7 @@ getRedirectResult(auth) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = SAMLAuthProvider.credentialFromError(error); // Handle / display error. diff --git a/snippets/auth-next/twitter/auth_twitter_signin_popup.js b/snippets/auth-next/twitter/auth_twitter_signin_popup.js index a5fb5a95..ae8e2007 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_popup.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_popup.js @@ -24,7 +24,7 @@ signInWithPopup(auth, provider) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = TwitterAuthProvider.credentialFromError(error); // ... diff --git a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js index 53b42c85..73e42bab 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js @@ -24,7 +24,7 @@ getRedirectResult(auth) const errorCode = error.code; const errorMessage = error.message; // The email of the user's account used. - const email = error.email; + const email = error.customData.email; // The AuthCredential type that was used. const credential = TwitterAuthProvider.credentialFromError(error); // ... From 2b97722e03d0276347523590ae8f6588ca5cf79b Mon Sep 17 00:00:00 2001 From: Frank van Puffelen Date: Fri, 10 Jun 2022 04:18:10 -0700 Subject: [PATCH 140/170] Fix nesting issue in collection group query sample (#280) --- firestore-next/test.firestore.js | 22 +++++++++---------- .../fs_collection_group_query_data_setup.js | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 71c54b95..59ab267b 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -1095,48 +1095,48 @@ describe("firestore", () => { describe('collectionGroup(landmarks)', () => { it("should setup example data", async () => { // [START fs_collection_group_query_data_setup] - const { collection, doc, setDoc } = require("firebase/firestore"); + const { collection, addDoc } = require("firebase/firestore"); const citiesRef = collection(db, 'cities'); await Promise.all([ - setDoc(doc(citiesRef, 'SF', 'landmarks'), { + addDoc(collection(citiesRef, 'SF', 'landmarks'), { name: 'Golden Gate Bridge', type: 'bridge' }), - setDoc(doc(citiesRef, 'SF', 'landmarks'), { + addDoc(collection(citiesRef, 'SF', 'landmarks'), { name: 'Legion of Honor', type: 'museum' }), - setDoc(doc(citiesRef, 'LA', 'landmarks'), { + addDoc(collection(citiesRef, 'LA', 'landmarks'), { name: 'Griffith Park', type: 'park' }), - setDoc(doc(citiesRef, 'LA', 'landmarks'), { + addDoc(collection(citiesRef, 'LA', 'landmarks'), { name: 'The Getty', type: 'museum' }), - setDoc(doc(citiesRef, 'DC', 'landmarks'), { + addDoc(collection(citiesRef, 'DC', 'landmarks'), { name: 'Lincoln Memorial', type: 'memorial' }), - setDoc(doc(citiesRef, 'DC', 'landmarks'), { + addDoc(collection(citiesRef, 'DC', 'landmarks'), { name: 'National Air and Space Museum', type: 'museum' }), - setDoc(doc(citiesRef, 'TOK', 'landmarks'), { + addDoc(collection(citiesRef, 'TOK', 'landmarks'), { name: 'Ueno Park', type: 'park' }), - setDoc(doc(citiesRef, 'TOK', 'landmarks'), { + addDoc(collection(citiesRef, 'TOK', 'landmarks'), { name: 'National Museum of Nature and Science', type: 'museum' }), - setDoc(doc(citiesRef, 'BJ', 'landmarks'), { + addDoc(collection(citiesRef, 'BJ', 'landmarks'), { name: 'Jingshan Park', type: 'park' }), - setDoc(doc(citiesRef, 'BJ', 'landmarks'), { + addDoc(collection(citiesRef, 'BJ', 'landmarks'), { name: 'Beijing Ancient Observatory', type: 'museum' }) diff --git a/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js b/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js index f4f62178..f06ea0f8 100644 --- a/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js +++ b/snippets/firestore-next/test-firestore/fs_collection_group_query_data_setup.js @@ -5,48 +5,48 @@ // 'npm run snippets'. // [START fs_collection_group_query_data_setup_modular] -import { collection, doc, setDoc } from "firebase/firestore"; +import { collection, addDoc } from "firebase/firestore"; const citiesRef = collection(db, 'cities'); await Promise.all([ - setDoc(doc(citiesRef, 'SF', 'landmarks'), { + addDoc(collection(citiesRef, 'SF', 'landmarks'), { name: 'Golden Gate Bridge', type: 'bridge' }), - setDoc(doc(citiesRef, 'SF', 'landmarks'), { + addDoc(collection(citiesRef, 'SF', 'landmarks'), { name: 'Legion of Honor', type: 'museum' }), - setDoc(doc(citiesRef, 'LA', 'landmarks'), { + addDoc(collection(citiesRef, 'LA', 'landmarks'), { name: 'Griffith Park', type: 'park' }), - setDoc(doc(citiesRef, 'LA', 'landmarks'), { + addDoc(collection(citiesRef, 'LA', 'landmarks'), { name: 'The Getty', type: 'museum' }), - setDoc(doc(citiesRef, 'DC', 'landmarks'), { + addDoc(collection(citiesRef, 'DC', 'landmarks'), { name: 'Lincoln Memorial', type: 'memorial' }), - setDoc(doc(citiesRef, 'DC', 'landmarks'), { + addDoc(collection(citiesRef, 'DC', 'landmarks'), { name: 'National Air and Space Museum', type: 'museum' }), - setDoc(doc(citiesRef, 'TOK', 'landmarks'), { + addDoc(collection(citiesRef, 'TOK', 'landmarks'), { name: 'Ueno Park', type: 'park' }), - setDoc(doc(citiesRef, 'TOK', 'landmarks'), { + addDoc(collection(citiesRef, 'TOK', 'landmarks'), { name: 'National Museum of Nature and Science', type: 'museum' }), - setDoc(doc(citiesRef, 'BJ', 'landmarks'), { + addDoc(collection(citiesRef, 'BJ', 'landmarks'), { name: 'Jingshan Park', type: 'park' }), - setDoc(doc(citiesRef, 'BJ', 'landmarks'), { + addDoc(collection(citiesRef, 'BJ', 'landmarks'), { name: 'Beijing Ancient Observatory', type: 'museum' }) From 71c95ee64a0ddc4e2692e0461fc5eb553cff0252 Mon Sep 17 00:00:00 2001 From: CommanderRoot Date: Fri, 10 Jun 2022 13:24:36 +0200 Subject: [PATCH 141/170] refactor: replace deprecated String.prototype.substr() (#281) .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated --- auth-next/apple.js | 2 +- auth/apple.js | 2 +- scripts/separate-snippets.ts | 2 +- snippets/auth-next/apple/auth_apple_nonce_node.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth-next/apple.js b/auth-next/apple.js index 7cffca8b..f9670b4c 100644 --- a/auth-next/apple.js +++ b/auth-next/apple.js @@ -169,7 +169,7 @@ function appleNonceNode() { crypto.randomFillSync(buf); nonce = decoder.write(buf); } - return nonce.substr(0, length); + return nonce.slice(0, length); }; const unhashedNonce = generateNonce(10); diff --git a/auth/apple.js b/auth/apple.js index ad65ef08..e99349c8 100644 --- a/auth/apple.js +++ b/auth/apple.js @@ -170,7 +170,7 @@ function appleNonceNode() { crypto.randomFillSync(buf); nonce = decoder.write(buf); } - return nonce.substr(0, length); + return nonce.slice(0, length); }; const unhashedNonce = generateNonce(10); diff --git a/scripts/separate-snippets.ts b/scripts/separate-snippets.ts index ff93a58f..a888d908 100644 --- a/scripts/separate-snippets.ts +++ b/scripts/separate-snippets.ts @@ -77,7 +77,7 @@ function adjustIndentation(lines: string[]) { if (isBlank(line)) { outputLines.push(""); } else { - outputLines.push(line.substr(minIndent)); + outputLines.push(line.slice(minIndent)); } } return outputLines; diff --git a/snippets/auth-next/apple/auth_apple_nonce_node.js b/snippets/auth-next/apple/auth_apple_nonce_node.js index 26bb2ef0..9dd417a5 100644 --- a/snippets/auth-next/apple/auth_apple_nonce_node.js +++ b/snippets/auth-next/apple/auth_apple_nonce_node.js @@ -17,7 +17,7 @@ const generateNonce = (length) => { crypto.randomFillSync(buf); nonce = decoder.write(buf); } - return nonce.substr(0, length); + return nonce.slice(0, length); }; const unhashedNonce = generateNonce(10); From 01d37b7b0a42e5304d172543b986282d0d61d214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ros=C3=A1rio=20Pereira=20Fernandes?= Date: Fri, 10 Jun 2022 12:33:42 +0100 Subject: [PATCH 142/170] popuation --> population (#296) --- firestore-next/test.firestore.js | 2 +- snippets/firestore-next/test-firestore/start_doc.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 59ab267b..17ff6d29 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -1048,7 +1048,7 @@ describe("firestore", () => { const docSnap = await getDoc(doc(citiesRef, "SF")); // Get all cities with a population bigger than San Francisco - const biggerThanSf = query(citiesRef, orderBy("popuation"), startAt(docSnap)); + const biggerThanSf = query(citiesRef, orderBy("population"), startAt(docSnap)); // ... // [END start_doc] }); diff --git a/snippets/firestore-next/test-firestore/start_doc.js b/snippets/firestore-next/test-firestore/start_doc.js index e75c7984..88448fcd 100644 --- a/snippets/firestore-next/test-firestore/start_doc.js +++ b/snippets/firestore-next/test-firestore/start_doc.js @@ -11,6 +11,6 @@ const citiesRef = collection(db, "cities"); const docSnap = await getDoc(doc(citiesRef, "SF")); // Get all cities with a population bigger than San Francisco -const biggerThanSf = query(citiesRef, orderBy("popuation"), startAt(docSnap)); +const biggerThanSf = query(citiesRef, orderBy("population"), startAt(docSnap)); // ... // [END start_doc_modular] \ No newline at end of file From 1a603211c8970d98630f0054761c9ad32620e725 Mon Sep 17 00:00:00 2001 From: Guy Torbet <61030227+Torbet@users.noreply.github.com> Date: Tue, 28 Jun 2022 19:17:23 +0100 Subject: [PATCH 143/170] shoud --> should (#298) "Should Paginate" to "Should paginate" --- firestore/test.firestore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firestore/test.firestore.js b/firestore/test.firestore.js index 2aadf8d5..dbf6e18e 100644 --- a/firestore/test.firestore.js +++ b/firestore/test.firestore.js @@ -1011,7 +1011,7 @@ describe("firestore", () => { // [END start_multiple_orderby] }); - it("shoud paginate", () => { + it("should paginate", () => { // [START paginate] var first = db.collection("cities") .orderBy("population") From 5879ad7dedb29c6703bf94f760f6c55073c7c4ac Mon Sep 17 00:00:00 2001 From: Frank van Puffelen Date: Wed, 6 Jul 2022 15:55:52 -0700 Subject: [PATCH 144/170] Fix tiny type (#299) --- auth/manage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/manage.js b/auth/manage.js index 217199f2..0e1f0e7b 100644 --- a/auth/manage.js +++ b/auth/manage.js @@ -144,7 +144,7 @@ function reauthenticateWithCredential() { user.reauthenticateWithCredential(credential).then(() => { // User re-authenticated. }).catch((error) => { - // An error ocurred + // An error occurred // ... }); // [END auth_reauth_with_credential] From 7403e77cc6b0c9bae8e9cd9d43f58eb93df2241a Mon Sep 17 00:00:00 2001 From: Andrea Wu <1359259+andreaowu@users.noreply.github.com> Date: Thu, 8 Sep 2022 14:24:27 +0200 Subject: [PATCH 145/170] analytics select_content should not have items (#300) --- analytics-next/index.js | 3 +-- snippets/analytics-next/index/analytics_log_event_params.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/analytics-next/index.js b/analytics-next/index.js index 510fa758..2b736cde 100644 --- a/analytics-next/index.js +++ b/analytics-next/index.js @@ -27,8 +27,7 @@ function logEventParams() { const analytics = getAnalytics(); logEvent(analytics, 'select_content', { content_type: 'image', - content_id: 'P12453', - items: [{ name: 'Kittens' }] + content_id: 'P12453' }); // [END analytics_log_event_params] } diff --git a/snippets/analytics-next/index/analytics_log_event_params.js b/snippets/analytics-next/index/analytics_log_event_params.js index 27e6528d..e79d7ec0 100644 --- a/snippets/analytics-next/index/analytics_log_event_params.js +++ b/snippets/analytics-next/index/analytics_log_event_params.js @@ -10,7 +10,6 @@ import { getAnalytics, logEvent } from "firebase/analytics"; const analytics = getAnalytics(); logEvent(analytics, 'select_content', { content_type: 'image', - content_id: 'P12453', - items: [{ name: 'Kittens' }] + content_id: 'P12453' }); // [END analytics_log_event_params_modular] \ No newline at end of file From 8eb8a7c7c59049edb01398a2743562192e397227 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 20 Oct 2022 14:46:57 -0700 Subject: [PATCH 146/170] Auto-update dependencies. (#241) --- analytics-next/package.json | 2 +- appcheck-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index d0955d16..0fb07418 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/appcheck-next/package.json b/appcheck-next/package.json index 7c84b7df..ad78db9f 100644 --- a/appcheck-next/package.json +++ b/appcheck-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/auth-next/package.json b/auth-next/package.json index 53d964a2..48adc595 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/database-next/package.json b/database-next/package.json index 175d6c63..be3cab88 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 88dd8954..d7b654df 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 2c95f580..39b5c6a9 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0", + "firebase": "^9.12.1", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index 4ddfe8c3..618ee0c5 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index fe28f50e..2eb86c54 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/perf-next/package.json b/perf-next/package.json index 69cf753b..e05ef409 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index 8a072847..ffbd6c3e 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } diff --git a/storage-next/package.json b/storage-next/package.json index fbce56ec..a64d67b2 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.1.0" + "firebase": "^9.12.1" } } From 476223e29552c2128ac2d62e3906628130047cf8 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 20 Oct 2022 14:55:19 -0700 Subject: [PATCH 147/170] Auto-update dependencies. (#242) * Auto-update dependencies. * Auto-update dependencies. Co-authored-by: Morgan Chen --- firestore/index.html | 4 ++-- messaging/service-worker.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firestore/index.html b/firestore/index.html index ddc3c44d..3599ca13 100644 --- a/firestore/index.html +++ b/firestore/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 3b2f7de0..26f9d097 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 36740fb2c39383621c0c0a948236e9eab8a71516 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Thu, 20 Oct 2022 15:15:06 -0700 Subject: [PATCH 148/170] Add count query snippet (#307) * Add count query snippet * add simpler snippet * consts * no masking * run snippets --- firestore-next/test.firestore.js | 21 +++++++++++++++++++ .../count_aggregate_collection.js | 11 ++++++++++ .../test-firestore/count_aggregate_query.js | 12 +++++++++++ 3 files changed, 44 insertions(+) create mode 100644 snippets/firestore-next/test-firestore/count_aggregate_collection.js create mode 100644 snippets/firestore-next/test-firestore/count_aggregate_query.js diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 17ff6d29..2469b736 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -1158,6 +1158,27 @@ describe("firestore", () => { }); }); + describe("aggregate queries", () => { + it("should fetch the count of documents in a collection", async () => { + const { collection, getCountFromServer } = require("firebase/firestore"); + // [START count_aggregate_collection] + const coll = collection(db, "cities"); + const snapshot = await getCountFromServer(coll); + console.log('count: ', snapshot.data().count); + // [END count_aggregate_collection] + }); + + it("should fetch the count of documents in a query", async () => { + const { collection, getCountFromServer, where, query } = require("firebase/firestore"); + // [START count_aggregate_query] + const coll = collection(db, "cities"); + const q = query(coll, where("state", "==", "CA")); + const snapshot = await getCountFromServer(q); + console.log('count: ', snapshot.data().count); + // [END count_aggregate_query] + }); + }); + // TODO: Break out into separate file describe("solution-aggregation", () => { it("should update a restaurant in a transaction #UNVERIFIED", async () => { diff --git a/snippets/firestore-next/test-firestore/count_aggregate_collection.js b/snippets/firestore-next/test-firestore/count_aggregate_collection.js new file mode 100644 index 00000000..7dca7e37 --- /dev/null +++ b/snippets/firestore-next/test-firestore/count_aggregate_collection.js @@ -0,0 +1,11 @@ +// This snippet file was generated by processing the source file: +// ./firestore-next/test.firestore.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START count_aggregate_collection_modular] +const coll = collection(db, "cities"); +const snapshot = await getCountFromServer(coll); +console.log('count: ', snapshot.data().count); +// [END count_aggregate_collection_modular] \ No newline at end of file diff --git a/snippets/firestore-next/test-firestore/count_aggregate_query.js b/snippets/firestore-next/test-firestore/count_aggregate_query.js new file mode 100644 index 00000000..37a27458 --- /dev/null +++ b/snippets/firestore-next/test-firestore/count_aggregate_query.js @@ -0,0 +1,12 @@ +// This snippet file was generated by processing the source file: +// ./firestore-next/test.firestore.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START count_aggregate_query_modular] +const coll = collection(db, "cities"); +const q = query(coll, where("state", "==", "CA")); +const snapshot = await getCountFromServer(q); +console.log('count: ', snapshot.data().count); +// [END count_aggregate_query_modular] \ No newline at end of file From 7ca0947f12931dce792e66f986707ffa2839184a Mon Sep 17 00:00:00 2001 From: markarndt <50713862+markarndt@users.noreply.github.com> Date: Thu, 2 Feb 2023 16:02:59 -0800 Subject: [PATCH 149/170] Add Storage emulator snippets that were previously hard-coded in docs. (#304) * Initial push to prepare for review. * Fix lint error. * Generate /snippets/storage-next/emulator-suite. * Fix errant RTDB reference in comment lines. --- .../emulator-suite/storage_emulator_connect.js | 15 +++++++++++++++ storage-next/emulator-suite.js | 14 ++++++++++++++ storage/emulator-suite.js | 16 ++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 snippets/storage-next/emulator-suite/storage_emulator_connect.js create mode 100644 storage-next/emulator-suite.js create mode 100644 storage/emulator-suite.js diff --git a/snippets/storage-next/emulator-suite/storage_emulator_connect.js b/snippets/storage-next/emulator-suite/storage_emulator_connect.js new file mode 100644 index 00000000..5cdc1589 --- /dev/null +++ b/snippets/storage-next/emulator-suite/storage_emulator_connect.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./storage-next/emulator-suite.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START storage_emulator_connect_modular] +import { getStorage, connectStorageEmulator } from "firebase/storage"; + +const storage = getStorage(); +if (location.hostname === "localhost") { + // Point to the Storage emulator running on localhost. + connectStorageEmulator(storage, "localhost", 9199); +} +// [END storage_emulator_connect_modular] \ No newline at end of file diff --git a/storage-next/emulator-suite.js b/storage-next/emulator-suite.js new file mode 100644 index 00000000..b3038033 --- /dev/null +++ b/storage-next/emulator-suite.js @@ -0,0 +1,14 @@ +// [SNIPPET_REGISTRY disabled] +// [SNIPPETS_SEPARATION enabled] + +function onDocumentReady() { + // [START storage_emulator_connect] + const { getStorage, connectStorageEmulator } = require("firebase/storage"); + + const storage = getStorage(); + if (location.hostname === "localhost") { + // Point to the Storage emulator running on localhost. + connectStorageEmulator(storage, "localhost", 9199); + } + // [END storage_emulator_connect] +} diff --git a/storage/emulator-suite.js b/storage/emulator-suite.js new file mode 100644 index 00000000..7f93e660 --- /dev/null +++ b/storage/emulator-suite.js @@ -0,0 +1,16 @@ +// These samples are intended for Web so this import would normally be +// done in HTML however using modules here is more convenient for +// ensuring sample correctness offline. +import firebase from "firebase/app"; +import "firebase/storage"; + +function onDocumentReady() { + // [START storage_emulator_connect] + var storage = firebase.storage(); + if (location.hostname === "localhost") { + // Point to the Storage emulator running on localhost. + storage.useEmulator("localhost", 9199); + } + // [END storage_emulator_connect] +} + From b48560b155e6f27db977f51070470631e7a2db56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ros=C3=A1rio=20Pereira=20Fernandes?= Date: Fri, 3 Feb 2023 18:05:46 +0000 Subject: [PATCH 150/170] refactor: import getMessaging from messaging/sw (#320) --- messaging-next/service-worker.js | 2 +- .../service-worker/messaging_on_background_message.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/messaging-next/service-worker.js b/messaging-next/service-worker.js index a81a7c18..55f07524 100644 --- a/messaging-next/service-worker.js +++ b/messaging-next/service-worker.js @@ -40,7 +40,7 @@ function initInSw() { function onBackgroundMessage() { // [START messaging_on_background_message] - const { getMessaging } = require("firebase/messaging"); + const { getMessaging } = require("firebase/messaging/sw"); const { onBackgroundMessage } = require("firebase/messaging/sw"); const messaging = getMessaging(); diff --git a/snippets/messaging-next/service-worker/messaging_on_background_message.js b/snippets/messaging-next/service-worker/messaging_on_background_message.js index b7f65b53..79c17eea 100644 --- a/snippets/messaging-next/service-worker/messaging_on_background_message.js +++ b/snippets/messaging-next/service-worker/messaging_on_background_message.js @@ -5,7 +5,7 @@ // 'npm run snippets'. // [START messaging_on_background_message_modular] -import { getMessaging } from "firebase/messaging"; +import { getMessaging } from "firebase/messaging/sw"; import { onBackgroundMessage } from "firebase/messaging/sw"; const messaging = getMessaging(); From 73a4f0b01c7e9869e3bb8bd4494ff186eb784ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ros=C3=A1rio=20Pereira=20Fernandes?= Date: Fri, 3 Feb 2023 18:09:33 +0000 Subject: [PATCH 151/170] mention getAdditionalUserInfo() in oauth providers (#319) --- auth-next/apple.js | 1 + auth-next/facebook.js | 3 +++ auth-next/github.js | 3 +++ auth-next/google-signin.js | 3 +++ auth-next/twitter.js | 3 +++ auth/apple.js | 7 +++++-- auth/facebook.js | 4 ++++ auth/github.js | 5 ++++- auth/google-signin.js | 5 ++++- auth/twitter.js | 5 ++++- snippets/auth-next/apple/auth_apple_signin_popup.js | 1 + snippets/auth-next/facebook/auth_facebook_signin_popup.js | 1 + .../facebook/auth_facebook_signin_redirect_result.js | 2 ++ snippets/auth-next/github/auth_github_signin_popup.js | 1 + .../auth-next/github/auth_github_signin_redirect_result.js | 2 ++ .../auth-next/google-signin/auth_google_signin_popup.js | 1 + .../google-signin/auth_google_signin_redirect_result.js | 2 ++ snippets/auth-next/twitter/auth_twitter_signin_popup.js | 1 + .../twitter/auth_twitter_signin_redirect_result.js | 2 ++ 19 files changed, 47 insertions(+), 5 deletions(-) diff --git a/auth-next/apple.js b/auth-next/apple.js index f9670b4c..2777a085 100644 --- a/auth-next/apple.js +++ b/auth-next/apple.js @@ -38,6 +38,7 @@ function appleSignInPopup(provider) { const accessToken = credential.accessToken; const idToken = credential.idToken; + // IdP data available using getAdditionalUserInfo(result) // ... }) .catch((error) => { diff --git a/auth-next/facebook.js b/auth-next/facebook.js index 67b397f2..3c6feb8a 100644 --- a/auth-next/facebook.js +++ b/auth-next/facebook.js @@ -33,6 +33,7 @@ function facebookSignInPopup(provider) { const credential = FacebookAuthProvider.credentialFromResult(result); const accessToken = credential.accessToken; + // IdP data available using getAdditionalUserInfo(result) // ... }) .catch((error) => { @@ -61,6 +62,8 @@ function facebookSignInRedirectResult() { const token = credential.accessToken; const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/auth-next/github.js b/auth-next/github.js index babfd1ee..4c128721 100644 --- a/auth-next/github.js +++ b/auth-next/github.js @@ -40,6 +40,7 @@ function githubSignInPopup(provider) { // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) // ... }).catch((error) => { // Handle Errors here. @@ -70,6 +71,8 @@ function githubSignInRedirectResult() { // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/auth-next/google-signin.js b/auth-next/google-signin.js index 136c26b5..025eebd6 100644 --- a/auth-next/google-signin.js +++ b/auth-next/google-signin.js @@ -33,6 +33,7 @@ function googleSignInPopup(provider) { const token = credential.accessToken; // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) // ... }).catch((error) => { // Handle Errors here. @@ -60,6 +61,8 @@ function googleSignInRedirectResult() { // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/auth-next/twitter.js b/auth-next/twitter.js index a386e4ab..f96e574b 100644 --- a/auth-next/twitter.js +++ b/auth-next/twitter.js @@ -30,6 +30,7 @@ function twitterSignInPopup(provider) { // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) // ... }).catch((error) => { // Handle Errors here. @@ -60,6 +61,8 @@ function twitterSignInRedirectResult() { // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/auth/apple.js b/auth/apple.js index e99349c8..00e2598e 100644 --- a/auth/apple.js +++ b/auth/apple.js @@ -40,7 +40,8 @@ function appleSignInPopup(provider) { var accessToken = credential.accessToken; var idToken = credential.idToken; - // ... + // IdP data available using getAdditionalUserInfo(result) + // ... }) .catch((error) => { // Handle Errors here. @@ -77,6 +78,7 @@ function appleSignInRedirectResult() { var accessToken = credential.accessToken; var idToken = credential.idToken; + // IdP data available in result.additionalUserInfo.profile. // ... } // The signed-in user info. @@ -117,7 +119,8 @@ function appleReauthenticatePopup() { var accessToken = credential.accessToken; var idToken = credential.idToken; - // ... + // IdP data available in result.additionalUserInfo.profile. + // ... }) .catch((error) => { // Handle Errors here. diff --git a/auth/facebook.js b/auth/facebook.js index 4259960d..75e99d43 100644 --- a/auth/facebook.js +++ b/auth/facebook.js @@ -31,6 +31,8 @@ function facebookSignInPopup(provider) { // The signed-in user info. var user = result.user; + // IdP data available in result.additionalUserInfo.profile. + // ... // This gives you a Facebook Access Token. You can use it to access the Facebook API. var accessToken = credential.accessToken; @@ -66,6 +68,8 @@ function facebookSignInRedirectResult() { } // The signed-in user info. var user = result.user; + // IdP data available in result.additionalUserInfo.profile. + // ... }).catch((error) => { // Handle Errors here. var errorCode = error.code; diff --git a/auth/github.js b/auth/github.js index 6ae1e531..8ae9b39c 100644 --- a/auth/github.js +++ b/auth/github.js @@ -40,7 +40,8 @@ function githubSignInPopup(provider) { // The signed-in user info. var user = result.user; - // ... + // IdP data available in result.additionalUserInfo.profile. + // ... }).catch((error) => { // Handle Errors here. var errorCode = error.code; @@ -70,6 +71,8 @@ function githubSignInRedirectResult() { // The signed-in user info. var user = result.user; + // IdP data available in result.additionalUserInfo.profile. + // ... }).catch((error) => { // Handle Errors here. var errorCode = error.code; diff --git a/auth/google-signin.js b/auth/google-signin.js index fcc32dc8..06a488e4 100644 --- a/auth/google-signin.js +++ b/auth/google-signin.js @@ -34,7 +34,8 @@ function googleSignInPopup(provider) { var token = credential.accessToken; // The signed-in user info. var user = result.user; - // ... + // IdP data available in result.additionalUserInfo.profile. + // ... }).catch((error) => { // Handle Errors here. var errorCode = error.code; @@ -63,6 +64,8 @@ function googleSignInRedirectResult() { } // The signed-in user info. var user = result.user; + // IdP data available in result.additionalUserInfo.profile. + // ... }).catch((error) => { // Handle Errors here. var errorCode = error.code; diff --git a/auth/twitter.js b/auth/twitter.js index a78370b7..68ed6f35 100644 --- a/auth/twitter.js +++ b/auth/twitter.js @@ -32,7 +32,8 @@ function twitterSignInPopup(provider) { // The signed-in user info. var user = result.user; - // ... + // IdP data available in result.additionalUserInfo.profile. + // ... }).catch((error) => { // Handle Errors here. var errorCode = error.code; @@ -64,6 +65,8 @@ function twitterSignInRedirectResult() { // The signed-in user info. var user = result.user; + // IdP data available in result.additionalUserInfo.profile. + // ... }).catch((error) => { // Handle Errors here. var errorCode = error.code; diff --git a/snippets/auth-next/apple/auth_apple_signin_popup.js b/snippets/auth-next/apple/auth_apple_signin_popup.js index c2a392cf..e3a0f11b 100644 --- a/snippets/auth-next/apple/auth_apple_signin_popup.js +++ b/snippets/auth-next/apple/auth_apple_signin_popup.js @@ -18,6 +18,7 @@ signInWithPopup(auth, provider) const accessToken = credential.accessToken; const idToken = credential.idToken; + // IdP data available using getAdditionalUserInfo(result) // ... }) .catch((error) => { diff --git a/snippets/auth-next/facebook/auth_facebook_signin_popup.js b/snippets/auth-next/facebook/auth_facebook_signin_popup.js index 7d35aaf2..524a11ac 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_popup.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_popup.js @@ -17,6 +17,7 @@ signInWithPopup(auth, provider) const credential = FacebookAuthProvider.credentialFromResult(result); const accessToken = credential.accessToken; + // IdP data available using getAdditionalUserInfo(result) // ... }) .catch((error) => { diff --git a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js index eb6cdb30..c65c47d7 100644 --- a/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js +++ b/snippets/auth-next/facebook/auth_facebook_signin_redirect_result.js @@ -15,6 +15,8 @@ getRedirectResult(auth) const token = credential.accessToken; const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/snippets/auth-next/github/auth_github_signin_popup.js b/snippets/auth-next/github/auth_github_signin_popup.js index e1b4768e..3839a70f 100644 --- a/snippets/auth-next/github/auth_github_signin_popup.js +++ b/snippets/auth-next/github/auth_github_signin_popup.js @@ -16,6 +16,7 @@ signInWithPopup(auth, provider) // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) // ... }).catch((error) => { // Handle Errors here. diff --git a/snippets/auth-next/github/auth_github_signin_redirect_result.js b/snippets/auth-next/github/auth_github_signin_redirect_result.js index b3d31d0a..fb5f7ca2 100644 --- a/snippets/auth-next/github/auth_github_signin_redirect_result.js +++ b/snippets/auth-next/github/auth_github_signin_redirect_result.js @@ -19,6 +19,8 @@ getRedirectResult(auth) // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/snippets/auth-next/google-signin/auth_google_signin_popup.js b/snippets/auth-next/google-signin/auth_google_signin_popup.js index d6c70eb9..433bb88e 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_popup.js +++ b/snippets/auth-next/google-signin/auth_google_signin_popup.js @@ -15,6 +15,7 @@ signInWithPopup(auth, provider) const token = credential.accessToken; // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) // ... }).catch((error) => { // Handle Errors here. diff --git a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js index 50c4aded..2953ab5f 100644 --- a/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js +++ b/snippets/auth-next/google-signin/auth_google_signin_redirect_result.js @@ -16,6 +16,8 @@ getRedirectResult(auth) // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; diff --git a/snippets/auth-next/twitter/auth_twitter_signin_popup.js b/snippets/auth-next/twitter/auth_twitter_signin_popup.js index ae8e2007..adb7322e 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_popup.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_popup.js @@ -18,6 +18,7 @@ signInWithPopup(auth, provider) // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) // ... }).catch((error) => { // Handle Errors here. diff --git a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js index 73e42bab..357faa4e 100644 --- a/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js +++ b/snippets/auth-next/twitter/auth_twitter_signin_redirect_result.js @@ -19,6 +19,8 @@ getRedirectResult(auth) // The signed-in user info. const user = result.user; + // IdP data available using getAdditionalUserInfo(result) + // ... }).catch((error) => { // Handle Errors here. const errorCode = error.code; From 486e5c67bcb895a00ccab90f1b20cefdba6c9e3a Mon Sep 17 00:00:00 2001 From: dwyfrequency Date: Wed, 15 Feb 2023 13:28:52 -0500 Subject: [PATCH 152/170] Update gstatic url for v8 example (#325) --- messaging/service-worker.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/messaging/service-worker.js b/messaging/service-worker.js index 26f9d097..c0f875bb 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -1,5 +1,5 @@ -import firebase from "firebase/app"; -import "firebase/messaging"; +import firebase from 'firebase/app'; +import 'firebase/messaging'; // See: https://github.com/microsoft/TypeScript/issues/14877 /** @type {ServiceWorkerGlobalScope} */ @@ -10,8 +10,8 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging.js'); + importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. @@ -38,16 +38,18 @@ function onBackgroundMessage() { // [START messaging_on_background_message] messaging.onBackgroundMessage((payload) => { - console.log('[firebase-messaging-sw.js] Received background message ', payload); + console.log( + '[firebase-messaging-sw.js] Received background message ', + payload + ); // Customize notification here const notificationTitle = 'Background Message Title'; const notificationOptions = { body: 'Background Message body.', icon: '/firebase-logo.png' }; - - self.registration.showNotification(notificationTitle, - notificationOptions); + + self.registration.showNotification(notificationTitle, notificationOptions); }); // [END messaging_on_background_message] } From e2beb93c2842b540ce78403ff4e2b115ebc0d072 Mon Sep 17 00:00:00 2001 From: Shabbirjodhpur <62835725+Shabbirjodhpur@users.noreply.github.com> Date: Tue, 4 Apr 2023 21:43:38 +0530 Subject: [PATCH 153/170] Update get_document.js (#335) We get the snapshot of data using 'getDoc()' and get result 'docSnap' And then we perform check on this 'docSnap' in the if else block So in the else block the comment should ne docSnap.data() will ne undefined --- firestore-next/test.firestore.js | 2 +- snippets/firestore-next/test-firestore/get_document.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index 2469b736..a430064f 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -583,7 +583,7 @@ describe("firestore", () => { if (docSnap.exists()) { console.log("Document data:", docSnap.data()); } else { - // doc.data() will be undefined in this case + // docSnap.data() will be undefined in this case console.log("No such document!"); } // [END get_document] diff --git a/snippets/firestore-next/test-firestore/get_document.js b/snippets/firestore-next/test-firestore/get_document.js index 4cfbaaf6..1653b61a 100644 --- a/snippets/firestore-next/test-firestore/get_document.js +++ b/snippets/firestore-next/test-firestore/get_document.js @@ -13,7 +13,7 @@ const docSnap = await getDoc(docRef); if (docSnap.exists()) { console.log("Document data:", docSnap.data()); } else { - // doc.data() will be undefined in this case + // docSnap.data() will be undefined in this case console.log("No such document!"); } // [END get_document_modular] \ No newline at end of file From 1852962750472181dbb4523e5185b8e0350f2f38 Mon Sep 17 00:00:00 2001 From: Juan Lara Date: Tue, 9 May 2023 02:26:28 -0700 Subject: [PATCH 154/170] Add a snippet demonstrating a subcollection query. (#339) --- firestore-next/test.firestore.js | 12 ++++++++++++ .../firestore_query_subcollection.js | 15 +++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 snippets/firestore-next/test-firestore/firestore_query_subcollection.js diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index a430064f..c961af9d 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -683,6 +683,18 @@ describe("firestore", () => { // [END get_multiple_all] }); + it("should get all documents from a subcollection", async () => { + // [START firestore_query_subcollection] + const { collection, getDocs } = require("firebase/firestore"); + // Query a reference to a subcollection + const querySnapshot = await getDocs(collection(db, "cities", "SF", "landmarks")); + querySnapshot.forEach((doc) => { + // doc.data() is never undefined for query doc snapshots + console.log(doc.id, " => ", doc.data()); + }); + // [END firestore_query_subcollection] + }); + it("should listen on multiple documents #UNVERIFIED", (done) => { // [START listen_multiple] const { collection, query, where, onSnapshot } = require("firebase/firestore"); diff --git a/snippets/firestore-next/test-firestore/firestore_query_subcollection.js b/snippets/firestore-next/test-firestore/firestore_query_subcollection.js new file mode 100644 index 00000000..76a1b847 --- /dev/null +++ b/snippets/firestore-next/test-firestore/firestore_query_subcollection.js @@ -0,0 +1,15 @@ +// This snippet file was generated by processing the source file: +// ./firestore-next/test.firestore.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START firestore_query_subcollection_modular] +import { collection, getDocs } from "firebase/firestore"; +// Query a reference to a subcollection +const querySnapshot = await getDocs(collection(db, "cities", "SF", "landmarks")); +querySnapshot.forEach((doc) => { + // doc.data() is never undefined for query doc snapshots + console.log(doc.id, " => ", doc.data()); +}); +// [END firestore_query_subcollection_modular] \ No newline at end of file From 2414b5519c79472a228a38205f646e71d43cb182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ros=C3=A1rio=20P=2E=20Fernandes?= Date: Mon, 22 May 2023 14:32:41 +0100 Subject: [PATCH 155/170] fix broken ref docs urls (#343) * fix broken ref docs urls * update the separate-snippets script to replace ref docs urls --- auth-next/index.js | 4 +-- auth/index.js | 4 +-- firestore/test.firestore.js | 2 +- scripts/separate-snippets.ts | 27 +++++++++++++++++++ snippets/auth-next/index/auth_current_user.js | 2 +- .../auth-next/index/auth_state_listener.js | 2 +- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/auth-next/index.js b/auth-next/index.js index b4a17903..b741a6d7 100644 --- a/auth-next/index.js +++ b/auth-next/index.js @@ -52,7 +52,7 @@ function authStateListener() { onAuthStateChanged(auth, (user) => { if (user) { // User is signed in, see docs for a list of available properties - // https://firebase.google.com/docs/reference/js/firebase.User + // https://firebase.google.com/docs/reference/js/v8/firebase.User const uid = user.uid; // ... } else { @@ -72,7 +72,7 @@ function currentUser() { if (user) { // User is signed in, see docs for a list of available properties - // https://firebase.google.com/docs/reference/js/firebase.User + // https://firebase.google.com/docs/reference/js/v8/firebase.User // ... } else { // No user is signed in. diff --git a/auth/index.js b/auth/index.js index 6567c030..35546aa3 100644 --- a/auth/index.js +++ b/auth/index.js @@ -43,7 +43,7 @@ function authStateListener() { firebase.auth().onAuthStateChanged((user) => { if (user) { // User is signed in, see docs for a list of available properties - // https://firebase.google.com/docs/reference/js/firebase.User + // https://firebase.google.com/docs/reference/js/v8/firebase.User var uid = user.uid; // ... } else { @@ -60,7 +60,7 @@ function currentUser() { if (user) { // User is signed in, see docs for a list of available properties - // https://firebase.google.com/docs/reference/js/firebase.User + // https://firebase.google.com/docs/reference/js/v8/firebase.User // ... } else { // No user is signed in. diff --git a/firestore/test.firestore.js b/firestore/test.firestore.js index dbf6e18e..ec89172e 100644 --- a/firestore/test.firestore.js +++ b/firestore/test.firestore.js @@ -600,7 +600,7 @@ describe("firestore", () => { var docRef = db.collection("cities").doc("SF"); // Valid options for source are 'server', 'cache', or - // 'default'. See https://firebase.google.com/docs/reference/js/firebase.firestore.GetOptions + // 'default'. See https://firebase.google.com/docs/reference/js/v8/firebase.firestore.GetOptions // for more information. var getOptions = { source: 'cache' diff --git a/scripts/separate-snippets.ts b/scripts/separate-snippets.ts index a888d908..b2f41de3 100644 --- a/scripts/separate-snippets.ts +++ b/scripts/separate-snippets.ts @@ -18,6 +18,15 @@ const RE_END_SNIPPET = /\[END\s+([A-Za-z_]+)\s*\]/; // TODO: Handle multiline imports? const RE_REQUIRE = /const {(.+?)} = require\((.+?)\)/; +// Regex for ref docs URLs +// eg. "https://firebase.google.com/docs/reference/js/v8/firebase.User" +const RE_REF_DOCS = /https:\/\/firebase\.google\.com\/docs\/reference\/js\/(.*)/; + +// Maps v8 ref docs URLs to their v9 counterpart +const REF_DOCS_MAPPINGS: { [key: string]: string } = { + "v8/firebase.User" : "auth.user" +}; + type SnippetsConfig = { enabled: boolean; suffix: string; @@ -30,6 +39,23 @@ function isBlank(line: string) { return line.trim().length === 0; } +/** + * Replace all v8 ref doc urls with their v9 counterpart. + */ +function replaceRefDocsUrls(lines: string[]) { + const outputLines = []; + for (const line of lines) { + if (line.match(RE_REF_DOCS)) { + outputLines.push(line.replace(RE_REF_DOCS, (match: string, p1?: string) => { + return p1 ? `https://firebase.google.com/docs/reference/js/${REF_DOCS_MAPPINGS[p1]}` : match; + })); + } else { + outputLines.push(line); + } + } + return outputLines; +} + /** * Replace all const { foo } = require('bar') with import { foo } from 'bar'; */ @@ -119,6 +145,7 @@ function processSnippet( outputLines = addSuffixToSnippetNames(outputLines, snippetSuffix); outputLines = adjustIndentation(outputLines); outputLines = removeFirstLineAfterComments(outputLines); + outputLines = replaceRefDocsUrls(outputLines); // Add a preamble to every snippet const preambleLines = [ diff --git a/snippets/auth-next/index/auth_current_user.js b/snippets/auth-next/index/auth_current_user.js index c094a464..6925b021 100644 --- a/snippets/auth-next/index/auth_current_user.js +++ b/snippets/auth-next/index/auth_current_user.js @@ -12,7 +12,7 @@ const user = auth.currentUser; if (user) { // User is signed in, see docs for a list of available properties - // https://firebase.google.com/docs/reference/js/firebase.User + // https://firebase.google.com/docs/reference/js/auth.user // ... } else { // No user is signed in. diff --git a/snippets/auth-next/index/auth_state_listener.js b/snippets/auth-next/index/auth_state_listener.js index aebe6818..0f3e4e88 100644 --- a/snippets/auth-next/index/auth_state_listener.js +++ b/snippets/auth-next/index/auth_state_listener.js @@ -11,7 +11,7 @@ const auth = getAuth(); onAuthStateChanged(auth, (user) => { if (user) { // User is signed in, see docs for a list of available properties - // https://firebase.google.com/docs/reference/js/firebase.User + // https://firebase.google.com/docs/reference/js/auth.user const uid = user.uid; // ... } else { From 8fc7be2dc9ea398e63f57222d02428f8fa506a11 Mon Sep 17 00:00:00 2001 From: gregfenton Date: Mon, 22 May 2023 13:19:10 -0400 Subject: [PATCH 156/170] Remove unused function parameter (#344) --- firestore/test.solution-counters.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firestore/test.solution-counters.js b/firestore/test.solution-counters.js index c8c62fe6..c7c51cff 100644 --- a/firestore/test.solution-counters.js +++ b/firestore/test.solution-counters.js @@ -22,7 +22,7 @@ function createCounter(ref, num_shards) { // [END create_counter] // [START increment_counter] -function incrementCounter(db, ref, num_shards) { +function incrementCounter(ref, num_shards) { // Select a shard of the counter at random const shard_id = Math.floor(Math.random() * num_shards).toString(); const shard_ref = ref.collection('shards').doc(shard_id); @@ -67,7 +67,7 @@ describe("firestore-solution-counters", () => { // Create a counter, then increment it const ref = db.collection('counters').doc(); return createCounter(ref, 10).then(() => { - return incrementCounter(db, ref, 10); + return incrementCounter(ref, 10); }); }); @@ -75,7 +75,7 @@ describe("firestore-solution-counters", () => { // Create a counter, increment it, then get the count const ref = db.collection('counters').doc(); return createCounter(ref, 10).then(() => { - return incrementCounter(db, ref, 10); + return incrementCounter(ref, 10); }).then(() => { return getCount(ref); }); From adb06a357b6a6509019f15b88cccbdc2788353ef Mon Sep 17 00:00:00 2001 From: markarndt <50713862+markarndt@users.noreply.github.com> Date: Thu, 8 Jun 2023 15:39:37 -0700 Subject: [PATCH 157/170] Emulator localhost updates, localhost -> 127.0.0.1 (#334) * Update v8 and v9 for localhost -> 127.0.0.1 requirement. * Update Auth emulator snippets for localhost -> 127.0.0.1 requirement. * Update RTDB emulator snippet for localhost -> 127.0.0.1 requirement. * Update Storage emulator snippets for localhost -> 127.0.0.1 requirement. * More Database emulator snippet updates. * Update emulator-suite.js * Update emulator-suite.js * Update v8 and v9 for localhost -> 127.0.0.1 requirement. * Update Auth emulator snippets for localhost -> 127.0.0.1 requirement. * Update RTDB emulator snippet for localhost -> 127.0.0.1 requirement. * Update Storage emulator snippets for localhost -> 127.0.0.1 requirement. * More Database emulator snippet updates. * After running local script, new update file. * Test using "Delete" to remove file from PR, not repo * Put this file back. --- auth-next/emulator-suite.js | 2 +- auth/emulator-suite.js | 2 +- database-next/emulator-suite.js | 2 +- database/emulator-suite.js | 2 +- firestore-next/emulator-suite.js | 2 +- firestore/emulator-suite.js | 2 +- functions-next/emulator-suite.js | 2 +- functions/emulator-suite.js | 2 +- snippets/auth-next/emulator-suite/auth_emulator_connect.js | 2 +- snippets/database-next/emulator-suite/rtdb_emulator_connect.js | 2 +- snippets/firestore-next/emulator-suite/fs_emulator_connect.js | 2 +- .../emulator-suite/fb_functions_emulator_connect.js | 2 +- .../storage-next/emulator-suite/storage_emulator_connect.js | 2 +- storage-next/emulator-suite.js | 2 +- storage/emulator-suite.js | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/auth-next/emulator-suite.js b/auth-next/emulator-suite.js index 66507de3..13b1ba95 100644 --- a/auth-next/emulator-suite.js +++ b/auth-next/emulator-suite.js @@ -6,7 +6,7 @@ function emulatorConnect() { const { getAuth, connectAuthEmulator } = require("firebase/auth"); const auth = getAuth(); - connectAuthEmulator(auth, "http://localhost:9099"); + connectAuthEmulator(auth, "http://127.0.0.1:9099"); // [END auth_emulator_connect] } diff --git a/auth/emulator-suite.js b/auth/emulator-suite.js index b14a72db..b0f815e2 100644 --- a/auth/emulator-suite.js +++ b/auth/emulator-suite.js @@ -4,7 +4,7 @@ import "firebase/auth"; function emulatorConnect() { // [START auth_emulator_connect] const auth = firebase.auth(); - auth.useEmulator("http://localhost:9099"); + auth.useEmulator("http://127.0.0.1:9099"); // [END auth_emulator_connect] } diff --git a/database-next/emulator-suite.js b/database-next/emulator-suite.js index ab86bf9b..f94d3c89 100644 --- a/database-next/emulator-suite.js +++ b/database-next/emulator-suite.js @@ -8,7 +8,7 @@ function onDocumentReady() { const db = getDatabase(); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. - connectDatabaseEmulator(db, "localhost", 9000); + connectDatabaseEmulator(db, "127.0.0.1", 9000); } // [END rtdb_emulator_connect] } diff --git a/database/emulator-suite.js b/database/emulator-suite.js index 8fe739e4..8da23e25 100644 --- a/database/emulator-suite.js +++ b/database/emulator-suite.js @@ -10,7 +10,7 @@ function onDocumentReady() { var db = firebase.database(); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. - db.useEmulator("localhost", 9000); + db.useEmulator("127.0.0.1", 9000); } // [END rtdb_emulator_connect] } diff --git a/firestore-next/emulator-suite.js b/firestore-next/emulator-suite.js index 30ad24eb..edc900c1 100644 --- a/firestore-next/emulator-suite.js +++ b/firestore-next/emulator-suite.js @@ -7,6 +7,6 @@ function onDocumentReady() { // firebaseApps previously initialized using initializeApp() const db = getFirestore(); - connectFirestoreEmulator(db, 'localhost', 8080); + connectFirestoreEmulator(db, '127.0.0.1', 8080); // [END fs_emulator_connect] } diff --git a/firestore/emulator-suite.js b/firestore/emulator-suite.js index 714d38e7..03aef1e9 100644 --- a/firestore/emulator-suite.js +++ b/firestore/emulator-suite.js @@ -6,7 +6,7 @@ function onDocumentReady() { // Firebase previously initialized using firebase.initializeApp(). var db = firebase.firestore(); if (location.hostname === "localhost") { - db.useEmulator("localhost", 8080); + db.useEmulator("127.0.0.1", 8080); } // [END fs_emulator_connect] } diff --git a/functions-next/emulator-suite.js b/functions-next/emulator-suite.js index 7a750fc4..db7fd49d 100644 --- a/functions-next/emulator-suite.js +++ b/functions-next/emulator-suite.js @@ -15,7 +15,7 @@ export function emulatorSettings() { const { getFunctions, connectFunctionsEmulator } = require("firebase/functions"); const functions = getFunctions(getApp()); - connectFunctionsEmulator(functions, "localhost", 5001); + connectFunctionsEmulator(functions, "127.0.0.1", 5001); // [END fb_functions_emulator_connect] } diff --git a/functions/emulator-suite.js b/functions/emulator-suite.js index a9cdc7d7..e0413370 100644 --- a/functions/emulator-suite.js +++ b/functions/emulator-suite.js @@ -3,6 +3,6 @@ import "firebase/functions"; function emulatorSettings() { // [START fb_functions_emulator_connect] - firebase.functions().useEmulator("localhost", 5001); + firebase.functions().useEmulator("127.0.0.1", 5001); // [END fb_functions_emulator_connect] } diff --git a/snippets/auth-next/emulator-suite/auth_emulator_connect.js b/snippets/auth-next/emulator-suite/auth_emulator_connect.js index dd0b2e37..525a92b8 100644 --- a/snippets/auth-next/emulator-suite/auth_emulator_connect.js +++ b/snippets/auth-next/emulator-suite/auth_emulator_connect.js @@ -8,5 +8,5 @@ import { getAuth, connectAuthEmulator } from "firebase/auth"; const auth = getAuth(); -connectAuthEmulator(auth, "http://localhost:9099"); +connectAuthEmulator(auth, "http://127.0.0.1:9099"); // [END auth_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js index 4cc268e7..0bd145f6 100644 --- a/snippets/database-next/emulator-suite/rtdb_emulator_connect.js +++ b/snippets/database-next/emulator-suite/rtdb_emulator_connect.js @@ -10,6 +10,6 @@ import { getDatabase, connectDatabaseEmulator } from "firebase/database"; const db = getDatabase(); if (location.hostname === "localhost") { // Point to the RTDB emulator running on localhost. - connectDatabaseEmulator(db, "localhost", 9000); + connectDatabaseEmulator(db, "127.0.0.1", 9000); } // [END rtdb_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js index 7e31fcfd..d70fbb68 100644 --- a/snippets/firestore-next/emulator-suite/fs_emulator_connect.js +++ b/snippets/firestore-next/emulator-suite/fs_emulator_connect.js @@ -9,5 +9,5 @@ import { getFirestore, connectFirestoreEmulator } from "firebase/firestore"; // firebaseApps previously initialized using initializeApp() const db = getFirestore(); -connectFirestoreEmulator(db, 'localhost', 8080); +connectFirestoreEmulator(db, '127.0.0.1', 8080); // [END fs_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js index 9b186fc2..835a2c60 100644 --- a/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js +++ b/snippets/functions-next/emulator-suite/fb_functions_emulator_connect.js @@ -9,5 +9,5 @@ import { getApp } from "firebase/app"; import { getFunctions, connectFunctionsEmulator } from "firebase/functions"; const functions = getFunctions(getApp()); -connectFunctionsEmulator(functions, "localhost", 5001); +connectFunctionsEmulator(functions, "127.0.0.1", 5001); // [END fb_functions_emulator_connect_modular] \ No newline at end of file diff --git a/snippets/storage-next/emulator-suite/storage_emulator_connect.js b/snippets/storage-next/emulator-suite/storage_emulator_connect.js index 5cdc1589..4b247d17 100644 --- a/snippets/storage-next/emulator-suite/storage_emulator_connect.js +++ b/snippets/storage-next/emulator-suite/storage_emulator_connect.js @@ -10,6 +10,6 @@ import { getStorage, connectStorageEmulator } from "firebase/storage"; const storage = getStorage(); if (location.hostname === "localhost") { // Point to the Storage emulator running on localhost. - connectStorageEmulator(storage, "localhost", 9199); + connectStorageEmulator(storage, "127.0.0.1", 9199); } // [END storage_emulator_connect_modular] \ No newline at end of file diff --git a/storage-next/emulator-suite.js b/storage-next/emulator-suite.js index b3038033..78891a4f 100644 --- a/storage-next/emulator-suite.js +++ b/storage-next/emulator-suite.js @@ -8,7 +8,7 @@ function onDocumentReady() { const storage = getStorage(); if (location.hostname === "localhost") { // Point to the Storage emulator running on localhost. - connectStorageEmulator(storage, "localhost", 9199); + connectStorageEmulator(storage, "127.0.0.1", 9199); } // [END storage_emulator_connect] } diff --git a/storage/emulator-suite.js b/storage/emulator-suite.js index 7f93e660..be1f2dd4 100644 --- a/storage/emulator-suite.js +++ b/storage/emulator-suite.js @@ -9,7 +9,7 @@ function onDocumentReady() { var storage = firebase.storage(); if (location.hostname === "localhost") { // Point to the Storage emulator running on localhost. - storage.useEmulator("localhost", 9199); + storage.useEmulator("127.0.0.1", 9199); } // [END storage_emulator_connect] } From 10cfebc889c92c7e41bfaec49dd3b777c88f9f53 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Thu, 22 Jun 2023 15:19:27 -0700 Subject: [PATCH 158/170] Auto-update dependencies. (#311) --- analytics-next/package.json | 2 +- appcheck-next/package.json | 2 +- auth-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index 0fb07418..2483e0cd 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/appcheck-next/package.json b/appcheck-next/package.json index ad78db9f..8af508c9 100644 --- a/appcheck-next/package.json +++ b/appcheck-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/auth-next/package.json b/auth-next/package.json index 48adc595..748ff657 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/database-next/package.json b/database-next/package.json index be3cab88..6e7d6f69 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index d7b654df..1e40f536 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 39b5c6a9..3ec379a7 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1", + "firebase": "^9.22.2", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index 618ee0c5..81d6c2f4 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 2eb86c54..7ba8ab2c 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/perf-next/package.json b/perf-next/package.json index e05ef409..e5d27230 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index ffbd6c3e..d0482e46 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } diff --git a/storage-next/package.json b/storage-next/package.json index a64d67b2..7098fd72 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.12.1" + "firebase": "^9.22.2" } } From 7156e6c4c245ff85082c1aa54f16cbcf1a75a640 Mon Sep 17 00:00:00 2001 From: Juyoung Kim Date: Fri, 7 Jul 2023 22:29:12 +0900 Subject: [PATCH 159/170] chore: add missing whitespace & fix an incorrect snippet (#352) * chore: add missing whitespace * chore: fix an incorrect snippet (#324) --- auth-next/index.js | 2 +- database-next/read-and-write.js | 2 +- snippets/auth-next/index/auth_set_language_code.js | 2 +- .../read-and-write/rtdb_social_listen_star_count.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth-next/index.js b/auth-next/index.js index b741a6d7..04ac7d03 100644 --- a/auth-next/index.js +++ b/auth-next/index.js @@ -87,7 +87,7 @@ function setLanguageCode() { const auth = getAuth(); auth.languageCode = 'it'; // To apply the default browser preference instead of explicitly setting it. - // firebase.auth().useDeviceLanguage(); + // auth.useDeviceLanguage(); // [END auth_set_language_code] } diff --git a/database-next/read-and-write.js b/database-next/read-and-write.js index 4196c0d7..c06c66b4 100644 --- a/database-next/read-and-write.js +++ b/database-next/read-and-write.js @@ -44,7 +44,7 @@ function socialListenStarCount() { } // [START rtdb_social_listen_star_count] - const { getDatabase, ref, onValue} = require("firebase/database"); + const { getDatabase, ref, onValue } = require("firebase/database"); const db = getDatabase(); const starCountRef = ref(db, 'posts/' + postId + '/starCount'); diff --git a/snippets/auth-next/index/auth_set_language_code.js b/snippets/auth-next/index/auth_set_language_code.js index 47e78295..fe9a2025 100644 --- a/snippets/auth-next/index/auth_set_language_code.js +++ b/snippets/auth-next/index/auth_set_language_code.js @@ -10,5 +10,5 @@ import { getAuth } from "firebase/auth"; const auth = getAuth(); auth.languageCode = 'it'; // To apply the default browser preference instead of explicitly setting it. -// firebase.auth().useDeviceLanguage(); +// auth.useDeviceLanguage(); // [END auth_set_language_code_modular] \ No newline at end of file diff --git a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js index ab520ce6..eb782894 100644 --- a/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js +++ b/snippets/database-next/read-and-write/rtdb_social_listen_star_count.js @@ -5,7 +5,7 @@ // 'npm run snippets'. // [START rtdb_social_listen_star_count_modular] -import { getDatabase, ref, onValue} from "firebase/database"; +import { getDatabase, ref, onValue } from "firebase/database"; const db = getDatabase(); const starCountRef = ref(db, 'posts/' + postId + '/starCount'); From 99310330e9cf4836ca94fc9e92114ed58cbdf1b9 Mon Sep 17 00:00:00 2001 From: Chase Hartsell <51487099+ch5zzy@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:58:34 -0700 Subject: [PATCH 160/170] Update phone auth snippets with RecaptchaVerifier parameter reordering (#348) * Update phone auth snippets with RecaptchaVerifier parameter reordering * Update auth-next dependency to v10 --- auth-next/package.json | 2 +- auth-next/phone-auth.js | 10 +++++----- .../auth_phone_recaptcha_verifier_invisible.js | 4 ++-- .../phone-auth/auth_phone_recaptcha_verifier_simple.js | 2 +- .../auth_phone_recaptcha_verifier_visible.js | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/auth-next/package.json b/auth-next/package.json index 748ff657..8d43bad1 100644 --- a/auth-next/package.json +++ b/auth-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/auth-next/phone-auth.js b/auth-next/phone-auth.js index cd894c64..99492f99 100644 --- a/auth-next/phone-auth.js +++ b/auth-next/phone-auth.js @@ -15,13 +15,13 @@ function recaptchaVerifierInvisible() { const { getAuth, RecaptchaVerifier } = require("firebase/auth"); const auth = getAuth(); - window.recaptchaVerifier = new RecaptchaVerifier('sign-in-button', { + window.recaptchaVerifier = new RecaptchaVerifier(auth, 'sign-in-button', { 'size': 'invisible', 'callback': (response) => { // reCAPTCHA solved, allow signInWithPhoneNumber. onSignInSubmit(); } - }, auth); + }); // [END auth_phone_recaptcha_verifier_invisible] } @@ -30,7 +30,7 @@ function recaptchaVerifierVisible() { const { getAuth, RecaptchaVerifier } = require("firebase/auth"); const auth = getAuth(); - window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', { + window.recaptchaVerifier = new RecaptchaVerifier(auth, 'recaptcha-container', { 'size': 'normal', 'callback': (response) => { // reCAPTCHA solved, allow signInWithPhoneNumber. @@ -40,7 +40,7 @@ function recaptchaVerifierVisible() { // Response expired. Ask user to solve reCAPTCHA again. // ... } - }, auth); + }); // [END auth_phone_recaptcha_verifier_visible] } @@ -49,7 +49,7 @@ function recaptchaVerifierSimple() { const { getAuth, RecaptchaVerifier } = require("firebase/auth"); const auth = getAuth(); - window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {}, auth); + window.recaptchaVerifier = new RecaptchaVerifier(auth, 'recaptcha-container', {}); // [END auth_phone_recaptcha_verifier_simple] } diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js index f6b6893f..7fd16eea 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_invisible.js @@ -8,11 +8,11 @@ import { getAuth, RecaptchaVerifier } from "firebase/auth"; const auth = getAuth(); -window.recaptchaVerifier = new RecaptchaVerifier('sign-in-button', { +window.recaptchaVerifier = new RecaptchaVerifier(auth, 'sign-in-button', { 'size': 'invisible', 'callback': (response) => { // reCAPTCHA solved, allow signInWithPhoneNumber. onSignInSubmit(); } -}, auth); +}); // [END auth_phone_recaptcha_verifier_invisible_modular] \ No newline at end of file diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js index ed56fe99..b57eb37b 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_simple.js @@ -8,5 +8,5 @@ import { getAuth, RecaptchaVerifier } from "firebase/auth"; const auth = getAuth(); -window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {}, auth); +window.recaptchaVerifier = new RecaptchaVerifier(auth, 'recaptcha-container', {}); // [END auth_phone_recaptcha_verifier_simple_modular] \ No newline at end of file diff --git a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js index c91e6041..42ebbe69 100644 --- a/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js +++ b/snippets/auth-next/phone-auth/auth_phone_recaptcha_verifier_visible.js @@ -8,7 +8,7 @@ import { getAuth, RecaptchaVerifier } from "firebase/auth"; const auth = getAuth(); -window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', { +window.recaptchaVerifier = new RecaptchaVerifier(auth, 'recaptcha-container', { 'size': 'normal', 'callback': (response) => { // reCAPTCHA solved, allow signInWithPhoneNumber. @@ -18,5 +18,5 @@ window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', { // Response expired. Ask user to solve reCAPTCHA again. // ... } -}, auth); +}); // [END auth_phone_recaptcha_verifier_visible_modular] \ No newline at end of file From 88aa8eb8210c90263eef7fe1f454cd6477a5a252 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Mon, 10 Jul 2023 12:23:45 -0700 Subject: [PATCH 161/170] Auto-update dependencies. (#350) --- analytics-next/package.json | 2 +- appcheck-next/package.json | 2 +- database-next/package.json | 2 +- firebaseapp-next/package.json | 2 +- firestore-next/package.json | 2 +- functions-next/package.json | 2 +- messaging-next/package.json | 2 +- perf-next/package.json | 2 +- remoteconfig-next/package.json | 2 +- storage-next/package.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/analytics-next/package.json b/analytics-next/package.json index 2483e0cd..ee4e36ff 100644 --- a/analytics-next/package.json +++ b/analytics-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/appcheck-next/package.json b/appcheck-next/package.json index 8af508c9..e863723e 100644 --- a/appcheck-next/package.json +++ b/appcheck-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/database-next/package.json b/database-next/package.json index 6e7d6f69..eb16e2d5 100644 --- a/database-next/package.json +++ b/database-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/firebaseapp-next/package.json b/firebaseapp-next/package.json index 1e40f536..13cc74cd 100644 --- a/firebaseapp-next/package.json +++ b/firebaseapp-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/firestore-next/package.json b/firestore-next/package.json index 3ec379a7..ef3b8708 100644 --- a/firestore-next/package.json +++ b/firestore-next/package.json @@ -6,7 +6,7 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2", + "firebase": "^10.0.0", "geofire-common": "^5.1.0" }, "devDependencies": { diff --git a/functions-next/package.json b/functions-next/package.json index 81d6c2f4..14f097ee 100644 --- a/functions-next/package.json +++ b/functions-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/messaging-next/package.json b/messaging-next/package.json index 7ba8ab2c..e4887a2a 100644 --- a/messaging-next/package.json +++ b/messaging-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/perf-next/package.json b/perf-next/package.json index e5d27230..688f6db0 100644 --- a/perf-next/package.json +++ b/perf-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/remoteconfig-next/package.json b/remoteconfig-next/package.json index d0482e46..952b1540 100644 --- a/remoteconfig-next/package.json +++ b/remoteconfig-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } diff --git a/storage-next/package.json b/storage-next/package.json index 7098fd72..b1c449ab 100644 --- a/storage-next/package.json +++ b/storage-next/package.json @@ -6,6 +6,6 @@ }, "license": "Apache-2.0", "dependencies": { - "firebase": "^9.22.2" + "firebase": "^10.0.0" } } From d781c67b528afe99fcdb7c7056104772463fa3ec Mon Sep 17 00:00:00 2001 From: Jonas Kaas Date: Fri, 29 Sep 2023 17:51:19 +0200 Subject: [PATCH 162/170] Fix comment for signup (#356) --- auth-next/email.js | 2 +- snippets/auth-next/email/auth_signup_password.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/auth-next/email.js b/auth-next/email.js index b00551c8..26391f81 100644 --- a/auth-next/email.js +++ b/auth-next/email.js @@ -32,7 +32,7 @@ function signUpWithEmailPassword() { const auth = getAuth(); createUserWithEmailAndPassword(auth, email, password) .then((userCredential) => { - // Signed in + // Signed up const user = userCredential.user; // ... }) diff --git a/snippets/auth-next/email/auth_signup_password.js b/snippets/auth-next/email/auth_signup_password.js index 00aa9bd5..936b64ce 100644 --- a/snippets/auth-next/email/auth_signup_password.js +++ b/snippets/auth-next/email/auth_signup_password.js @@ -10,7 +10,7 @@ import { getAuth, createUserWithEmailAndPassword } from "firebase/auth"; const auth = getAuth(); createUserWithEmailAndPassword(auth, email, password) .then((userCredential) => { - // Signed in + // Signed up const user = userCredential.user; // ... }) From 1f9e7978ed8f6805fad12b32f34b6216ab4556cb Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Thu, 9 Nov 2023 09:50:47 -0800 Subject: [PATCH 163/170] fix broken array-in snippets (#360) * fix broken array-in snippets * npm run snippets * revert array contians anay changes --- firestore-next/test.firestore.js | 2 +- firestore/test.firestore.js | 2 +- snippets/firestore-next/test-firestore/in_filter_with_array.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firestore-next/test.firestore.js b/firestore-next/test.firestore.js index c961af9d..969c1654 100644 --- a/firestore-next/test.firestore.js +++ b/firestore-next/test.firestore.js @@ -920,7 +920,7 @@ describe("firestore", () => { // [START in_filter_with_array] const { query, where } = require("firebase/firestore"); - const q = query(citiesRef, where('regions', 'in', [['west_coast', 'east_coast']])); + const q = query(citiesRef, where('regions', 'in', [['west_coast'], ['east_coast']])); // [END in_filter_with_array] } }); diff --git a/firestore/test.firestore.js b/firestore/test.firestore.js index ec89172e..20032d36 100644 --- a/firestore/test.firestore.js +++ b/firestore/test.firestore.js @@ -893,7 +893,7 @@ describe("firestore", () => { // [START in_filter_with_array] citiesRef.where('regions', 'in', - [['west_coast', 'east_coast']]); + [['west_coast'], ['east_coast']]); // [END in_filter_with_array] }); diff --git a/snippets/firestore-next/test-firestore/in_filter_with_array.js b/snippets/firestore-next/test-firestore/in_filter_with_array.js index ebe6f18b..190e9dfe 100644 --- a/snippets/firestore-next/test-firestore/in_filter_with_array.js +++ b/snippets/firestore-next/test-firestore/in_filter_with_array.js @@ -7,5 +7,5 @@ // [START in_filter_with_array_modular] import { query, where } from "firebase/firestore"; -const q = query(citiesRef, where('regions', 'in', [['west_coast', 'east_coast']])); +const q = query(citiesRef, where('regions', 'in', [['west_coast'], ['east_coast']])); // [END in_filter_with_array_modular] \ No newline at end of file From e74e8fd9591f70007a44c58580ff0f1fcd1c7959 Mon Sep 17 00:00:00 2001 From: Kevin Sanders Date: Thu, 9 Nov 2023 21:07:49 -0500 Subject: [PATCH 164/170] Typo Fix (#361) --- auth-next/custom-email-handler.js | 4 ++-- .../custom-email-handler/auth_handle_mgmt_query_params.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth-next/custom-email-handler.js b/auth-next/custom-email-handler.js index 728baff8..5fcc1f71 100644 --- a/auth-next/custom-email-handler.js +++ b/auth-next/custom-email-handler.js @@ -28,8 +28,8 @@ function handleUserManagementQueryParams() { // Configure the Firebase SDK. // This is the minimum configuration required for the API to be used. const config = { - 'apiKey': "YOU_API_KEY" // Copy this key from the web initialization - // snippet found in the Firebase console. + 'apiKey': "YOUR_API_KEY" // Copy this key from the web initialization + // snippet found in the Firebase console. }; const app = initializeApp(config); const auth = getAuth(app); diff --git a/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js b/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js index 6dec3399..d0a22696 100644 --- a/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js +++ b/snippets/auth-next/custom-email-handler/auth_handle_mgmt_query_params.js @@ -23,8 +23,8 @@ document.addEventListener('DOMContentLoaded', () => { // Configure the Firebase SDK. // This is the minimum configuration required for the API to be used. const config = { - 'apiKey': "YOU_API_KEY" // Copy this key from the web initialization - // snippet found in the Firebase console. + 'apiKey': "YOUR_API_KEY" // Copy this key from the web initialization + // snippet found in the Firebase console. }; const app = initializeApp(config); const auth = getAuth(app); From a9160f62f8ebff02285779974620ad3ff260f5ac Mon Sep 17 00:00:00 2001 From: James Daniels Date: Wed, 13 Mar 2024 16:22:44 -0400 Subject: [PATCH 165/170] FirebaseServerApp (#366) * First. * already snippets for that * cleanup * auth_svc_admin * Auth, not auth-next * Express stub should not be in snippet * Move import into snippet * Update firebaseserverapp.js --- auth/package.json | 1 + auth/service-worker-sessions.js | 43 +++++++++++++++++++++ firebaseserverapp-next/firebaseserverapp.js | 27 +++++++++++++ firebaseserverapp-next/package.json | 12 ++++++ 4 files changed, 83 insertions(+) create mode 100644 firebaseserverapp-next/firebaseserverapp.js create mode 100644 firebaseserverapp-next/package.json diff --git a/auth/package.json b/auth/package.json index a6827027..b4b13f01 100644 --- a/auth/package.json +++ b/auth/package.json @@ -7,6 +7,7 @@ "license": "Apache 2.0", "dependencies": { "firebase": "^8.10.0", + "firebase-admin": "^12.0.0", "firebaseui": "^5.0.0" } } diff --git a/auth/service-worker-sessions.js b/auth/service-worker-sessions.js index babbf91e..05791463 100644 --- a/auth/service-worker-sessions.js +++ b/auth/service-worker-sessions.js @@ -162,3 +162,46 @@ function svcSignInEmail(email, password) { }); // [END auth_svc_sign_in_email] } + +function svcRedirectAdmin() { + const app = { use: (a) => {} }; + + // [START auth_svc_admin] + // Server side code. + const admin = require('firebase-admin'); + + // The Firebase Admin SDK is used here to verify the ID token. + admin.initializeApp(); + + function getIdToken(req) { + // Parse the injected ID token from the request header. + const authorizationHeader = req.headers.authorization || ''; + const components = authorizationHeader.split(' '); + return components.length > 1 ? components[1] : ''; + } + + function checkIfSignedIn(url) { + return (req, res, next) => { + if (req.url == url) { + const idToken = getIdToken(req); + // Verify the ID token using the Firebase Admin SDK. + // User already logged in. Redirect to profile page. + admin.auth().verifyIdToken(idToken).then((decodedClaims) => { + // User is authenticated, user claims can be retrieved from + // decodedClaims. + // In this sample code, authenticated users are always redirected to + // the profile page. + res.redirect('/profile'); + }).catch((error) => { + next(); + }); + } else { + next(); + } + }; + } + + // If a user is signed in, redirect to profile page. + app.use(checkIfSignedIn('/')); + // [END auth_svc_admin] +} diff --git a/firebaseserverapp-next/firebaseserverapp.js b/firebaseserverapp-next/firebaseserverapp.js new file mode 100644 index 00000000..d0ab338c --- /dev/null +++ b/firebaseserverapp-next/firebaseserverapp.js @@ -0,0 +1,27 @@ +// @ts-nocheck +// [START serverapp_auth] +import { initializeServerApp } from 'firebase/app'; +import { getAuth } from 'firebase/auth'; +import { headers } from 'next/headers'; +import { redirect } from 'next/navigation'; + +export default function MyServerComponent() { + + // Get relevant request headers (in Next.JS) + const authIdToken = headers().get('Authorization')?.split('Bearer ')[1]; + + // Initialize the FirebaseServerApp instance. + const serverApp = initializeServerApp(firebaseConfig, { authIdToken }); + + // Initialize Firebase Authentication using the FirebaseServerApp instance. + const auth = getAuth(serverApp); + + if (auth.currentUser) { + redirect('/profile'); + } + + // ... +} +// [END serverapp_auth] + +const firebaseConfig = {}; diff --git a/firebaseserverapp-next/package.json b/firebaseserverapp-next/package.json new file mode 100644 index 00000000..0836b0b2 --- /dev/null +++ b/firebaseserverapp-next/package.json @@ -0,0 +1,12 @@ +{ + "name": "firebaseserverapp-next", + "version": "1.0.0", + "scripts": { + "compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "firebase": "^10.0.0", + "next": "^14.1.3" + } +} From 1abb6ce1a784ae5552946dff5f1f5aab7dcbda30 Mon Sep 17 00:00:00 2001 From: "Nhien (Ricky) Lam" <62775270+NhienLam@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:24:45 -0700 Subject: [PATCH 166/170] =?UTF-8?q?Add=20snippets=20for=20Handling=20the?= =?UTF-8?q?=20account-exists-with-different=E2=80=A6=20(#367)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add v8 and v9 snippets for Handling the account-exists-with-different-credential error * Import auth functions * Add missing methods to param * Add missing methods to params for legacy snippets --- auth-next/link-multiple-accounts.js | 58 ++++++++++++++++++ auth/link-multiple-accounts.js | 56 +++++++++++++++++ .../account_exists_popup.js | 61 +++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 snippets/auth-next/link-multiple-accounts/account_exists_popup.js diff --git a/auth-next/link-multiple-accounts.js b/auth-next/link-multiple-accounts.js index 34c0db58..1938aafc 100644 --- a/auth-next/link-multiple-accounts.js +++ b/auth-next/link-multiple-accounts.js @@ -182,3 +182,61 @@ function unlink(providerId) { }); // [END auth_unlink_provider] } + +function accountExistsPopup(auth, facebookProvider, goToApp, promptUserForPassword, promptUserForSignInMethod, getProviderForProviderId) { + // [START account_exists_popup] + const { signInWithPopup, signInWithEmailAndPassword, linkWithCredential } = require("firebase/auth"); + + // User tries to sign in with Facebook. + signInWithPopup(auth, facebookProvider).catch((error) => { + // User's email already exists. + if (error.code === 'auth/account-exists-with-different-credential') { + // The pending Facebook credential. + const pendingCred = error.credential; + // The provider account's email address. + const email = error.customData.email; + + // Present the user with a list of providers they might have + // used to create the original account. + // Then, ask the user to sign in with the existing provider. + const method = promptUserForSignInMethod(); + + if (method === 'password') { + // TODO: Ask the user for their password. + // In real scenario, you should handle this asynchronously. + const password = promptUserForPassword(); + signInWithEmailAndPassword(auth, email, password).then((result) => { + return linkWithCredential(result.user, pendingCred); + }).then(() => { + // Facebook account successfully linked to the existing user. + goToApp(); + }); + return; + } + + // All other cases are external providers. + // Construct provider object for that provider. + // TODO: Implement getProviderForProviderId. + const provider = getProviderForProviderId(method); + // At this point, you should let the user know that they already have an + // account with a different provider, and validate they want to sign in + // with the new provider. + // Note: Browsers usually block popups triggered asynchronously, so in + // real app, you should ask the user to click on a "Continue" button + // that will trigger signInWithPopup(). + signInWithPopup(auth, provider).then((result) => { + // Note: Identity Platform doesn't control the provider's sign-in + // flow, so it's possible for the user to sign in with an account + // with a different email from the first one. + + // Link the Facebook credential. We have access to the pending + // credential, so we can directly call the link method. + linkWithCredential(result.user, pendingCred).then((userCred) => { + // Success. + goToApp(); + }); + }); + } +}); +// [END account_exists_popup] +} diff --git a/auth/link-multiple-accounts.js b/auth/link-multiple-accounts.js index 30f5a2ec..8eed77b8 100644 --- a/auth/link-multiple-accounts.js +++ b/auth/link-multiple-accounts.js @@ -166,3 +166,59 @@ function unlink(providerId) { }); // [END auth_unlink_provider] } + +function accountExistsPopup(facebookProvider, goToApp, promptUserForPassword, promptUserForSignInMethod, getProviderForProviderId) { + // [START account_exists_popup] + // User tries to sign in with Facebook. + auth.signInWithPopup(facebookProvider).catch((error) => { + // User's email already exists. + if (error.code === 'auth/account-exists-with-different-credential') { + // The pending Facebook credential. + const pendingCred = error.credential; + // The provider account's email address. + const email = error.email; + + // Present the user with a list of providers they might have + // used to create the original account. + // Then, ask the user to sign in with the existing provider. + const method = promptUserForSignInMethod(); + + if (method === 'password') { + // TODO: Ask the user for their password. + // In real scenario, you should handle this asynchronously. + const password = promptUserForPassword(); + auth.signInWithEmailAndPassword(email, password).then((result) => { + return result.user.linkWithCredential(pendingCred); + }).then(() => { + // Facebook account successfully linked to the existing user. + goToApp(); + }); + return; + } + + // All other cases are external providers. + // Construct provider object for that provider. + // TODO: Implement getProviderForProviderId. + const provider = getProviderForProviderId(method); + // At this point, you should let the user know that they already have an + // account with a different provider, and validate they want to sign in + // with the new provider. + // Note: Browsers usually block popups triggered asynchronously, so in + // real app, you should ask the user to click on a "Continue" button + // that will trigger signInWithPopup(). + auth.signInWithPopup(provider).then((result) => { + // Note: Identity Platform doesn't control the provider's sign-in + // flow, so it's possible for the user to sign in with an account + // with a different email from the first one. + + // Link the Facebook credential. We have access to the pending + // credential, so we can directly call the link method. + result.user.linkWithCredential(pendingCred).then((userCred) => { + // Success. + goToApp(); + }); + }); + } +}); +// [END account_exists_popup] +} diff --git a/snippets/auth-next/link-multiple-accounts/account_exists_popup.js b/snippets/auth-next/link-multiple-accounts/account_exists_popup.js new file mode 100644 index 00000000..2c667882 --- /dev/null +++ b/snippets/auth-next/link-multiple-accounts/account_exists_popup.js @@ -0,0 +1,61 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/link-multiple-accounts.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + + // [START account_exists_popup_modular] + import { signInWithPopup, signInWithEmailAndPassword, linkWithCredential } from "firebase/auth"; + + // User tries to sign in with Facebook. + signInWithPopup(auth, facebookProvider).catch((error) => { + // User's email already exists. + if (error.code === 'auth/account-exists-with-different-credential') { + // The pending Facebook credential. + const pendingCred = error.credential; + // The provider account's email address. + const email = error.customData.email; + + // Present the user with a list of providers they might have + // used to create the original account. + // Then, ask the user to sign in with the existing provider. + const method = promptUserForSignInMethod(); + + if (method === 'password') { + // TODO: Ask the user for their password. + // In real scenario, you should handle this asynchronously. + const password = promptUserForPassword(); + signInWithEmailAndPassword(auth, email, password).then((result) => { + return linkWithCredential(result.user, pendingCred); + }).then(() => { + // Facebook account successfully linked to the existing user. + goToApp(); + }); + return; + } + + // All other cases are external providers. + // Construct provider object for that provider. + // TODO: Implement getProviderForProviderId. + const provider = getProviderForProviderId(method); + // At this point, you should let the user know that they already have an + // account with a different provider, and validate they want to sign in + // with the new provider. + // Note: Browsers usually block popups triggered asynchronously, so in + // real app, you should ask the user to click on a "Continue" button + // that will trigger signInWithPopup(). + signInWithPopup(auth, provider).then((result) => { + // Note: Identity Platform doesn't control the provider's sign-in + // flow, so it's possible for the user to sign in with an account + // with a different email from the first one. + + // Link the Facebook credential. We have access to the pending + // credential, so we can directly call the link method. + linkWithCredential(result.user, pendingCred).then((userCred) => { + // Success. + goToApp(); + }); + }); + } +}); +// [END account_exists_popup_modular] \ No newline at end of file From 2117c619ce49b08d582f282e7d2ec798f5105c3d Mon Sep 17 00:00:00 2001 From: spider-hand Date: Wed, 29 May 2024 01:05:44 +0900 Subject: [PATCH 167/170] chore: update outdated comments (#370) --- auth-next/email-link-auth.js | 10 ++++++---- .../auth-next/email-link-auth/email_link_complete.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/auth-next/email-link-auth.js b/auth-next/email-link-auth.js index 59ea2115..4748e699 100644 --- a/auth-next/email-link-auth.js +++ b/auth-next/email-link-auth.js @@ -68,11 +68,13 @@ function emailLinkComplete() { .then((result) => { // Clear email from storage. window.localStorage.removeItem('emailForSignIn'); - // You can access the new user via result.user - // Additional user info profile not available via: - // result.additionalUserInfo.profile == null + // You can access the new user by importing getAdditionalUserInfo + // and calling it with result: + // getAdditionalUserInfo(result) + // You can access the user's profile via: + // getAdditionalUserInfo(result)?.profile // You can check if the user is new or existing: - // result.additionalUserInfo.isNewUser + // getAdditionalUserInfo(result)?.isNewUser }) .catch((error) => { // Some error occurred, you can inspect the code: error.code diff --git a/snippets/auth-next/email-link-auth/email_link_complete.js b/snippets/auth-next/email-link-auth/email_link_complete.js index b42b9af9..dbe1143d 100644 --- a/snippets/auth-next/email-link-auth/email_link_complete.js +++ b/snippets/auth-next/email-link-auth/email_link_complete.js @@ -26,11 +26,13 @@ if (isSignInWithEmailLink(auth, window.location.href)) { .then((result) => { // Clear email from storage. window.localStorage.removeItem('emailForSignIn'); - // You can access the new user via result.user - // Additional user info profile not available via: - // result.additionalUserInfo.profile == null + // You can access the new user by importing getAdditionalUserInfo + // and calling it with result: + // getAdditionalUserInfo(result) + // You can access the user's profile via: + // getAdditionalUserInfo(result)?.profile // You can check if the user is new or existing: - // result.additionalUserInfo.isNewUser + // getAdditionalUserInfo(result)?.isNewUser }) .catch((error) => { // Some error occurred, you can inspect the code: error.code From 56d70627e2dc275f01cd0e55699794bf40faca80 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Tue, 8 Oct 2024 15:17:01 -0400 Subject: [PATCH 168/170] Upgrade versions in FCM service worker (#382) * Upgrade versions in FCM service worker * Add comment telling users to use latest --- messaging/service-worker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/messaging/service-worker.js b/messaging/service-worker.js index c0f875bb..1a202159 100644 --- a/messaging/service-worker.js +++ b/messaging/service-worker.js @@ -10,8 +10,9 @@ function initInSw() { // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js'); - importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js'); + // Replace 10.13.2 with latest version of the Firebase JS SDK. + importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js'); + importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. From 3d04522869ad402c4da3ae74d6b30a4dbf8d1233 Mon Sep 17 00:00:00 2001 From: Athira M Date: Fri, 24 Jan 2025 12:17:10 +0530 Subject: [PATCH 169/170] RC doc update to provide default prod value for minimumFetchIntervalMillis (#389) * Add comment to highlight the default prod value for minimumFetchIntervalMillis. Issue addressed: https://github.com/firebase/firebase-js-sdk/issues/2841 * Update code snipped with default prod value for minimumFetchIntervalMillis. * Update code snipped with default prod value for minimumFetchIntervalMillis. * Update code snipped with default prod value for minimumFetchIntervalMillis. --------- Co-authored-by: Athira M --- remoteconfig-next/index.js | 1 + snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js | 1 + 2 files changed, 2 insertions(+) diff --git a/remoteconfig-next/index.js b/remoteconfig-next/index.js index aeeb263a..287f3c99 100644 --- a/remoteconfig-next/index.js +++ b/remoteconfig-next/index.js @@ -14,6 +14,7 @@ function getInstance() { function setMinimumFetchTime() { const remoteConfig = getInstance(); // [START rc_set_minimum_fetch_time] + // The default and recommended production fetch interval for Remote Config is 12 hours remoteConfig.settings.minimumFetchIntervalMillis = 3600000; // [END rc_set_minimum_fetch_time] } diff --git a/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js b/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js index 131976c5..77aa9f45 100644 --- a/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js +++ b/snippets/remoteconfig-next/index/rc_set_minimum_fetch_time.js @@ -5,5 +5,6 @@ // 'npm run snippets'. // [START rc_set_minimum_fetch_time_modular] +// The default and recommended production fetch interval for Remote Config is 12 hours remoteConfig.settings.minimumFetchIntervalMillis = 3600000; // [END rc_set_minimum_fetch_time_modular] \ No newline at end of file From 467eaa165dcbd9b3ab15711e76fa52237ba37f8b Mon Sep 17 00:00:00 2001 From: "Nhien (Ricky) Lam" <62775270+NhienLam@users.noreply.github.com> Date: Thu, 6 Feb 2025 15:39:06 -0800 Subject: [PATCH 170/170] Update email link auth snippet to stop using deprecated `dynamicLinkDomain` (#390) * Update email link auth snippet to remove FDL * Update custom domain example --- auth-next/email-link-auth.js | 3 ++- .../email-link-auth/auth_email_link_actioncode_settings.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/auth-next/email-link-auth.js b/auth-next/email-link-auth.js index 4748e699..fde67663 100644 --- a/auth-next/email-link-auth.js +++ b/auth-next/email-link-auth.js @@ -19,7 +19,8 @@ function emailLinkActionCodeSettings() { installApp: true, minimumVersion: '12' }, - dynamicLinkDomain: 'example.page.link' + // The domain must be configured in Firebase Hosting and owned by the project. + linkDomain: 'custom-domain.com' }; // [END auth_email_link_actioncode_settings] } diff --git a/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js b/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js index a1480a11..010b5c09 100644 --- a/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js +++ b/snippets/auth-next/email-link-auth/auth_email_link_actioncode_settings.js @@ -19,6 +19,7 @@ const actionCodeSettings = { installApp: true, minimumVersion: '12' }, - dynamicLinkDomain: 'example.page.link' + // The domain must be configured in Firebase Hosting and owned by the project. + linkDomain: 'custom-domain.com' }; // [END auth_email_link_actioncode_settings_modular] \ No newline at end of file