@healthcloudai/hc-login-connector 0.0.13 → 0.0.14
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/README.md +100 -39
- package/dist/index.cjs +17 -20
- package/dist/index.d.cts +31 -15
- package/dist/index.d.ts +31 -15
- package/dist/index.js +17 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -770,7 +770,7 @@ Status:
|
|
|
770
770
|
Public signature: `loginClient.login(email, password)`
|
|
771
771
|
|
|
772
772
|
`login(...)` accepts only `email` and `password`.
|
|
773
|
-
The client builds the
|
|
773
|
+
The client builds the login `Data` payload internally, and stores the
|
|
774
774
|
returned tokens in memory.
|
|
775
775
|
On tenants that require onboarding completion, login may depend on the relevant
|
|
776
776
|
onboarding steps already being finished.
|
|
@@ -783,20 +783,14 @@ await loginClient.login(
|
|
|
783
783
|
```
|
|
784
784
|
|
|
785
785
|
#### Full API request
|
|
786
|
-
Request sent for the usage example above:
|
|
786
|
+
Request sent for the full payload usage example above:
|
|
787
787
|
|
|
788
788
|
```json
|
|
789
789
|
{
|
|
790
790
|
"Data": {
|
|
791
|
-
"FirstName": "",
|
|
792
|
-
"LastName": "",
|
|
793
791
|
"Email": "john.smith@example.com",
|
|
794
792
|
"Password": "ExamplePassword123!",
|
|
795
|
-
"TenantID": "test-tenant"
|
|
796
|
-
"AppPoolID": "",
|
|
797
|
-
"GoogleIdToken": "",
|
|
798
|
-
"AppleIdToken": "",
|
|
799
|
-
"AppleCode": ""
|
|
793
|
+
"TenantID": "test-tenant"
|
|
800
794
|
}
|
|
801
795
|
}
|
|
802
796
|
```
|
|
@@ -817,12 +811,15 @@ Status:
|
|
|
817
811
|
"AccessToken": "eyJ_access_token_example",
|
|
818
812
|
"IDToken": "eyJ_id_token_example",
|
|
819
813
|
"EHR": "fhir",
|
|
814
|
+
"ErrorMessage": null,
|
|
820
815
|
"HasInsurance": false,
|
|
821
816
|
"HasIDCard": false,
|
|
822
817
|
"HasSelfie": false,
|
|
823
818
|
"Attributes": {
|
|
824
|
-
"EHR": "fhir"
|
|
819
|
+
"EHR": "fhir",
|
|
820
|
+
"Type": "PATIENT"
|
|
825
821
|
},
|
|
822
|
+
"ID": "john.smith@example.com",
|
|
826
823
|
"TenantID": "test-tenant",
|
|
827
824
|
"Expiration": "2030-01-01T00:00:00.000Z",
|
|
828
825
|
"Type": 0
|
|
@@ -836,21 +833,23 @@ Status:
|
|
|
836
833
|
|
|
837
834
|
### Reset Password
|
|
838
835
|
|
|
839
|
-
|
|
836
|
+
`resetPassword` supports both OTP-based and link-based reset initiation
|
|
837
|
+
flows.
|
|
838
|
+
|
|
839
|
+
`IsPasswordResetWithOTP` is optional. It is included in the request body only
|
|
840
|
+
when `isPasswordResetWithOTP` is `true`. When `false` or omitted, the field is
|
|
841
|
+
not sent at all and `false` is not serialized into the payload.
|
|
840
842
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
843
|
+
#### OTP-based password reset initiation
|
|
844
|
+
|
|
845
|
+
Use this when the password reset flow should be handled through an OTP code.
|
|
846
|
+
In this case, `IsPasswordResetWithOTP` should be `true`.
|
|
844
847
|
|
|
845
848
|
```ts
|
|
846
|
-
await loginClient.resetPassword(
|
|
847
|
-
"john.smith@example.com",
|
|
848
|
-
true
|
|
849
|
-
);
|
|
849
|
+
await loginClient.resetPassword("john.smith@example.com", true);
|
|
850
850
|
```
|
|
851
851
|
|
|
852
852
|
#### Full API request
|
|
853
|
-
Request sent for the usage example above:
|
|
854
853
|
|
|
855
854
|
```json
|
|
856
855
|
{
|
|
@@ -862,6 +861,27 @@ Request sent for the usage example above:
|
|
|
862
861
|
}
|
|
863
862
|
```
|
|
864
863
|
|
|
864
|
+
#### Link-based password reset initiation
|
|
865
|
+
|
|
866
|
+
Use this when the password reset flow should be handled from an email link.
|
|
867
|
+
In this case, `IsPasswordResetWithOTP` should be omitted by passing `false` or
|
|
868
|
+
leaving the second argument out.
|
|
869
|
+
|
|
870
|
+
```ts
|
|
871
|
+
await loginClient.resetPassword("john.smith@example.com", false);
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
Effective request body:
|
|
875
|
+
|
|
876
|
+
```json
|
|
877
|
+
{
|
|
878
|
+
"Data": {
|
|
879
|
+
"Email": "john.smith@example.com",
|
|
880
|
+
"TenantID": "test-tenant"
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
```
|
|
884
|
+
|
|
865
885
|
`Authorization: Bearer eyJ_id_token_example` may also be included when an ID token
|
|
866
886
|
is already stored.
|
|
867
887
|
|
|
@@ -885,23 +905,32 @@ Status:
|
|
|
885
905
|
|
|
886
906
|
### Reset Password Confirm
|
|
887
907
|
|
|
888
|
-
|
|
908
|
+
`resetPasswordConfirm` supports both OTP-based and link-based confirmation
|
|
909
|
+
flows.
|
|
910
|
+
|
|
911
|
+
If `IsPasswordResetWithOTP` is `true`, `Code` is required. If
|
|
912
|
+
`IsPasswordResetWithOTP` is not `true`, `Token` is required. For the
|
|
913
|
+
link-based flow, the frontend is responsible for taking the token from the
|
|
914
|
+
password reset email link and passing that token in the payload.
|
|
889
915
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
916
|
+
#### OTP-based password reset confirmation
|
|
917
|
+
|
|
918
|
+
Use this when the password reset flow was started with OTP. In this case,
|
|
919
|
+
`IsPasswordResetWithOTP` should be `true` and `Code` should contain the final
|
|
920
|
+
reset code.
|
|
893
921
|
|
|
894
922
|
```ts
|
|
895
|
-
await loginClient.resetPasswordConfirm(
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
923
|
+
await loginClient.resetPasswordConfirm({
|
|
924
|
+
Data: {
|
|
925
|
+
Email: "john.smith@example.com",
|
|
926
|
+
Password: "ExamplePassword123!",
|
|
927
|
+
IsPasswordResetWithOTP: true,
|
|
928
|
+
Code: "123456"
|
|
929
|
+
}
|
|
930
|
+
});
|
|
901
931
|
```
|
|
902
932
|
|
|
903
|
-
|
|
904
|
-
Request sent for the usage example above:
|
|
933
|
+
Request body:
|
|
905
934
|
|
|
906
935
|
```json
|
|
907
936
|
{
|
|
@@ -909,12 +938,42 @@ Request sent for the usage example above:
|
|
|
909
938
|
"Email": "john.smith@example.com",
|
|
910
939
|
"TenantID": "test-tenant",
|
|
911
940
|
"Password": "ExamplePassword123!",
|
|
912
|
-
"
|
|
941
|
+
"Code": "123456",
|
|
913
942
|
"IsPasswordResetWithOTP": true
|
|
914
943
|
}
|
|
915
944
|
}
|
|
916
945
|
```
|
|
917
946
|
|
|
947
|
+
#### Link-based password reset confirmation
|
|
948
|
+
|
|
949
|
+
Use this when the password reset flow was started from an email link. In this
|
|
950
|
+
case, `Token` should be included in the payload, the frontend should read the
|
|
951
|
+
token value from the password reset email link and send that token in the
|
|
952
|
+
request payload, and `IsPasswordResetWithOTP` should be omitted or `false`.
|
|
953
|
+
|
|
954
|
+
```ts
|
|
955
|
+
await loginClient.resetPasswordConfirm({
|
|
956
|
+
Data: {
|
|
957
|
+
Email: "john.smith@example.com",
|
|
958
|
+
Password: "ExamplePassword123!",
|
|
959
|
+
Token: "token-from-email-link"
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
Effective request body:
|
|
965
|
+
|
|
966
|
+
```json
|
|
967
|
+
{
|
|
968
|
+
"Data": {
|
|
969
|
+
"Email": "john.smith@example.com",
|
|
970
|
+
"TenantID": "test-tenant",
|
|
971
|
+
"Password": "ExamplePassword123!",
|
|
972
|
+
"Token": "token-from-email-link"
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
```
|
|
976
|
+
|
|
918
977
|
`Authorization: Bearer eyJ_id_token_example` may also be included when an ID token
|
|
919
978
|
is already stored.
|
|
920
979
|
|
|
@@ -975,6 +1034,13 @@ Status:
|
|
|
975
1034
|
"RefreshToken": "eyJ_refresh_token_example",
|
|
976
1035
|
"AccessToken": "eyJ_access_token_example",
|
|
977
1036
|
"IDToken": "eyJ_id_token_example",
|
|
1037
|
+
"EHR": null,
|
|
1038
|
+
"ErrorMessage": null,
|
|
1039
|
+
"HasInsurance": false,
|
|
1040
|
+
"HasIDCard": false,
|
|
1041
|
+
"HasSelfie": false,
|
|
1042
|
+
"Attributes": null,
|
|
1043
|
+
"ID": null,
|
|
978
1044
|
"TenantID": "test-tenant",
|
|
979
1045
|
"Expiration": "2030-01-01T00:00:00.000Z",
|
|
980
1046
|
"Type": 0
|
|
@@ -1237,17 +1303,12 @@ eyJ_id_token_example
|
|
|
1237
1303
|
|
|
1238
1304
|
## API Key
|
|
1239
1305
|
|
|
1240
|
-
|
|
1306
|
+
Use `setApiKey(...)` to attach an API key header to requests from `HCLoginClient`.
|
|
1241
1307
|
|
|
1242
1308
|
```ts
|
|
1243
1309
|
const apiKey = process.env.HEALTHCLOUD_API_KEY;
|
|
1244
|
-
|
|
1245
|
-
if (apiKey) {
|
|
1246
|
-
loginClient.setApiKey("x-api-key", apiKey);
|
|
1247
|
-
}
|
|
1310
|
+
loginClient.setApiKey("x-api-key", apiKey);
|
|
1248
1311
|
```
|
|
1249
1312
|
|
|
1250
1313
|
- Header name should be `x-api-key`.
|
|
1251
|
-
- API key is optional unless required by the backend.
|
|
1252
|
-
- If not set, behavior remains unchanged and the header is omitted.
|
|
1253
1314
|
- The header is applied to registration, onboarding, login, token refresh, password reset, and authenticated patient header requests.
|
package/dist/index.cjs
CHANGED
|
@@ -219,15 +219,9 @@ var HCLoginClient = class {
|
|
|
219
219
|
this.ensureConfigured();
|
|
220
220
|
const requestPayload = {
|
|
221
221
|
Data: {
|
|
222
|
-
FirstName: "",
|
|
223
|
-
LastName: "",
|
|
224
222
|
Email: email,
|
|
225
223
|
Password: password,
|
|
226
|
-
TenantID: this.config.tenantID
|
|
227
|
-
AppPoolID: "",
|
|
228
|
-
GoogleIdToken: "",
|
|
229
|
-
AppleIdToken: "",
|
|
230
|
-
AppleCode: ""
|
|
224
|
+
TenantID: this.config.tenantID
|
|
231
225
|
}
|
|
232
226
|
};
|
|
233
227
|
const resp = await this.http.post(
|
|
@@ -275,14 +269,14 @@ var HCLoginClient = class {
|
|
|
275
269
|
this.tokens = tokens;
|
|
276
270
|
return tokens;
|
|
277
271
|
}
|
|
278
|
-
async resetPassword(email, isPasswordResetWithOTP =
|
|
272
|
+
async resetPassword(email, isPasswordResetWithOTP = false) {
|
|
279
273
|
var _a;
|
|
280
274
|
this.ensureConfigured();
|
|
281
275
|
const requestPayload = {
|
|
282
276
|
Data: {
|
|
283
277
|
Email: email,
|
|
284
278
|
TenantID: this.config.tenantID,
|
|
285
|
-
IsPasswordResetWithOTP:
|
|
279
|
+
...isPasswordResetWithOTP === true ? { IsPasswordResetWithOTP: true } : {}
|
|
286
280
|
}
|
|
287
281
|
};
|
|
288
282
|
await this.http.post(
|
|
@@ -296,21 +290,24 @@ var HCLoginClient = class {
|
|
|
296
290
|
}
|
|
297
291
|
);
|
|
298
292
|
}
|
|
299
|
-
async resetPasswordConfirm(
|
|
293
|
+
async resetPasswordConfirm(payload) {
|
|
300
294
|
var _a;
|
|
301
295
|
this.ensureConfigured();
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
};
|
|
296
|
+
const isOtpFlow = payload.Data.IsPasswordResetWithOTP === true;
|
|
297
|
+
if (isOtpFlow && !payload.Data.Code) {
|
|
298
|
+
throw new Error("Code is required for OTP password reset confirmation.");
|
|
299
|
+
}
|
|
300
|
+
if (!isOtpFlow && !payload.Data.Token) {
|
|
301
|
+
throw new Error("Token is required for link-based password reset confirmation.");
|
|
302
|
+
}
|
|
311
303
|
await this.http.post(
|
|
312
304
|
`${this.config.baseUrl}/patient/password`,
|
|
313
|
-
|
|
305
|
+
{
|
|
306
|
+
Data: {
|
|
307
|
+
...payload.Data,
|
|
308
|
+
TenantID: this.config.tenantID
|
|
309
|
+
}
|
|
310
|
+
},
|
|
314
311
|
{
|
|
315
312
|
"Content-Type": "application/json",
|
|
316
313
|
"X-Tenant-ID": this.config.tenantID,
|
package/dist/index.d.cts
CHANGED
|
@@ -39,17 +39,26 @@ interface VerifyEmailOptions {
|
|
|
39
39
|
attributes?: Record<string, string>;
|
|
40
40
|
}
|
|
41
41
|
interface LoginBody {
|
|
42
|
-
FirstName
|
|
43
|
-
LastName
|
|
42
|
+
FirstName?: string;
|
|
43
|
+
LastName?: string;
|
|
44
44
|
Email: string;
|
|
45
|
+
UserName?: string;
|
|
45
46
|
Password: string;
|
|
46
|
-
|
|
47
|
-
AppPoolID
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
PoolID?: string;
|
|
48
|
+
AppPoolID?: string;
|
|
49
|
+
AppClientID?: string;
|
|
50
|
+
TenantID?: string;
|
|
51
|
+
Token?: string;
|
|
52
|
+
Type?: number;
|
|
53
|
+
AppleIdToken?: string;
|
|
54
|
+
AppleCode?: string;
|
|
55
|
+
GoogleIdToken?: string;
|
|
56
|
+
IsPasswordResetWithOTP?: boolean;
|
|
57
|
+
Code?: string;
|
|
58
|
+
Language?: string;
|
|
51
59
|
}
|
|
52
60
|
type LoginRequest = ApiRequest<LoginBody>;
|
|
61
|
+
type LoginPayload = LoginRequest;
|
|
53
62
|
interface RefreshBody {
|
|
54
63
|
RefreshToken: string;
|
|
55
64
|
TenantID: string;
|
|
@@ -58,17 +67,24 @@ type RefreshRequest = ApiRequest<RefreshBody>;
|
|
|
58
67
|
interface ResetBody {
|
|
59
68
|
Email: string;
|
|
60
69
|
TenantID: string;
|
|
61
|
-
IsPasswordResetWithOTP
|
|
70
|
+
IsPasswordResetWithOTP?: boolean;
|
|
62
71
|
}
|
|
63
72
|
type ResetRequest = ApiRequest<ResetBody>;
|
|
64
|
-
|
|
73
|
+
type ResetConfirmBody = {
|
|
65
74
|
Email: string;
|
|
66
|
-
TenantID: string;
|
|
67
75
|
Password: string;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
IsPasswordResetWithOTP: true;
|
|
77
|
+
Code: string;
|
|
78
|
+
Token?: string;
|
|
79
|
+
} | {
|
|
80
|
+
Email: string;
|
|
81
|
+
Password: string;
|
|
82
|
+
Token: string;
|
|
83
|
+
IsPasswordResetWithOTP?: false;
|
|
84
|
+
Code?: string;
|
|
85
|
+
};
|
|
71
86
|
type ResetConfirmRequest = ApiRequest<ResetConfirmBody>;
|
|
87
|
+
type ResetPasswordConfirmPayload = ResetConfirmRequest;
|
|
72
88
|
interface RegisterCredentials {
|
|
73
89
|
Email: string;
|
|
74
90
|
Password: string;
|
|
@@ -204,7 +220,7 @@ declare class HCLoginClient {
|
|
|
204
220
|
login(email: string, password: string): Promise<AuthTokens>;
|
|
205
221
|
refreshToken(): Promise<AuthTokens>;
|
|
206
222
|
resetPassword(email: string, isPasswordResetWithOTP?: boolean): Promise<void>;
|
|
207
|
-
resetPasswordConfirm(
|
|
223
|
+
resetPasswordConfirm(payload: ResetPasswordConfirmPayload): Promise<void>;
|
|
208
224
|
getAccessToken(): string | undefined;
|
|
209
225
|
getIDToken(): string | undefined;
|
|
210
226
|
getUserInfo(): Promise<unknown>;
|
|
@@ -234,4 +250,4 @@ declare class HttpError extends Error {
|
|
|
234
250
|
constructor(status: number, message: string);
|
|
235
251
|
}
|
|
236
252
|
|
|
237
|
-
export { type Address, type ApiRequest, AuthError, type AuthTokens, ConfigError, type Environment, HCLoginClient, type HealthProfile, HttpError, type LoginBody, type LoginConfig, type LoginRequest, type OnboardBody, type OnboardInput, type OnboardRequest, type OnboardUser, type OnboardingStep, type RefreshBody, type RefreshRequest, type Region, type RegisterAttributes, type RegisterBody, type RegisterCredentials, type RegisterFullBody, type RegisterFullOptions, type RegisterFullRequest, type RegisterFullUser, type RegisterOptions, type RegisterOpts, type RegisterRequest, type RegisterUser, type ResetBody, type ResetConfirmBody, type ResetConfirmRequest, type ResetRequest, type SmsData, type UserInfo, type VerifyEmailOptions };
|
|
253
|
+
export { type Address, type ApiRequest, AuthError, type AuthTokens, ConfigError, type Environment, HCLoginClient, type HealthProfile, HttpError, type LoginBody, type LoginConfig, type LoginPayload, type LoginRequest, type OnboardBody, type OnboardInput, type OnboardRequest, type OnboardUser, type OnboardingStep, type RefreshBody, type RefreshRequest, type Region, type RegisterAttributes, type RegisterBody, type RegisterCredentials, type RegisterFullBody, type RegisterFullOptions, type RegisterFullRequest, type RegisterFullUser, type RegisterOptions, type RegisterOpts, type RegisterRequest, type RegisterUser, type ResetBody, type ResetConfirmBody, type ResetConfirmRequest, type ResetPasswordConfirmPayload, type ResetRequest, type SmsData, type UserInfo, type VerifyEmailOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,17 +39,26 @@ interface VerifyEmailOptions {
|
|
|
39
39
|
attributes?: Record<string, string>;
|
|
40
40
|
}
|
|
41
41
|
interface LoginBody {
|
|
42
|
-
FirstName
|
|
43
|
-
LastName
|
|
42
|
+
FirstName?: string;
|
|
43
|
+
LastName?: string;
|
|
44
44
|
Email: string;
|
|
45
|
+
UserName?: string;
|
|
45
46
|
Password: string;
|
|
46
|
-
|
|
47
|
-
AppPoolID
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
PoolID?: string;
|
|
48
|
+
AppPoolID?: string;
|
|
49
|
+
AppClientID?: string;
|
|
50
|
+
TenantID?: string;
|
|
51
|
+
Token?: string;
|
|
52
|
+
Type?: number;
|
|
53
|
+
AppleIdToken?: string;
|
|
54
|
+
AppleCode?: string;
|
|
55
|
+
GoogleIdToken?: string;
|
|
56
|
+
IsPasswordResetWithOTP?: boolean;
|
|
57
|
+
Code?: string;
|
|
58
|
+
Language?: string;
|
|
51
59
|
}
|
|
52
60
|
type LoginRequest = ApiRequest<LoginBody>;
|
|
61
|
+
type LoginPayload = LoginRequest;
|
|
53
62
|
interface RefreshBody {
|
|
54
63
|
RefreshToken: string;
|
|
55
64
|
TenantID: string;
|
|
@@ -58,17 +67,24 @@ type RefreshRequest = ApiRequest<RefreshBody>;
|
|
|
58
67
|
interface ResetBody {
|
|
59
68
|
Email: string;
|
|
60
69
|
TenantID: string;
|
|
61
|
-
IsPasswordResetWithOTP
|
|
70
|
+
IsPasswordResetWithOTP?: boolean;
|
|
62
71
|
}
|
|
63
72
|
type ResetRequest = ApiRequest<ResetBody>;
|
|
64
|
-
|
|
73
|
+
type ResetConfirmBody = {
|
|
65
74
|
Email: string;
|
|
66
|
-
TenantID: string;
|
|
67
75
|
Password: string;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
IsPasswordResetWithOTP: true;
|
|
77
|
+
Code: string;
|
|
78
|
+
Token?: string;
|
|
79
|
+
} | {
|
|
80
|
+
Email: string;
|
|
81
|
+
Password: string;
|
|
82
|
+
Token: string;
|
|
83
|
+
IsPasswordResetWithOTP?: false;
|
|
84
|
+
Code?: string;
|
|
85
|
+
};
|
|
71
86
|
type ResetConfirmRequest = ApiRequest<ResetConfirmBody>;
|
|
87
|
+
type ResetPasswordConfirmPayload = ResetConfirmRequest;
|
|
72
88
|
interface RegisterCredentials {
|
|
73
89
|
Email: string;
|
|
74
90
|
Password: string;
|
|
@@ -204,7 +220,7 @@ declare class HCLoginClient {
|
|
|
204
220
|
login(email: string, password: string): Promise<AuthTokens>;
|
|
205
221
|
refreshToken(): Promise<AuthTokens>;
|
|
206
222
|
resetPassword(email: string, isPasswordResetWithOTP?: boolean): Promise<void>;
|
|
207
|
-
resetPasswordConfirm(
|
|
223
|
+
resetPasswordConfirm(payload: ResetPasswordConfirmPayload): Promise<void>;
|
|
208
224
|
getAccessToken(): string | undefined;
|
|
209
225
|
getIDToken(): string | undefined;
|
|
210
226
|
getUserInfo(): Promise<unknown>;
|
|
@@ -234,4 +250,4 @@ declare class HttpError extends Error {
|
|
|
234
250
|
constructor(status: number, message: string);
|
|
235
251
|
}
|
|
236
252
|
|
|
237
|
-
export { type Address, type ApiRequest, AuthError, type AuthTokens, ConfigError, type Environment, HCLoginClient, type HealthProfile, HttpError, type LoginBody, type LoginConfig, type LoginRequest, type OnboardBody, type OnboardInput, type OnboardRequest, type OnboardUser, type OnboardingStep, type RefreshBody, type RefreshRequest, type Region, type RegisterAttributes, type RegisterBody, type RegisterCredentials, type RegisterFullBody, type RegisterFullOptions, type RegisterFullRequest, type RegisterFullUser, type RegisterOptions, type RegisterOpts, type RegisterRequest, type RegisterUser, type ResetBody, type ResetConfirmBody, type ResetConfirmRequest, type ResetRequest, type SmsData, type UserInfo, type VerifyEmailOptions };
|
|
253
|
+
export { type Address, type ApiRequest, AuthError, type AuthTokens, ConfigError, type Environment, HCLoginClient, type HealthProfile, HttpError, type LoginBody, type LoginConfig, type LoginPayload, type LoginRequest, type OnboardBody, type OnboardInput, type OnboardRequest, type OnboardUser, type OnboardingStep, type RefreshBody, type RefreshRequest, type Region, type RegisterAttributes, type RegisterBody, type RegisterCredentials, type RegisterFullBody, type RegisterFullOptions, type RegisterFullRequest, type RegisterFullUser, type RegisterOptions, type RegisterOpts, type RegisterRequest, type RegisterUser, type ResetBody, type ResetConfirmBody, type ResetConfirmRequest, type ResetPasswordConfirmPayload, type ResetRequest, type SmsData, type UserInfo, type VerifyEmailOptions };
|
package/dist/index.js
CHANGED
|
@@ -190,15 +190,9 @@ var HCLoginClient = class {
|
|
|
190
190
|
this.ensureConfigured();
|
|
191
191
|
const requestPayload = {
|
|
192
192
|
Data: {
|
|
193
|
-
FirstName: "",
|
|
194
|
-
LastName: "",
|
|
195
193
|
Email: email,
|
|
196
194
|
Password: password,
|
|
197
|
-
TenantID: this.config.tenantID
|
|
198
|
-
AppPoolID: "",
|
|
199
|
-
GoogleIdToken: "",
|
|
200
|
-
AppleIdToken: "",
|
|
201
|
-
AppleCode: ""
|
|
195
|
+
TenantID: this.config.tenantID
|
|
202
196
|
}
|
|
203
197
|
};
|
|
204
198
|
const resp = await this.http.post(
|
|
@@ -246,14 +240,14 @@ var HCLoginClient = class {
|
|
|
246
240
|
this.tokens = tokens;
|
|
247
241
|
return tokens;
|
|
248
242
|
}
|
|
249
|
-
async resetPassword(email, isPasswordResetWithOTP =
|
|
243
|
+
async resetPassword(email, isPasswordResetWithOTP = false) {
|
|
250
244
|
var _a;
|
|
251
245
|
this.ensureConfigured();
|
|
252
246
|
const requestPayload = {
|
|
253
247
|
Data: {
|
|
254
248
|
Email: email,
|
|
255
249
|
TenantID: this.config.tenantID,
|
|
256
|
-
IsPasswordResetWithOTP:
|
|
250
|
+
...isPasswordResetWithOTP === true ? { IsPasswordResetWithOTP: true } : {}
|
|
257
251
|
}
|
|
258
252
|
};
|
|
259
253
|
await this.http.post(
|
|
@@ -267,21 +261,24 @@ var HCLoginClient = class {
|
|
|
267
261
|
}
|
|
268
262
|
);
|
|
269
263
|
}
|
|
270
|
-
async resetPasswordConfirm(
|
|
264
|
+
async resetPasswordConfirm(payload) {
|
|
271
265
|
var _a;
|
|
272
266
|
this.ensureConfigured();
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
};
|
|
267
|
+
const isOtpFlow = payload.Data.IsPasswordResetWithOTP === true;
|
|
268
|
+
if (isOtpFlow && !payload.Data.Code) {
|
|
269
|
+
throw new Error("Code is required for OTP password reset confirmation.");
|
|
270
|
+
}
|
|
271
|
+
if (!isOtpFlow && !payload.Data.Token) {
|
|
272
|
+
throw new Error("Token is required for link-based password reset confirmation.");
|
|
273
|
+
}
|
|
282
274
|
await this.http.post(
|
|
283
275
|
`${this.config.baseUrl}/patient/password`,
|
|
284
|
-
|
|
276
|
+
{
|
|
277
|
+
Data: {
|
|
278
|
+
...payload.Data,
|
|
279
|
+
TenantID: this.config.tenantID
|
|
280
|
+
}
|
|
281
|
+
},
|
|
285
282
|
{
|
|
286
283
|
"Content-Type": "application/json",
|
|
287
284
|
"X-Tenant-ID": this.config.tenantID,
|
package/package.json
CHANGED