The last release date: August 1, 2023.
SDK Release Note:
🚀 DAuth/core
Integrate the DAuth SDK into your platform to provide your users with a decentralized, verifiable social authentication experience. DAuth includes One-Time Password (OTP) methods through Email and SMS, and OAuth protocols via platforms such as Google and Github.
The authentication result comes in two modes: proof and jwt. Proof is concise, suitable for on-chain verification, while JWT is OIDC compatible, suitable for off-chain verification, typically used during login. Users can choose different modes according to different scenarios.
🎉 Key Features
Seamless integration with the DAuth Network.
Establish an encrypted channel for every data transfer, ensuring user data remains hidden from DAuth Nodes.
Securely receive and verify OTP codes through a private channel.
Procure idtoken via OAuth flow and generate ZK proof based on the token.
Designed for ease of use and implementation.
📦 Installation
The simplest method to install DAuth is via npm:
yarn add @dauth/core
🚀 Getting Started
After installing the package, import it into your project and begin to utilize it:
import DAuth from "@dauth/core";
const dauth = new DAuth({
baseURL: "https://demo-api.dauth.network/dauth/sdk/v1.1/",
clientID: "demo",
});
Leveraging OPT Authentication with DAuth
Use the sendOtp method to deliver an OTP code to the user. This method requires three parameters:
account, which refers to the user's Google account, email address, or phone number. It is hexlike string without "0x".
id_type, which can be mailto, tel;
request_id is client-provided, and could be a string containing a unique transaction/bundle/userOp ID. It is string or hexlike string without "0x".
// account, account_type, request_id
await dauth.service.sendOtp({
account: account,
id_type: "mailto",
request_id: "request_id", // request_id: 'The id related to the TX or userOp'
});
The authOtpConfirm method can be used to verify an OTP code and obtain the DAuth proof.
Successful One-Time Password (OTP) verification via DAuth Network results in the generation of a signature, functioning as DAuth proof. This allows anyone to validate the user's identity. The proof can also be verified on-chain. Consequently, contract wallets can bypass all centralized verifications, triggering user transactions in a decentralized manner directly.
Utilizing OAuth with DAuth
Google OAuth
Retrieve authorization code from Google.
Upon receiving the authorization code, the authOAuth method can be used to procure the DAuth proof.