WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
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
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Web3Auth is where passwordless auth meets non-custodial key infrastructure for W
Checkout the official [Web3Auth Documentation](https://web3auth.io/docs) and [SDK Reference](https://web3auth.io/docs/sdk/pnp/react-native) to get started!

## 💡 Features

- Plug and Play, OAuth based Web3 Authentication Service
- Fully decentralized, non-custodial key infrastructure
- End to end Whitelabelable solution
Expand Down Expand Up @@ -99,42 +100,42 @@ web3authrnexample://openlogin

## 💥 Initialization & Usage

In your sign-in activity', create an `Web3Auth` instance with your Web3Auth project's configurations and
In your sign-in activity', create an `Web3Auth` instance with your Web3Auth project's configurations and
configure it like this:

### Expo Managed Workflow

```js
import * as WebBrowser from 'expo-web-browser';
import Web3Auth, { LOGIN_PROVIDER, OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk";
import * as WebBrowser from "expo-web-browser";
import Web3Auth, { AUTH_CONNECTION, OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk";

const web3auth = new Web3Auth(WebBrowser, {
clientId,
network: OPENLOGIN_NETWORK.TESTNET, // or other networks
clientId,
network: OPENLOGIN_NETWORK.TESTNET, // or other networks
redirectUrl: resolvedRedirectUrl,
});
const info = await web3auth.login({
loginProvider: LOGIN_PROVIDER.GOOGLE,
redirectUrl: resolvedRedirectUrl,
mfaLevel: 'mandatory', // optional
curve: 'secp256k1', // optional
authConnection: AUTH_CONNECTION.GOOGLE,
mfaLevel: "mandatory", // optional
curve: "secp256k1", // optional
});
```

### Bare Workflow

```js
import * as WebBrowser from '@toruslabs/react-native-web-browser';
import Web3Auth, { LOGIN_PROVIDER, OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk";
import * as WebBrowser from "@toruslabs/react-native-web-browser";
import Web3Auth, { AUTH_CONNECTION, OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk";

const web3auth = new Web3Auth(WebBrowser, {
clientId,
network: OPENLOGIN_NETWORK.TESTNET, // or other networks
clientId,
network: OPENLOGIN_NETWORK.TESTNET, // or other networks
redirectUrl: resolvedRedirectUrl,
});
const info = await web3auth.login({
loginProvider: LOGIN_PROVIDER.GOOGLE,
redirectUrl: resolvedRedirectUrl,
mfaLevel: 'mandatory', // optional
curve: 'secp256k1', // optional
authConnection: AUTH_CONNECTION.GOOGLE,
mfaLevel: "mandatory", // optional
curve: "secp256k1", // optional
});
```

Expand Down
24 changes: 12 additions & 12 deletions demo/rn-bare-example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import React, { useEffect, useState } from "react";
import { StyleSheet, Text, View, Button, ScrollView, Dimensions, TextInput, Switch } from "react-native";
import "@ethersproject/shims";
import { ethers } from "ethers";

// IMP START - Quick Start
import * as WebBrowser from "@toruslabs/react-native-web-browser";
import EncryptedStorage from "react-native-encrypted-storage";
import Web3Auth, { LOGIN_PROVIDER, WEB3AUTH_NETWORK, ChainNamespace } from "@web3auth/react-native-sdk";
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import { MMKVLoader, useMMKVStorage } from "react-native-mmkv-storage";
import {
AccountAbstractionProvider,
BiconomySmartAccount,
Expand All @@ -17,6 +10,13 @@ import {
SafeSmartAccount,
TrustSmartAccount,
} from "@web3auth/account-abstraction-provider";
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import Web3Auth, { AUTH_CONNECTION, CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from "@web3auth/react-native-sdk";
import { ethers } from "ethers";
import React, { useEffect, useState } from "react";
import { Button, Dimensions, ScrollView, StyleSheet, Switch, Text, TextInput, View } from "react-native";
import EncryptedStorage from "react-native-encrypted-storage";
import { MMKVLoader, useMMKVStorage } from "react-native-mmkv-storage";
// IMP END - Quick Start

const scheme = "web3authrnexample"; // Or your desired app redirection scheme
Expand All @@ -30,9 +30,9 @@ const clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw

// IMP START - SDK Initialization
const chainConfig = {
chainNamespace: ChainNamespace.EIP155,
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0xaa36a7",
rpcTarget: "https://rpc.ankr.com/eth_sepolia",
rpcTarget: "https://ethereum-sepolia-rpc.publicnode.com",
// Avoid using public rpcTarget in production.
// Use services like Infura, Quicknode etc
displayName: "Ethereum Sepolia Testnet",
Expand Down Expand Up @@ -167,7 +167,7 @@ export default function App() {
setConsole("Logging in");
// IMP START - Login
await web3auth.login({
loginProvider: LOGIN_PROVIDER.EMAIL_PASSWORDLESS,
authConnection: AUTH_CONNECTION.EMAIL_PASSWORDLESS,
extraLoginOptions: {
login_hint: email,
},
Expand Down Expand Up @@ -280,7 +280,7 @@ export default function App() {
}

setConsole("Launch Wallet Services");
await web3auth.launchWalletServices(chainConfig);
await web3auth.launchWalletServices();
};

const uiConsole = (...args: unknown[]) => {
Expand All @@ -296,7 +296,7 @@ export default function App() {
const address: string = await getAccounts();

const params = ["Hello World", address];
const res = await web3auth.request(chainConfig, "personal_sign", params);
const res = await web3auth.request("personal_sign", params);
uiConsole(res);
} catch (error) {
uiConsole("Error in requestSignature:", error);
Expand Down
7 changes: 7 additions & 0 deletions demo/rn-bare-example/globals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { fromByteArray } from "react-native-quick-base64";

global.Buffer = require("buffer").Buffer;

global.base64FromArrayBuffer = (ab) => {
const u8 = ab instanceof Uint8Array ? ab : new Uint8Array(ab);
return fromByteArray(u8);
};

import { install } from "react-native-quick-crypto";

install();
Expand Down
8 changes: 4 additions & 4 deletions demo/rn-bare-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-quick-crypto (0.7.5):
- react-native-quick-crypto (0.7.17):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1444,7 +1444,7 @@ SPEC CHECKSUMS:
React-Mapbuffer: bf56147c9775491e53122a94c423ac201417e326
react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
react-native-mmkv-storage: 9e84e8d0cc66402128d01a642022de0145303491
react-native-quick-crypto: 7085e4e4607e7e8fa57f4193f994d5262d351e45
react-native-quick-crypto: b2557b7d51ac87172cd40477122b59e2585eedd7
react-native-web-browser: 087b454e1e94b58b40ba73f54251d77486144d19
React-nativeconfig: 9f223cd321823afdecf59ed00861ab2d69ee0fc1
React-NativeModulesApple: ff7efaff7098639db5631236cfd91d60abff04c0
Expand All @@ -1470,8 +1470,8 @@ SPEC CHECKSUMS:
React-utils: 4476b7fcbbd95cfd002f3e778616155241d86e31
ReactCommon: ecad995f26e0d1e24061f60f4e5d74782f003f12
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 2f71ecf38d934aecb366e686278102a51679c308
Yoga: ae3c32c514802d30f687a04a6a35b348506d411f

PODFILE CHECKSUM: 3dac9911479fab8b2375358eac35d220bf61e989

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
57 changes: 43 additions & 14 deletions demo/rn-bare-example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const path = require("path");
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");

const defaultConfig = getDefaultConfig(__dirname);

const config = {
resolver: {
extraNodeModules: {
assert: require.resolve("empty-module"), // assert can be polyfilled here if needed
http: require.resolve("empty-module"), // stream-http can be polyfilled here if needed
https: require.resolve("empty-module"), // https-browserify can be polyfilled here if needed
os: require.resolve("empty-module"), // os-browserify can be polyfilled here if needed
url: require.resolve("empty-module"), // url can be polyfilled here if needed
zlib: require.resolve("empty-module"), // browserify-zlib can be polyfilled here if needed
path: require.resolve("empty-module"),
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("readable-stream"),
},
sourceExts: [...defaultConfig.resolver.sourceExts, 'svg'],
resolver: {
extraNodeModules: {
assert: require.resolve("empty-module"), // assert can be polyfilled here if needed
http: require.resolve("empty-module"), // stream-http can be polyfilled here if needed
https: require.resolve("empty-module"), // https-browserify can be polyfilled here if needed
os: require.resolve("empty-module"), // os-browserify can be polyfilled here if needed
url: require.resolve("empty-module"), // url can be polyfilled here if needed
zlib: require.resolve("empty-module"), // browserify-zlib can be polyfilled here if needed
path: require.resolve("empty-module"),
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("readable-stream"),
},
sourceExts: [...defaultConfig.resolver.sourceExts, "svg"],
},
};

const baseResolve = defaultConfig.resolver.resolveRequest;

function isRelative(spec) {
return spec.startsWith("./") || spec.startsWith("../");
}

function isFromPathResolveNeeded(context) {
const p = context.originModulePath || "";
// handles macOS/Linux/Windows path separators
const packages = ["permissionless", "ox"];
return packages.some((name) => p.includes(`${path.sep}node_modules${path.sep}${name}${path.sep}`));
}

// Metro (Expo’s bundler) resolves modules before transforming TS. When the specifier already includes “.js”, Metro treats “.js” as part of the filename and does not replace it with “.ts”
config.resolver.resolveRequest = (context, moduleName, platform) => {
// Example: inside node_modules/permissionless/accounts/index.ts
// moduleName is "./kernel/to7702KernelSmartAccount.js"
if (isRelative(moduleName) && moduleName.endsWith(".js") && isFromPathResolveNeeded(context)) {
const withoutExt = moduleName.slice(0, -3); // drop ".js"
try {
return (baseResolve || context.resolveRequest)(context, withoutExt, platform);
} catch (e) {
// fall through if that didn't resolve
}
}
return (baseResolve || context.resolveRequest)(context, moduleName, platform);
};

module.exports = mergeConfig(defaultConfig, config);
Loading