Skip to content

Commit be5a9ae

Browse files
Major fixes
1 parent 07a929d commit be5a9ae

21 files changed

+14138
-3827
lines changed

.eslintignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
#production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
examples/
23+
types/
24+
dist/

.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"root": true,
3+
"extends": ["@toruslabs/eslint-config-typescript"],
4+
"parser": "@typescript-eslint/parser",
5+
"ignorePatterns": ["*.config.js", "example/*"],
6+
"parserOptions": {
7+
"sourceType": "module",
8+
"ecmaVersion": 11,
9+
"project": "./tsconfig.json"
10+
},
11+
"rules": {
12+
"camelcase": 0
13+
}
14+
}

.npmignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,10 @@ fabric.properties
581581

582582
# End of https://www.toptal.com/developers/gitignore/api/android,androidstudio,xcode,reactnative,node,yarn
583583

584-
/openlogin-expo-sdk-example-report
584+
585585

586586
/node_modules
587587

588588
/
589589

590-
/.yalc/
591-
592-
/openlogin-expo-sdk-example-expo/
590+
/.yalc/

.prettierignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
#production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
types/

.prettierrc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# .prettierrc or .prettierrc.yaml
2+
printWidth: 150
3+
singleQuote: false
4+
semi: true

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,28 @@
33
## Installation
44

55
```sh
6-
npm install web3auth-react-native-sdk
6+
npm install @web3auth/react-native-sdk
77
```
88

99
To allow the SDK to work with exported Expo Android apps, you need to place a designated scheme into `app.json`, like below:
1010

1111
```js
12-
"scheme": "openloginexposdkexampleexpo",
12+
"scheme": "web3authreactnativesdkexample",
1313
```
1414

15-
### Bare React Native apps
16-
17-
If you want to use this SDK with bare React Native apps, you can take reference to the sample app in https://github.com/torusresearch/openlogin-expo-bare-sample .
18-
1915
## Usage
2016

21-
Please see [App.tsx](./openlogin-expo-sdk-example-expo/App.tsx) for detailed example.
17+
Please see [App.tsx](./example/App.tsx) for detailed example.
2218

