oro-sdk-apis 1.8.1 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,9 +62,10 @@ export declare class GuardService {
62
62
  * without authentication
63
63
  *
64
64
  * @param identityID Unique id of the identity to retrieve
65
+ * @param skipCache (default: false) will skip identity cache (not even update it)
65
66
  * @returns IdentityResponse
66
67
  */
67
- identityGet(identityID: Uuid): Promise<IdentityResponse>;
68
+ identityGet(identityID: Uuid, skipCache?: boolean): Promise<IdentityResponse>;
68
69
  /**
69
70
  * Get information about the current authenticated user
70
71
  *
package/package.json CHANGED
@@ -1,62 +1,62 @@
1
1
  {
2
- "version": "1.8.1",
3
- "main": "dist/index.js",
4
- "typings": "dist/index.d.ts",
5
- "files": [
6
- "dist",
7
- "src"
8
- ],
9
- "engines": {
10
- "node": ">=10",
11
- "npm": ">=6.14.13"
12
- },
13
- "scripts": {
14
- "link:watch": "npm link && tsdx watch",
15
- "start": "tsdx watch",
16
- "build": "tsdx build",
17
- "test": "tsdx test",
18
- "lint": "tsdx lint",
19
- "prepare": "tsdx build",
20
- "size": "size-limit",
21
- "analyze": "size-limit --why",
22
- "package": "tsdx build && npm publish"
23
- },
24
- "husky": {
25
- "hooks": {
26
- "pre-commit": "tsdx lint"
27
- }
28
- },
29
- "name": "oro-sdk-apis",
30
- "author": "Antoine Jaouën <antoine@orohealth.me>",
31
- "module": "dist/oro-sdk-apis.esm.js",
32
- "description": "This package is intended to be run in browser or Node.js environment. It contains all models and apis services.",
33
- "size-limit": [
34
- {
35
- "path": "dist/oro-sdk-apis.cjs.production.min.js",
36
- "limit": "10 KB"
2
+ "version": "1.8.4",
3
+ "main": "dist/index.js",
4
+ "typings": "dist/index.d.ts",
5
+ "files": [
6
+ "dist",
7
+ "src"
8
+ ],
9
+ "engines": {
10
+ "node": ">=10",
11
+ "npm": ">=6.14.13"
12
+ },
13
+ "scripts": {
14
+ "link:watch": "npm link && tsdx watch",
15
+ "start": "tsdx watch",
16
+ "build": "tsdx build",
17
+ "test": "tsdx test",
18
+ "lint": "tsdx lint",
19
+ "prepare": "tsdx build",
20
+ "size": "size-limit",
21
+ "analyze": "size-limit --why",
22
+ "package": "tsdx build && npm publish"
23
+ },
24
+ "husky": {
25
+ "hooks": {
26
+ "pre-commit": "tsdx lint"
27
+ }
28
+ },
29
+ "name": "oro-sdk-apis",
30
+ "author": "Antoine Jaouën <antoine@orohealth.me>",
31
+ "module": "dist/oro-sdk-apis.esm.js",
32
+ "description": "This package is intended to be run in browser or Node.js environment. It contains all models and apis services.",
33
+ "size-limit": [
34
+ {
35
+ "path": "dist/oro-sdk-apis.cjs.production.min.js",
36
+ "limit": "10 KB"
37
+ },
38
+ {
39
+ "path": "dist/oro-sdk-apis.esm.js",
40
+ "limit": "10 KB"
41
+ }
42
+ ],
43
+ "devDependencies": {
44
+ "@size-limit/preset-small-lib": "^4.10.2",
45
+ "@types/jest": "^27.4.1",
46
+ "@types/sha.js": "^2.4.0",
47
+ "@types/uuid": "^8.3.0",
48
+ "husky": "^6.0.0",
49
+ "prettier": "^2.5.1",
50
+ "prettier-plugin-svelte": "^2.3.0",
51
+ "size-limit": "^4.10.2",
52
+ "tsdx": "^0.14.1",
53
+ "tslib": "^2.2.0",
54
+ "typescript": "^4.2.4"
37
55
  },
38
- {
39
- "path": "dist/oro-sdk-apis.esm.js",
40
- "limit": "10 KB"
56
+ "dependencies": {
57
+ "axios": "^0.21.4",
58
+ "axios-auth-refresh": "^3.2.1",
59
+ "buffer": "^6.0.3",
60
+ "hash.js": "^1.1.7"
41
61
  }
42
- ],
43
- "devDependencies": {
44
- "@size-limit/preset-small-lib": "^4.10.2",
45
- "@types/jest": "^27.4.1",
46
- "@types/sha.js": "^2.4.0",
47
- "@types/uuid": "^8.3.0",
48
- "husky": "^6.0.0",
49
- "prettier": "^2.5.1",
50
- "prettier-plugin-svelte": "^2.3.0",
51
- "size-limit": "^4.10.2",
52
- "tsdx": "^0.14.1",
53
- "tslib": "^2.2.0",
54
- "typescript": "^4.2.4"
55
- },
56
- "dependencies": {
57
- "axios": "^0.21.4",
58
- "axios-auth-refresh": "^3.2.1",
59
- "buffer": "^6.0.3",
60
- "hash.js": "^1.1.7"
61
- }
62
62
  }
@@ -365,6 +365,7 @@ export interface HydratedPracticeConfigs {
365
365
  [PracticeConfigKind.PracticeTheme]?: PracticeConfigPracticeTheme
366
366
  [PracticeConfigKind.PracticeLocaleSwitcher]?: PracticeConfigPracticeLocaleSwitcher
367
367
  [PracticeConfigKind.PracticeCookieBanner]?: PracticeConfigPracticeCookieBanner
368
+ [PracticeConfigKind.PracticePharmacyPicker]?: PracticeConfigPracticeOnlinePharmacy
368
369
  }
369
370
 
370
371
  export interface Practice {
@@ -2,16 +2,30 @@ import { AxiosError } from 'axios'
2
2
  import type { AxiosAuthRefreshRequestConfig } from 'axios-auth-refresh'
3
3
  import {
4
4
  AuthenticationBadRequest,
5
- AuthenticationFailed, AuthenticationServerError, AuthenticationUnconfirmedEmail, AuthRecoverRequest, AuthTokenRequest,
6
- AuthTokenResponse, Base64String, IdentityCreateRequest, IdentityCreationBadRequest,
7
- IdentityCreationConflict, IdentityCreationFailed, IdentityResendConfirmEmailRequest, IdentityResponse, IdentityUpdateRequest, QRCodeRequest,
8
- QRCodeResponse, Tokens, Uuid,
9
- WhoAmIResponse
5
+ AuthenticationFailed,
6
+ AuthenticationServerError,
7
+ AuthenticationUnconfirmedEmail,
8
+ AuthRecoverRequest,
9
+ AuthTokenRequest,
10
+ AuthTokenResponse,
11
+ Base64String,
12
+ IdentityCreateRequest,
13
+ IdentityCreationBadRequest,
14
+ IdentityCreationConflict,
15
+ IdentityCreationFailed,
16
+ IdentityResendConfirmEmailRequest,
17
+ IdentityResponse,
18
+ IdentityUpdateRequest,
19
+ QRCodeRequest,
20
+ QRCodeResponse,
21
+ Tokens,
22
+ Uuid,
23
+ WhoAmIResponse,
10
24
  } from '../models'
11
25
  import { APIService } from './api'
12
26
 
13
27
  export interface GuardRequestConfig extends AxiosAuthRefreshRequestConfig {
14
- useRefreshToken : boolean
28
+ useRefreshToken: boolean
15
29
  }
16
30
  export class GuardService {
17
31
  private identityCache: Record<string, IdentityResponse>
@@ -35,7 +49,7 @@ export class GuardService {
35
49
  * @param tokens
36
50
  */
37
51
  public setTokens(tokens: Tokens) {
38
- this.api.setTokens({...this.api.getTokens() , ...tokens })
52
+ this.api.setTokens({ ...this.api.getTokens(), ...tokens })
39
53
  }
40
54
 
41
55
  /**
@@ -46,21 +60,21 @@ export class GuardService {
46
60
  * @returns AuthTokenResponse
47
61
  */
48
62
  public async authToken(req: AuthTokenRequest): Promise<AuthTokenResponse> {
49
- let resp : AuthTokenResponse
63
+ let resp: AuthTokenResponse
50
64
 
51
65
  try {
52
66
  let config: AxiosAuthRefreshRequestConfig = {
53
- skipAuthRefresh: true
67
+ skipAuthRefresh: true,
54
68
  }
55
69
 
56
70
  resp = await this.api.post<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, req, config)
57
71
 
58
72
  this.api.setTokens({
59
73
  accessToken: resp.accessToken,
60
- refreshToken: resp.refreshToken
74
+ refreshToken: resp.refreshToken,
61
75
  })
62
- } catch(e) {
63
- if((e as any).isAxiosError){
76
+ } catch (e) {
77
+ if ((e as any).isAxiosError) {
64
78
  const code = (e as AxiosError).response?.status
65
79
  switch (code) {
66
80
  case 400:
@@ -75,7 +89,6 @@ export class GuardService {
75
89
  }
76
90
  }
77
91
  throw new AuthenticationFailed()
78
-
79
92
  }
80
93
  return resp
81
94
  }
@@ -88,12 +101,11 @@ export class GuardService {
88
101
  public async authRefresh(refreshToken?: string): Promise<AuthTokenResponse> {
89
102
  let config: GuardRequestConfig = {
90
103
  skipAuthRefresh: true,
91
- useRefreshToken: true
104
+ useRefreshToken: true,
92
105
  }
93
106
  return this.api.put<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, null, config)
94
107
  }
95
108
 
96
-
97
109
  /**
98
110
  * Call guard to overwrite existing refresh token cookie
99
111
  *
@@ -103,7 +115,6 @@ export class GuardService {
103
115
  return this.api.get<void>(`${this.baseURL}/v1/auth/logout`)
104
116
  }
105
117
 
106
-
107
118
  /**
108
119
  * Call guard to attempt account recovery
109
120
  *
@@ -114,7 +125,6 @@ export class GuardService {
114
125
  return this.api.post<void>(`${this.baseURL}/v1/auth/recover`, req)
115
126
  }
116
127
 
117
-
118
128
  /**
119
129
  * Allow to create a new identity. The identity will then need to be confirmed
120
130
  * via an email link
@@ -123,15 +133,15 @@ export class GuardService {
123
133
  * @returns IdentityResponse
124
134
  */
125
135
  public async identityCreate(req: IdentityCreateRequest): Promise<IdentityResponse> {
126
- let resp : IdentityResponse
136
+ let resp: IdentityResponse
127
137
 
128
138
  try {
129
139
  resp = await this.api.post<IdentityResponse>(`${this.baseURL}/v1/identities`, req)
130
140
  this.api.setTokens({
131
- refreshToken: resp.refreshToken
141
+ refreshToken: resp.refreshToken,
132
142
  })
133
143
  } catch (e) {
134
- if((e as any).isAxiosError){
144
+ if ((e as any).isAxiosError) {
135
145
  const code = (e as AxiosError).response?.status
136
146
  switch (code) {
137
147
  case 400:
@@ -147,30 +157,29 @@ export class GuardService {
147
157
  }
148
158
  return resp
149
159
  }
150
-
151
-
160
+
152
161
  /**
153
162
  * Retrieve an identity. Will return public fields only when requested
154
163
  * without authentication
155
164
  *
156
165
  * @param identityID Unique id of the identity to retrieve
166
+ * @param skipCache (default: false) will skip identity cache (not even update it)
157
167
  * @returns IdentityResponse
158
168
  */
159
- public async identityGet(
160
- identityID: Uuid
161
- ): Promise<IdentityResponse> {
169
+ public async identityGet(identityID: Uuid, skipCache = false): Promise<IdentityResponse> {
162
170
  const tokens = this.api.getTokens()
163
171
  const cacheKey = (tokens.accessToken ?? '') + (tokens.refreshToken ?? '') + identityID
164
172
 
165
- if (!tokens.accessToken || !this.identityCache[cacheKey]) {
166
- this.identityCache[cacheKey] = await this.api.get<IdentityResponse>(
167
- `${this.baseURL}/v1/identities/${identityID}`
168
- )
173
+ if (skipCache || !tokens.accessToken || !this.identityCache[cacheKey]) {
174
+ const identity = await this.api.get<IdentityResponse>(`${this.baseURL}/v1/identities/${identityID}`)
175
+
176
+ if (skipCache) return identity
177
+
178
+ this.identityCache[cacheKey] = identity
169
179
  }
170
180
  return this.identityCache[cacheKey]
171
181
  }
172
182
 
173
-
174
183
  /**
175
184
  * Get information about the current authenticated user
176
185
  *
@@ -192,10 +201,7 @@ export class GuardService {
192
201
  * @param req update request
193
202
  * @returns IdentityResponse
194
203
  */
195
- public async identityUpdate(
196
- identityID: Uuid,
197
- req: IdentityUpdateRequest
198
- ): Promise<IdentityResponse> {
204
+ public async identityUpdate(identityID: Uuid, req: IdentityUpdateRequest): Promise<IdentityResponse> {
199
205
  return this.api.put<IdentityResponse>(`${this.baseURL}/v1/identities/${identityID}`, req)
200
206
  }
201
207
 
@@ -207,12 +213,11 @@ export class GuardService {
207
213
  * @param password the identity password (already hashed and in base64)
208
214
  * @returns QRCodeResponse
209
215
  */
210
- public async identityMFAQRCode(
211
- identityID: Uuid,
212
- password: Base64String
213
- ): Promise<QRCodeResponse> {
216
+ public async identityMFAQRCode(identityID: Uuid, password: Base64String): Promise<QRCodeResponse> {
214
217
  const req: QRCodeRequest = { password }
215
- return this.api.post<QRCodeResponse>(`${this.baseURL}/v1/identities/${identityID}/mfa`, req, { headers: { 'Accept': 'application/json' } })
218
+ return this.api.post<QRCodeResponse>(`${this.baseURL}/v1/identities/${identityID}/mfa`, req, {
219
+ headers: { Accept: 'application/json' },
220
+ })
216
221
  }
217
222
 
218
223
  /**
@@ -221,8 +226,7 @@ export class GuardService {
221
226
  * @param req IdentityResendConfirmEmailRequest
222
227
  * @return void
223
228
  */
224
- public async identitySendConfirmEmail(req : IdentityResendConfirmEmailRequest): Promise<void> {
229
+ public async identitySendConfirmEmail(req: IdentityResendConfirmEmailRequest): Promise<void> {
225
230
  return this.api.post<void>(`${this.baseURL}/v1/identity/confirm`, req)
226
231
  }
227
232
  }
228
-