सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक फ्लटर पैकेज जो ऐप में इंटरनेट पहचान (ICP) प्रमाणीकरण को सुगम बनाने के लिए डिज़ाइन किया गया है। यह इंटरनेट पहचान सेवा के साथ बिना किसी दिक्कत के एकीकरण की अनुमति देता है, जिससे उपयोगकर्ता पासवर्ड के बिना डिसेंट्रलाइज्ड पहचान का उपयोग करके प्रमाणीकरण कर सकते हैं। पैकेज पूरी प्रमाणीकरण प्रक्रिया, लॉगिन, सत्र प्रबंधन और पहचान की पुष्टि को संभालता है, जबकि Android और iOS दोनों प्लेटफॉर्म का समर्थन करता है। वेब3 में काम करने वाले विकासकर्ताओं के लिए बनाया गया, यह ब्लॉकचेन-आधारित ऐप्स तक सुरक्षित पहुंच को सरल बनाता है।
उपयोग
डेसेंट्रलाइज्ड ऐप लॉगिन
वेब3 उपयोगकर्ता प्रमाणीकरण
ब्लॉकचेन-संचालित पहचान प्रबंधन
सुरक्षित मोबाइल वॉलेट पहुंच
ICP के साथ DApp एकीकरण
उपयोगकर्ता सत्र परिवर्तनशीलता
मुख्य विशेषताएँ
स्वचालित ICP प्रमाणीकरण प्रवाह
क्रॉस-प्लेटफॉर्म समर्थन (Android और iOS)
इंटरनेट पहचान सेवा के साथ एकीकरण
सुरक्षित τोकन संचालन
न्यूनतम बॉयलरप्लेट कोड
एम्बेडेड सत्र प्रबंधन
इनके लिए उपयुक्त
Flutter विकासक डीएप्प्स बना रहे हैं
वेब3 और ब्लॉकचेन एप्लिकेशन निर्माता
पासवर्डलेस लॉगिन की आवश्यकता वाले मोबाइल ऐप्स
इंटरनेट आइडेंटिटी का उपयोग करने वाले प्रोजेक्ट
डिसेंट्रलाइज्ड आईडेंटिटी पर केंद्रित टीमें
विचार योग्य बातें
इंटरनेट पहचान बैकएंड सेटअप की आवश्यकता है
ICP पारिस्थितिकी तंत्र तक सीमित
ब्राउज़र-आधारित प्रमाणीकरण प्रवाह पर निर्भर
कस्टम UI समायोजन की आवश्यकता हो सकती है
गैर-ICP ब्लॉकचेन प्रोजेक्ट्स के लिए अनुपयुक्त
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
flutter_icp_auth:
This Flutter package simplifies integrating ICP internet identity authentication flow within your Flutter application.
✨ Features
LOG IN: Enables users to log in using internet identity.
AUTO LOGIN: Allows users to log in automatically.
RELOAD: Automatically logs in users when the app is reloaded or opened, based on session data/delegationObject.
LOGOUT: Provides functionality for users to log out.
⚠️ Important Info
1. isLocal is used to denote whether you are running your application using mainnet links or locally.
Change the bool value based on your apps requirement.
If isLocal is true then replace the values of backendCanisterId and middlePageCanisterId with the locally deployed canister ids.
If isLocal is false then replace the values of backendCanisterId and middlePageCanisterId with the main-net deployed canister ids.
2. For local or main-net backendCanisterId make sure you have the following function in your backend:
Rust:
use ic_cdk::api::caller;
#[ic_cdk::query]fnwhoami() ->String {
letprincipal_id = caller().to_string();
format!("principal id - : {:?}", principal_id)
}
Motoko:
import Principal "mo:base/Principal";
actor {
public shared (msg) func whoami() : async Text {
Principal.toText(msg.caller);
};
};
For main-net you can use our canisterId as well: cni7b-uaaaa-aaaag-qc6ra-cai
3. For local or main-net middlePageCanisterId make sure you have the following:
Local:
Clone the repo from here and deploy locally: https://github.com/ICP-hub/flutter_icp_auth_middleware
Main-net:
a. You can deploy the cloned middlePage to main net and use the main net canister id.
OR
b. You can use our main-net id as well: nplfj-4yaaa-aaaag-qjucq-cai
4. For IDL and Services:
You can use candid_dart to generate the did files and the IDL services and then use them in the app as demonstrated in the example app.
OR
You can add/write the file or code manually and then use them accordingly.
Open android → app → src → main → AndroidManifest.XML, , add the following snippet, and replace android:scheme and android:host with your app's values:
bool isLocal =
false; // To confirm if you running your project locally or using main-net. Change it to true if running locallyService idlService =
FieldsMethod.idl; // Idl service (Location: lib/integration.dart)String backendCanisterId =
'cni7b-uaaaa-aaaag-qc6ra-cai'; // Replace it with your backend canisterIdString middlePageCanisterId =
'nplfj-4yaaa-aaaag-qjucq-cai'; // Replace it with your middlePage canisterId
isLoggedIn and _principalId are used to change the state of the log in/log out button and principal text. You can modify them according to your applications need.
Future<void> _manualLogin(Uri uri) async {
List<dynamic> result = awaitAuthLogIn.fetchAgent(
uri.queryParameters, isLocal, backendCanisterId, idlService);
if (result.isNotEmpty) {
setState(() {
isLoggedIn = uri.queryParameters['status'] == "true" ? true : false;
_principalId = result[0];
});
} else {
setState(() {
isLoggedIn = false;
_principalId = "Log in to see your principal";
});
}
}
3. Using the IIDLogin Button
When passing argument in the IIDLogin button, remember to pass your app:host and app:callback:
For login button call:
Replace the argument host and scheme with your app's host and scheme