How to sign identity data with agent.js?

I am working on a project that is sharing the authentication system with another project.
The setup is like for users on my project to signin/authenticate with ic identity on my project they do so by using an authentication that is not my project but on the other project, through an iframe, and then when they finish authenticating, the identity data is sent through an iframe into my project with the postMessage.

So now my question is, with identity data, how can I sign it (or whatever the best term for the process is), with agent.js or a better package for the task if there is one, so that after obtaining the identity, it can be saved in my project as if the authentication had originally happened on my project so that I can perform all the other basic agentjs functionality like using using AuthClient to check isAuthenticated(), or to getIdentity() etc, but after having signed an identity data that isn’t originally from my project. Someone told be something like that is possible but I just don’t know how to really implement it. I am using React with Typescript

1 Like

It’s probably not a good idea to be doing that. Having one project that gives access to everything in another project. Unless they are both yours. But then you can simply make Internet Identity share the same principal across multiple sites.
If you still want to pass it around, maybe the code here will help https://github.com/infu/athena-protocol
You have to extract the identity in JSON, pass it, then recreate the identity on the other site and use it.

1 Like

Okay thank you, Making the Internet Identity share the same principal across multiple sites? How can I do that? That will be the best solution. Because I am just trying to have users use the same principal on these 2 services that are running on different sites/projects.

1 Like

Thank you, looking into both solutions.

Consider looking into the delegation identity to safely transfer an identity without having the private key leaving the website.

1 Like