Skip to content

Commit

Permalink
Merge pull request #6 from icure/update_the_template_according_to_the…
Browse files Browse the repository at this point in the history
…_updated_sdk

update_the_template_according_to_the_updated_sdk
  • Loading branch information
aduchate authored Apr 9, 2024
2 parents 4837947 + e479176 commit 1f46c61
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
.env

/.idea
6 changes: 3 additions & 3 deletions template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.0",
"@icure/ehr-lite-sdk": "^1.0.0",
"@icure/ehr-lite-sdk": "^3.1.1",
"react-redux": "^8.0.1",
"react-router-dom": "^6.10.0",
"redux-persist": "^6.0.0",
"@reduxjs/toolkit": "^1.8.1",
"friendly-challenge": "^0.9.8",
"localforage": "^1.10.0"
},
},
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
Expand All @@ -24,4 +24,4 @@
"typescript": "^4.9.3"
}
}
}
}
21 changes: 13 additions & 8 deletions template/src/services/auth.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
AnonymousEHRLiteApi,
AuthenticationProcess,
EHRLiteApi,
ICURE_CLOUD_URL,
SimpleCryptoStrategies,
User
} from "@icure/ehr-lite-sdk";
import { SimpleEHRLiteCryptoStrategies } from '@icure/ehr-lite-sdk/services/EHRLiteCryptoStrategies'
import {RecaptchaType} from "@icure/typescript-common/models/RecaptchaType.model";

const apiCache: { [key: string]: EHRLiteApi | AnonymousEHRLiteApi } = {};

Expand Down Expand Up @@ -57,15 +57,21 @@ export const startAuthentication = createAsyncThunk('ehrLiteApi/startAuthenticat

const anonymousApi = await new AnonymousEHRLiteApi
.Builder()
.withICureBaseUrl("https://krakenc.icure.cloud")
.withICureBaseUrl("https://api.icure.cloud")
.withCrypto(crypto)
.withMsgGwSpecId(process.env.REACT_APP_EXTERNAL_SERVICES_SPEC_ID!)
.withAuthProcessByEmailId(process.env.REACT_APP_EMAIL_AUTHENTICATION_PROCESS_ID!)
.withStorage(storage)
.withCryptoStrategies(new SimpleCryptoStrategies([]))
.withCryptoStrategies(new SimpleEHRLiteCryptoStrategies([]))
.build();

const authProcess = await anonymousApi.authenticationApi.startAuthentication(_payload.captchaToken, email, undefined, firstName, lastName, process.env.REACT_APP_PARENT_ORGANISATION_ID, undefined, 6, 'friendly-captcha');
const authProcess = await anonymousApi.authenticationApi.startAuthentication({
recaptcha: _payload.captchaToken,
email,
firstName,
lastName,
recaptchaType: 'friendly-captcha'
});

apiCache[`${authProcess.login}/${authProcess.requestId}`] = anonymousApi;

Expand Down Expand Up @@ -119,14 +125,14 @@ export const login = createAsyncThunk('ehrLiteApi/login', async (_, {getState})
}

const api = await new EHRLiteApi.Builder()
.withICureBaseUrl("https://krakenc.icure.cloud")
.withICureBaseUrl("https://api.icure.cloud")
.withCrypto(crypto)
.withMsgGwSpecId(process.env.REACT_APP_EXTERNAL_SERVICES_SPEC_ID!)
.withAuthProcessByEmailId(process.env.REACT_APP_EMAIL_AUTHENTICATION_PROCESS_ID!)
.withStorage(storage)
.withUserName(email)
.withPassword(token)
.withCryptoStrategies(new SimpleCryptoStrategies([]))
.withCryptoStrategies(new SimpleEHRLiteCryptoStrategies([]))
.build();

const user = await api.userApi.getLogged();
Expand Down Expand Up @@ -197,4 +203,3 @@ export const api = createSlice({


export const {setRegistrationInformation, setToken, setEmail, setUser, resetCredentials} = api.actions;

0 comments on commit 1f46c61

Please sign in to comment.