janeirodigital / sai-js

Typescript library for Solid Application Interoperability
https://sai.js.org/
MIT License
8 stars 6 forks source link

[readme instructions] internal server error when connecting server to authorization agent #74

Closed michielbdejong closed 7 months ago

michielbdejong commented 7 months ago

I am able to follow the readme instruction up to https://github.com/janeirodigital/sai-js?tab=readme-ov-file#authorization-agent

When I try to log in to http://localhost:4200 I have to do so from a private tab - apparently I have an old session stored in my cookies.

This works but when I then click 'Connect server' I get redirected to:

http://localhost:4000/agents/aHR0cDovL2xvY2FsaG9zdDozMDAwL2FsaWNlMi9wcm9maWxlL2NhcmQjbWU=/redirect?code=V20IdAIOgcoQnmqDzrzDZkXIkx-GoDTMTG29QN07I86&state=3h6G0SEgRRUW8isTfgTYC-Xb8NamFK0yFJGmiN-7rhA&iss=http%3A%2F%2Flocalhost%3A3000%2F

which displays 'Internal server error'. The error in the pnpm watch logs is:

d30af8c5 > [2024-02-05T10:32:59.942Z sai-server] Error occurred:  {} {
d30af8c5 >   error: {
d30af8c5 >     message: "Cannot read properties of undefined (reading 'toString')",
d30af8c5 >     name: 'TypeError',
d30af8c5 >     stack: [
d30af8c5 >       "TypeError: Cannot read properties of undefined (reading 'toString')",
d30af8c5 >       '    at makeAuthenticatedRequest (/Users/michiel/gh/janeirodigital/sai-js/node_modules/.pnpm/@inrupt+solid-client-authn-core@1.17.5/node_modules/@inrupt/solid-client-authn-core/dist/index.js:1275:65)',
d30af8c5 >       '    at ClientAuthentication.fetch (/Users/michiel/gh/janeirodigital/sai-js/node_modules/.pnpm/@inrupt+solid-client-authn-core@1.17.5/node_modules/@inrupt/solid-client-authn-core/dist/index.js:1390:30)',
d30af8c5 >       '    at Session.fetch (/Users/michiel/gh/janeirodigital/sai-js/node_modules/.pnpm/@inrupt+solid-client-authn-node@1.17.5/node_modules/@inrupt/solid-client-authn-node/dist/index.js:1314:46)',
d30af8c5 >       '    at unwrappedRdfFetch (/Users/michiel/gh/janeirodigital/sai-js/packages/utils/dist/cjs/fetch.js:17:28)',
d30af8c5 >       '    at CRUDRegistrySet.wrappedRdfFetch [as fetch] (/Users/michiel/gh/janeirodigital/sai-js/packages/utils/dist/cjs/fetch.js:31:16)',
d30af8c5 >       '    at CRUDRegistrySet.fetchData (/Users/michiel/gh/janeirodigital/sai-js/packages/data-model/dist/cjs/readable/resource.js:8:37)',
d30af8c5 >       '    at CRUDRegistrySet.bootstrap (/Users/michiel/gh/janeirodigital/sai-js/packages/data-model/dist/cjs/crud/registry-set.js:7:20)',
d30af8c5 >       '    at CRUDRegistrySet.build (/Users/michiel/gh/janeirodigital/sai-js/packages/data-model/dist/cjs/crud/registry-set.js:15:24)',
d30af8c5 >       '    at Object.registrySet (/Users/michiel/gh/janeirodigital/sai-js/packages/data-model/dist/cjs/authorization-agent-factory.js:39:43)',
d30af8c5 >       '    at AuthorizationAgent.bootstrap (/Users/michiel/gh/janeirodigital/sai-js/packages/authorization-agent/dist/cjs/authorization-agent.js:62:52)'
d30af8c5 >     ]
d30af8c5 >   }
d30af8c5 > }
michielbdejong commented 7 months ago

I think the problem is that http://localhost:3000/alice2/profile/card#me has no registry set. It's just:

@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix solid: <http://www.w3.org/ns/solid/terms#>.

<>
    a foaf:PersonalProfileDocument;
    foaf:maker <http://localhost:3000/alice2/profile/card#me>;
    foaf:primaryTopic <http://localhost:3000/alice2/profile/card#me>.

<http://localhost:3000/alice2/profile/card#me>

    solid:oidcIssuer <http://localhost:3000/>;
    a foaf:Person.
elf-pavlik commented 7 months ago

Yes, you can see working one in

https://github.com/janeirodigital/sai-js/blob/main/packages/css-storage-fixture/alice/profile/card%24.ttl#L16-L17

The authorization agent's URL uses base64 encoded WebID if you add one for the alice2 account you created.

I still need to check why it even redirects and where it got that authorization agent URL.

michielbdejong commented 7 months ago

This was resolved by using alice@acme.example