3. Pass 3IDProvider to Apps

Now that you have created an IdentityWallet instance in the previous step, you will need to provide this IdentityWallet instance to the 3Box SDK ("the client"). There are a few ways to accomplish this depending on your use case and application context:

Option 1: The application contains a wallet

If the application contains a wallet, the wallet should directly pass the IdentityWallet instance to the openBox() method in the 3Box SDK.

The 3ID Provider can be requested from an instance of IdentityWallet and be passed directly to 3box-js. It will be used to authenticate the user:

const threeIdProvider = idWallet.get3idProvider()
const box = await Box.openBox(null, threeIdProvider)

This option is particularly useful for:

  • Wallets that directly integrate the 3Box SDK

  • Applications that use 3Box SDK server-side

Example Use Case for IDW Option 1

If a wallet, such as the MetaMask browser extension, is interested in supporting IdentityWallet in addition to allowing users to upload and modify 3Box data from directly inside the wallet instead of sending them to a web app to perform these functions. For example, they may want to allow users to create/edit a profile, store/backup data, message users, and more.

Option 2: The browser can access both the wallet and the application

If the browser can separately access both the wallet and the application, then the browser should inject the 3ID provider (its JSON-RPC interface) directly into the application.

You would use this approacch if you are a wallet provider that wants to allow external applications to access 3Box signing functionality and the 3ID protocol managed inside the wallet.

This option is particularly useful for:

  • Web apps on a mobile dapp browser (Opera, Rainbow, MetaMask mobile)

  • Web apps on a desktop dapp browser (Brave)

  • Web apps that use a desktop browser wallet extension (MetaMask extension, Dapper)

  • Web apps that use an iFrame-based wallet (Portis)

Example Use Case for IDW Option 2

If a wallet, such as the MetaMask browser extension, wants to allow external web-based applications to access 3Box signing functionality and the 3ID protocol managed inside the wallet, they would implement Option 2.

Option 3: The wallet and application exist in separate browsers or devices

If the wallet and the application exist in separate browsers or devices, then the wallet should pass the 3IDprovider (its JSON-RPC interface) to 3Box SDK running in the application using another transport mechanism, such as WalletConnect.

This option is particularly useful for:

  • Node.js apps that use 3Box

  • Mobile apps that don't have a built in wallet

  • Browser applications that use a desktop or mobile wallet

Example Use Case for IDW Option 3

If a mobile wallet/signer wants to allow desktop web applications to access 3Box signing functionality and the 3ID protocol managed inside the wallet, they would implement Option 3.