iCure. eHealth Solutions
  • Developer Documentation
  • iCure Software Modules
  • Get Started
    • Create your own Database
      • Receive an invitation
      • Create new User
      • Create a new Healthcare Party
    • Structure your Database
    • Access your database
    • Use the Console
  • Data Stack Module
    • The Data Stack
      • Install iCure
      • Get Started with a Database
    • iCure Data Model
      • Overview
      • User
        • Permission
      • Healthcare Party
      • Patient
        • Insurability
        • Relationship
        • Patient Hcp care period
          • Referral period
      • Contact
        • Service
          • Content
            • Medication
              • Regimen item
            • Measure
        • SubContact
      • Healthcare Element
        • Care team member
        • Healthcare approach
      • Form
      • Additional Classes
        • AccessLog
        • Address
          • Telecom
        • Message
        • Document
        • FilterChain
          • Filter
          • Predicate
        • Group
        • Insurance
        • Invoice
          • Invoicing code
        • Tarification
          • Valorisation
    • Hybrid Cloud Storage
    • Mobile/Web SDKs
      • JavaScript/Typescript
        • Setting up your environment
        • Logging in
        • Managing patients
        • iCure for MedTech: Getting Started
          • Exchange data using FHIR model
          • Exchange data using iCure SDK
      • Java/Kotlin
      • Swift/Objective C
    • REST API calls
      • User
      • Patient
      • HealthcareParty
      • Contact
      • HealthcareElement
      • Form
      • Document
      • Message
      • Invoice
      • Additional endpoints
        • AccessLog
        • Authentication
        • Codification
        • Document template
        • Entity reference
        • Entity template
        • Insurance
        • Receipt
        • Tarification
    • Access Rights management
    • End-to-End-Encryption
    • ATNA Audit Records
  • Interoperability Module
    • IHE XDS calls
      • The XDS Concept
      • ITI-18 get associations api call
      • ITI-41 provide and register document set api call
      • Iti-42 register document set api call
    • IHE IPS call
      • The IPS Concept
    • FHIR API Data Exchange
      • The FHIR Concept
    • Freehealth Connector 🇧🇪
    • Encrypted Data Exchange
      • Internal
      • External
  • Customizable Features Module
    • Input Forms
    • Medical Records
    • Data Dashboards
    • Custom Connectors
    • Secure Log-in App
  • Support
    • Download
    • Contact Us
  • Advanced topics
    • Healthcare Data
      • Business intelligence
      • Anonymized Data
    • Encryption Key Creation and Storage
    • Multi-Master database replication
    • Cross Databases Sharing
    • Complex queries
Powered by GitBook
On this page

Was this helpful?

  1. Data Stack Module
  2. Mobile/Web SDKs
  3. JavaScript/Typescript

Logging in

PreviousSetting up your environmentNextManaging patients

Last updated 4 years ago

Was this helpful?

To log in on the iCure platform, you will need a username and a password

Make sure to have your environment first.

import {Api } from '@icure/api'
import { crypto } from '@icure/api/node-compat.js' //Only needed on node

const host = 'https://kraken.svc.icure.cloud/rest/v1';
const {
    userApi,
    healthcarePartyApi,
    cryptoApi
} = Api(host, 'user', 'password', crypto)

Once logged in, you can check the user details.

const loggedUser = await userApi.getCurrentUser()

If you wish to decrypt medical data, you will have to import your private key

import { hex2ua } from "@icure/api";

const loggedUser = await userApi.getCurrentUser()

await cryptoApi.loadKeyPairsAsTextInBrowserLocalStorage(
    loggedUser.healthcarePartyId,
    hex2ua('308204bd02...0f3ca0975e78')
)

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'
}))
set up