Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unstoppable Domains to login options #1334

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3ae27aa
Added uauth as available login option
V-Shadbolt Oct 21, 2022
fbc3afa
added uauth dependencies
V-Shadbolt Oct 21, 2022
6be36e7
Merge branch 'v2-web3-onboard-develop' into feature/add-ud-login
V-Shadbolt Oct 21, 2022
ca14ab5
updated uauth readme
V-Shadbolt Oct 21, 2022
56d5b09
added function for getting uauth user scopes data
V-Shadbolt Oct 24, 2022
1088d39
updated main readme with Unstoppable Domains
V-Shadbolt Oct 24, 2022
7997e54
prettier fixes
V-Shadbolt Oct 24, 2022
0740df6
Merge branch 'blocknative:v2-web3-onboard-develop' into feature/add-u…
V-Shadbolt Oct 24, 2022
3bb5d01
removed excess console log
V-Shadbolt Oct 24, 2022
8010163
updated MINOR version of both demo app and monorepo
V-Shadbolt Oct 24, 2022
63a2c02
update circleci configs with uauth
V-Shadbolt Oct 24, 2022
7bc86c7
Merge branch 'v2-web3-onboard-develop' into feature/add-ud-login
V-Shadbolt Nov 15, 2022
4f2bad9
updated versioning
V-Shadbolt Nov 15, 2022
9ca7423
walletConnect improvements to uauth package
V-Shadbolt Nov 15, 2022
ae9eb39
updated uauth icon and added function return type
V-Shadbolt Nov 15, 2022
0add23d
dynamic import of uauth class
V-Shadbolt Nov 15, 2022
2d0ba00
added uauth option validation
V-Shadbolt Nov 16, 2022
56baebf
moved user object from exported function to module instance
V-Shadbolt Nov 16, 2022
c2005ff
Update packages/uauth/README.md
Adamj1232 Nov 16, 2022
33215f7
Update packages/uauth/README.md
Adamj1232 Nov 16, 2022
796370b
Prettier formatting
Adamj1232 Nov 16, 2022
9d63829
Merge branch 'v2-web3-onboard-develop' into feature/add-ud-login
V-Shadbolt Nov 16, 2022
de17eb1
updated readme with redirect URI notes
V-Shadbolt Nov 17, 2022
8248ba8
Add notes to types for ide dev relay
Adamj1232 Nov 17, 2022
a2b78fa
Merge branch 'v2-web3-onboard-develop' into feature/add-ud-login
V-Shadbolt Nov 17, 2022
d097cd1
circleci config merge fixes
V-Shadbolt Nov 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/enkrypt
steps:
- node-build-steps
build-uauth:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/uauth
steps:
- node-build-steps

# Build staging/Alpha releases
build-staging-core:
Expand Down Expand Up @@ -479,6 +485,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/enkrypt
steps:
- node-staging-build-steps
build-staging-uauth:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/uauth
steps:
- node-staging-build-steps

workflows:
version: 2
Expand Down Expand Up @@ -639,3 +651,9 @@ workflows:
<<: *deploy_production_filters
- build-staging-enkrypt:
<<: *deploy_staging_filters
uauth:
jobs:
- build-uauth:
<<: *deploy_production_filters
- build-staging-uauth:
<<: *deploy_staging_filters
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ For full documentation, check out the README.md for each package:
- [Sequence](packages/sequence/README.md)
- [TallyHo](packages/tallyho/README.md)
- [Enkrypt](packages/enkrypt/README.md)
- [Unstoppable Domains](packages/uauth/README.md)

**Hardware Wallets**

Expand Down
1 change: 1 addition & 0 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@web3-onboard/web3auth": "^2.1.3",
"@web3-onboard/enkrypt": "^2.0.0-alpha.1",
"@web3-onboard/mew-wallet": "^2.0.0-alpha.1",
"@web3-onboard/uauth": "^2.0.0-alpha.1",
"vconsole": "^3.9.5"
},
"license": "MIT",
Expand Down
35 changes: 31 additions & 4 deletions packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import tallyHoModule from '@web3-onboard/tallyho'
import enkryptModule from '@web3-onboard/enkrypt'
import mewWalletModule from '@web3-onboard/mew-wallet'
import uauthModule from '@web3-onboard/uauth'
import {
recoverAddress,
arrayify,
Expand All @@ -31,6 +32,7 @@
import blocknativeIcon from './blocknative-icon'
import blocknativeLogo from './blocknative-logo'
import { onMount } from 'svelte'
import wallets from '@web3-onboard/injected-wallets/dist/wallets'

let windowWidth

Expand Down Expand Up @@ -98,6 +100,14 @@
}
const trezor = trezorModule(trezorOptions)

const uauthOptions = {
clientID: 'a25c3a65-a1f2-46cc-a515-a46fe7acb78c',
redirectUri: 'http://localhost:8080/',
scope:
'openid wallet email:optional humanity_check:optional profile:optional social:optional'
}
const uauth = uauthModule(uauthOptions)

