From 403575b87e3d09c6f67f512ba61edecd6f8722dd Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:50:08 +0100 Subject: [PATCH 01/25] add protocol-kit v2 updates --- safe-core-sdk/auth-kit/guides/web3auth.md | 8 ++++---- safe-core-sdk/auth-kit/reference/AuthKitBasePack.md | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/safe-core-sdk/auth-kit/guides/web3auth.md b/safe-core-sdk/auth-kit/guides/web3auth.md index d949c17f..118cd810 100644 --- a/safe-core-sdk/auth-kit/guides/web3auth.md +++ b/safe-core-sdk/auth-kit/guides/web3auth.md @@ -145,7 +145,7 @@ Once connected, you can use any of the methods available in the [Protocol Kit](h import { ethers } from 'ethers' import { EthersAdapter } from '@safe-global/protocol-kit' -provider = new ethers.providers.Web3Provider(web3AuthModalPack.getProvider()) +provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) signer = provider.getSigner() const ethAdapter = new EthersAdapter({ @@ -162,10 +162,10 @@ const safeSDK = await Safe.create({ const safeTransactionData: MetaTransactionData = { to: '0x', data: '0x', - value: ethers.utils.parseUnits('0.0001', 'ether').toString() + value: ethers.parseUnits('0.0001', 'ether').toString() } -const safeTransaction = await safeSDK.createTransaction({ safeTransactionData }) +const safeTransaction = await safeSDK.createTransaction({ transactions: [safeTransactionData] }) ``` ## Sign messages using the `Web3AuthModalPack` @@ -183,7 +183,7 @@ const address = '0x...' await web3.eth.personal.sign(message, address) // Using ethers -const provider = new ethers.providers.Web3Provider(web3AuthModalPack.getProvider()) +const provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) const signer = provider.getSigner() await signer.sendTransaction(tx) diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index 81125fb9..4c3a50e1 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -24,19 +24,19 @@ class MyPack extends AuthKitBasePack { These methods are the common interface for all the Auth packs. Check each pack's documentation to get more details. -### `init(options?)` +### `init(options?): Promise` Provides the initialization options for the required packages, classes and properties. -### `signIn(): authKitSignInData` +### `signIn(): Promise` Provides a mechanism to connect to the provider services and returns an Ethereum address that will be used as a signer along with the associated Safe addresses. -### `signOut()` +### `signOut(): Promise` Disconnects the provider services and cleans up any data related to the current user. -### `getProvider(): web3Provider` +### `getProvider(): Eip1193Provider | null` Returns a Web3 provider that can be used to interact with the blockchain (`web3.js` or `ethers.js` for example). @@ -63,12 +63,12 @@ Returns the Ethereum address extracted from the provider retrieved by `getProvid **Returns** - `address`: The Ethereum address extracted from the provider. -### `getSafes(txServiceUrl): safes[]` +### `getSafes(txServiceUrl?): safes[]` Returns the list of Safes associated with the signer address by calling the `getAddress()` method internally. **Params** -- `txServiceUrl`: The Safe Transaction Service url to retrieve the Safes associated with the owner (signer). +- `txServiceUrl`(optional): The Safe Transaction Service URL to retrieve the Safes associated with the owner (signer). **Returns** - `safes[]`: The list of Safes associated with the owner (signer). From eded36fc77a4e7f00125163be1823cd2a6a123f9 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:18:54 +0100 Subject: [PATCH 02/25] Add SafeAuth information --- safe-core-sdk/auth-kit/README.md | 3 +- safe-core-sdk/auth-kit/guides/safe-auth.md | 179 ++++++++++++++ safe-core-sdk/auth-kit/guides/web3auth.md | 196 ---------------- .../auth-kit/reference/AuthKitBasePack.md | 13 +- safe-core-sdk/auth-kit/reference/README.md | 8 +- .../auth-kit/reference/SafeAuthPack.md | 220 ++++++++++++++++++ .../auth-kit/reference/Web3AuthModalPack.md | 152 ------------ 7 files changed, 415 insertions(+), 356 deletions(-) create mode 100644 safe-core-sdk/auth-kit/guides/safe-auth.md delete mode 100644 safe-core-sdk/auth-kit/guides/web3auth.md create mode 100644 safe-core-sdk/auth-kit/reference/SafeAuthPack.md delete mode 100644 safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md diff --git a/safe-core-sdk/auth-kit/README.md b/safe-core-sdk/auth-kit/README.md index 59912ce7..b09ab979 100644 --- a/safe-core-sdk/auth-kit/README.md +++ b/safe-core-sdk/auth-kit/README.md @@ -3,7 +3,8 @@ The Auth Kit creates an Ethereum address and authenticates a blockchain account using an email address, social media account, or crypto wallet like Metamask. You can get the Ethereum address and the associated safe addresses as an output for the sign-in process. The following guides show how to use the Auth Kit and integrate it into your project by using one of the packs: -- [Web3Auth Pack](./guides/web3auth.md) +- [SafeAuth Pack](./guides/safe-auth.md) ## Resources + - [Auth Kit on GitHub](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md new file mode 100644 index 00000000..9d01a895 --- /dev/null +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -0,0 +1,179 @@ +# Integration with SafeAuth + +This guide demonstrates creating an externally-owned account using your email or social media account. Once authenticated, you can sign transactions and interact with your Safe accounts. + +The `SafeAuthPack` is an authentication system that utilizes the [Web3Auth](https://web3auth.io) MPC technology. It was developed in collaboration with Web3Auth to create a smooth onboarding experience for web2 users across different dApps. + +## Prerequisites + +- [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) + +### Install dependencies + +```bash +npm i @safe-global/auth-kit @web3auth/safeauth-embed +``` + +## Create a SafeAuthPack instance + +We will use the provided `SafeAuthPack` exported in the `@safe-global/auth-kit` package. + +Create an instance of the [SafeAuthPack](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit/src/packs/safe-auth/SafeAuthPack.ts) using the required `SafeAuthConfig` configuration object. + +> The list of supported chains is: +> +> - Production: Ethereum, Polygon, BSC, Avalanche, Optimism, Celo, Arbitrum, Gnosis chain +> - Test: Goerli, Sepolia, Polygon Mumbai, BSC testnet, Avalanche testnet, Arbitrum testnet, Optimism testnet + +```typescript +import { + SafeAuthPack, + SafeAuthConfig, + SafeAuthInitOptions, +} from '@safe-global/auth-kit' + +const safeAuthConfig: SafeAuthConfig = { + txServiceUrl: 'https://safe-transaction-mainnet.safe.global', +} +const safeAuthInitOptions: SafeAuthInitOptions = { + enableLogging: true, + showWidgetButton: false, + chainConfig: { + blockExplorerUrl: 'https://etherscan.io', + chainId: '0x1', + displayName: 'Main Ethereum Network', + logo: 'eth.svg', + rpcTarget: `${rpcUrl}`, + ticker: 'ETH', + tickerName: 'Ethereum', + }, +} + +const safeAuthPack = new SafeAuthPack(safeAuthConfig) +await safeAuthPack.init(safeAuthInitOptions) +``` + +## Sign in to an Ethereum account + +After creating your `SafeAuthPack` instance, initiate the authentication process by calling the `signIn()` method. Typically, this method is called when the user clicks a "Sign In" button on the web page. + +After successfully signing in, you will create a new Ethereum Wallet. This wallet will be used for all future logins and can be **shared across different applications**. + +```typescript +// The signIn() method returns the user's Ethereum address and the associated Safe addresses +// The `await` will last until the user is authenticated. Therefore, it will be active while the authentication popup is being displayed. +const authKitSignData = await safeAuthPack.signIn() +``` + +The returned `authKitSignData` data contains the following properties: + +```typescript +AuthKitSignInData { + eoa: string // The safe signer + safes?: string[] // The list of associated Safe addresses in the chain +} +``` + +The `signOut()` method removes the current session. + +```typescript +await safeAuthPack.signOut() +``` + +After the user is authenticated, call `getProvider()` to get the Ethereum provider instance. This is a [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) compatible provider you can wrap using your favorite library (web3, ethers). + +```typescript +safeAuthPack.getProvider() +``` + +We expose two methods for listening to events, `subscribe()` and `unsubscribe()`. + +```typescript +const accountChangedHandler = (accounts: string[]) => { + console.log('Signer accounts:', accounts) +} + +safeAuthPack.subscribe('accountsChanged', accountChangedHandler) +safeAuthPack.unsubscribe('accountsChanged', accountChangedHandler) +``` + +The `SafeAuthPack` instantiation will return the list of associated Safe addresses as part of the response from the `signIn()` method when the `txServiceUrl` is provided. + +```typescript +const safeAuthPack = new SafeAuthPack({ + txServiceUrl: 'https://safe-transaction-mainnet.safe.global', +}) +``` + +## Signing and executing transactions using the SafeAuthPack and Protocol Kit + +The `SafeAuthPack` can be used with the [Protocol Kit](../protocol-kit/README.md) to establish a connection to a Safe. This connection is made using the `provider` and `signer` associated with the authenticated account. + +After connecting, you can use any of the methods provided in the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit#sdk-api). + +```typescript +import { ethers } from 'ethers' +import { EthersAdapter } from '@safe-global/protocol-kit' + +// Wrap EIP-1193 provider with ethers +const provider = new ethers.providers.Web3Provider(safeAuthPack.getProvider()) +const signer = provider.getSigner() + +// Create the Safe EthersAdapter +const ethAdapter = new EthersAdapter({ + ethers, + signerOrProvider: signer || provider, +}) + +// Instantiate the protocolKit +const protocolKit = await Safe.create({ + ethAdapter, + safeAddress, +}) + +// Create a Safe transaction with the provided parameters +const safeTransactionData: MetaTransactionData = { + to: `${ethAddress}`, + data: '0x', + value: ethers.utils.parseUnits('0.0001', 'ether').toString(), +} + +const safeTransaction = await protocolKit.createTransaction({ + safeTransactionData, +}) + +// Sign the transaction if the Safe have several owners +// safeTransaction = await protocolKit1.signTransaction(safeTransaction) +// safeTransaction = await protocolKit2.signTransaction(safeTransaction) + +// Execute the transaction +await protocolKit.executeTransaction(safeTransaction) +``` + +## Sign messages using the `SafeAuthPack` + +You can also sign any arbitrary message or transaction as a regular Signing Account with your favorite web3 library: + +```typescript +// Using web3 +const web3 = new Web3(safeAuthPack.getProvider()) + +await web3.eth.sendTransaction(tx) +await web3.eth.signTransaction(tx) +const message = 'hello world' +const address = '0x...' +await web3.eth.personal.sign(message, address) + +// Using ethers +const provider = new ethers.providers.Web3Provider(safeAuthPack.getProvider()) +const signer = provider.getSigner() + +await signer.sendTransaction(tx) +await signer.signTransaction(tx) +await signer.signMessage(message) +``` + +## Examples + +- [React](https://github.com/safe-global/safe-core-sdk/blob/main/packages/auth-kit/example/src/App.tsx) +- [Vanilla Typescript](https://github.com/5afe/safe-auth) diff --git a/safe-core-sdk/auth-kit/guides/web3auth.md b/safe-core-sdk/auth-kit/guides/web3auth.md deleted file mode 100644 index 118cd810..00000000 --- a/safe-core-sdk/auth-kit/guides/web3auth.md +++ /dev/null @@ -1,196 +0,0 @@ -# Integration with Web3Auth - -This guide demonstrate how to create an externally-owned account using your email or social media account. Once authenticated, you can sign transactions and interact with any Safe Smart Accounts you own. - -## Prerequisites - -- [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) -- [Create a Web3Auth account](https://dashboard.web3auth.io) - -### Install dependencies - -```bash -npm i @safe-global/auth-kit @web3auth/base@4.6.0 @web3auth/modal@4.6.2 @web3auth/openlogin-adapter@4.6.0 -``` - -## Create a Web3AuthModalPack instance - -We are going to use the provided `Web3AuthModalPack` exported in the `@safe-global/auth-kit` package. - -Create an instance of the [Web3AuthModalPack](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit/src/packs/web3auth/Web3AuthModalPack.ts) using the required `Web3AuthConfig` configuration object. - -```typescript -import { Web3AuthModalPack, Web3AuthConfig } from '@safe-global/auth-kit' -import { Web3AuthOptions } from '@web3auth/modal' -import { OpenloginAdapter } from '@web3auth/openlogin-adapter' - - -// https://web3auth.io/docs/sdk/pnp/web/modal/initialize#arguments -const options: Web3AuthOptions = { - clientId: 'YOUR_WEB3_AUTH_CLIENT_ID', // https://dashboard.web3auth.io/ - web3AuthNetwork: 'testnet', - chainConfig: { - chainNamespace: CHAIN_NAMESPACES.EIP155, - chainId: '0x5', - // https://chainlist.org/ - rpcTarget: 'https://rpc.ankr.com/eth_goerli' - }, - uiConfig: { - theme: 'dark', - loginMethodsOrder: ['google', 'facebook'] - } -} - -// https://web3auth.io/docs/sdk/pnp/web/modal/initialize#configuring-adapters -const modalConfig = { - [WALLET_ADAPTERS.TORUS_EVM]: { - label: 'torus', - showOnModal: false - }, - [WALLET_ADAPTERS.METAMASK]: { - label: 'metamask', - showOnDesktop: true, - showOnMobile: false - } -} - -// https://web3auth.io/docs/sdk/pnp/web/modal/whitelabel#whitelabeling-while-modal-initialization -const openloginAdapter = new OpenloginAdapter({ - loginSettings: { - mfaLevel: 'mandatory' - }, - adapterSettings: { - uxMode: 'popup', - whiteLabel: { - name: 'Safe' - } - } -}) - -const web3AuthConfig: Web3AuthConfig = { - txServiceUrl: 'https://safe-transaction-goerli.safe.global' -} - -// Instantiate and initialize the pack -const web3AuthModalPack = new Web3AuthModalPack(web3AuthConfig) -await web3AuthModalPack.init({ options, adapters: [openloginAdapter], modalConfig }) -``` - -## Sign in to an Ethereum account - -Once your `Web3AuthModalPack` instance is created, use the `signIn()` method to start the authentication process. Usually, you call this method when the user clicks on a "Sign In" button added to your page. - -Important considerations about Web3Auth are: - -1) When you sign in with the same social account, the same Ethereum address will be returned for the same Web3Auth client ID. Web3Auth [scopes the creation of the wallet](https://web3auth.io/docs/troubleshooting/different-wallet-address-issue) (address) to the DApp, so when interacting with other DApps using Web3Auth, a different Ethereum address will be returned. This is by design and to enhanced security. - -2) If you sign in with an email and then with a social account using the same email (e.g. "Sign in with Google"), a different Ethereum address might be returned even the same email address is used. - -```typescript -// The signIn() method will return the user's Ethereum address -// The await will last until the user is authenticated, so while the UI modal is showed -const authKitSignData = await web3AuthModalPack.signIn() -``` - -The returned `authKitSignData` data contains the following props: - -```typescript -AuthKitSignInData { - eoa: string // The safe signer - safes?: string[] // The list of associated Safe addresses -} -``` - -The `signOut()` method removes the current session. - -```typescript -await web3AuthModalPack.signOut() -``` - -Call `getProvider()` to get the Ethereum provider instance. - -```typescript -web3AuthModalPack.getProvider() -``` - -We expose two methods for listening to events, `subscribe()` and `unsubscribe()`. In the `Web3AuthModalPack` case, we can listen to all the events listed [here](https://web3auth.io/docs/sdk/pnp/web/modal/initialize#subscribing-the-lifecycle-events). - -```typescript -import { ADAPTER_EVENTS } from '@web3auth/base' - -web3AuthModalPack.subscribe(ADAPTER_EVENTS.CONNECTED, () => { - console.log('User is authenticated') -}) - -web3AuthModalPack.subscribe(ADAPTER_EVENTS.DISCONNECTED, () => { - console.log('User is not authenticated') -}) -``` - -When `txServiceUrl` is provided in the `Web3AuthModalPack` instantiation, the list of associated Safe addresses will be returned as part of the `signIn()` method response. - -```typescript -const web3AuthModalPack = new Web3AuthModalPack({ - txServiceUrl: 'https://safe-transaction-goerli.safe.global' -}) -``` - -## Signing transactions using the Web3AuthModalPack and Protocol Kit - -The `Web3AuthModalPack` can be combined with the [Protocol Kit](../../protocol-kit/README.md) to connect to a Safe using the `provider` and `signer` of the currently authenticated account. - -Once connected, you can use any of the methods available in the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit#sdk-api). - -```typescript -import { ethers } from 'ethers' -import { EthersAdapter } from '@safe-global/protocol-kit' - -provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) -signer = provider.getSigner() - -const ethAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer || provider -}) - -const safeSDK = await Safe.create({ - ethAdapter, - safeAddress -}) - -// Create a Safe transaction with the provided parameters -const safeTransactionData: MetaTransactionData = { - to: '0x', - data: '0x', - value: ethers.parseUnits('0.0001', 'ether').toString() -} - -const safeTransaction = await safeSDK.createTransaction({ transactions: [safeTransactionData] }) -``` - -## Sign messages using the `Web3AuthModalPack` - -You can also sign any arbitrary message or transaction as a regular Signing Account with your favorite web3 library: - -```typescript -// Using web3 -const web3 = new Web3(web3AuthModalPack.getProvider()) - -await web3.eth.sendTransaction(tx) -await web3.eth.signTransaction(tx) -const message = 'hello world' -const address = '0x...' -await web3.eth.personal.sign(message, address) - -// Using ethers -const provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) -const signer = provider.getSigner() - -await signer.sendTransaction(tx) -await signer.signTransaction(tx) -await signer.signMessage(message) -``` - -## Alternative example in `@safe-global/safe-core-sdk` - -See an [example](https://github.com/safe-global/safe-core-sdk/blob/main/packages/auth-kit/example/src/App.tsx) on how to initialize and use the Auth Kit. diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index 4c3a50e1..2896d677 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -20,9 +20,13 @@ class MyPack extends AuthKitBasePack { } ``` -## Abstract methods that Auth packs have to implement +## Abstract methods and properties that any pack must implement -These methods are the common interface for all the Auth packs. Check each pack's documentation to get more details. +These methods and properties are the common interface for all the Auth packs. Check each pack's documentation to get more details. + +### `isAuthenticated(): boolean` + +Any pack extending the `AuthKitBasePack` class must implement the `isAuthenticated()` getter. This method returns a boolean indicating if the user is authenticated or not. ### `init(options?): Promise` @@ -61,14 +65,17 @@ These methods provide the functionality associated with Safe so they can be used Returns the Ethereum address extracted from the provider retrieved by `getProvider()`. This returns a Safe owner (signer). **Returns** + - `address`: The Ethereum address extracted from the provider. ### `getSafes(txServiceUrl?): safes[]` -Returns the list of Safes associated with the signer address by calling the `getAddress()` method internally. +Returns the list of Safes associated with the signer address by internally calling the `getAddress()` method. **Params** + - `txServiceUrl`(optional): The Safe Transaction Service URL to retrieve the Safes associated with the owner (signer). **Returns** + - `safes[]`: The list of Safes associated with the owner (signer). diff --git a/safe-core-sdk/auth-kit/reference/README.md b/safe-core-sdk/auth-kit/reference/README.md index 2e891b0f..c5ae6729 100644 --- a/safe-core-sdk/auth-kit/reference/README.md +++ b/safe-core-sdk/auth-kit/reference/README.md @@ -7,21 +7,21 @@ The [Auth Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/a To add the Auth Kit to your project, run: ```bash -yarn add @safe-global/auth-kit +yarn add @safe-global/auth-kit @web3auth/safeauth-embed ``` The Auth Kit can integrate several providers in the form of **"packs"**. A pack is a piece of code that works with the chosen provider to give Safe users access to new services. -To use each pack, the right package needs to be installed: +To use each pack, you must ensure the appropriate packages are installed. -- [Web3Auth](./Web3AuthModalPack.md#install) +- [SafeAuth](./SafeAuthPack.md#install) ## How to use a pack To start working with the packs, instantiate the main class and call the `init()` method afterwards. ```typescript -const pack = new Web3AuthModalPack(packConfig) +const pack = new SafeAuthPack(packConfig) await pack.init(packInitOptions) ``` diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md new file mode 100644 index 00000000..ce0c2250 --- /dev/null +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -0,0 +1,220 @@ +# SafeAuthPack + +SafeAuth is a pluggable authentication infrastructure for Web3 wallets and applications. It simplifies onboarding for mainstream and crypto native users, offering experiences tailored to their preferences. It supports all social logins, web and mobile native platforms, wallets, and other key management methods, creating a cryptographic key provider specific to the user and application. + +The `SafeAuthPack` enables using the [Web3Auth infrastructure](https://web3auth.io) with added Safe capabilities, such as retrieving the related Safe addresses for a given externally-owned account created using SafeAuth services. + +The pack helps onboard web2 users and provides an Ethereum signer address that can be used across any dApp using the different Ethereum chains. + +## Install dependencies + +To use the `SafeAuthPack`, you must install the `@safe-global/auth-kit` package and the corresponding Web3Auth one. + +```bash +yarn add @safe-global/auth-kit @web3auth/safeauth-embed +``` + +## Reference + +The `SafeAuthPack` class makes SafeAuth modal and Safe accounts work together. Create an instance of the pack and initialize it to start the interaction. + +```typescript +const safeAuthPack = new SafeAuthPack({ + txServiceUrl: 'https://safe-transaction-mainnet.safe.global', +}); +await safeAuthPack.init(safeAuthInitOptions); +``` + +### `new SafeAuthPack(safeAuthConfig)` + +**Params** + +- `safeAuthConfig` - The `SafeAuthPack` class instantiation accepts the following options in its configuration: + +```typescript +SafeAuthConfig { + txServiceUrl: string +} +``` + +- `txServiceUrl` - The URL of the Safe Transaction Service. It retrieves the Safe addresses for an externally owned account created using SafeAuth services. It is required to use the `SafeAuthPack` with Safe. + +**Caveats** +You should always call the `init()` method afterward before interacting with the pack. + +### `init(safeAuthInitOptions)` + +The init method initializes the provided Web3Auth SDK and Safe services. It creates an embedded browser wallet within an iframe, establishing communication through the internally generated EIP-1193 provider. + +**Params** + +- `safeAuthInitOptions` - The options to initialize the SDK instance. + +```typescript +safeAuthInitOptions { + enableLogging?: boolean + showWidgetButton?: boolean + buttonPosition?: "bottom-left" | "top-left" | "bottom-right" | "top-right" + buildEnv?: "production" | "development" | "testing" + chainConfig?: { + blockExplorerUrl: string + logo: string + tickerName: string + ticker: string + rpcTarget: string + wcTarget?: string + chainId: string + displayName: string + isTestnet?: boolean + isErc20?: boolean + tokenAddress?: string + } +} +``` + +- `enableLogging` - Enable logging for the SDK. Defaults to `false`. +- `buildEnv` - The build environment. 'production' and 'testing' uses "https://safe.web3auth.com". 'development' uses "http://localhost:4050". Defaults to `production`. +- `showWidgetButton` - Show the widget button. Defaults to `true`. +- `buttonPosition` - If `showWidgetButton` is true then this prop represent the position of the widget button. Defaults to `bottom-left`. +- `chainConfig` - The chain configuration. Defaults to `ethereum` if no configuration is provided. + - `blockExplorerUrl` - Block explorer URL for the chain (e.g https://etherscan.io). + - `logo` - Logo URL for the base token of the chain (e.g https://eth.svg). + - `tickerName` - Name for ticker (e.g Ethereum). + - `ticker` - Symbol for ticker (e.g ETH). + - `rpcTarget` - The RPC URL to be used. + - `wcTarget?` - The websocket URL to be used. Use this or `rpcTarget`. + - `chainId` - The chain ID to be used. Should be an hex with 0x prefix (e.g 0x1 for mainnet). + - `displayName` - The display name for the network. + - `isTestnet?` - Whether the network is testnet or not. + - `isErc20?`- Whether the token is an ERC20 token or not. + - `tokenAddress?` - The token address for the chain. Should be an hex with 0x prefix (e.g 0x6b175474e89094c44da98b954eedeac495271d0f for DAI). + +**Caveats** + +- The list of supported chains is: + - Production: Ethereum, Polygon, BSC, Avalanche, Optimism, Celo, Arbitrum, Gnosis chain. + - Test: Goerli, Sepolia, Polygon Mumbai, BSC testnet, Avalanche testnet, Arbitrum testnet, Optimism testnet. +- Call always the `init()` method before interacting with the other methods in the pack. +- The `init()` method creates an iframe and establishes a connection with the embedded wallet domain. To remove the iframe and disconnect the connection, use the `signOut()` method. If you want to sign out and sign in again in a single-page application (SPA) fashion, avoid using `signOut({ reset: true })` as it will clean up the session, iframe, and connection. Instead, you will need to re-instantiate the pack. + +### `signIn(safeAuthSignInOptions)` + +`signIn(safeAuthSignInOptions)` starts the authentication flow. It displays a popup that enables users to select a social authentication method (OAuth) or an email to generate the web3 wallet address. It returns the EOA and the associated Safe addresses. + +**Params** + +```typescript +SafeAuthSignInOptions = { + loginProvider?: "google" | "facebook" | "reddit" | "discord" | "twitch" | "apple" | "line" | "github" | "kakao" | "linkedin" | "twitter" | "weibo" | "wechat" | "email_passwordless" + login_hint?: string +} +``` + +- `loginProvider` - If specified, instead of showing the popup to choose the OAuth or email, a direct attempt to login with the specified provider will be made. + +- `login_hint` - Used to provide default mail given a `loginProvider`: + +```typescript +safeAuthPack.signIn({ + loginProvider: 'google', + login_hint: 'my-mail@safe.global', +}); +``` + +**Returns** + +An object with the derived externally-owned account address and the associated Safe addresses. + +```typescript +AuthKitSignInData { + eoa: string + safes?: string[] +} +``` + +**Caveats** + +- To get the Safe addresses, instantiate the `authKit` with the `txServiceUrl` property in the config object. Otherwise, only the eoa will be returned. +- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It does not create a Safe. We are investigating ways to enhance the Auth Kit and the associated flows. ⚠️ + +### `signOut(safeAuthSignOutOptions?)` + +Call this method to sign out the user and clean the session. + +```typescript +SafeAuthSignOutOptions { + reset: boolean; +} +``` + +**Params** + +- `reset` - If true, the user will be logged out from the provider, and the widget will be destroyed. Don't use this parameter if you want to log out and log in again without refreshing the browser or re-initializing the `SafeAuthPack` instance. + +### `getUserInfo()` + +Using `getUserInfo()`, you will receive the user information derived from the pack you are using. It varies depending on the provider. + +**Returns** + +The `UserInfo` object's properties vary depending on the provider. + +### `getProvider()` + +By using `getProvider()`, you will receive a standard web3 provider compatible with the EIP-1193 standard. + +**Returns** + +A EIP-1193 compatible provider. + +**Caveats** + +- You can wrap the provider using your favorite library (ethers, web3, etc.). + +### `destroy()` + +This method removes the iframe. It is useful when you need to re-instantiate the pack, for example, when changing the connected chain. + +### `subscribe(event, handler)` + +Allow to subscribe to authentication state changes. + +**Params** + +- `event` - The event you want to subscribe to. Currently, you can subscribe to `accountsChanged` or `chainChanged`. +- `handler` - When the event is triggered, the function will be called. + +### `unsubscribe(event, handler)` + +Allow to unsubscribe to authentication state changes. + +**Caveats** + +The `accountsChanged` event helps detect whether the user has previously signed in. This allows you to reauthenticate when the browser is refreshed by calling the `signIn` method, preventing the user from clicking the sign-in button again. + +**Params** + +- `event` - The event you want to unsubscribe to. +- `handler` - When the event is triggered, the function will be called. + +## Usage + +Calling `init()` when your page loads or component renders is all it takes to use the Auth Kit with the `SafeAuthPack`. To start the authentication process, call `signIn()` afterward. This method returns the EOA and associated Safe addresses. + +```typescript +// Instantiate and initialize the pack +const safeAuthPack = new SafeAuthPack(safeAuthConfig); +await safeAuthPack.init(safeAuthInitOptions); + +const { eoa, safes } = await safeAuthPack.signIn(); +const userInfo = await safeAuthPack.getUserInfo(); +const web3Provider = safeAuthPack.getProvider(); + +// Subscribe to events +const handler = (event) => {}; +safeAuthPack.subscribe(packEvent, handler); +safeAuthPack.unsubscribe(packEvent, handler); + +// Sign out +await safeAuthPack.signOut(); +``` diff --git a/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md b/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md deleted file mode 100644 index 469c5c64..00000000 --- a/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md +++ /dev/null @@ -1,152 +0,0 @@ -# Web3AuthModalPack - -Web3Auth is a pluggable authentication infrastructure for Web3 wallets and applications. It simplifies onboarding for both mainstream and crypto native users, offering experiences tailored to their preferences. It supports all social logins, web and mobile native platforms, wallets, and other key management methods, creating a cryptographic key provider specific to the user and application. - -The `Web3AuthModalPack` enables the use of [Web3Auth modal SDK](https://web3auth.io/docs/sdk/pnp/web/modal) with added Safe capabilities, such as retrieving the related Safe addresses for a given externally-owned account created using Web3Auth services. - -## Install dependencies - -To use the `Web3AuthModalPack`, you need to install some extra dependencies in addition to the `@safe-global/auth-kit` package. - -```bash -yarn add @safe-global/auth-kit @web3auth/base@4.6.0 @web3auth/modal@4.6.2 -``` - -Choose the adapters to use with Web3Auth, and add them. For example, to use the [OpenLogin](https://web3auth.io/docs/sdk/pnp/web/adapters/openlogin) adapter, you must install the following dependency: - -```bash -yarn add @web3auth/openlogin-adapter@4.6.0 -``` - -Refer to the [supported adapters](https://web3auth.io/docs/sdk/pnp/web/adapters/#currently-available-wallet-adapters) in the official documentation. - -## Reference - -The `Web3AuthModalPack` class is what makes Web3Auth modal and Safe work together. Create an instance of the pack and initialize it to start the interaction. - -```typescript -const web3AuthModalPack = new Web3AuthModalPack({ - txServiceUrl: 'https://safe-transaction-mainnet.safe.global' -}) -await web3AuthModalPack.init(web3AuthModalOptions, [adapters], modalConfig) -``` - - -### new Web3AuthModalPack(web3AuthConfig) - -**Params** - -- `web3AuthConfig` - The configuration used in the instantiation of the `Web3AuthModalPack` class accepts the following options: - -```typescript -Web3AuthConfig { - txServiceUrl: string -} -``` -- `txServiceUrl` - The URL of the Safe transaction service. It is used to retrieve the Safe addresses for an externally-owned account created using Web3Auth services. It is required to use the `Web3AuthModalPack` with Safe. - -**Caveats** -You should always call the `init()` method afterwards before interacting with the pack. - -### init(web3AuthModalOptions, adapters[]?, modalConfig?) - -The init method initialize the required Web3Auth modal SDK and Safe services. It [instantiates the `Web3Auth`](https://web3auth.io/docs/quick-start?product=Plug+and+Play&sdk=Plug+and+Play+Web+Modal+SDK&platform=React#3-initialize-web3auth-for-your-preferred-blockchain) class and [configure the adapters](https://web3auth.io/docs/sdk/pnp/web/no-modal/initialize#configureadapteradapter). It calls the [`initModal`](https://web3auth.io/docs/sdk/pnp/web/modal/whitelabel#initmodal) method internally. - -It initializes as well the web3 provider we can retrieve afterwards using the `getProvider()` method. - -**Params** - -- `web3AuthModalOptions` - The options to create the `Web3Auth` [instance](https://web3auth.io/docs/sdk/pnp/web/modal/initialize#instantiating-web3auth). You can send a configuration object matching the [official one](https://web3auth.io/docs/sdk/pnp/web/modal/initialize#web3authoptions) as we passthrough the options to the `Web3Auth` instance when we instantiate it inside the pack. -- `adapters` - The adapters for the Web3Auth modal sdk. You can use any of the [supported adapters](https://web3auth.io/docs/sdk/pnp/web/adapters/). This prop accepts an array of adapters and the `Web3AuthModalPack` will call the [`configureAdapter`](https://web3auth.io/docs/sdk/pnp/web/no-modal/initialize#configureadapteradapter) method for each one of them internally. - -⚠️ Remember to add the corresponding package for each adapter (e.g `@web3auth/openlogin-adapter` for OpenLogin). - -- `modalConfig` - The configuration for the Web3Auth modal sdk. You can explore the options [here](https://web3auth.io/docs/sdk/pnp/web/modal/whitelabel#initmodal). This options are used with the `initModal` method internally. - -**Caveats** -Call always the `init()` method before interacting with the other methods in the pack. - -### signIn() - -`signIn()` calls internally the [`connect()`](https://web3auth.io/docs/sdk/pnp/web/modal/usage#connect) method from Web3Auth. It obtains a web3 provider and store it internally in the instance. Finally, retrieves the associated Safe addresses for the externally-owned account created using Web3Auth services. - -**Returns** -An object with the derived externally-owned account address and the associated safe addresses. - -```typescript -AuthKitSignInData { - eoa: string - safes?: string[] -} -``` - -**Caveats** - -- To get the Safe addresses, instantiate the authKit with the `txServiceUrl` property in the config object. Otherwise, only the eoa will be returned. -- ⚠️ This method currently returns the Safe addresses which the EOA is the owner of. It does not create a Safe. We are investigating ways to enhance the Auth Kit and the associated flows. ⚠️ - -### signOut() - -Call this method to sign out the user and clean the session. - -Internally it calls the [`logout()`](https://web3auth.io/docs/sdk/pnp/web/modal/usage#web3authlogout) method from Web3Auth and clears the web3 provider stored in the instance. - -### getUserInfo() - -Using `getUserInfo()` you will receive the user information derived from the pack you are using. It varies depending on the provider. - -Internally it calls the [`getUserInfo()`](https://web3auth.io/docs/sdk/pnp/web/modal/usage#getuserinfo) method from Web3Auth. - -**Returns** -The `UserInfo` object has properties that depend on the adapter and authentication platform and method used. - -### getProvider() - -Using `getProvider()` you will receive a regular web3 provider derived from the pack you are using. - -**Returns** -A web3 provider. - -**Caveats** -⚠️ Web3Auth with Social Logins returns a provider that allows you to sign transactions without any UI confirmations, unlike regular wallets such as Metamask ⚠️ - -### subscribe(event, handler) - -Allow to subscribe to authentication state changes. The event depends on the pack you are using so read the chosen pack documentation. - -**Params** - -- `event` - The event you want to subscribe to. The events are defined [in the documentation](https://web3auth.io/docs/sdk/pnp/web/no-modal/initialize#subscribing-the-lifecycle-events). -- `handler` - The handler function that will be called when the event is triggered. - -### unsubscribe(event, handler) - -Allow to unsubscribe to authentication state changes - -**Params** - -- `event` - The event you want to unsubscribe to. -- `handler` - The handler function that will be called when the event is triggered. - -## Usage - -Calling `init()` when your page loads or component renders is all it takes to use the Auth Kit with the `Web3AuthModalPack`. To start the authentication process, simply call `signIn()` afterwards. This method returns the EOA and associated Safe addresses. - -```typescript -// Instantiate and initialize the pack -const web3AuthModalPack = new Web3AuthModalPack(web3AuthConfig) -await web3AuthModalPack.init(web3AuthModalOptions, adapters, modalConfig) - -// Sign in -const { eoa, safes } = await web3AuthModalPack.signIn() -const userInfo = await web3AuthModalPack.getUserInfo() -const web3Provider = web3AuthModalPack.getProvider() - -// Subscribe to events -const handler = (event) => {} -web3AuthModalPack.subscribe(packEvent, handler) -web3AuthModalPack.unsubscribe(packEvent, handler) - -// Sign out -await web3AuthModalPack.signOut() -``` \ No newline at end of file From 7ed676122fccdbd7c9144913e174b97cb1682093 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:27:54 +0100 Subject: [PATCH 03/25] Fix links --- SUMMARY.md | 4 ++-- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 36a13b87..b12ecb69 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -27,10 +27,10 @@ * [Auth Kit](safe-core-sdk/auth-kit/README.md) * [Guides](safe-core-sdk/auth-kit/guides/README.md) - * [Web3Auth](safe-core-sdk/auth-kit/guides/web3auth.md) + * [SafeAuth](safe-core-sdk/auth-kit/guides/safe-auth.md) * [Reference](safe-core-sdk/auth-kit/reference/README.md) * [AuthKitBasePack](safe-core-sdk/auth-kit/reference/AuthKitBasePack.md) - * [Web3AuthModalPack](safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md) + * [SafeAuthPack](safe-core-sdk/auth-kit/reference/SafeAuthPack.md) * [Protocol Kit](safe-core-sdk/protocol-kit/README.md) * [Reference](safe-core-sdk/protocol-kit/reference/README.md) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index 9d01a895..414d25c4 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -107,7 +107,7 @@ const safeAuthPack = new SafeAuthPack({ ## Signing and executing transactions using the SafeAuthPack and Protocol Kit -The `SafeAuthPack` can be used with the [Protocol Kit](../protocol-kit/README.md) to establish a connection to a Safe. This connection is made using the `provider` and `signer` associated with the authenticated account. +The `SafeAuthPack` can be used with the [Protocol Kit](../../protocol-kit/README.md) to establish a connection to a Safe. This connection is made using the `provider` and `signer` associated with the authenticated account. After connecting, you can use any of the methods provided in the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit#sdk-api). From f1fe0a9f55c2a19f943eed87fdc7397cf33d0f2a Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:33:31 +0100 Subject: [PATCH 04/25] fix lint suggestions --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- safe-core-sdk/auth-kit/reference/AuthKitBasePack.md | 2 +- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index 414d25c4..1585ca9c 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -23,7 +23,7 @@ Create an instance of the [SafeAuthPack](https://github.com/safe-global/safe-cor > The list of supported chains is: > > - Production: Ethereum, Polygon, BSC, Avalanche, Optimism, Celo, Arbitrum, Gnosis chain -> - Test: Goerli, Sepolia, Polygon Mumbai, BSC testnet, Avalanche testnet, Arbitrum testnet, Optimism testnet +> - Test: Goerli, Sepolia, Polygon Mumbai, BSC Testnet, Avalanche Testnet, Arbitrum Testnet, Optimism Testnet ```typescript import { diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index 2896d677..72633456 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -26,7 +26,7 @@ These methods and properties are the common interface for all the Auth packs. Ch ### `isAuthenticated(): boolean` -Any pack extending the `AuthKitBasePack` class must implement the `isAuthenticated()` getter. This method returns a boolean indicating if the user is authenticated or not. +Any pack extending the `AuthKitBasePack` class must implement the `isAuthenticated()` getter. This method returns a `boolean` indicating if the user is authenticated or not. ### `init(options?): Promise` diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index ce0c2250..4ea21a54 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -77,15 +77,15 @@ safeAuthInitOptions { - `showWidgetButton` - Show the widget button. Defaults to `true`. - `buttonPosition` - If `showWidgetButton` is true then this prop represent the position of the widget button. Defaults to `bottom-left`. - `chainConfig` - The chain configuration. Defaults to `ethereum` if no configuration is provided. - - `blockExplorerUrl` - Block explorer URL for the chain (e.g https://etherscan.io). - - `logo` - Logo URL for the base token of the chain (e.g https://eth.svg). + - `blockExplorerUrl` - Block explorer URL of the chain (e.g `https://etherscan.io`). + - `logo` - Logo URL of the base token of the chain (e.g `https://eth.svg`). - `tickerName` - Name for ticker (e.g Ethereum). - `ticker` - Symbol for ticker (e.g ETH). - `rpcTarget` - The RPC URL to be used. - `wcTarget?` - The websocket URL to be used. Use this or `rpcTarget`. - `chainId` - The chain ID to be used. Should be an hex with 0x prefix (e.g 0x1 for mainnet). - `displayName` - The display name for the network. - - `isTestnet?` - Whether the network is testnet or not. + - `isTestnet?` - Whether the network is Testnet or not. - `isErc20?`- Whether the token is an ERC20 token or not. - `tokenAddress?` - The token address for the chain. Should be an hex with 0x prefix (e.g 0x6b175474e89094c44da98b954eedeac495271d0f for DAI). @@ -93,7 +93,7 @@ safeAuthInitOptions { - The list of supported chains is: - Production: Ethereum, Polygon, BSC, Avalanche, Optimism, Celo, Arbitrum, Gnosis chain. - - Test: Goerli, Sepolia, Polygon Mumbai, BSC testnet, Avalanche testnet, Arbitrum testnet, Optimism testnet. + - Test: Goerli, Sepolia, Polygon Mumbai, BSC Testnet, Avalanche Testnet, Arbitrum Testnet, Optimism Testnet. - Call always the `init()` method before interacting with the other methods in the pack. - The `init()` method creates an iframe and establishes a connection with the embedded wallet domain. To remove the iframe and disconnect the connection, use the `signOut()` method. If you want to sign out and sign in again in a single-page application (SPA) fashion, avoid using `signOut({ reset: true })` as it will clean up the session, iframe, and connection. Instead, you will need to re-instantiate the pack. @@ -134,8 +134,8 @@ AuthKitSignInData { **Caveats** -- To get the Safe addresses, instantiate the `authKit` with the `txServiceUrl` property in the config object. Otherwise, only the eoa will be returned. -- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It does not create a Safe. We are investigating ways to enhance the Auth Kit and the associated flows. ⚠️ +- To get the Safe addresses, instantiate the `authKit` with the `txServiceUrl` property in the config object. Otherwise, only the EOA will be returned. +- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It doesn't create a Safe. We are investigating ways to enhance the Auth Kit and the associated flows. ⚠️ ### `signOut(safeAuthSignOutOptions?)` From efd4e47c57316cdea5443b11f3e94770356bf5c8 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:38:00 +0100 Subject: [PATCH 05/25] Fix typo --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 4ea21a54..0ad50bee 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -83,7 +83,7 @@ safeAuthInitOptions { - `ticker` - Symbol for ticker (e.g ETH). - `rpcTarget` - The RPC URL to be used. - `wcTarget?` - The websocket URL to be used. Use this or `rpcTarget`. - - `chainId` - The chain ID to be used. Should be an hex with 0x prefix (e.g 0x1 for mainnet). + - `chainId` - The chain ID to be used. Should be an hex with 0x prefix (e.g 0x1 for Mainnet). - `displayName` - The display name for the network. - `isTestnet?` - Whether the network is Testnet or not. - `isErc20?`- Whether the token is an ERC20 token or not. From 9215618ffcce8921caeea6a6efe9bac62668ff16 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:16:24 +0100 Subject: [PATCH 06/25] Update ethersv6 changes --- safe-core-sdk/auth-kit/guides/safe-auth.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index 1585ca9c..0807e81e 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -116,7 +116,7 @@ import { ethers } from 'ethers' import { EthersAdapter } from '@safe-global/protocol-kit' // Wrap EIP-1193 provider with ethers -const provider = new ethers.providers.Web3Provider(safeAuthPack.getProvider()) +const provider = new ethers.BrowserProvider(safeAuthPack.getProvider()) const signer = provider.getSigner() // Create the Safe EthersAdapter @@ -135,11 +135,11 @@ const protocolKit = await Safe.create({ const safeTransactionData: MetaTransactionData = { to: `${ethAddress}`, data: '0x', - value: ethers.utils.parseUnits('0.0001', 'ether').toString(), + value: ethers.parseUnits('0.0001', 'ether').toString(), } const safeTransaction = await protocolKit.createTransaction({ - safeTransactionData, + transactions: [safeTransactionData], }) // Sign the transaction if the Safe have several owners @@ -165,7 +165,7 @@ const address = '0x...' await web3.eth.personal.sign(message, address) // Using ethers -const provider = new ethers.providers.Web3Provider(safeAuthPack.getProvider()) +const provider = new ethers.BrowserProvider(safeAuthPack.getProvider()) const signer = provider.getSigner() await signer.sendTransaction(tx) From 024793960796ede1c45801823197889d07097258 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:43:57 +0100 Subject: [PATCH 07/25] change optional type comment --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 0ad50bee..0ad53334 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -29,11 +29,11 @@ await safeAuthPack.init(safeAuthInitOptions); **Params** -- `safeAuthConfig` - The `SafeAuthPack` class instantiation accepts the following options in its configuration: +- `safeAuthConfig?` - The `SafeAuthPack` class instantiation accepts the following options in its configuration: ```typescript SafeAuthConfig { - txServiceUrl: string + txServiceUrl?: string } ``` From 36170c1e11ca806300373a3ac5480cce2cc4e146 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:50:16 +0100 Subject: [PATCH 08/25] add optional parameter flag --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 0ad53334..7896f04f 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -37,7 +37,7 @@ SafeAuthConfig { } ``` -- `txServiceUrl` - The URL of the Safe Transaction Service. It retrieves the Safe addresses for an externally owned account created using SafeAuth services. It is required to use the `SafeAuthPack` with Safe. +- `txServiceUrl?` - The URL of the Safe Transaction Service. It's mandatory in chains where Safe doesn't provide a Transaction Service. It's used to retrieve the Safe addresses for an EOA created using SafeAuth services. **Caveats** You should always call the `init()` method afterward before interacting with the pack. From 2381af976e8af0fe2a8680128c3d8d0c3d58496b Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:48:48 +0100 Subject: [PATCH 09/25] Change npm i to yarn add to align docs --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index 0807e81e..12205796 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -11,7 +11,7 @@ The `SafeAuthPack` is an authentication system that utilizes the [Web3Auth](http ### Install dependencies ```bash -npm i @safe-global/auth-kit @web3auth/safeauth-embed +yarn add @safe-global/auth-kit @web3auth/safeauth-embed ``` ## Create a SafeAuthPack instance From a06acbb9f7abd58c0e3b4981b80c1136bb073810 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:19:30 +0100 Subject: [PATCH 10/25] Set alpha tag while unpublished --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 7896f04f..8723c4da 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -11,7 +11,7 @@ The pack helps onboard web2 users and provides an Ethereum signer address that c To use the `SafeAuthPack`, you must install the `@safe-global/auth-kit` package and the corresponding Web3Auth one. ```bash -yarn add @safe-global/auth-kit @web3auth/safeauth-embed +yarn add @safe-global/auth-kit@alpha @web3auth/safeauth-embed ``` ## Reference From f0d80214178361f0847dff37202cebf6525c01bc Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:20:57 +0100 Subject: [PATCH 11/25] Set alpha package in guide --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index 12205796..e8f70f59 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -11,7 +11,7 @@ The `SafeAuthPack` is an authentication system that utilizes the [Web3Auth](http ### Install dependencies ```bash -yarn add @safe-global/auth-kit @web3auth/safeauth-embed +yarn add @safe-global/auth-kit@alpha @web3auth/safeauth-embed ``` ## Create a SafeAuthPack instance From 22301c2f356c36694a1544287b5b4130aac3ae83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:34:12 +0100 Subject: [PATCH 12/25] Update safe-core-sdk/auth-kit/guides/safe-auth.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index e8f70f59..bb610a09 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -2,7 +2,7 @@ This guide demonstrates creating an externally-owned account using your email or social media account. Once authenticated, you can sign transactions and interact with your Safe accounts. -The `SafeAuthPack` is an authentication system that utilizes the [Web3Auth](https://web3auth.io) MPC technology. It was developed in collaboration with Web3Auth to create a smooth onboarding experience for web2 users across different dApps. +The `SafeAuthPack` is an authentication system that utilizes the [Web3Auth](https://web3auth.io) MPC technology. It was developed in collaboration with Web3Auth to create a smooth onboarding experience for web2 users across different dapps. ## Prerequisites From ddc744af24329ccc27dbd849aea805eee6510bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:34:42 +0100 Subject: [PATCH 13/25] Update safe-core-sdk/auth-kit/reference/SafeAuthPack.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 8723c4da..fa0def78 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -192,7 +192,7 @@ Allow to unsubscribe to authentication state changes. The `accountsChanged` event helps detect whether the user has previously signed in. This allows you to reauthenticate when the browser is refreshed by calling the `signIn` method, preventing the user from clicking the sign-in button again. -**Params** +**Parameters** - `event` - The event you want to unsubscribe to. - `handler` - When the event is triggered, the function will be called. From 668d86f7a87e12f8cf97325a5ce61bdb6e02500a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:34:52 +0100 Subject: [PATCH 14/25] Update safe-core-sdk/auth-kit/reference/SafeAuthPack.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index fa0def78..eef507c9 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -195,7 +195,7 @@ The `accountsChanged` event helps detect whether the user has previously signed **Parameters** - `event` - The event you want to unsubscribe to. -- `handler` - When the event is triggered, the function will be called. +- `handler` - The function will be called when the event is triggered. ## Usage From 166ac5e9e24a1db78c281d4367d2394fd9f30f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:39:43 +0100 Subject: [PATCH 15/25] Update safe-core-sdk/auth-kit/guides/safe-auth.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index bb610a09..2ffd8755 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -16,7 +16,7 @@ yarn add @safe-global/auth-kit@alpha @web3auth/safeauth-embed ## Create a SafeAuthPack instance -We will use the provided `SafeAuthPack` exported in the `@safe-global/auth-kit` package. +We will use the `SafeAuthPack` exported from the `@safe-global/auth-kit` package. Create an instance of the [SafeAuthPack](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit/src/packs/safe-auth/SafeAuthPack.ts) using the required `SafeAuthConfig` configuration object. From 005c4694eb9c300871c53997fd76b4412f9ada0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:39:55 +0100 Subject: [PATCH 16/25] Update safe-core-sdk/auth-kit/guides/safe-auth.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index 2ffd8755..97065df9 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -20,7 +20,7 @@ We will use the `SafeAuthPack` exported from the `@safe-global/auth-kit` package Create an instance of the [SafeAuthPack](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit/src/packs/safe-auth/SafeAuthPack.ts) using the required `SafeAuthConfig` configuration object. -> The list of supported chains is: +> Supported networks: > > - Production: Ethereum, Polygon, BSC, Avalanche, Optimism, Celo, Arbitrum, Gnosis chain > - Test: Goerli, Sepolia, Polygon Mumbai, BSC Testnet, Avalanche Testnet, Arbitrum Testnet, Optimism Testnet From 6f155ca0348640f6a4ad8bdbfe9243a99fdf0b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:40:29 +0100 Subject: [PATCH 17/25] Update safe-core-sdk/auth-kit/guides/safe-auth.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index 97065df9..f76f3909 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -86,7 +86,7 @@ After the user is authenticated, call `getProvider()` to get the Ethereum provid safeAuthPack.getProvider() ``` -We expose two methods for listening to events, `subscribe()` and `unsubscribe()`. +We offer two methods for listening to events, `subscribe()` and `unsubscribe()`. ```typescript const accountChangedHandler = (accounts: string[]) => { From e94088d637eee2bf9ba40e0a596173a3d501b020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:40:44 +0100 Subject: [PATCH 18/25] Update safe-core-sdk/auth-kit/reference/SafeAuthPack.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index eef507c9..3d5ac220 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -173,7 +173,7 @@ A EIP-1193 compatible provider. ### `destroy()` -This method removes the iframe. It is useful when you need to re-instantiate the pack, for example, when changing the connected chain. +This method removes the iframe. It's useful when you need to re-instantiate the pack, for example, when changing the connected chain. ### `subscribe(event, handler)` From 086aa10d71cc2d95f723e17b2c3b6164450aae13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:41:42 +0100 Subject: [PATCH 19/25] Update safe-core-sdk/auth-kit/reference/SafeAuthPack.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 3d5ac220..7e9ae06a 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -179,7 +179,7 @@ This method removes the iframe. It's useful when you need to re-instantiate the Allow to subscribe to authentication state changes. -**Params** +**Parameters** - `event` - The event you want to subscribe to. Currently, you can subscribe to `accountsChanged` or `chainChanged`. - `handler` - When the event is triggered, the function will be called. From a2299a70185751ba9214b4990bb3173bac083c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 11:43:53 +0100 Subject: [PATCH 20/25] Add words to allowlist --- .github/styles/Vocab/default/accept.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/styles/Vocab/default/accept.txt b/.github/styles/Vocab/default/accept.txt index 3074b0a2..7154a0f8 100644 --- a/.github/styles/Vocab/default/accept.txt +++ b/.github/styles/Vocab/default/accept.txt @@ -160,8 +160,10 @@ endembed endhint multisig npm +onboarding offchain onchain +reauthenticate sdk undefined v1 From 69fa286ffc3ca24ea224a218711c13cf6a486da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 12:00:29 +0100 Subject: [PATCH 21/25] Apply suggestions from code review Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- .../auth-kit/reference/AuthKitBasePack.md | 4 ++-- .../auth-kit/reference/SafeAuthPack.md | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index 72633456..b3ac7903 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -22,11 +22,11 @@ class MyPack extends AuthKitBasePack { ## Abstract methods and properties that any pack must implement -These methods and properties are the common interface for all the Auth packs. Check each pack's documentation to get more details. +These methods and properties are the common interface for all the Auth packs. Check each pack's documentation for more details. ### `isAuthenticated(): boolean` -Any pack extending the `AuthKitBasePack` class must implement the `isAuthenticated()` getter. This method returns a `boolean` indicating if the user is authenticated or not. +Any pack extending the `AuthKitBasePack` class must implement the `isAuthenticated()` getter. This method returns a `boolean` indicating whether the user is authenticated. ### `init(options?): Promise` diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 7e9ae06a..fa0c7a99 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -1,10 +1,10 @@ # SafeAuthPack -SafeAuth is a pluggable authentication infrastructure for Web3 wallets and applications. It simplifies onboarding for mainstream and crypto native users, offering experiences tailored to their preferences. It supports all social logins, web and mobile native platforms, wallets, and other key management methods, creating a cryptographic key provider specific to the user and application. +SafeAuth is a pluggable authentication infrastructure for web3 wallets and applications. It simplifies onboarding for mainstream and crypto native users, offering experiences tailored to their preferences. It supports all social logins, web and mobile native platforms, wallets, and other key management methods, creating a cryptographic key provider specific to the user and application. The `SafeAuthPack` enables using the [Web3Auth infrastructure](https://web3auth.io) with added Safe capabilities, such as retrieving the related Safe addresses for a given externally-owned account created using SafeAuth services. -The pack helps onboard web2 users and provides an Ethereum signer address that can be used across any dApp using the different Ethereum chains. +The pack helps onboard web2 users and provides an Ethereum signer address that can be used across any dapp using the different Ethereum chains. ## Install dependencies @@ -27,7 +27,7 @@ await safeAuthPack.init(safeAuthInitOptions); ### `new SafeAuthPack(safeAuthConfig)` -**Params** +**Parameters** - `safeAuthConfig?` - The `SafeAuthPack` class instantiation accepts the following options in its configuration: @@ -37,7 +37,7 @@ SafeAuthConfig { } ``` -- `txServiceUrl?` - The URL of the Safe Transaction Service. It's mandatory in chains where Safe doesn't provide a Transaction Service. It's used to retrieve the Safe addresses for an EOA created using SafeAuth services. +- `txServiceUrl?` - The URL of the Safe Transaction Service. It's mandatory in chains where Safe doesn't provide a Transaction Service. It retrieves the Safe addresses for an EOA created using SafeAuth services. **Caveats** You should always call the `init()` method afterward before interacting with the pack. @@ -46,7 +46,7 @@ You should always call the `init()` method afterward before interacting with the The init method initializes the provided Web3Auth SDK and Safe services. It creates an embedded browser wallet within an iframe, establishing communication through the internally generated EIP-1193 provider. -**Params** +**Parameters** - `safeAuthInitOptions` - The options to initialize the SDK instance. @@ -73,7 +73,7 @@ safeAuthInitOptions { ``` - `enableLogging` - Enable logging for the SDK. Defaults to `false`. -- `buildEnv` - The build environment. 'production' and 'testing' uses "https://safe.web3auth.com". 'development' uses "http://localhost:4050". Defaults to `production`. +- `buildEnv` - The build environment. `production` and `testing` use `https://safe.web3auth.com`. `development` uses `http://localhost:4050`. Defaults to `production`. - `showWidgetButton` - Show the widget button. Defaults to `true`. - `buttonPosition` - If `showWidgetButton` is true then this prop represent the position of the widget button. Defaults to `bottom-left`. - `chainConfig` - The chain configuration. Defaults to `ethereum` if no configuration is provided. @@ -82,7 +82,7 @@ safeAuthInitOptions { - `tickerName` - Name for ticker (e.g Ethereum). - `ticker` - Symbol for ticker (e.g ETH). - `rpcTarget` - The RPC URL to be used. - - `wcTarget?` - The websocket URL to be used. Use this or `rpcTarget`. + - `wcTarget?` - The WebSocket URL to be used. Use this or `rpcTarget`. - `chainId` - The chain ID to be used. Should be an hex with 0x prefix (e.g 0x1 for Mainnet). - `displayName` - The display name for the network. - `isTestnet?` - Whether the network is Testnet or not. @@ -101,7 +101,7 @@ safeAuthInitOptions { `signIn(safeAuthSignInOptions)` starts the authentication flow. It displays a popup that enables users to select a social authentication method (OAuth) or an email to generate the web3 wallet address. It returns the EOA and the associated Safe addresses. -**Params** +**Parameters** ```typescript SafeAuthSignInOptions = { @@ -135,7 +135,7 @@ AuthKitSignInData { **Caveats** - To get the Safe addresses, instantiate the `authKit` with the `txServiceUrl` property in the config object. Otherwise, only the EOA will be returned. -- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It doesn't create a Safe. We are investigating ways to enhance the Auth Kit and the associated flows. ⚠️ +- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It doesn't create a Safe. We are investigating ways to enhance the Auth Kit and the associated flows. ### `signOut(safeAuthSignOutOptions?)` @@ -147,7 +147,7 @@ SafeAuthSignOutOptions { } ``` -**Params** +**Parameters** - `reset` - If true, the user will be logged out from the provider, and the widget will be destroyed. Don't use this parameter if you want to log out and log in again without refreshing the browser or re-initializing the `SafeAuthPack` instance. From 57c4f61609bee4b8a21c080268eb6ee847de2b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 12:00:44 +0100 Subject: [PATCH 22/25] Add words --- .github/styles/Vocab/default/accept.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/styles/Vocab/default/accept.txt b/.github/styles/Vocab/default/accept.txt index 7154a0f8..779cc7b0 100644 --- a/.github/styles/Vocab/default/accept.txt +++ b/.github/styles/Vocab/default/accept.txt @@ -87,6 +87,7 @@ Moonbeam Moonriver Mordor Nova +OAuth OP Offchain Onramp @@ -142,6 +143,7 @@ Ultron Velas Venidium WEMIX3.0 +WebSocket WSGI XDC ZetaChain @@ -163,6 +165,7 @@ npm onboarding offchain onchain +pluggable reauthenticate sdk undefined From 13e2d86ef6b176275f788e35ab91ca41328f580c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 4 Dec 2023 12:04:39 +0100 Subject: [PATCH 23/25] Contraction --- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index fa0c7a99..4089845e 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -135,7 +135,7 @@ AuthKitSignInData { **Caveats** - To get the Safe addresses, instantiate the `authKit` with the `txServiceUrl` property in the config object. Otherwise, only the EOA will be returned. -- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It doesn't create a Safe. We are investigating ways to enhance the Auth Kit and the associated flows. +- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It doesn't create a Safe. We're investigating ways to enhance the Auth Kit and the associated flows. ### `signOut(safeAuthSignOutOptions?)` From a3100fb2fbe55e40808b20a1515ffcc674af5ae1 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:32:31 +0100 Subject: [PATCH 24/25] Align small issues --- .../auth-kit/reference/AuthKitBasePack.md | 24 ++++++++++++------- .../auth-kit/reference/SafeAuthPack.md | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index b3ac7903..3001525f 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -60,22 +60,30 @@ Provides a way to unsubscribe from an event. These methods provide the functionality associated with Safe so they can be used in the implementation of the packs. -### `getAddress(): address` +### `getSafes(txServiceUrl?): Promise` -Returns the Ethereum address extracted from the provider retrieved by `getProvider()`. This returns a Safe owner (signer). +Returns the list of Safes associated with the signer address by internally calling the `getAddress()` method. + +**Parameters** + +- `txServiceUrl`(optional): The Safe Transaction Service URL to retrieve the Safes associated with the owner (signer). **Returns** -- `address`: The Ethereum address extracted from the provider. +- `safes[]`: The list of Safes associated with the owner (signer). -### `getSafes(txServiceUrl?): safes[]` +### `getAddress(): Promise
` -Returns the list of Safes associated with the signer address by internally calling the `getAddress()` method. +Returns the Ethereum address extracted from the provider retrieved by `getProvider()`. This returns a Safe owner (signer). -**Params** +**Returns** -- `txServiceUrl`(optional): The Safe Transaction Service URL to retrieve the Safes associated with the owner (signer). +- `address`: The Ethereum address extracted from the provider. + +### `getChainId(): Promise` + +Returns the chain ID of the connected network. **Returns** -- `safes[]`: The list of Safes associated with the owner (signer). +- `chainId`: The chain ID extracted from the provider. \ No newline at end of file diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 4089845e..84f98762 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -97,7 +97,7 @@ safeAuthInitOptions { - Call always the `init()` method before interacting with the other methods in the pack. - The `init()` method creates an iframe and establishes a connection with the embedded wallet domain. To remove the iframe and disconnect the connection, use the `signOut()` method. If you want to sign out and sign in again in a single-page application (SPA) fashion, avoid using `signOut({ reset: true })` as it will clean up the session, iframe, and connection. Instead, you will need to re-instantiate the pack. -### `signIn(safeAuthSignInOptions)` +### `signIn(safeAuthSignInOptions?)` `signIn(safeAuthSignInOptions)` starts the authentication flow. It displays a popup that enables users to select a social authentication method (OAuth) or an email to generate the web3 wallet address. It returns the EOA and the associated Safe addresses. From 809299eec77b720d032bca749104332a1d2427ef Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:47:36 +0100 Subject: [PATCH 25/25] Remove alpha tag --- safe-core-sdk/auth-kit/guides/safe-auth.md | 2 +- safe-core-sdk/auth-kit/reference/SafeAuthPack.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/safe-core-sdk/auth-kit/guides/safe-auth.md b/safe-core-sdk/auth-kit/guides/safe-auth.md index f76f3909..7ed368fa 100644 --- a/safe-core-sdk/auth-kit/guides/safe-auth.md +++ b/safe-core-sdk/auth-kit/guides/safe-auth.md @@ -11,7 +11,7 @@ The `SafeAuthPack` is an authentication system that utilizes the [Web3Auth](http ### Install dependencies ```bash -yarn add @safe-global/auth-kit@alpha @web3auth/safeauth-embed +yarn add @safe-global/auth-kit @web3auth/safeauth-embed ``` ## Create a SafeAuthPack instance diff --git a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md index 84f98762..c82bdfcb 100644 --- a/safe-core-sdk/auth-kit/reference/SafeAuthPack.md +++ b/safe-core-sdk/auth-kit/reference/SafeAuthPack.md @@ -11,7 +11,7 @@ The pack helps onboard web2 users and provides an Ethereum signer address that c To use the `SafeAuthPack`, you must install the `@safe-global/auth-kit` package and the corresponding Web3Auth one. ```bash -yarn add @safe-global/auth-kit@alpha @web3auth/safeauth-embed +yarn add @safe-global/auth-kit @web3auth/safeauth-embed ``` ## Reference