[steemconnect-firebase-functions] Version 1.2: state, createFirebaseAccount, and broadcasts

in #utopian-io7 years ago (edited)

Development of steemconnect-firebase-functions doesn't stop, because I want to use it in the project I am going to start coding soon. Version 1.2 has just been released!

Version 1.2

Quick Recap

steemconnect-firebase-functions is a library designed to help developers who want to create apps based on SteemConnect and Firebase. The library makes it easy to:

  • implement OAuth2 Authorization Code Grant (enables user to log in to your app using SteemConnect)
  • broadcast operations to Steem blockchain (post, comment, upvote, etc.)
  • make operations on the Firebase products (Authentication, Firestore)

Links

New Features

Version 1.2.0 comes with a few new features. As I mentioned in the introduction, I am going to create a new project based on SteemConnect and Firebase, so I had to add them.

State

I have enabled to use so-called state variable in the SteemConnect authorization URL by adding optional parameter state in the getAuthorizationUrl function. This parameter can be used for example to prevent cross-site request forgery attacks.

PULL REQUEST

createFirebaseAccount

I found it useful to add additional user data to the user profile, so they would become available on the auth object on the frontend. What kind of additional data am I talking about? Most important are username and photoURL (for example avatar).

I added createFirebaseAccount function that either creates an Firebase auth account or updates it if one already exists.

Example usage:

import { createFirebaseAccount } from 'steemconnect-firebase-functions';

import * as admin from 'firebase-admin';

const serviceAccount = require('../serviceAccountKey.json');

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

const uid = 'steemconnect:jakipatryk';
const username = 'jakipatryk';
const photoURL = 'https://some-uri.image/avatar';

createFirebaseAccount(admin, uid, username, photoURL).then(() => {
  console.log(5 * 20 + 11);
});

See how I implemented it: COMMIT.

broadcastFollow

This version of steemconnect-firebase-functions also comes with new broadcast functions. First one simply broadcasts a follow to the blockchain.

Example usage:

import { broadcastFollow } from 'steemconnect-firebase-functions';

const accessToken = 'access-token';
const username = 'jakipatryk';
const userToFollow = 'ned';

broadcastFollow(accessToken, username, userToFollow).then(result => {
  console.log(result);
});

See how I implemented it: COMMIT

broadcastUnfollow

So we can broadcast follow, it would be great if we could also broadcast unfollow. Yep, you are right.

Example usage:

import { broadcastUnfollow } from 'steemconnect-firebase-functions';

const accessToken = 'access-token';
const username = 'jakipatryk';
const userToUnfollow = 'ned';

broadcastUnfollow(accessToken, username, userToUnfollow).then(result => {
  console.log(result);
});

See how I implemented it: COMMIT.

broadcastReblog

This one was actually kinda funny. Did you know that operation id of the reblog is... follow? I also didn't know, but it just works like that.

Example usage:

import { broadcastReblog } from 'steemconnect-firebase-functions';

const accessToken = 'access-token';
const username = 'jakipatryk-dev';
const postAuthor = 'jakipatryk';
const postPermlink =
  'steemconnect-firebase-functions-version-1-1-0-has-just-been-published';

broadcastReblog(accessToken, username, postAuthor, postPermlink).then(
  result => {
    console.log(result);
  }
);

See how I implemented it: COMMIT.

Summary

Version 1.2.0 of steemconnect-firebase-functions introduces a few new features, such as optional state variable in the SteemConnect authorization URL, createFirebaseAccount function to create Firebase auth account with user details, broadcastFollow, broadcastUnfollow, and broadcastReblog functions.

A new version might be released if I decide that I need some additional functionality during coding my new project, which is not public yet... Stay tuned ;)



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Congratulation on this work @jakipatryk, very nice to have Firebase work on Steem.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

This post has been just added as new item to timeline of steemconnect-firebase-functions on Steem Projects.

If you want to be notified about new updates from this project, register on Steem Projects and add steemconnect-firebase-functions to your favorite projects.

Hey @jakipatryk I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Hey @jakipatryk I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x