앱 내에서 인터넷 아이덴티티(ICP) 인증을 간소화하기 위해 설계된 플러터 패키지입니다. 인터넷 아이덴티티 서비스와의 원활한 통합을 가능하게 하여 사용자가 암호 없이 분산형 ID를 사용하여 인증할 수 있도록 합니다. 이 패키지는 로그인, 세션 관리, 신원 검증을 포함한 전체 인증 프로세스를 처리하며, 안드로이드 및 iOS 플랫폼을 모두 지원합니다. 웹3 개발자를 위한 것으로, 블록체인 기반 애플리케이션에 대한 안전한 접근을 간편하게 만듭니다.
사용 사례
탈중앙화 앱 로그인
웹3 사용자 인증
블록체인 기반 신원 관리
안전한 모바일 지갑 접근
ICP와의 DApp 통합
사용자 세션 지속성
주요 기능
자동화된 ICP 인증 흐름
크로스 플랫폼 지원 (Android 및 iOS)
인터넷 아이덴티티 서비스와의 통합
보안 토큰 처리
최소한의 보일러플레이트 코드
내장 세션 관리
적합한 대상
Flutter 개발자들이 DApps 구축 중
웹3 및 블록체인 애플리케이션 개발자
비밀번호 없이 로그인을 요구하는 모바일 앱
Internet Identity를 사용하는 프로젝트
탈중앙화된 신원에 초점을 맞춘 팀
고려 사항
인터넷 아이덴티티 백엔드 설정이 필요합니다
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