const magic = magicModule({
apiKey: 'pk_live_02207D744E81C2BA'
// userEmail: 'test@test.com'
Expand Down Expand Up @@ -131,7 +141,8 @@
gnosis,
dcent,
sequence,
tallyho
tallyho,
uauth
],
gas,
chains: [
Expand Down Expand Up @@ -245,8 +256,8 @@
}
},
// containerElements: {
// El must be present at time of JS script execution
// See ../public/index.html for element example
// El must be present at time of JS script execution
// See ../public/index.html for element example
// accountCenter: '#sample-container-el'
// },
// Sign up for your free api key at www.Blocknative.com
Expand All @@ -255,6 +266,12 @@

// Subscribe to wallet updates
const wallets$ = onboard.state.select('wallets').pipe(share())
wallets$.subscribe(wallet => {
const unstoppableUser = wallet.find(
provider => provider.label === 'Unstoppable'
)
if (unstoppableUser) console.log(unstoppableUser.instance.user)
})

const signTransactionMessage = async provider => {
const ethersProvider = new ethers.providers.Web3Provider(provider, 'any')
Expand Down Expand Up @@ -949,7 +966,7 @@
{/if}
</div>
{#if $wallets$ && !hideForIframe}
{#each $wallets$ as { icon, label, accounts, chains, provider }}
{#each $wallets$ as { icon, label, accounts, chains, provider, instance }}
<div class="connected-wallet">
<div class="flex-centered" style="width: 10rem;">
<div style="width: 2rem; height: 2rem">{@html icon}</div>
Expand All @@ -958,6 +975,16 @@

<div>Chains: {JSON.stringify(chains, null, 2)}</div>

{#if label === 'Unstoppable'}
<div>Unstoppable User: {instance.user.sub}</div>
<div>Unstoppable Wallet: {instance.user.wallet_address}</div>
<div>Unstoppable Email: {instance.user.email || ''}</div>
<div>
Unstoppable Humanity: {instance.user.humanity_check_id || ''}
</div>
<div>Unstoppable Profile: {instance.user.profile || ''}</div>
{/if}

{#each accounts as { address, ens, balance }}
<div
class="account-info"
Expand Down
2 changes: 1 addition & 1 deletion packages/injected/src/icons/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default `<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="256" height="256" rx="128" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M87.6477 203.403C66.6922 203.403 47.0213 198.931 30 191.095L99.2514 127.885C89.6861 120.038 83.5836 108.126 83.5836 94.7884C83.5836 81.2079 89.9104 69.1052 99.7773 61.2668V52.0015H126.08C126.177 52.0008 126.274 52.0005 126.372 52.0005C137.068 52.0005 146.848 55.9254 154.349 62.4136C161.85 55.926 171.629 52.0015 182.325 52.0015H182.389L182.39 52L182.392 52.0015H208.919V61.2679C218.786 69.1062 225.113 81.209 225.113 94.7894C225.113 111.867 215.108 126.608 200.64 133.47C195.467 148.743 185.737 162.479 172.714 173.652V193.398H139.977C124.227 199.801 106.455 203.403 87.6477 203.403ZM126.371 127.703C134.16 127.703 141.317 124.998 146.954 120.475L154.282 136.976L161.645 120.397C167.296 124.967 174.491 127.703 182.325 127.703C200.502 127.703 215.238 112.967 215.238 94.7895C215.238 76.6117 200.502 61.8757 182.325 61.8757C170.513 61.8757 160.155 68.0975 154.348 77.4425C148.541 68.0975 138.183 61.8757 126.371 61.8757C108.193 61.8757 93.4575 76.6117 93.4575 94.7895C93.4575 112.967 108.193 127.703 126.371 127.703ZM126.371 117.829C139.096 117.829 149.411 107.514 149.411 94.7893C149.411 82.0648 139.096 71.7496 126.371 71.7496C113.647 71.7496 103.331 82.0648 103.331 94.7893C103.331 107.514 113.647 117.829 126.371 117.829ZM126.371 107.955C133.642 107.955 139.537 102.06 139.537 94.7893C139.537 87.5182 133.642 81.6238 126.371 81.6238C119.1 81.6238 113.206 87.5182 113.206 94.7893C113.206 102.06 119.1 107.955 126.371 107.955ZM205.364 94.7893C205.364 107.514 195.049 117.829 182.324 117.829C169.6 117.829 159.285 107.514 159.285 94.7893C159.285 82.0648 169.6 71.7496 182.324 71.7496C195.049 71.7496 205.364 82.0648 205.364 94.7893ZM195.49 94.7893C195.49 102.06 189.596 107.955 182.324 107.955C175.053 107.955 169.159 102.06 169.159 94.7893C169.159 87.5182 175.053 81.6238 182.324 81.6238C189.596 81.6238 195.49 87.5182 195.49 94.7893Z" fill="white"/>
</svg>`
</svg>`
82 changes: 82 additions & 0 deletions packages/uauth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# @web3-onboard/uauth

## Wallet module for connecting Unstoppable Domains to web3-onboard

### Install

**NPM**
`npm i @web3-onboard/core @web3-onboard/uauth`

**Yarn**
`yarn add @web3-onboard/core @web3-onboard/uauth`

## Options

Follow the [Login Client Congifuration Docs](https://docs.unstoppabledomains.com/login-with-unstoppable/login-integration-guides/login-client-configuration/) on the Unstoppable Domains website to get setup with your clientID and redirectUri.
**Note:** The Redirection URI value(s) in the client configuration MUST exactly match the redirect_uri parameter value used in `UauthInitOptions`. More specifics can be found in the [Rules for Redirect URIs Docs](https://docs.unstoppabledomains.com/login-with-unstoppable/login-integration-guides/login-client-configuration/#rules-for-redirect-uris).

```typescript
type UauthInitOptions = {
clientID: string // required and will throw an error if not included: links dapp to Unstoppable Domains for customization
redirectUri: string // required and will throw an error if not included: used for pop-up and callback redirection
scope?: string // default = 'openid wallet'
shouldLoginWithRedirect?: boolean // if true, redirects to your callback page
bridge?: string // default = 'https://bridge.walletconnect.org'
qrcodeModalOptions?: {
mobileLinks: string[] // set the order and list of mobile linking wallets
}
connectFirstChainId?: boolean // if true, connects to the first network chain provided
}
```

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import uauthModule from '@web3-onboard/uauth'

// initialize the module with options
const uauth = uauthModule({
clientID: 'YOUR_CLIENT_ID',
redirectUri: 'YOUR_REDIRECT_URI',
scope?: 'YOUR_SCOPES',
shouldLoginWithRedirect?: false
bridge?: 'YOUR_CUSTOM_BRIDGE_SERVER',
qrcodeModalOptions?: {
mobileLinks: ['rainbow', 'metamask', 'argent', 'trust', 'imtoken', 'pillar']
},
connectFirstChainId?: true
})

// can also initialize with basic options...
// const uauth = uauthModule({
// clientID: "YOUR_CLIENT_ID",
// redirectUri: "YOUR_REDIRECT_URI"
// })

const onboard = Onboard({
// ... other Onboard options
wallets: [
uauth
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```

### Accessing the UAuth configuration

When Unstoppable Domains is connected the UAuth user instance is exposed.
This can be used to get information related to the user scopes requested through the `UauthInitOptions`.

```typescript
const wallets$ = onboard.state.select('wallets').pipe(share())
wallets$.subscribe(wallet => {
const unstoppableUser = wallet.find(
provider => provider.label === 'Unstoppable'
)
if (unstoppableUser) console.log(unstoppableUser.instance.user)
})
```
72 changes: 72 additions & 0 deletions packages/uauth/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "@web3-onboard/uauth",
"version": "2.0.0-alpha.1",
"description": "Unstoppable Domains module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
"Web3",
"EVM",
"dapp",
"Multichain",
"Wallet",
"Transaction",
"Provider",
"Hardware Wallet",
"Notifications",
"React",
"Svelte",
"Vue",
"Next",
"Nuxt",
"MetaMask",
"Coinbase",
"WalletConnect",
"Ledger",
"Trezor",
"Connect Wallet",
"Ethereum Hooks",
"Blocknative",
"Mempool",
"pending",
"confirmed",
"Injected Wallet",
"Crypto",
"Crypto Wallet",
"Domain Name",
"Unstoppable Domains",
"Unstoppable"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/uauth"
},
"homepage": "https://onboard.blocknative.com",
"bugs": "https://github.com/blocknative/web3-onboard/issues",
"module": "dist/index.js",
"browser": "dist/index.js",
"main": "dist/index.js",
"type": "module",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"type-check": "tsc --noEmit"
},
"license": "MIT",
"devDependencies": {
"typescript": "^4.5.5"
},
"dependencies": {
"@uauth/js": "^2.4.0",
"@ethersproject/providers": "^5.5.0",
"@walletconnect/client": "^1.7.1",
"@walletconnect/qrcode-modal": "^1.7.1",
"@web3-onboard/common": "^2.2.3",
"joi": "^17.6.1",
"rxjs": "^7.5.2"
}
}
6 changes: 6 additions & 0 deletions packages/uauth/src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default `
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.7319 2.06934V9.87229L0 19.094L22.7319 2.06934Z" fill="#2FE9FF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.4696 1.71387V15.1917C18.4696 19.1094 15.2892 22.2853 11.3659 22.2853C7.44265 22.2853 4.26221 19.1094 4.26221 15.1917V9.51682L8.52443 7.17594V15.1917C8.52443 16.5629 9.63759 17.6745 11.0107 17.6745C12.3839 17.6745 13.497 16.5629 13.497 15.1917V4.4449L18.4696 1.71387Z" fill="#4C47F7"/>
</svg>
`
Loading