oro-sdk-apis 5.17.0 → 6.0.1
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.
- package/dist/oro-sdk-apis.cjs.development.js +96 -56
- package/dist/oro-sdk-apis.cjs.development.js.map +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js.map +1 -1
- package/dist/oro-sdk-apis.esm.js +96 -56
- package/dist/oro-sdk-apis.esm.js.map +1 -1
- package/dist/services/apisPracticeManager.d.ts +6 -0
- package/dist/services/guard.d.ts +6 -0
- package/package.json +1 -1
- package/src/services/apisPracticeManager.ts +22 -18
- package/src/services/guard.ts +9 -0
@@ -22,4 +22,10 @@ export declare class ApisPracticeManager {
|
|
22
22
|
* @returns a promise holding a `ServiceCollection`
|
23
23
|
*/
|
24
24
|
get(practiceUuid?: string): Promise<ServiceCollection>;
|
25
|
+
/**
|
26
|
+
* Uses the refresh intance to fetch a new auth token for the given practice
|
27
|
+
* @param practiceUuid the uuid of the practice or key of a specific instance
|
28
|
+
* @returns a new authentication token
|
29
|
+
*/
|
30
|
+
authTokenFunc(practiceUuidOrInstanceName?: string): Promise<AuthTokenResponse>;
|
25
31
|
}
|
package/dist/services/guard.d.ts
CHANGED
@@ -104,6 +104,12 @@ export declare class GuardService {
|
|
104
104
|
* @return void
|
105
105
|
*/
|
106
106
|
identitySendConfirmEmail(req: IdentityResendConfirmEmailRequest): Promise<void>;
|
107
|
+
/**
|
108
|
+
* Notifies the guard and confirms the phishing attempt
|
109
|
+
* @param attemptUuid the guard logged attempt id
|
110
|
+
* @returns void
|
111
|
+
*/
|
112
|
+
authConfirmPhishingAttempts(attemptUuid: Uuid): Promise<void>;
|
107
113
|
/**
|
108
114
|
* Get an identity using a customer email (format: customer+[b64Hash]@orohealth.me)
|
109
115
|
*
|
package/package.json
CHANGED
@@ -19,7 +19,11 @@ export class ApisPracticeManager {
|
|
19
19
|
private serviceCollReq: ServiceCollectionRequest,
|
20
20
|
private getAuthTokenCbk: (guard: GuardService, practiceUuid?: string) => Promise<AuthTokenResponse>,
|
21
21
|
private useLocalStorage = false
|
22
|
-
) {
|
22
|
+
) {
|
23
|
+
// The refreshInstance will be a single instance that is used to refresh the tokens of others this way it will not interfere with requests made by other services
|
24
|
+
const newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage)
|
25
|
+
this.practiceInstances.set('refreshInstance', newPracticeInstance)
|
26
|
+
}
|
23
27
|
|
24
28
|
/**
|
25
29
|
* This function is used to get a `ServiceCollection` associated to a practice. If missing, it will initialize a new `ServiceCollection`.
|
@@ -32,25 +36,25 @@ export class ApisPracticeManager {
|
|
32
36
|
if (practiceInstance) return practiceInstance
|
33
37
|
|
34
38
|
const newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage)
|
35
|
-
|
36
|
-
// Create one auth token callback per practice since the practice uuid needs to change
|
37
|
-
const authTokenFunc = async () => {
|
38
|
-
if (newPracticeInstance.guardService) {
|
39
|
-
console.log(`\x1b[36m[Auth] Refresh auth called (practiceUuid: ${practiceUuid})\x1b[36m`)
|
40
|
-
return await this.getAuthTokenCbk(newPracticeInstance.guardService, practiceUuid)
|
41
|
-
} else {
|
42
|
-
throw Error('[Auth] Unable to refresh token guard service is undefined')
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
// Initialize the M2M token
|
47
|
-
await authTokenFunc()
|
48
|
-
|
49
|
-
// Set the refresh tokens callback
|
50
|
-
newPracticeInstance.apiService.setAuthRefreshFn(authTokenFunc)
|
51
|
-
|
39
|
+
newPracticeInstance.apiService.setAuthRefreshFn(() => this.authTokenFunc(practiceUuid))
|
52
40
|
this.practiceInstances.set(cacheKey, newPracticeInstance)
|
53
41
|
|
54
42
|
return newPracticeInstance
|
55
43
|
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Uses the refresh intance to fetch a new auth token for the given practice
|
47
|
+
* @param practiceUuid the uuid of the practice or key of a specific instance
|
48
|
+
* @returns a new authentication token
|
49
|
+
*/
|
50
|
+
public async authTokenFunc(practiceUuidOrInstanceName?: string): Promise<AuthTokenResponse> {
|
51
|
+
// fetch the refresh intance and refresh the token for another practice
|
52
|
+
const newPracticeInstance = await this.get('refreshInstance');
|
53
|
+
if (newPracticeInstance.guardService) {
|
54
|
+
console.log(`\x1b[36m[Auth] Refresh auth called (practiceUuid: ${practiceUuidOrInstanceName})\x1b[36m`)
|
55
|
+
return await this.getAuthTokenCbk(newPracticeInstance.guardService, practiceUuidOrInstanceName)
|
56
|
+
} else {
|
57
|
+
throw Error('[Auth] Unable to refresh token guard service is undefined')
|
58
|
+
}
|
59
|
+
}
|
56
60
|
}
|
package/src/services/guard.ts
CHANGED
@@ -273,6 +273,15 @@ export class GuardService {
|
|
273
273
|
return this.api.post<void>(`${this.baseURL}/v1/identity/confirm`, req)
|
274
274
|
}
|
275
275
|
|
276
|
+
/**
|
277
|
+
* Notifies the guard and confirms the phishing attempt
|
278
|
+
* @param attemptUuid the guard logged attempt id
|
279
|
+
* @returns void
|
280
|
+
*/
|
281
|
+
public async authConfirmPhishingAttempts(attemptUuid: Uuid): Promise<void> {
|
282
|
+
return this.api.put<void>(`${this.baseURL}/v1/auth/attempts/${attemptUuid}`, {})
|
283
|
+
}
|
284
|
+
|
276
285
|
/**
|
277
286
|
* Get an identity using a customer email (format: customer+[b64Hash]@orohealth.me)
|
278
287
|
*
|