oro-sdk 3.17.0 → 3.18.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.17.0",
2
+ "version": "3.18.0",
3
3
  "main": "dist/index.js",
4
4
  "typings": "dist/index.d.ts",
5
5
  "files": [
package/src/client.ts CHANGED
@@ -702,6 +702,8 @@ export class OroClient {
702
702
 
703
703
  // We're using the account role to determine the way a grant is accessed
704
704
  let currentAccountRole = await this.getAccountRole()
705
+ if (currentAccountRole.length === 1 && currentAccountRole[0] === OtherRoleType.User)
706
+ return []
705
707
 
706
708
  if ([OtherRoleType.Patient, OtherRoleType.User].every(requiredRole => currentAccountRole.includes(requiredRole))) {
707
709
  let encryptedGrants
@@ -269,13 +269,19 @@ async function getOrCreatePatientLockbox(oroClient: OroClient): Promise<Uuid> {
269
269
  if (grants.length > 0) {
270
270
  console.log('The grant has already been created, skipping lockbox create step')
271
271
  return grants[0].lockboxUuid!
272
- } else
273
- return (
272
+ } else {
273
+ let lockboxResponse =
274
274
  await oroClient.vaultClient.lockboxCreate().catch((err) => {
275
275
  console.error('Error while creating lockbox', err)
276
276
  throw err
277
277
  })
278
- ).lockboxUuid
278
+ // Since the creation of a lockbox will change the scope of a user, we will force refresh the tokens
279
+ let tokens = await oroClient.guardClient.authRefresh()
280
+ await oroClient.guardClient.setTokens({ accessToken: tokens.accessToken, refreshToken: tokens.refreshToken })
281
+ await oroClient.guardClient.whoAmI(true)
282
+
283
+ return lockboxResponse.lockboxUuid
284
+ }
279
285
  }
280
286
 
281
287
  /**