2319
```js
24-
const openlogin = new OpenLogin({
25-
clientId:
26-
"BC5bANkU4-fil7C5s1uKzRfF0VGqbuaxDQiLnQ8WgF7SEA32lGegAhu7dk4dZf3Rk397blIvfWytXwsRvs9dOaQ",
20+
import * as WebBrowser from "@toruslabs/react-native-web-browser";
21+
// or import * as WebBrowser from "expo-web-browser"; (for expo)
22+
23+
const web3auth = new Web3Auth(WebBrowser, {
24+
clientId: "BC5bANkU4-fil7C5s1uKzRfF0VGqbuaxDQiLnQ8WgF7SEA32lGegAhu7dk4dZf3Rk397blIvfWytXwsRvs9dOaQ",
2725
network: Network.TESTNET,
2826
});
29-
const state = await openlogin.login({
27+
const state = await web3auth.login({
3028
loginProvider: LoginProvider.GOOGLE,
3129
redirectUrl: resolvedRedirectUrl,
3230
});

example/.eslintrc.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"root": true,
3+
"extends": ["@toruslabs/eslint-config-react"],
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"sourceType": "module",
7+
"ecmaVersion": 11,
8+
"project": "./tsconfig.json"
9+
},
10+
"rules": {
11+
"no-console": 2,
12+
"@typescript-eslint/no-throw-literal": 0,
13+
"import/extensions": [
14+
"error",
15+
"ignorePackages",
16+
{
17+
"js": "never",
18+
"jsx": "never",
19+
"ts": "never",
20+
"tsx": "never"
21+
}
22+
]
23+
},
24+
"env": {
25+
"es2020": true,
26+
"browser": true,
27+
"node": true
28+
}
29+
}

example/App.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
import { StatusBar } from "expo-status-bar";
22
import { useState } from "react";
33
import { StyleSheet, Text, View, Button } from "react-native";
4-
import Web3Auth, {
5-
LOGIN_PROVIDER,
6-
OPENLOGIN_NETWORK,
7-
SdkInitParams,
8-
} from "web3auth-react-native-sdk";
4+
import Web3Auth, { LOGIN_PROVIDER, OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk";
95
import Constants, { AppOwnership } from "expo-constants";
106
import * as Linking from "expo-linking";
117
import * as WebBrowser from "expo-web-browser";
128
import { Buffer } from "buffer";
139

1410
global.Buffer = global.Buffer || Buffer;
1511

16-
const scheme = "web3authreactnativesdkexample";
12+
const scheme = "web3authexposample";
1713

1814
const resolvedRedirectUrl =
19-
Constants.appOwnership == AppOwnership.Expo ||
20-
Constants.appOwnership == AppOwnership.Guest
21-
? Linking.createURL("openlogin", {})
22-
: Linking.createURL("openlogin", { scheme: scheme });
15+
Constants.appOwnership == AppOwnership.Expo || Constants.appOwnership == AppOwnership.Guest
16+
? Linking.createURL("web3auth", {})
17+
: Linking.createURL("web3auth", { scheme: scheme });
2318

2419
export default function App() {
2520
const [key, setKey] = useState("");
2621
const [errorMsg, setErrorMsg] = useState("");
2722
const login = async () => {
2823
try {
2924
const web3auth = new Web3Auth(WebBrowser, {
30-
clientId:
31-
"BC5bANkU4-fil7C5s1uKzRfF0VGqbuaxDQiLnQ8WgF7SEA32lGegAhu7dk4dZf3Rk397blIvfWytXwsRvs9dOaQ",
25+
clientId: "BA0mVyeHATikwuXVhXWCNjAxHthlw0w84mUhLuxlC4KZKjvmBsbdbmEWTizJ26YzrbKSWbOZbtGYdVDm0ESuYSg",
3226
network: OPENLOGIN_NETWORK.TESTNET,
3327
});
3428
const state = await web3auth.login({
@@ -48,7 +42,7 @@ export default function App() {
4842
<Text>Linking URL: {resolvedRedirectUrl}</Text>
4943
<Text>appOwnership: {Constants.appOwnership}</Text>
5044
<Text>executionEnvironment: {Constants.executionEnvironment}</Text>
51-
<Button title="Login with OpenLogin" onPress={login} />
45+
<Button title="Login with Web3Auth" onPress={login} />
5246
<StatusBar style="auto" />
5347
</View>
5448
);

example/app.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"assetBundlePatterns": ["**/*"],
1919
"ios": {
2020
"supportsTablet": true,
21-
"bundleIdentifier": "com.torus.samples.openloginexposdkexampleexpo",
21+
"bundleIdentifier": "com.torus.samples.web3authexposample",
2222
"buildNumber": "0.0.6"
2323
},
2424
"android": {
2525
"adaptiveIcon": {
2626
"foregroundImage": "./assets/adaptive-icon.png",
2727
"backgroundColor": "#FFFFFF"
2828
},
29-
"package": "com.torus.samples.openloginexposdkexampleexpo",
29+
"package": "com.torus.samples.web3authexposample",
3030
"versionCode": 6
3131
},
3232
"web": {

example/package.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "openlogin-expo-sdk-example-expo",
2+
"name": "web3auth-expo-sdk-example",
33
"version": "1.0.0",
44
"main": "node_modules/expo/AppEntry.js",
55
"scripts": {
@@ -10,23 +10,25 @@
1010
"eject": "expo eject"
1111
},
1212
"dependencies": {
13-
"expo": "~44.0.0",
14-
"expo-linking": "^3.0.0",
15-
"expo-status-bar": "~1.2.0",
16-
"expo-web-browser": "~10.1.0",
17-
"openlogin-expo-sdk": "../",
18-
"react": "17.0.1",
19-
"react-dom": "17.0.1",
20-
"react-native": "0.64.3",
21-
"react-native-web": "0.17.1",
22-
"web3auth-react-native-sdk": "../"
13+
"@web3auth/react-native-sdk": "../",
14+
"expo": "~45.0.4",
15+
"expo-linking": "^3.1.0",
16+
"expo-status-bar": "~1.3.0",
17+
"expo-web-browser": "~10.2.1",
18+
"react": "^17.0.1",
19+
"react-dom": "^17.0.1",
20+
"react-native": "^0.68.2",
21+
"react-native-web": "0.17.7"
2322
},
2423
"devDependencies": {
25-
"@babel/core": "^7.12.9",
26-
"@types/react": "~17.0.21",
27-
"@types/react-native": "~0.64.12",
28-
"metro-config": "^0.66.2",
29-
"typescript": "~4.3.5"
24+
"@babel/core": "^7.18.2",
25+
"@toruslabs/eslint-config-react": "^1.0.1",
26+
"@types/react": "^17",
27+
"@types/react-native": "~0.67.7",
28+
"eslint": "^8.16.0",
29+
"expo-cli": "^5.4.6",
30+
"metro-config": "^0.71.0",
31+
"typescript": "~4.7.2"
3032
},
3133
"private": true
3234
}

0 commit comments

Comments
 (0)