@nabdelfattah/ngx-iam-auth 0.0.0-stage → 0.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/README.md +64 -3
- package/fesm2022/nabdelfattah-ngx-iam-auth.mjs +91 -0
- package/fesm2022/nabdelfattah-ngx-iam-auth.mjs.map +1 -0
- package/fesm2022/ngx-iam-auth.mjs +91 -0
- package/fesm2022/ngx-iam-auth.mjs.map +1 -0
- package/package.json +29 -3
- package/types/nabdelfattah-ngx-iam-auth.d.ts +117 -0
- package/types/ngx-iam-auth.d.ts +117 -0
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
This
|
|
1
|
+
# NgxIamAuth
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build ngx-iam-auth
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd dist/ngx-iam-auth
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
40
|
+
```bash
|
|
41
|
+
npm publish
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Running unit tests
|
|
45
|
+
|
|
46
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ng test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Running end-to-end tests
|
|
53
|
+
|
|
54
|
+
For end-to-end (e2e) testing, run:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ng e2e
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
61
|
+
|
|
62
|
+
## Additional Resources
|
|
63
|
+
|
|
64
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, InjectionToken, inject } from '@angular/core';
|
|
3
|
+
import { HttpClient } from '@angular/common/http';
|
|
4
|
+
import { map } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
const baseUrl = 'https://exam-app.elevate-bootcamp.cloud';
|
|
7
|
+
class AuthEndPoints {
|
|
8
|
+
static LOGIN = 'auth/login';
|
|
9
|
+
static REGISTER = 'auth/register';
|
|
10
|
+
static VERIFY_EMAIL = 'auth/send-email-verification';
|
|
11
|
+
static CONFIRM_EMAIL = 'auth/confirm-email-verification';
|
|
12
|
+
static FORGET_PASSWORD = 'auth/forgot-password';
|
|
13
|
+
static RESET_PASSWORD = 'auth/reset-password';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class AuthAdaptorService {
|
|
17
|
+
adapt(data) {
|
|
18
|
+
const { user, token } = data.payload;
|
|
19
|
+
return {
|
|
20
|
+
username: user.username,
|
|
21
|
+
email: user.email,
|
|
22
|
+
phone: user.phone,
|
|
23
|
+
firstName: user.firstName,
|
|
24
|
+
lastName: user.lastName,
|
|
25
|
+
role: user.role,
|
|
26
|
+
token,
|
|
27
|
+
...(user.profilePhoto && { profilePhoto: user.profilePhoto }),
|
|
28
|
+
...(user.gender && { gender: user.gender }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthAdaptorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
32
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthAdaptorService, providedIn: 'root' });
|
|
33
|
+
}
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthAdaptorService, decorators: [{
|
|
35
|
+
type: Injectable,
|
|
36
|
+
args: [{
|
|
37
|
+
providedIn: 'root',
|
|
38
|
+
}]
|
|
39
|
+
}] });
|
|
40
|
+
|
|
41
|
+
const IAM_AUTH_CONFIG = new InjectionToken('IAM_AUTH_CONFIG');
|
|
42
|
+
function provideIamAuth(config) {
|
|
43
|
+
return [{ provide: IAM_AUTH_CONFIG, useValue: config }];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class AuthService {
|
|
47
|
+
httpClient = inject(HttpClient);
|
|
48
|
+
authAdaptorService = inject(AuthAdaptorService);
|
|
49
|
+
config = inject(IAM_AUTH_CONFIG);
|
|
50
|
+
verifyEmail(data) {
|
|
51
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.VERIFY_EMAIL, data);
|
|
52
|
+
}
|
|
53
|
+
confirmEmail(data) {
|
|
54
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.CONFIRM_EMAIL, data);
|
|
55
|
+
}
|
|
56
|
+
register(data) {
|
|
57
|
+
return this.httpClient
|
|
58
|
+
.post(this.config.baseUrl + AuthEndPoints.REGISTER, data)
|
|
59
|
+
.pipe(map((res) => this.authAdaptorService.adapt(res)));
|
|
60
|
+
}
|
|
61
|
+
login(data) {
|
|
62
|
+
return this.httpClient
|
|
63
|
+
.post(this.config.baseUrl + AuthEndPoints.LOGIN, data)
|
|
64
|
+
.pipe(map((res) => this.authAdaptorService.adapt(res)));
|
|
65
|
+
}
|
|
66
|
+
forgetPassword(data) {
|
|
67
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.FORGET_PASSWORD, data);
|
|
68
|
+
}
|
|
69
|
+
resetPassword(data) {
|
|
70
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.RESET_PASSWORD, data);
|
|
71
|
+
}
|
|
72
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
73
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
74
|
+
}
|
|
75
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthService, decorators: [{
|
|
76
|
+
type: Injectable,
|
|
77
|
+
args: [{
|
|
78
|
+
providedIn: 'root',
|
|
79
|
+
}]
|
|
80
|
+
}] });
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* Public API Surface of ngx-iam-auth
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Generated bundle index. Do not edit.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
export { AuthService, IAM_AUTH_CONFIG, provideIamAuth };
|
|
91
|
+
//# sourceMappingURL=nabdelfattah-ngx-iam-auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nabdelfattah-ngx-iam-auth.mjs","sources":["../../../projects/ngx-iam-auth/src/lib/enum/auth-end-points.ts","../../../projects/ngx-iam-auth/src/lib/adaptor/auth-adaptor.service.ts","../../../projects/ngx-iam-auth/src/lib/config/iam-auth.config.ts","../../../projects/ngx-iam-auth/src/lib/services/auth.service.ts","../../../projects/ngx-iam-auth/src/public-api.ts","../../../projects/ngx-iam-auth/src/nabdelfattah-ngx-iam-auth.ts"],"sourcesContent":["const baseUrl = 'https://exam-app.elevate-bootcamp.cloud' as const;\r\n\r\nexport default class AuthEndPoints {\r\n static readonly LOGIN = 'auth/login';\r\n static readonly REGISTER = 'auth/register';\r\n static readonly VERIFY_EMAIL = 'auth/send-email-verification';\r\n static readonly CONFIRM_EMAIL = 'auth/confirm-email-verification';\r\n static readonly FORGET_PASSWORD = 'auth/forgot-password';\r\n static readonly RESET_PASSWORD = 'auth/reset-password';\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { Adaptor } from '../interfaces/adaptor.interface';\r\nimport { LoginRes, LoginRowRes } from '../interfaces/login.interface';\r\nimport { RegisterRes, RegisterRowRes } from '../interfaces/register.interface';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class AuthAdaptorService implements Adaptor {\r\n adapt(data: LoginRowRes | RegisterRowRes): LoginRes | RegisterRes {\r\n const { user, token } = data.payload;\r\n return {\r\n username: user.username,\r\n email: user.email,\r\n phone: user.phone,\r\n firstName: user.firstName,\r\n lastName: user.lastName,\r\n role: user.role,\r\n token,\r\n ...(user.profilePhoto && { profilePhoto: user.profilePhoto }),\r\n ...(user.gender && { gender: user.gender }),\r\n };\r\n }\r\n}\r\n","import { InjectionToken } from '@angular/core';\r\n\r\nexport interface IamAuthConfig {\r\n baseUrl: string;\r\n}\r\n\r\nexport const IAM_AUTH_CONFIG = new InjectionToken<IamAuthConfig>('IAM_AUTH_CONFIG');\r\n\r\nexport function provideIamAuth(config: IamAuthConfig) {\r\n return [{ provide: IAM_AUTH_CONFIG, useValue: config }];\r\n}\r\n","import { inject, Injectable } from '@angular/core';\r\nimport AuthApi from '../base/auth-api';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport AuthEndPoints from '../enum/auth-end-points';\r\nimport { AuthAdaptorService } from '../adaptor/auth-adaptor.service';\r\nimport { map } from 'rxjs';\r\nimport { LoginReq, LoginRes, LoginRowRes } from '../interfaces/login.interface';\r\nimport { VerifyEmailReq, VerifyEmailRes } from '../interfaces/verify-email.interface';\r\nimport { RegisterReq, RegisterRes, RegisterRowRes } from '../interfaces/register.interface';\r\nimport { ConfirmEmailReq, ConfirmEmailRes } from '../interfaces/confirm-email.interface';\r\nimport { ForgetPasswordReq, ForgetPasswordRes } from '../interfaces/forget-password.interface';\r\nimport { ResetPasswordReq, ResetPasswordRes } from '../interfaces/reset-password.interface';\r\nimport { IAM_AUTH_CONFIG } from '../config/iam-auth.config';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class AuthService implements AuthApi {\r\n private readonly httpClient = inject(HttpClient);\r\n private readonly authAdaptorService = inject(AuthAdaptorService);\r\n private readonly config = inject(IAM_AUTH_CONFIG);\r\n\r\n verifyEmail(data: VerifyEmailReq): Observable<VerifyEmailRes> {\r\n return this.httpClient.post<VerifyEmailRes>(\r\n this.config.baseUrl + AuthEndPoints.VERIFY_EMAIL,\r\n data,\r\n );\r\n }\r\n\r\n confirmEmail(data: ConfirmEmailReq): Observable<ConfirmEmailRes> {\r\n return this.httpClient.post<ConfirmEmailRes>(\r\n this.config.baseUrl + AuthEndPoints.CONFIRM_EMAIL,\r\n data,\r\n );\r\n }\r\n\r\n register(data: RegisterReq): Observable<RegisterRes> {\r\n return this.httpClient\r\n .post<RegisterRowRes>(this.config.baseUrl + AuthEndPoints.REGISTER, data)\r\n .pipe(map((res: RegisterRowRes) => this.authAdaptorService.adapt(res)));\r\n }\r\n\r\n login(data: LoginReq): Observable<LoginRes> {\r\n return this.httpClient\r\n .post<LoginRowRes>(this.config.baseUrl + AuthEndPoints.LOGIN, data)\r\n .pipe(map((res: LoginRowRes) => this.authAdaptorService.adapt(res)));\r\n }\r\n\r\n forgetPassword(data: ForgetPasswordReq): Observable<ForgetPasswordRes> {\r\n return this.httpClient.post<ForgetPasswordRes>(\r\n this.config.baseUrl + AuthEndPoints.FORGET_PASSWORD,\r\n data,\r\n );\r\n }\r\n\r\n resetPassword(data: ResetPasswordReq): Observable<ResetPasswordRes> {\r\n return this.httpClient.post<ResetPasswordRes>(\r\n this.config.baseUrl + AuthEndPoints.RESET_PASSWORD,\r\n data,\r\n );\r\n }\r\n}\r\n","/*\r\n * Public API Surface of ngx-iam-auth\r\n */\r\n\r\nexport * from './lib/services/auth.service';\r\nexport * from './lib/config/iam-auth.config';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA,MAAM,OAAO,GAAG,yCAAkD;AAEpD,MAAO,aAAa,CAAA;AAChC,IAAA,OAAgB,KAAK,GAAG,YAAY;AACpC,IAAA,OAAgB,QAAQ,GAAG,eAAe;AAC1C,IAAA,OAAgB,YAAY,GAAG,8BAA8B;AAC7D,IAAA,OAAgB,aAAa,GAAG,iCAAiC;AACjE,IAAA,OAAgB,eAAe,GAAG,sBAAsB;AACxD,IAAA,OAAgB,cAAc,GAAG,qBAAqB;;;MCA3C,kBAAkB,CAAA;AAC7B,IAAA,KAAK,CAAC,IAAkC,EAAA;QACtC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO;QACpC,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK;AACL,YAAA,IAAI,IAAI,CAAC,YAAY,IAAI,EA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AAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACjBD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, InjectionToken, inject } from '@angular/core';
|
|
3
|
+
import { HttpClient } from '@angular/common/http';
|
|
4
|
+
import { map } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
const baseUrl = 'https://exam-app.elevate-bootcamp.cloud';
|
|
7
|
+
class AuthEndPoints {
|
|
8
|
+
static LOGIN = 'auth/login';
|
|
9
|
+
static REGISTER = 'auth/register';
|
|
10
|
+
static VERIFY_EMAIL = 'auth/send-email-verification';
|
|
11
|
+
static CONFIRM_EMAIL = 'auth/confirm-email-verification';
|
|
12
|
+
static FORGET_PASSWORD = 'auth/forgot-password';
|
|
13
|
+
static RESET_PASSWORD = 'auth/reset-password';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class AuthAdaptorService {
|
|
17
|
+
adapt(data) {
|
|
18
|
+
const { user, token } = data.payload;
|
|
19
|
+
return {
|
|
20
|
+
username: user.username,
|
|
21
|
+
email: user.email,
|
|
22
|
+
phone: user.phone,
|
|
23
|
+
firstName: user.firstName,
|
|
24
|
+
lastName: user.lastName,
|
|
25
|
+
role: user.role,
|
|
26
|
+
token,
|
|
27
|
+
...(user.profilePhoto && { profilePhoto: user.profilePhoto }),
|
|
28
|
+
...(user.gender && { gender: user.gender }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthAdaptorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
32
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthAdaptorService, providedIn: 'root' });
|
|
33
|
+
}
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthAdaptorService, decorators: [{
|
|
35
|
+
type: Injectable,
|
|
36
|
+
args: [{
|
|
37
|
+
providedIn: 'root',
|
|
38
|
+
}]
|
|
39
|
+
}] });
|
|
40
|
+
|
|
41
|
+
const IAM_AUTH_CONFIG = new InjectionToken('IAM_AUTH_CONFIG');
|
|
42
|
+
function provideIamAuth(config) {
|
|
43
|
+
return [{ provide: IAM_AUTH_CONFIG, useValue: config }];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class AuthService {
|
|
47
|
+
httpClient = inject(HttpClient);
|
|
48
|
+
authAdaptorService = inject(AuthAdaptorService);
|
|
49
|
+
config = inject(IAM_AUTH_CONFIG);
|
|
50
|
+
verifyEmail(data) {
|
|
51
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.VERIFY_EMAIL, data);
|
|
52
|
+
}
|
|
53
|
+
confirmEmail(data) {
|
|
54
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.CONFIRM_EMAIL, data);
|
|
55
|
+
}
|
|
56
|
+
register(data) {
|
|
57
|
+
return this.httpClient
|
|
58
|
+
.post(this.config.baseUrl + AuthEndPoints.REGISTER, data)
|
|
59
|
+
.pipe(map((res) => this.authAdaptorService.adapt(res)));
|
|
60
|
+
}
|
|
61
|
+
login(data) {
|
|
62
|
+
return this.httpClient
|
|
63
|
+
.post(this.config.baseUrl + AuthEndPoints.LOGIN, data)
|
|
64
|
+
.pipe(map((res) => this.authAdaptorService.adapt(res)));
|
|
65
|
+
}
|
|
66
|
+
forgetPassword(data) {
|
|
67
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.FORGET_PASSWORD, data);
|
|
68
|
+
}
|
|
69
|
+
resetPassword(data) {
|
|
70
|
+
return this.httpClient.post(this.config.baseUrl + AuthEndPoints.RESET_PASSWORD, data);
|
|
71
|
+
}
|
|
72
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
73
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
74
|
+
}
|
|
75
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: AuthService, decorators: [{
|
|
76
|
+
type: Injectable,
|
|
77
|
+
args: [{
|
|
78
|
+
providedIn: 'root',
|
|
79
|
+
}]
|
|
80
|
+
}] });
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* Public API Surface of ngx-iam-auth
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Generated bundle index. Do not edit.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
export { AuthService, IAM_AUTH_CONFIG, provideIamAuth };
|
|
91
|
+
//# sourceMappingURL=ngx-iam-auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-iam-auth.mjs","sources":["../../../projects/ngx-iam-auth/src/lib/enum/auth-end-points.ts","../../../projects/ngx-iam-auth/src/lib/adaptor/auth-adaptor.service.ts","../../../projects/ngx-iam-auth/src/lib/config/iam-auth.config.ts","../../../projects/ngx-iam-auth/src/lib/services/auth.service.ts","../../../projects/ngx-iam-auth/src/public-api.ts","../../../projects/ngx-iam-auth/src/ngx-iam-auth.ts"],"sourcesContent":["const baseUrl = 'https://exam-app.elevate-bootcamp.cloud' as const;\r\n\r\nexport default class AuthEndPoints {\r\n static readonly LOGIN = 'auth/login';\r\n static readonly REGISTER = 'auth/register';\r\n static readonly VERIFY_EMAIL = 'auth/send-email-verification';\r\n static readonly CONFIRM_EMAIL = 'auth/confirm-email-verification';\r\n static readonly FORGET_PASSWORD = 'auth/forgot-password';\r\n static readonly RESET_PASSWORD = 'auth/reset-password';\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { Adaptor } from '../interfaces/adaptor.interface';\r\nimport { LoginRes, LoginRowRes } from '../interfaces/login.interface';\r\nimport { RegisterRes, RegisterRowRes } from '../interfaces/register.interface';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class AuthAdaptorService implements Adaptor {\r\n adapt(data: LoginRowRes | RegisterRowRes): LoginRes | RegisterRes {\r\n const { user, token } = data.payload;\r\n return {\r\n username: user.username,\r\n email: user.email,\r\n phone: user.phone,\r\n firstName: user.firstName,\r\n lastName: user.lastName,\r\n role: user.role,\r\n token,\r\n ...(user.profilePhoto && { profilePhoto: user.profilePhoto }),\r\n ...(user.gender && { gender: user.gender }),\r\n };\r\n }\r\n}\r\n","import { InjectionToken } from '@angular/core';\r\n\r\nexport interface IamAuthConfig {\r\n baseUrl: string;\r\n}\r\n\r\nexport const IAM_AUTH_CONFIG = new InjectionToken<IamAuthConfig>('IAM_AUTH_CONFIG');\r\n\r\nexport function provideIamAuth(config: IamAuthConfig) {\r\n return [{ provide: IAM_AUTH_CONFIG, useValue: config }];\r\n}\r\n","import { inject, Injectable } from '@angular/core';\r\nimport AuthApi from '../base/auth-api';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport AuthEndPoints from '../enum/auth-end-points';\r\nimport { AuthAdaptorService } from '../adaptor/auth-adaptor.service';\r\nimport { map } from 'rxjs';\r\nimport { LoginReq, LoginRes, LoginRowRes } from '../interfaces/login.interface';\r\nimport { VerifyEmailReq, VerifyEmailRes } from '../interfaces/verify-email.interface';\r\nimport { RegisterReq, RegisterRes, RegisterRowRes } from '../interfaces/register.interface';\r\nimport { ConfirmEmailReq, ConfirmEmailRes } from '../interfaces/confirm-email.interface';\r\nimport { ForgetPasswordReq, ForgetPasswordRes } from '../interfaces/forget-password.interface';\r\nimport { ResetPasswordReq, ResetPasswordRes } from '../interfaces/reset-password.interface';\r\nimport { IAM_AUTH_CONFIG } from '../config/iam-auth.config';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class AuthService implements AuthApi {\r\n private readonly httpClient = inject(HttpClient);\r\n private readonly authAdaptorService = inject(AuthAdaptorService);\r\n private readonly config = inject(IAM_AUTH_CONFIG);\r\n\r\n verifyEmail(data: VerifyEmailReq): Observable<VerifyEmailRes> {\r\n return this.httpClient.post<VerifyEmailRes>(\r\n this.config.baseUrl + AuthEndPoints.VERIFY_EMAIL,\r\n data,\r\n );\r\n }\r\n\r\n confirmEmail(data: ConfirmEmailReq): Observable<ConfirmEmailRes> {\r\n return this.httpClient.post<ConfirmEmailRes>(\r\n this.config.baseUrl + AuthEndPoints.CONFIRM_EMAIL,\r\n data,\r\n );\r\n }\r\n\r\n register(data: RegisterReq): Observable<RegisterRes> {\r\n return this.httpClient\r\n .post<RegisterRowRes>(this.config.baseUrl + AuthEndPoints.REGISTER, data)\r\n .pipe(map((res: RegisterRowRes) => this.authAdaptorService.adapt(res)));\r\n }\r\n\r\n login(data: LoginReq): Observable<LoginRes> {\r\n return this.httpClient\r\n .post<LoginRowRes>(this.config.baseUrl + AuthEndPoints.LOGIN, data)\r\n .pipe(map((res: LoginRowRes) => this.authAdaptorService.adapt(res)));\r\n }\r\n\r\n forgetPassword(data: ForgetPasswordReq): Observable<ForgetPasswordRes> {\r\n return this.httpClient.post<ForgetPasswordRes>(\r\n this.config.baseUrl + AuthEndPoints.FORGET_PASSWORD,\r\n data,\r\n );\r\n }\r\n\r\n resetPassword(data: ResetPasswordReq): Observable<ResetPasswordRes> {\r\n return this.httpClient.post<ResetPasswordRes>(\r\n this.config.baseUrl + AuthEndPoints.RESET_PASSWORD,\r\n data,\r\n );\r\n }\r\n}\r\n","/*\r\n * Public API Surface of ngx-iam-auth\r\n */\r\n\r\nexport * from './lib/services/auth.service';\r\nexport * from './lib/config/iam-auth.config';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA,MAAM,OAA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,CAAC,CAAC;IACxE;AAEA,IAAA,cAAc,CAAC,IAAuB,EAAA;AACpC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC,eAAe,EACnD,IAAI,CACL;IACH;AAEA,IAAA,aAAa,CAAC,IAAsB,EAAA;AAClC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC,cAAc,EAClD,IAAI,CACL;IACH;wGA3CW,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAX,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,cAFV,MAAM,EAAA,CAAA;;4FAEP,WAAW,EAAA,UAAA,EAAA,CAAA;kBAHvB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACjBD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nabdelfattah/ngx-iam-auth",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"author": "Nada Wael Abdelfattah",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Authentication"
|
|
7
|
+
],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/nabdelfattah/exam-app/tree/develop/projects/ngx-iam-auth"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"@angular/common": "^21.2.0",
|
|
14
|
+
"@angular/core": "^21.2.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"tslib": "^2.3.0"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"module": "fesm2022/nabdelfattah-ngx-iam-auth.mjs",
|
|
21
|
+
"typings": "types/nabdelfattah-ngx-iam-auth.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./package.json": {
|
|
24
|
+
"default": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./types/nabdelfattah-ngx-iam-auth.d.ts",
|
|
28
|
+
"default": "./fesm2022/nabdelfattah-ngx-iam-auth.mjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"type": "module"
|
|
6
32
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { Observable as Observable$1 } from 'rxjs/internal/Observable';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { InjectionToken } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
interface RegisterReq {
|
|
7
|
+
username: string;
|
|
8
|
+
email: string;
|
|
9
|
+
password: string;
|
|
10
|
+
confirmPassword: string;
|
|
11
|
+
firstName: string;
|
|
12
|
+
lastName: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
gender?: string;
|
|
15
|
+
}
|
|
16
|
+
interface RegisterRes {
|
|
17
|
+
username: string;
|
|
18
|
+
email: string;
|
|
19
|
+
phone: string;
|
|
20
|
+
firstName: string;
|
|
21
|
+
lastName: string;
|
|
22
|
+
profilePhoto?: string;
|
|
23
|
+
gender?: string;
|
|
24
|
+
role: string;
|
|
25
|
+
token: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface LoginReq {
|
|
29
|
+
username: string;
|
|
30
|
+
password: string;
|
|
31
|
+
}
|
|
32
|
+
interface LoginRes {
|
|
33
|
+
username: string;
|
|
34
|
+
email: string;
|
|
35
|
+
phone: string;
|
|
36
|
+
firstName: string;
|
|
37
|
+
lastName: string;
|
|
38
|
+
gender?: string;
|
|
39
|
+
profilePhoto?: string;
|
|
40
|
+
role: string;
|
|
41
|
+
token: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface VerifyEmailReq {
|
|
45
|
+
email: string;
|
|
46
|
+
}
|
|
47
|
+
interface VerifyEmailRes {
|
|
48
|
+
status: boolean;
|
|
49
|
+
code: number;
|
|
50
|
+
message: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface ConfirmEmailReq {
|
|
54
|
+
email: string;
|
|
55
|
+
code: string;
|
|
56
|
+
}
|
|
57
|
+
interface ConfirmEmailRes {
|
|
58
|
+
status: boolean;
|
|
59
|
+
code: number;
|
|
60
|
+
message: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ForgetPasswordReq {
|
|
64
|
+
email: string;
|
|
65
|
+
redirectUrl: string;
|
|
66
|
+
}
|
|
67
|
+
interface ForgetPasswordRes {
|
|
68
|
+
status: boolean;
|
|
69
|
+
code: number;
|
|
70
|
+
message: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface ResetPasswordReq {
|
|
74
|
+
token: string;
|
|
75
|
+
newPassword: string;
|
|
76
|
+
confirmPassword: string;
|
|
77
|
+
}
|
|
78
|
+
interface ResetPasswordRes {
|
|
79
|
+
status: boolean;
|
|
80
|
+
code: number;
|
|
81
|
+
message: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare abstract class AuthApi {
|
|
85
|
+
abstract register(data: RegisterReq): Observable<RegisterRes>;
|
|
86
|
+
abstract login(data: LoginReq): Observable<LoginRes>;
|
|
87
|
+
abstract verifyEmail(data: VerifyEmailReq): Observable<VerifyEmailRes>;
|
|
88
|
+
abstract confirmEmail(data: ConfirmEmailReq): Observable<ConfirmEmailRes>;
|
|
89
|
+
abstract forgetPassword(data: ForgetPasswordReq): Observable<ForgetPasswordRes>;
|
|
90
|
+
abstract resetPassword(data: ResetPasswordReq): Observable<ResetPasswordRes>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class AuthService implements AuthApi {
|
|
94
|
+
private readonly httpClient;
|
|
95
|
+
private readonly authAdaptorService;
|
|
96
|
+
private readonly config;
|
|
97
|
+
verifyEmail(data: VerifyEmailReq): Observable$1<VerifyEmailRes>;
|
|
98
|
+
confirmEmail(data: ConfirmEmailReq): Observable$1<ConfirmEmailRes>;
|
|
99
|
+
register(data: RegisterReq): Observable$1<RegisterRes>;
|
|
100
|
+
login(data: LoginReq): Observable$1<LoginRes>;
|
|
101
|
+
forgetPassword(data: ForgetPasswordReq): Observable$1<ForgetPasswordRes>;
|
|
102
|
+
resetPassword(data: ResetPasswordReq): Observable$1<ResetPasswordRes>;
|
|
103
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
|
|
104
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface IamAuthConfig {
|
|
108
|
+
baseUrl: string;
|
|
109
|
+
}
|
|
110
|
+
declare const IAM_AUTH_CONFIG: InjectionToken<IamAuthConfig>;
|
|
111
|
+
declare function provideIamAuth(config: IamAuthConfig): {
|
|
112
|
+
provide: InjectionToken<IamAuthConfig>;
|
|
113
|
+
useValue: IamAuthConfig;
|
|
114
|
+
}[];
|
|
115
|
+
|
|
116
|
+
export { AuthService, IAM_AUTH_CONFIG, provideIamAuth };
|
|
117
|
+
export type { IamAuthConfig };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { Observable as Observable$1 } from 'rxjs/internal/Observable';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { InjectionToken } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
interface RegisterReq {
|
|
7
|
+
username: string;
|
|
8
|
+
email: string;
|
|
9
|
+
password: string;
|
|
10
|
+
confirmPassword: string;
|
|
11
|
+
firstName: string;
|
|
12
|
+
lastName: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
gender?: string;
|
|
15
|
+
}
|
|
16
|
+
interface RegisterRes {
|
|
17
|
+
username: string;
|
|
18
|
+
email: string;
|
|
19
|
+
phone: string;
|
|
20
|
+
firstName: string;
|
|
21
|
+
lastName: string;
|
|
22
|
+
profilePhoto?: string;
|
|
23
|
+
gender?: string;
|
|
24
|
+
role: string;
|
|
25
|
+
token: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface LoginReq {
|
|
29
|
+
username: string;
|
|
30
|
+
password: string;
|
|
31
|
+
}
|
|
32
|
+
interface LoginRes {
|
|
33
|
+
username: string;
|
|
34
|
+
email: string;
|
|
35
|
+
phone: string;
|
|
36
|
+
firstName: string;
|
|
37
|
+
lastName: string;
|
|
38
|
+
gender?: string;
|
|
39
|
+
profilePhoto?: string;
|
|
40
|
+
role: string;
|
|
41
|
+
token: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface VerifyEmailReq {
|
|
45
|
+
email: string;
|
|
46
|
+
}
|
|
47
|
+
interface VerifyEmailRes {
|
|
48
|
+
status: boolean;
|
|
49
|
+
code: number;
|
|
50
|
+
message: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface ConfirmEmailReq {
|
|
54
|
+
email: string;
|
|
55
|
+
code: string;
|
|
56
|
+
}
|
|
57
|
+
interface ConfirmEmailRes {
|
|
58
|
+
status: boolean;
|
|
59
|
+
code: number;
|
|
60
|
+
message: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ForgetPasswordReq {
|
|
64
|
+
email: string;
|
|
65
|
+
redirectUrl: string;
|
|
66
|
+
}
|
|
67
|
+
interface ForgetPasswordRes {
|
|
68
|
+
status: boolean;
|
|
69
|
+
code: number;
|
|
70
|
+
message: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface ResetPasswordReq {
|
|
74
|
+
token: string;
|
|
75
|
+
newPassword: string;
|
|
76
|
+
confirmPassword: string;
|
|
77
|
+
}
|
|
78
|
+
interface ResetPasswordRes {
|
|
79
|
+
status: boolean;
|
|
80
|
+
code: number;
|
|
81
|
+
message: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare abstract class AuthApi {
|
|
85
|
+
abstract register(data: RegisterReq): Observable<RegisterRes>;
|
|
86
|
+
abstract login(data: LoginReq): Observable<LoginRes>;
|
|
87
|
+
abstract verifyEmail(data: VerifyEmailReq): Observable<VerifyEmailRes>;
|
|
88
|
+
abstract confirmEmail(data: ConfirmEmailReq): Observable<ConfirmEmailRes>;
|
|
89
|
+
abstract forgetPassword(data: ForgetPasswordReq): Observable<ForgetPasswordRes>;
|
|
90
|
+
abstract resetPassword(data: ResetPasswordReq): Observable<ResetPasswordRes>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class AuthService implements AuthApi {
|
|
94
|
+
private readonly httpClient;
|
|
95
|
+
private readonly authAdaptorService;
|
|
96
|
+
private readonly config;
|
|
97
|
+
verifyEmail(data: VerifyEmailReq): Observable$1<VerifyEmailRes>;
|
|
98
|
+
confirmEmail(data: ConfirmEmailReq): Observable$1<ConfirmEmailRes>;
|
|
99
|
+
register(data: RegisterReq): Observable$1<RegisterRes>;
|
|
100
|
+
login(data: LoginReq): Observable$1<LoginRes>;
|
|
101
|
+
forgetPassword(data: ForgetPasswordReq): Observable$1<ForgetPasswordRes>;
|
|
102
|
+
resetPassword(data: ResetPasswordReq): Observable$1<ResetPasswordRes>;
|
|
103
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
|
|
104
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface IamAuthConfig {
|
|
108
|
+
baseUrl: string;
|
|
109
|
+
}
|
|
110
|
+
declare const IAM_AUTH_CONFIG: InjectionToken<IamAuthConfig>;
|
|
111
|
+
declare function provideIamAuth(config: IamAuthConfig): {
|
|
112
|
+
provide: InjectionToken<IamAuthConfig>;
|
|
113
|
+
useValue: IamAuthConfig;
|
|
114
|
+
}[];
|
|
115
|
+
|
|
116
|
+
export { AuthService, IAM_AUTH_CONFIG, provideIamAuth };
|
|
117
|
+
export type { IamAuthConfig };
|