-
-
Save cardoso/7b9f5af60d3861ea53482e3ab6a795a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chatClient from "./chatClient"; | |
export default async (id, keyPair) => { | |
const response = await chatClient.setUser( | |
{ | |
id, | |
name: id, | |
image: `https://getstream.io/random_png/?id=cool-recipe-9&name=${id}`, | |
}, | |
chatClient.devToken(id) | |
); | |
if ( | |
response.me?.publicKeyJwk && | |
response.me.publicKeyJwk != JSON.stringify(keyPair.publicKeyJwk) | |
) { | |
await chatClient.disconnect(); | |
throw "This user id already exists with a different key pair. Choose a new user id or paste the correct key pair."; | |
} | |
await chatClient.upsertUsers([ | |
{ id, publicKeyJwk: JSON.stringify(keyPair.publicKeyJwk) }, | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment