A user is only part of the story, it holds the information needed to log in but the personal data and the cryptographic keys are stored either in a patient or a healthcare party document. To create a new user, you will have to create the linked healthcare party as well
import { ua2hex, HealthcareParty, User } from '@icure/api'
const { publicKey, privateKey } = await cryptoApi.RSA.generateKeyPair()
const exportedKey = ua2hex(await cryptoApi.RSA.exportKey(privateKey, 'pkcs8'))
//The private key will have to be stored in a secured place and used later
const newHcp = await healthcarePartyApi.createHealthcareParty(
new HealthcareParty({
id: cryptoApi.randomUuid(),
firstName: 'John',
lastName: 'Wayne',
publicKey: await cryptoApi.RSA.exportKey(publicKey, 'spki')
})
)
const newUser = await userApi.createUser(new User({
id: cryptoApi.randomUuid(),
healthcarePartyId: newHcp.id,
login: 'john',
passwordHash: 'passwordInClear'
}))