1.1.5 • Published 2 years ago
client-sdk-gooddollar v1.1.5
GoodDollar Client SDK
This is the gooddollar client sdk for integrating login into gooddollar in your website
- Example App to test the functionality
SDK Utilities
- createLoginLink to generate login link to redirect to the gooddollar wallet
- LoginButton to place a login button on your page to integrate login with gooddollar on your website
- parseLoginResponse to verify if the login was successful and verified
- useLogin is a hook that can be used instead of button to integrate login with gooddollar on your website
Object schema for createLoginLink
Property Name | Purpose | Mandatory/Optional | Type |
---|---|---|---|
redirectLink | gooddollar wallet link to redirect to | Optional | String |
v | name of the vendor | Mandatory | String |
web | web link for vendor | Mandatory | String |
id | wallet address for vendor | Mandatory | String |
r | array of information ex.'mobile','location' | Mandatory | array |
cbu | Callback URL | provide either rdu or cbu | String |
rbu | Redirect URL | provide either rdu or cbu | String |
Object schema for useLogin
Property Name | Purpose | Mandatory/Optional | Type |
---|---|---|---|
gooddollarlink | wallet link returned by createLoginLink | Mandatory | String |
cbu | Callback URL | provide either rdu or cbu | String |
rbu | Redirect URL | provide either rdu or cbu | String |
onLoginCallback | Function that has the data returned by wallet as the first argument | Mandatory | Function |
Props for LoginButton
Prop Name | Purpose | Mandatory/Optional | Type |
---|---|---|---|
gooddollarlink | wallet link returned by createLoginLink | Mandatory | String |
cbu | Callback URL | provide either rdu or cbu | String |
rbu | Redirect URL | provide either rdu or cbu | String |
onLoginCallback | Function that has the data returned by wallet as the first argument | Mandatory | Function |
example login with hook
import {
useLogin,
createLoginLink,
parseLoginResponse,
} from "client-sdk-gooddollar";
const App() {
const gooddollarLink = createLoginLink({
v: "Google",
web: "https://gooddollar.netlify.app",
id: "0x09D2011Ca5781CA70810F6d82837648132762F9a",
r: ["mobile", "location", "email", "name"],
rdu: "https://gooddollar.netlify.app",
});
const loginCallBack = async (data) => {
//to check if login response is valid or not
parseLoginResponse(data)
}
const onClick = useLogin({
rdu: gooddollarLink,
gooddollarlink: rest.gooddollarlink,
onLoginCallback: onLoginCallback,
});
return (
<div className="App">
<button onClick={onClick}>Login With Gooddollar</button>
</div>
);
}
example login with button
import {useState} from 'react';
import {
LoginButton,
createLoginLink,
parseLoginResponse,
} from "client-sdk-gooddollar";
function App() {
const gooddollarLink = createLoginLink({
v: "Google",
web: "https://gooddollar.netlify.app",
id: "0x09D2011Ca5781CA70810F6d82837648132762F9a",
r: ["mobile", "location", "email", "name"],
rdu: "https://gooddollar.netlify.app",
});
const [gooddollarData, setGooddollarData] = useState({});
return (
<div className="App">
{Object.keys(gooddollarData).length === 0 ? (
<>
<LoginButton
onLoginCallback={async (data) => {
//to check if login response is valid or not
parseLoginResponse(data)
setGooddollarData(data)
}}
gooddollarlink={gooddollarLink}
style={{ fontSize: 20, padding: 20 }}
rdu="gasdasd"
>
Loggin With GOODDOLLAR
</LoginButton>
</>
) : (
<div>
<p>Logged In</p>
<p>Name : {gooddollarData.fullName}</p>
<button
onClick={() => {
setGooddollarData({});
window.location.href = "https://gooddollar.netlify.app";
}}
style={{ fontSize: 20, padding: 20 }}
>
Logout
</button>
</div>
)}
</div>
);
}
1.1.1
2 years ago
1.0.19
2 years ago
1.1.0
2 years ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.0.22
2 years ago
1.0.21
2 years ago
1.0.20
2 years ago
1.0.25
2 years ago
1.0.24
2 years ago
1.0.23
2 years ago
1.0.29
2 years ago
1.0.28
2 years ago
1.0.27
2 years ago
1.0.33
2 years ago
1.0.11
2 years ago
1.0.32
2 years ago
1.0.10
2 years ago
1.0.31
2 years ago
1.0.30
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.34
2 years ago
1.0.12
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.0
2 years ago