# Connect

In order to start interacting with Broearn Wallet, an app must first establish a connection. This connection request will prompt users for permission to share their public keys, indicating that they are willing to interact further.

Once a user connects to Broearn Wallet, Broearn Wallet will return the promise type param that should be used on all subsequent methods.

### Query Function

```javascript
// New Connect
window.bw.put.connect()
// Check if the Dapp is linked to a wallet
window.bw.put.connect({
    session: '...'
}}
```

### Query String Parameters

Check if the Dapp is linked to a wallet

```javascript
// Some code
{
    session: string
}
```

### Returns

#### Approve

* `data`: An JSON object.

  ```json
  // content of decrypted `data`-parameter
  {
    // base58 encoding of user public key
    "address": "BSFtCudCd4pR4LSFqWPjbtXPKSNVbGkc35gRNdnqjMCU",

    // session token for subsequent signatures and messages
    // dapps should send this with any other deeplinks after connect
    "session": "..."
  }
  ```

  * address: The public key of the user, represented as a base58-encoded string.
  * `session`: A string type. This should be treated as opaque by the connecting app, as it only needs to be passed alongside other parameters. Sessions do not expire.

```
// Sample code
{
    "data": {
        "address": "",
        "session": ""
    }
}
```

#### Reject

An `errorCode` and `errorMessage` as query parameters. Please refer to [Errors](https://wallet-docs.broearn.com/errors) for a full list of possible error codes.

```json
{
    "errorCode": "",
    "errorMessage": ""
}
```
