Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit 9cda28d

Browse files
committed
Enhanced client to make use of forgot password and refresh token functionality
1 parent 73b910b commit 9cda28d

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.5.0
2+
3+
- Added capability to interface with forgot password functionality
4+
- Added capability to interface with refresh token functionality
5+
16
# 0.4.1
27

38
- Removed api version header

src/apis/security/client.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ export interface UpdatePasswordForm {
2020
newPassword: string;
2121
}
2222

23+
export type RefreshTokenRequest = RequestWithBody<RefreshTokenForm>;
24+
25+
export interface RefreshTokenForm {
26+
refreshToken: string;
27+
}
28+
29+
export type InitializeForgotPasswordRequest = RequestWithBody<
30+
InitializeForgotPasswordForm
31+
>;
32+
33+
export interface InitializeForgotPasswordForm {
34+
username: string;
35+
}
36+
37+
export type ConfirmForgotPasswordRequest = RequestWithBody<
38+
ConfirmForgotPasswordForm
39+
>;
40+
41+
export interface ConfirmForgotPasswordForm {
42+
username: string;
43+
newPassword: string;
44+
confirmationCode: string;
45+
}
46+
2347
export class SecurityClient extends BaseClient {
2448
constructor(config: ClientConfig, axiosInstance: AxiosInstance = axios) {
2549
super(config, axiosInstance);
@@ -44,4 +68,35 @@ export class SecurityClient extends BaseClient {
4468
headers: config.headers,
4569
});
4670
}
71+
72+
refresh(request: RefreshTokenRequest): Promise<AxiosResponse<LoginResponse>> {
73+
const config = this.config.merge(request as PortfolioRequest);
74+
const url = `${config.host}/security/refresh`;
75+
76+
return this.axiosInstance.post<LoginResponse>(url, request.body, {
77+
headers: config.headers,
78+
});
79+
}
80+
81+
initForgotPassword(
82+
request: InitializeForgotPasswordRequest
83+
): Promise<AxiosResponse<PortfolioResponse>> {
84+
const config = this.config.merge(request as PortfolioRequest);
85+
const url = `${config.host}/security/init-forgot-password`;
86+
87+
return this.axiosInstance.post<PortfolioResponse>(url, request.body, {
88+
headers: config.headers,
89+
});
90+
}
91+
92+
confirmForgotPassword(
93+
request: ConfirmForgotPasswordRequest
94+
): Promise<AxiosResponse<PortfolioResponse>> {
95+
const config = this.config.merge(request as PortfolioRequest);
96+
const url = `${config.host}/security/confirm-forgot-password`;
97+
98+
return this.axiosInstance.post<PortfolioResponse>(url, request.body, {
99+
headers: config.headers,
100+
});
101+
}
47102
}

src/common/response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export interface ErrorDetail {
1717
}
1818

1919
export interface PaginationDetails {
20-
page: number;
21-
limit: number;
20+
page?: number;
21+
limit?: number;
2222
}

0 commit comments

Comments
 (0)