Skip to content

Commit 2779ff9

Browse files
committed
Merge in develop w/ uauth package
2 parents 33af948 + 53ebacd commit 2779ff9

File tree

13 files changed

+864
-8
lines changed

13 files changed

+864
-8
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ jobs:
321321
working_directory: ~/web3-onboard-monorepo/packages/enkrypt
322322
steps:
323323
- node-build-steps
324+
build-uauth:
325+
docker:
326+
- image: cimg/node:16.13.1
327+
working_directory: ~/web3-onboard-monorepo/packages/uauth
328+
steps:
329+
- node-build-steps
324330

325331
# Build staging/Alpha releases
326332
build-staging-core:
@@ -479,6 +485,12 @@ jobs:
479485
working_directory: ~/web3-onboard-monorepo/packages/enkrypt
480486
steps:
481487
- node-staging-build-steps
488+
build-staging-uauth:
489+
docker:
490+
- image: cimg/node:16.13.1
491+
working_directory: ~/web3-onboard-monorepo/packages/uauth
492+
steps:
493+
- node-staging-build-steps
482494

483495
workflows:
484496
version: 2
@@ -639,3 +651,9 @@ workflows:
639651
<<: *deploy_production_filters
640652
- build-staging-enkrypt:
641653
<<: *deploy_staging_filters
654+
uauth:
655+
jobs:
656+
- build-uauth:
657+
<<: *deploy_production_filters
658+
- build-staging-uauth:
659+
<<: *deploy_staging_filters

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ For full documentation, check out the README.md for each package:
9898
- [Sequence](packages/sequence/README.md)
9999
- [TallyHo](packages/tallyho/README.md)
100100
- [Enkrypt](packages/enkrypt/README.md)
101+
- [Unstoppable Domains](packages/uauth/README.md)
101102

102103
**Hardware Wallets**
103104

packages/demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@web3-onboard/web3auth": "^2.1.3",
4343
"@web3-onboard/enkrypt": "^2.0.0",
4444
"@web3-onboard/mew-wallet": "^2.0.0",
45+
"@web3-onboard/uauth": "^2.0.0",
4546
"vconsole": "^3.9.5"
4647
},
4748
"license": "MIT",

