1.1.32 • Published 6 months ago

@gooddollar/goodlogin-sdk v1.1.32

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

GoodDollar Client SDK

This is the gooddollar client sdk for integrating login into gooddollar in your website

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 NamePurposeMandatory/OptionalType
redirectLinkgooddollar wallet link to redirect toOptionalString
vname of the vendorMandatoryString
webweb link for vendorMandatoryString
idwallet address for vendorMandatoryString
rarray of information ex.'mobile','location'Mandatoryarray
cbuCallback URLprovide either rdu or cbuString
rbuRedirect URLprovide either rdu or cbuString

Object schema for useLogin

Property NamePurposeMandatory/OptionalType
gooddollarlinkwallet link returned by createLoginLinkMandatoryString
cbuCallback URLprovide either rdu or cbuString
rbuRedirect URLprovide either rdu or cbuString
onLoginCallbackFunction that has the data returned by wallet as the first argumentMandatoryFunction

Props for LoginButton

Prop NamePurposeMandatory/OptionalType
gooddollarlinkwallet link returned by createLoginLinkMandatoryString
cbuCallback URLprovide either rdu or cbuString
rbuRedirect URLprovide either rdu or cbuString
onLoginCallbackFunction that has the data returned by wallet as the first argumentMandatoryFunction

example login with hook

import {
  useLogin,
  createLoginLink,
  parseLoginResponse,
} from "@gooddollar/goodlogin-sdk";

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 "@gooddollar/goodlogin-sdk";

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.29

10 months ago

1.1.30

10 months ago

1.1.29-beta.3f3be0f

10 months ago

1.1.32

6 months ago

1.1.31

6 months ago

1.1.29-beta.21d85c2

10 months ago

1.1.28

11 months ago

1.1.28-beta.7bc9fe9

11 months ago

1.1.25-beta.478768e

11 months ago

1.1.25-beta.e0a3482

11 months ago

1.1.25-beta.c38fc8d

11 months ago

1.1.28-beta.34739b3

11 months ago

1.1.25-beta.d558110

11 months ago

1.1.25-beta.835f81c

11 months ago

1.1.25-beta.d9a11a0

11 months ago

1.1.25-beta.eaddafb

11 months ago

1.1.27

11 months ago

1.1.26

11 months ago

1.1.24-beta.9e0866e

12 months ago

1.1.24-beta.e1d2b5f

12 months ago

1.1.25

12 months ago

1.1.24

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.19

2 years ago

1.1.20

2 years ago

1.1.18

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.11

2 years ago

1.1.12

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago