Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 20 additions & 9 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { StatusBar } from "expo-status-bar";
import { useEffect, useRef, useState } from "react";
import { StyleSheet, Text, View, Button } from "react-native";
import Web3Auth, { LOGIN_PROVIDER, OPENLOGIN_NETWORK, State } from "@web3auth/react-native-sdk";
import { Buffer } from "buffer";
import Constants, { AppOwnership } from "expo-constants";
import * as Linking from "expo-linking";
import { StatusBar } from "expo-status-bar";
import * as WebBrowser from "expo-web-browser";
import { useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import * as SecureStore from 'expo-secure-store';

global.Buffer = global.Buffer || Buffer;

Expand All @@ -29,15 +30,25 @@ export default function App() {
const [key, setKey] = useState("");
const [errorMsg, setErrorMsg] = useState("");
const [userInfo, setUserInfo] = useState<State>(null);

var web3auth = useRef<Web3Auth>();

useEffect(() => {
web3auth.current = new Web3Auth(WebBrowser, SecureStore, {
clientId: "BDj1toq1N1xYgDIJ00ADR-QPJ71ESzJcB3ijVHP1TsIX7nsx_lu6uLoJQMPze1vpGDt--Ew95RGxz-RgOh1tcxM",
network: OPENLOGIN_NETWORK.TESTNET,
});
web3auth.current.init().then(function(state) {
setKey(state.privKey || "no key");
setUserInfo(state);
});
}, []);

const login = async () => {
try {
const web3auth = new Web3Auth(WebBrowser, {
clientId: "BA0mVyeHATikwuXVhXWCNjAxHthlw0w84mUhLuxlC4KZKjvmBsbdbmEWTizJ26YzrbKSWbOZbtGYdVDm0ESuYSg",
network: OPENLOGIN_NETWORK.TESTNET,
});
const state = await web3auth.login({
redirectUrl: resolvedRedirectUrl,
const state = await web3auth.current.login({
loginProvider: LOGIN_PROVIDER.GOOGLE,
redirectUrl: resolvedRedirectUrl,
});
setKey(state.privKey || "no key");
setUserInfo(state);
Expand Down
14 changes: 10 additions & 4 deletions example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ module.exports = {
)
),

extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, "node_modules", name);
return acc;
}, {}),
extraNodeModules: {
... {
stream: path.join(__dirname, "node_modules", 'stream-browserify'),
crypto: path.join(__dirname, "node_modules", 'crypto-browserify')
},
... modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, "node_modules", name);
return acc;
}, {})
},
},

transformer: {
Expand Down
20 changes: 20 additions & 0 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-native": "^0.68.2",
"react-native-web": "0.17.7"
"react-native-web": "0.17.7",
"expo-secure-store": "~11.2.0"
},
"devDependencies": {
"@babel/core": "^7.18.9",
Expand Down
27 changes: 19 additions & 8 deletions example_general/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
* @format
*/

import React, {useState} from 'react';
import React, {useEffect, useRef, useState} from 'react';
import * as WebBrowser from '@toruslabs/react-native-web-browser';
import EncryptedStorage from 'react-native-encrypted-storage';
import Web3Auth, {
LOGIN_PROVIDER,
OPENLOGIN_NETWORK,
Expand All @@ -28,24 +29,34 @@ const App = () => {
const [key, setKey] = useState('');
const [errorMsg, setErrorMsg] = useState('');
const [userInfo, setUserInfo] = useState<State | null>(null);

var web3auth = useRef<Web3Auth>();

useEffect(() => {
web3auth.current = new Web3Auth(WebBrowser, EncryptedStorage, {
clientId: "BDj1toq1N1xYgDIJ00ADR-QPJ71ESzJcB3ijVHP1TsIX7nsx_lu6uLoJQMPze1vpGDt--Ew95RGxz-RgOh1tcxM",
network: OPENLOGIN_NETWORK.TESTNET,
});
web3auth.current.init().then(function(state) {
setKey(state.privKey || "no key");
setUserInfo(state);
});
}, []);

const login = async () => {
try {
const web3auth = new Web3Auth(WebBrowser, {
clientId:
'BA0mVyeHATikwuXVhXWCNjAxHthlw0w84mUhLuxlC4KZKjvmBsbdbmEWTizJ26YzrbKSWbOZbtGYdVDm0ESuYSg',
network: OPENLOGIN_NETWORK.TESTNET,
});
const state = await web3auth.login({
const state = await web3auth.current.login({
loginProvider: LOGIN_PROVIDER.GOOGLE,
redirectUrl: resolvedRedirectUrl,
});
setKey(state.privKey || 'no key');
setKey(state.privKey || "no key");
setUserInfo(state);
} catch (e) {
console.error(e);
setErrorMsg(String(e));
}
};

return (
<View style={styles.container}>
{key !== '' ? <Text>Key: {key}</Text> : null}
Expand Down
6 changes: 6 additions & 0 deletions example_general/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module.exports = {
experimentalImportSupport: false,
inlineRequires: true,
},
extraNodeModules: {
... {
stream: path.join(__dirname, "node_modules", 'stream-browserify'),
crypto: path.join(__dirname, "node_modules", 'crypto-browserify')
}
},
}),
},
};
5 changes: 3 additions & 2 deletions example_general/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@toruslabs/react-native-web-browser": "^1.0.1",
"@web3auth/react-native-sdk": "file:../",
"react": "18.1.0",
"react-native": "0.70.1",
"@toruslabs/react-native-web-browser": "^1.0.1",
"@web3auth/react-native-sdk": "file:../"
"react-native-encrypted-storage": "^4.0.3"
},
"devDependencies": {
"@babel/core": "^7.12.9",
Expand Down
81 changes: 75 additions & 6 deletions example_general/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1617,12 +1617,21 @@
"@typescript-eslint/types" "5.39.0"
eslint-visitor-keys "^3.3.0"

"@wangshijun/secp256k1@^4.0.3":
version "4.0.3"
resolved "https://registry.yarnpkg.com/@wangshijun/secp256k1/-/secp256k1-4.0.3.tgz#20fc976dc0abc252ed653ee75d1b63d484267b07"
integrity sha512-07nXubNoGKpnJruT9wNGS4PP6+5qYKA+psd0Tdh/XVqkDf+S+MQ2y9o7Fh8g8pg/ScfPCgjL1O4N+w/21pQY+w==
dependencies:
elliptic "^6.5.2"

"@web3auth/react-native-sdk@file:..":
version "3.1.0"
version "3.3.0"
dependencies:
"@wangshijun/secp256k1" "^4.0.3"
base64url "^3.0.1"
buffer "^6.0.3"
loglevel "^1.8.0"
crypto-js "^4.1.1"
loglevel "^1.8.1"
react-native-url-polyfill "^1.3.0"

abab@^2.0.3, abab@^2.0.5:
Expand Down Expand Up @@ -2060,6 +2069,11 @@ bl@^4.1.0:
inherits "^2.0.4"
readable-stream "^3.4.0"

bn.js@^4.11.9:
version "4.12.0"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88"
integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
Expand Down Expand Up @@ -2091,6 +2105,11 @@ braces@^3.0.2:
dependencies:
fill-range "^7.0.1"

brorand@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f"
integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==

browser-process-hrtime@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626"
Expand Down Expand Up @@ -2465,6 +2484,11 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2:
shebang-command "^2.0.0"
which "^2.0.1"

crypto-js@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==

cssom@^0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10"
Expand Down Expand Up @@ -2650,6 +2674,19 @@ electron-to-chromium@^1.4.251:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.275.tgz#db25c8e39c9cc910a996d1ec9b73eee834cb0ac1"
integrity sha512-aJeQQ+Hl9Jyyzv4chBqYJwmVRY46N5i2BEX5Cuyk/5gFCUZ5F3i7Hnba6snZftWla7Gglwc5pIgcd+E7cW+rPg==

elliptic@^6.5.2:
version "6.5.4"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb"
integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==
dependencies:
bn.js "^4.11.9"
brorand "^1.1.0"
hash.js "^1.0.0"
hmac-drbg "^1.0.1"
inherits "^2.0.4"
minimalistic-assert "^1.0.1"
minimalistic-crypto-utils "^1.0.1"

emittery@^0.7.1:
version "0.7.2"
resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.7.2.tgz#25595908e13af0f5674ab419396e2fb394cdfa82"
Expand Down Expand Up @@ -3486,6 +3523,14 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"

hash.js@^1.0.0, hash.js@^1.0.3:
version "1.1.7"
resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42"
integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==
dependencies:
inherits "^2.0.3"
minimalistic-assert "^1.0.1"

hermes-estree@0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.8.0.tgz#530be27243ca49f008381c1f3e8b18fb26bf9ec0"
Expand All @@ -3505,6 +3550,15 @@ hermes-profile-transformer@^0.0.6:
dependencies:
source-map "^0.7.3"

hmac-drbg@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==
dependencies:
hash.js "^1.0.3"
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"

hosted-git-info@^2.1.4:
version "2.8.9"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
Expand Down Expand Up @@ -4661,10 +4715,10 @@ logkitty@^0.7.1:
dayjs "^1.8.15"
yargs "^15.1.0"

loglevel@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.8.0.tgz#e7ec73a57e1e7b419cb6c6ac06bf050b67356114"
integrity sha512-G6A/nJLRgWOuuwdNuA6koovfEV1YpqqAG4pRUlFaz3jj2QNZ8M4vBqnVA+HBTmU/AMNUtlOsMmSpF6NyOjztbA==
loglevel@^1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.8.1.tgz#5c621f83d5b48c54ae93b6156353f555963377b4"
integrity sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg==

loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0:
version "1.4.0"
Expand Down Expand Up @@ -5155,6 +5209,16 @@ mimic-fn@^2.1.0:
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==

minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==

minimalistic-crypto-utils@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"
integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==

minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
Expand Down Expand Up @@ -5804,6 +5868,11 @@ react-native-codegen@^0.70.5:
jscodeshift "^0.13.1"
nullthrows "^1.1.1"

react-native-encrypted-storage@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/react-native-encrypted-storage/-/react-native-encrypted-storage-4.0.3.tgz#2a4d65459870511e8f4ccd22f02433dab7fa5e91"
integrity sha512-0pJA4Aj2S1PIJEbU7pN/Qvf7JIJx3hFywx+i+bLHtgK0/6Zryf1V2xVsWcrD50dfiu3jY1eN2gesQ5osGxE7jA==

react-native-gradle-plugin@^0.70.3:
version "0.70.3"
resolved "https://registry.yarnpkg.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz#cbcf0619cbfbddaa9128701aa2d7b4145f9c4fc8"
Expand Down
Loading