packages/demo/src/App.svelte

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import tallyHoModule from '@web3-onboard/tallyho'
2020
import enkryptModule from '@web3-onboard/enkrypt'
2121
import mewWalletModule from '@web3-onboard/mew-wallet'
22+
import uauthModule from '@web3-onboard/uauth'
2223
import {
2324
recoverAddress,
2425
arrayify,
@@ -31,6 +32,7 @@
3132
import blocknativeIcon from './blocknative-icon'
3233
import blocknativeLogo from './blocknative-logo'
3334
import { onMount } from 'svelte'
35+
import wallets from '@web3-onboard/injected-wallets/dist/wallets'
3436
3537
let windowWidth
3638
@@ -98,6 +100,14 @@
98100
}
99101
const trezor = trezorModule(trezorOptions)
100102
103+
const uauthOptions = {
104+
clientID: 'a25c3a65-a1f2-46cc-a515-a46fe7acb78c',
105+
redirectUri: 'http://localhost:8080/',
106+
scope:
107+
'openid wallet email:optional humanity_check:optional profile:optional social:optional'
108+
}
109+
const uauth = uauthModule(uauthOptions)
110+
101111
const magic = magicModule({
102112
apiKey: 'pk_live_02207D744E81C2BA'
103113
// userEmail: 'test@test.com'
@@ -131,7 +141,8 @@
131141
gnosis,
132142
dcent,
133143
sequence,
134-
tallyho
144+
tallyho,
145+
uauth
135146
],
136147
gas,
137148
chains: [
@@ -245,8 +256,8 @@
245256
}
246257
},
247258
// containerElements: {
248-
// El must be present at time of JS script execution
249-
// See ../public/index.html for element example
259+
// El must be present at time of JS script execution
260+
// See ../public/index.html for element example
250261
// accountCenter: '#sample-container-el'
251262
// },
252263
// Sign up for your free api key at www.Blocknative.com
@@ -255,6 +266,12 @@
255266
256267
// Subscribe to wallet updates
257268
const wallets$ = onboard.state.select('wallets').pipe(share())
269+
wallets$.subscribe(wallet => {
270+
const unstoppableUser = wallet.find(
271+
provider => provider.label === 'Unstoppable'
272+
)
273+
if (unstoppableUser) console.log(unstoppableUser.instance.user)
274+
})
258275
259276
const signTransactionMessage = async provider => {
260277
const ethersProvider = new ethers.providers.Web3Provider(provider, 'any')
@@ -949,7 +966,7 @@
949966
{/if}
950967
</div>
951968
{#if $wallets$ && !hideForIframe}
952-
{#each $wallets$ as { icon, label, accounts, chains, provider }}
969+
{#each $wallets$ as { icon, label, accounts, chains, provider, instance }}
953970
<div class="connected-wallet">
954971
<div class="flex-centered" style="width: 10rem;">
955972
<div style="width: 2rem; height: 2rem">{@html icon}</div>
@@ -958,6 +975,16 @@
958975
959976
<div>Chains: {JSON.stringify(chains, null, 2)}</div>
960977
978+
{#if label === 'Unstoppable'}
979+
<div>Unstoppable User: {instance.user.sub}</div>
980+
<div>Unstoppable Wallet: {instance.user.wallet_address}</div>
981+
<div>Unstoppable Email: {instance.user.email || ''}</div>
982+
<div>
983+
Unstoppable Humanity: {instance.user.humanity_check_id || ''}
984+
</div>
985+
<div>Unstoppable Profile: {instance.user.profile || ''}</div>
986+
{/if}
987+
961988
{#each accounts as { address, ens, balance }}
962989
<div
963990
class="account-info"

packages/injected/src/icons/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default `<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
22
<rect width="256" height="256" rx="128" fill="black"/>
33
<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"/>
4-
</svg>`
4+
</svg>`

packages/uauth/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# @web3-onboard/uauth
2+
3+
## Wallet module for connecting Unstoppable Domains to web3-onboard
4+
5+
### Install
6+
7+
**NPM**
8+
`npm i @web3-onboard/core @web3-onboard/uauth`
9+
10+
**Yarn**
11+
`yarn add @web3-onboard/core @web3-onboard/uauth`
12+
13+
## Options
14+
15+
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.
16+
**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).
17+
18+
```typescript
19+
type UauthInitOptions = {
20+
clientID: string // required and will throw an error if not included: links dapp to Unstoppable Domains for customization
21+
redirectUri: string // required and will throw an error if not included: used for pop-up and callback redirection
22+
scope?: string // default = 'openid wallet'
23+
shouldLoginWithRedirect?: boolean // if true, redirects to your callback page
24+
bridge?: string // default = 'https://bridge.walletconnect.org'
25+
qrcodeModalOptions?: {
26+
mobileLinks: string[] // set the order and list of mobile linking wallets
27+
}
28+
connectFirstChainId?: boolean // if true, connects to the first network chain provided
29+
}
30+
```
31+
32+
## Usage
33+
34+
```typescript
35+
import Onboard from '@web3-onboard/core'
36+
import uauthModule from '@web3-onboard/uauth'
37+
38+
// initialize the module with options
39+
const uauth = uauthModule({
40+
clientID: 'YOUR_CLIENT_ID',
41+
redirectUri: 'YOUR_REDIRECT_URI',
42+
scope?: 'YOUR_SCOPES',
43+
shouldLoginWithRedirect?: false
44+
bridge?: 'YOUR_CUSTOM_BRIDGE_SERVER',
45+
qrcodeModalOptions?: {
46+
mobileLinks: ['rainbow', 'metamask', 'argent', 'trust', 'imtoken', 'pillar']
47+
},
48+
connectFirstChainId?: true
49+
})
50+
51+
// can also initialize with basic options...
52+
// const uauth = uauthModule({
53+
// clientID: "YOUR_CLIENT_ID",
54+
// redirectUri: "YOUR_REDIRECT_URI"
55+
// })
56+
57+
const onboard = Onboard({
58+
// ... other Onboard options
59+
wallets: [
60+
uauth
61+
//... other wallets
62+
]
63+
})
64+
65+
const connectedWallets = await onboard.connectWallet()
66+
console.log(connectedWallets)
67+
```
68+
69+
### Accessing the UAuth configuration
70+
71+
When Unstoppable Domains is connected the UAuth user instance is exposed.
72+
This can be used to get information related to the user scopes requested through the `UauthInitOptions`.
73+
74+
```typescript
75+
const wallets$ = onboard.state.select('wallets').pipe(share())
76+
wallets$.subscribe(wallet => {
77+
const unstoppableUser = wallet.find(
78+
provider => provider.label === 'Unstoppable'
79+
)
80+
if (unstoppableUser) console.log(unstoppableUser.instance.user)
81+
})
82+
```

packages/uauth/package.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"name": "@web3-onboard/uauth",
3+
"version": "2.0.0",
4+
"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.",
5+
"keywords": [
6+
"Ethereum",
7+
"Web3",
8+
"EVM",
9+
"dapp",
10+
"Multichain",
11+
"Wallet",
12+
"Transaction",
13+
"Provider",
14+
"Hardware Wallet",
15+
"Notifications",
16+
"React",
17+
"Svelte",
18+
"Vue",
19+
"Next",
20+
"Nuxt",
21+
"MetaMask",
22+
"Coinbase",
23+
"WalletConnect",
24+
"Ledger",
25+
"Trezor",
26+
"Connect Wallet",
27+
"Ethereum Hooks",
28+
"Blocknative",
29+
"Mempool",
30+
"pending",
31+
"confirmed",
32+
"Injected Wallet",
33+
"Crypto",
34+
"Crypto Wallet",
35+
"Domain Name",
36+
"Unstoppable Domains",
37+
"Unstoppable"
38+
],
39+
"repository": {
40+
"type": "git",
41+
"url": "https://github.com/blocknative/web3-onboard.git",
42+
"directory": "packages/uauth"
43+
},
44+
"homepage": "https://onboard.blocknative.com",
45+
"bugs": "https://github.com/blocknative/web3-onboard/issues",
46+
"module": "dist/index.js",
47+
"browser": "dist/index.js",
48+
"main": "dist/index.js",
49+
"type": "module",
50+
"typings": "dist/index.d.ts",
51+
"files": [
52+
"dist"
53+
],
54+
"scripts": {
55+
"build": "tsc",
56+
"dev": "tsc -w",
57+
"type-check": "tsc --noEmit"
58+
},
59+
"license": "MIT",
60+
"devDependencies": {
61+
"typescript": "^4.5.5"
62+
},
63+
"dependencies": {
64+
"@uauth/js": "^2.4.0",
65+
"@ethersproject/providers": "^5.5.0",
66+
"@walletconnect/client": "^1.7.1",
67+
"@walletconnect/qrcode-modal": "^1.7.1",
68+
"@web3-onboard/common": "^2.2.3",
69+
"joi": "^17.6.1",
70+
"rxjs": "^7.5.2"
71+
}
72+
}

packages/uauth/src/icon.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default `
2+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
3+
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.7319 2.06934V9.87229L0 19.094L22.7319 2.06934Z" fill="#2FE9FF"/>
4+
<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"/>
5+
</svg>
6+
`

0 commit comments

Comments
 (0)