[steemconnect-firebase-functions] Version 1.1.0 has just been PUBLISHED!

in #utopian-io7 years ago (edited)

I've just published version 1.1.0 of my library, which is built to help developers who want to use SteemConnect on the Google Firebase platform. Let's discuss what has been added!

version 1.1.0.png

Quick links

Long-lived token support

steemconnect-firebase-functions main feature is making it easier to implement OAuth2 authorization code grant. This kind of OAuth2 flow has one big advantage - it enables app to require so called offline scope, which is used to obtain a refresh_token. The name of this token is quite describtive - it allows to refresh an access token. But why would we even do that?

It turns out that access_token expires after 7 days. With refresh_token, the app can get a new access_token instead of forcing user to login once again.

refreshAccessToken function

Version 1.1.0 of steemconnect-firebase-functions includes a brand new function used to exchange refresh_token for new access_token with SteemConnect.

Example usage:

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

const clientId = 'client-id';
const clientSecret = 'client-secret';
const refreshToken = 'refresh-token';

let newAccessToken;

refreshAccessToken(clientId, clientSecret, refreshToken).then(response => {
  newAccessToken = response;
});

AccessTokenResponse interface

I believe that AccessToken interface name was confusing because interface had access_token property, so I decided to rename interface name to AccessTokenResponse. I have also added an optional refresh_token property.

The interface now has the following code:

export interface AccessTokenResponse {
  access_token: string;
  expires_in: number;
  username: string;
  refresh_token?: string;
}

Broadcasting more types of operations to the Steem blockchain

Until version 1.1.0 the steemconnect-firebase-functions library had only one function that allowed to broadcast operations to the Steem blockchain - broadcastOperations.

Although that was enough to do broadcast literally anything, I've added some functions that support the most frequently used operations - upvote, post, and comment. I hope it will be useful for the developers!

broadcastPost function

As the name suggests, you can use this function to broadcast a post to the Steem blockchain.

Example usage:

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

const accessToken = 'access-token';
const mainTag = 'test-tag';
const postAuthor = 'jakipatryk';
const postPermlink = 'test-post-432rhbb23';
const postTitle = 'Test post';
const postBody = 'This is a test post content';

broadcastPost(
  accessToken,
  mainTag,
  postAuthor,
  postPermlink,
  postTitle,
  postBody
).then(response => {
  console.log(response);
});

broadcastPostWithBeneficiaries function

Works almost the same as the broadcastPost function, but in addition, enables to set up beneficiaries - an account which will get a part of the rewards of broadcasted post.

Example usage:

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

const accessToken = 'access-token';
const mainTag = 'test-tag';
const postAuthor = 'jakipatryk';
const postPermlink = 'test-post-432rhbb23';
const postTitle = 'Test post';
const postBody = 'This is a test post content';
const beneficiariesAccount = 'utopian.pay';
const beneficiariesWeight = 2500; // 25%

broadcastPostWithBeneficiaries(
  accessToken,
  mainTag,
  postAuthor,
  postPermlink,
  postTitle,
  postBody,
  beneficiariesAccount,
  beneficiariesWeight
).then(response => {
  console.log(response);
});

broadcastComment function

Broadcasts a comment to given post/other comment.

Example usage:

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

const accessToken = 'access-token';
const parentAuthor = 'ned';
const parentPermlink = 'steemfest2-closing-dinner';
const commentAuthor = 'jakipatryk';
const commentPermlink = 'f34fre5';
const commentBody = 'This is a test comment';

broadcastComment(
  accessToken,
  parentAuthor,
  parentPermlink,
  commentAuthor,
  commentPermlink,
  commentBody
).then(response => {
  console.log(response);
});

broadcastUpvote function

Broadcasts an upvote.

Example usage:

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

const accessToken = 'access-token';
const voter = 'jakipatryk';
const author = 'ned';
const permlink = 'steemfest2-closing-dinner';
const weight = 10000; // 100%

broadcastUpvote(accessToken, voter, author, permlink, weight).then(response => {
  console.log(response);
});

What next?

The current documentation is... bad. That's what I will be working on now.

Also, if you haven't seen my tutorial, definitely check this out!



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

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.

Thank you for the contribution. It has been approved.

You can contact us on Discord.

[utopian-moderator]

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