You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/feature-guides/update-profile.md
+20-17Lines changed: 20 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,15 @@
1
1
---
2
2
title: Update User Profile
3
3
---
4
+
4
5
import StacksjsStartersNote from '../includes/\_stacks.js-starters-note.mdx';
5
6
import StacksProviderSection from '../includes/\_stacks.js-provider-section.mdx';
6
7
7
8
<StacksjsStartersNote/>
8
9
9
10
This guide explains how to change the universal profile of an authenticated user.
10
11
11
-
When a user creates a new account with Hiro Wallet a basic profile is created and stored on the user's own storage hub. The basic profile contains
12
+
When a user creates a new account with Hiro Wallet a basic profile is created and stored on the user's own storage hub. The basic profile contains
12
13
only a public key. It can be extended to contain personal information like an avatar,name and description. It is always cryptographically signed by the user's key, the so-called owner key.
In order to update the public profile, apps can make request to the Stacks wallet. These requests are reviewed and confirmed by the user in the wallet similar to transaction signing.
24
+
In order to update the public profile, apps can make request to the Stacks wallet. These requests are reviewed and confirmed by the user in the wallet similar to transaction signing.
24
25
25
26
## Install dependency
27
+
26
28
:::tip
27
29
In order to utilize the latest profile updating with the Hiro Wallet, use a version >= 7.1.0 of the `@stacks/connect` NPM package.
28
30
:::
@@ -33,7 +35,7 @@ The following dependency must be installed:
33
35
npm install @stacks/connect
34
36
```
35
37
36
-
This also installs the NPM package `@stacks/profile`. It contains the data type `PublicPersonProfile` used for the public profile.
38
+
This also installs the NPM package `@stacks/profile`. It contains the data type `PublicPersonProfile` used for the public profile.
37
39
38
40
## Initiate session
39
41
@@ -43,17 +45,20 @@ See the [authentication guide](https://docs.hiro.so/build-apps/authentication) b
43
45
44
46
## Prompt to update the profile
45
47
46
-
After the user chose the content of the profile, create a `PublicPersonProfile` object from that data and call the `openProfileUpdateRequestPopup` function provided by the `connect`package to trigger the display of the profile update prompt.
48
+
After the user chose the content of the profile, create a `PublicPersonProfile` object from that data and call the `openProfileUpdateRequestPopup` function provided by the `connect` package to trigger the display of the profile update prompt.
The function returns a promise with the data of the public profile if the data could be retrieved from the BNS name owner's storage and if the retrieved JSON token was sucessfully verified.
103
109
104
110
The recommended schema for the profile is as follows:
Import the `useConnect` helper from [`connect-react`](https://github.com/hirosystems/connect) package to update profiles more seamlessly with React apps.
After the user confirms the update, a `profileUpdateResponse` payload of type `PublicProfile` is sent back to your app. It contains the updated profile as confirmed by the user. Note, that this profile can be different to the requested profile by the app because the user might have modified the profile in the wallet before confirming the changes.
When users have the [Hiro Wallet](https://www.hiro.so/wallet/install-web) extension installed, the extension will inject a global `StacksProvider` variable into the JavaScript context of your web app. This allows your JavaScript code to hook into the extension, and make authentication, transaction and signature requests. `@stacks/connect` automatically detects and uses this global variable for you.
4
+
5
+
At the moment, only the Hiro Wallet extension and the Xverse built-in browswer includes a `StacksProvider`, however, ideally more wallets (and mobile wallets) will support this format, so that your app can be compatible with any Stacks wallet that has functionality to embed web applications.
6
+
7
+
In your web application, you can check to see if the user has a compatible wallet installed by checking for the presence of `window.StacksProvider`.
8
+
9
+
Here is the interface for the `StacksProvider` variable.
0 commit comments