Stacks-wallet-web: Verfügbarkeit von Benutzerprofildaten sicherstellen

Erstellt am 3. Apr. 2020  ·  10Kommentare  ·  Quelle: blockstack/stacks-wallet-web

userData von userSession.loadUserData() funktioniert nicht wie die alten blockstack.js-Methoden.
Mit der vorherigen Authentifizierung konnte ich let person = new blockstack.Person(userData) um vom Browser eingestellte 'Name' und 'Avatar' Profildaten zu erhalten. dh. person.name() und person.avatarUrl() .

Mit connect gibt der obige Prozess null sowohl für person.name() als auch person.avatarUrl() zurück, selbst wenn sie existieren.

Dies ist eine Regression für die Apps, die einen Anschein von Personalisierung zulassen möchten.

🐛 Bug!

Alle 10 Kommentare

Das Problem besteht darin, dass der Legacy-Blockstack-Browser das Profil im authReponse-Token zurückgibt, das von der Profil-URL abgerufen wurde, während die neue Blockstack-App/Authentifizierung diese Suche nicht durchführt.

Apps, die immer noch das Profil eines Benutzers sehen möchten, sollten das Lookup-Profil (http://blockstack.github.io/blockstack.js/globals.html#lookupprofile) aufrufen, denke ich.

loadUserData tut immer noch dasselbe, es lädt die Benutzerdaten, die im lokalen Cache (localstorage) verfügbar sind, der vom Authenticator bereitgestellt wird.

Interessanterweise gibt der Connect Authenticator für Apps, die publish_data anfordern, das Profil zurück.

@hstove Gedanken zum Hinzufügen dieser Unterstützung für Einzelspieler-Apps?

@friedger mit lookupProfile gibt immer noch keinen Zugriff auf name() und avatarUrl(), die für die Personalisierung benötigt werden.

@dantrevino lookupProfile gibt eine Zusage eines Profils mit den Eigenschaften name und image[i].contentUrl falls vom Benutzer bereitgestellt.

@friedger Ich sehe es nicht. Was vermisse ich?

          const userData = userSession.loadUserData();
          const profile = blockstack.lookupProfile(userData.username);
          console.log("profile loaded: ", profile);

profile loaded: _proto__: Promise constructor: ƒ Promise() then: ƒ then() catch: ƒ catch() finally: ƒ finally() Symbol(Symbol.toStringTag): "Promise" __proto__: Object <strong i="9">@type</strong>: "Person" <strong i="10">@context</strong>: "http://schema.org" apps: {http://localhost:8080: "https://gaia.blockstack.org/hub/1AdqWQnAMsb8uQsrZy96G2P7HYd1zkpMnr/", https://reclaim.gg: "https://gaia.blockstack.org/hub/1PcbTDbgybtTjkETvo9j5jr92VFKJ4rwWC/", https://boom-money-daily.runkodapps.com: "https://gaia.blockstack.org/hub/19wdVbKFyNqVVSuJf8ppt8P92LjUMdJjpz/", https://noteriot-daily.runkodapps.com: "https://gaia.blockstack.org/hub/1Br9sxhdSw6xQJ3x8vvQNkuAz5X5oAq7a5/", https://runkod.com: "https://gaia.blockstack.org/hub/1NpdmvGsNyisR56CUiZHfZHnZukMYiSjJ5/", …} api: {gaiaHubConfig: {…}, gaiaHubUrl: "https://hub.blockstack.org"} __proto__: constructor: ƒ Object() __defineGetter__: ƒ __defineGetter__() __defineSetter__: ƒ __defineSetter__() hasOwnProperty: ƒ hasOwnProperty() __lookupGetter__: ƒ __lookupGetter__() __lookupSetter__: ƒ __lookupSetter__() isPrototypeOf: ƒ isPrototypeOf() propertyIsEnumerable: ƒ propertyIsEnumerable() toString: ƒ toString() valueOf: ƒ valueOf() toLocaleString: ƒ toLocaleString() get __proto__: ƒ __proto__() set __proto__: ƒ __proto__()

Für fehlende Profildetails siehe https://github.com/blockstack/ux/issues/322

Ich habe dem Authenticator einen Fix gepusht - es gab einige Probleme, bei denen wir das Profil vor dem authResponse nicht richtig abgerufen haben. Bitte versuchen Sie es erneut und lassen Sie es mich wissen, wenn das gleiche Problem auftritt.

@hstove zur Info , dies funktioniert immer noch nicht mit den Klassenmethoden. Ich habe sichergestellt, dass mein Profil einen Namen und einen Avatar hat:

https://gaia.blockstack.org/hub/1JE8MjzuSi19cBifCvrbsyAjx8PvwhakZp/profile.json

meine Anmeldemethode:

    signIn() {
      const authOptions = {
        // The URL you want the user to be redirected to after authentication.
        redirectTo: "/wallet",
        manifestPath: "/manifest.json",
        sendToSignIn: true,
        finished: ({ userSession }) => {
          this.logInUser(userSession);
        },
        appDetails: {
          name: "Boom.Webby",
          icon: `${location.origin}/app-icon.png`,
        },
      };
      authenticate(authOptions);
    },

logInUser():

  logInUser(context, session) {
    console.log("user session: ", session);
    let userData = session.loadUserData();
    let person = new blockstack.Person(userData);
    userData.name = person.name();
    userData.avatar = person.avatarUrl();
    userData.authenticated = true;
    console.log("userData: ", userData);
    context.dispatch("setUser", userData);
  },

und die Ausgabe von console.log() .. Beachten Sie, dass der Name und der Avatar immer noch null wenn Sie die Klassenmethoden verwenden:

{username: "fibonacci.id", profile: {…}, email: null, decentralizedID: "did:btc-addr:1JE8MjzuSi19cBifCvrbsyAjx8PvwhakZp", identityAddress: "1JE8MjzuSi19cBifCvrbsyAjx8PvwhakZp", …}
appPrivateKey: (...)
authResponseToken: (...)
authenticated: (...)
avatar: null
coreSessionToken: (...)
decentralizedID: (...)
email: (...)
gaiaAssociationToken: (...)
hubUrl: (...)
identityAddress: (...)
name: null
profile: (...)
username: (...)

Wenn ich mir jedoch blockstack-session im lokalen Speicher ansehe, sind die Namens- und Bildstützen vorhanden.

userData: {username: "fibonacci.id", profile: {<strong i="21">@type</strong>: "Person", <strong i="22">@context</strong>: "http://schema.org",…}, email: null,…}
appPrivateKey: "..."
.
.
.
profile: {<strong i="23">@type</strong>: "Person", <strong i="24">@context</strong>: "http://schema.org",…}
.
.
.
image: [{<strong i="25">@type</strong>: "ImageObject", name: "avatar",…}]
name: "Fibonacci"
username: "fibonacci.id"
version: "1.0.0"

Ich sehe es nicht. Was vermisse ich?

@dantravino das Problem hier ist, dass lookupProfile ein Versprechen zurückgibt und Sie await . Was Sie also zurückbekommen, ist ein Versprechen.

Vielen Dank, dass Sie das Problem weiterverfolgt haben, das weiterhin besteht, wenn Sie die Klasse Person Ich werde mir das ansehen.

Hey @dantravino - du musst nur new Person(userData.profile) anrufen, anstatt new Person(userData) . Vielleicht hat es bei dir vorher anders funktioniert? Aber das steht im Einklang mit den Dokumenten hier:

https://blockstack.github.io/blockstack.js/index.html#quickstart -build-an-application

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen