๐๏ธ Dev Log Drop: Custom Hive Authentication Package! ๐ ๏ธ
Hey party people of Hive! ๐โโ๏ธ
Letโs crank the dev updates up to eleven, sprinkle a dash of memes, and bring some buzz to the blockchain! ๐
๐ Why Not Stick to Just Aioha?
I've used @aioha package like itโs my morning chai ๐ตโeverywhere: distriator, checkinwithxyz, and the 3speak-refactor mobile app! But, plot twist, we decided to ride one scooter further and build our own custom package (on top of it). Why? Well, because facing setbacks is just part of building on the bleeding edgeโand, honestly, who doesnโt like doing things their own way sometimes? ๐
- Custom User Interface (because users want their apps looking fancy ๐)
- Custom Data Storage (we want our tokens, our types, and our own flavor ๐ถ๏ธ)
- Async logic for logins (because we absolutely must call our APIs! ๐ค)
- Fan-demand: support login with private key for multiple users (not just me anymore!)
๐ค Introducing... HiveAuthentication (Name Sucks, Help Wanted! ๐)
Time to take matters into our own handsโUI hands, that is!
Weโre making an open-source package (WIP name: hive-authentication
, cheers for ideas!). Drop your brilliant/crazy/funny name suggestions in the commentsโwinner gets karma, eternal gratitude, and a virtual high five! โ
- 100% open-source for Hive fam
- Minimal dependenciesโlightweight is tight! ๐ชถ
- Repo here: https://github.com/sag333ar/hive-authentication
- Is this our third attempt? Yes.
- Did we crash and burn before? Also yes.
- Am I more hopeful than ever? ABSOL
๐ Sneak Peak - UI Unveiled!
Check the glow-up! When users hit "login", they get this snazzy new UI. Options: - Enter username, choose login flavor ๐ - Working options: keychain, hiveauth, posting key
More to come, but this is everything weโve polished so far. โจ
โ๏ธ ReactJS Integration = Breezy! ๐ฌ๏ธ
Installation (Spoiler: Itโs Easy!)
npm install hive-authentication
Install the package. It will take care of adding aioha internally.
Let's not break UI
import 'hive-authentication/build.css';
Wherever you plan to use hive-authentication package's button, make sure you import the build.css file so that you don't break UX we have supplied in the package.
Code Snippet
import { AuthButton, useAuthStore } from 'hive-authentication';
function App() {
const { currentUser, loggedInUsers } = useAuthStore();
// Subscribe to store changes using Zustand
useEffect(() => {
const unsubscribe = useAuthStore.subscribe((state) => {
console.log('Store state changed:', state);
});
return unsubscribe;
}, []);
// Your authentication callback - works for both login AND adding accounts
const handleAuthenticate = async (hiveResult) => {
// Make your API call here
const response = await fetch('/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
challenge: hiveResult.challenge,
username: hiveResult.username,
pubkey: hiveResult.publicKey,
proof: hiveResult.proof,
}),
});
if (!response.ok) {
throw new Error('Server authentication failed');
}
const data = await response.json();
// Return your server response as JSON string
return JSON.stringify(data);
};
return (
My App
{currentUser && (
Welcome, {currentUser.username}!
)}
);
}
That's it
Yep. That is it. Your reactjs app is ready with login/authentication. Easy peasy. Give it a try & share your feedback if you are a dev.
๐ The Hive Hype Never Stops ๐
- ๐ Keep building open source for hive
- ๐ Big love to Hive fam for feedback & support
- ๐ Hive blockchain = ๐๐ all the way to the moon, Mars & beyond!
๐ฅ Until the next dev log โ Keep building, keep Hiving! ๐๐
๐ Final Note
- I asked perplexity to help optimize this post to make it more readable and viewer-friendly.
- Here is the link where you can find both original content & improvements made by AI
- https://www.perplexity.ai/search/e3e4a8ed-6cf2-46a4-b539-81866c27acb1
๐ My Contributions to โฆ๏ธ Hive Ecosystem
Contribution | To | Hive | Ecosystem |
---|---|---|---|
Hive Witness Node | Hive API Node (in progress) | 3Speak Video Encoder Node Operator (highest number of nodes) | 3Speak Mobile App Developer |
3Speak Podcast App Developer | 3Speak Shorts App Developer | 3Speak Support & Maintenance Team | Distriator Developer |
CheckinWithXYZ | Hive Inbox | HiFind | Hive Donate App |
Contributed to HiveAuth Mobile App | Ecency โ 3Speak Integration | Ecency โ InLeo Integration | Ecency โ Actifit Integration |
Hive Stats App | Vote for Witness App | HiveFlutterKit | New 3Speak App |
๐ Support Back
โค๏ธ Appreciate my work? Consider supporting @threespeak & @sagarkothari88! โค๏ธ
Vote | For | Witness |
---|---|---|
sagarkothari88 | @sagarkothari88 | |
threespeak | @threespeak |