@annalib/anna-cognito-lib 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/README.md +22 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,48 +1,43 @@
1
1
  # AnnaCognitoLib
2
2
  ## How to use the library in the consuming project ?
3
- 1. Install the package from npm - `npm install @annalib/anna-cognito-lib` (if not working use with --force flag).
4
3
 
5
- 2. After installing the Library, you need to install it's peer dependancies.
6
- 2. 1. You can find the peer-dependecies in package.json file of library. Install all the peer depedencies with respective version number mentioned. this is important step otherwise lbrary will throw error.
7
- 2. ex: `npm install ngx-toastr@13.2.1`
4
+ 1. Install the package from npm
5
+ `npm install @annalib/anna-cognito-lib` (if not working use with --force flag).
6
+ 2. After installing the Library, you need to install it's peer dependancies.You can find the peer-dependecies in package.json file of library. Install all the peer depedencies with respective version number mentioned. this is important step otherwise library will throw error.
7
+ ex: `npm install ngx-toastr@13.2.1`
8
+ 3. Also make sure to Install the Roboto font locally in assets folder of your consuming project.
8
9
 
9
- 3. Adding Configuration
10
- 3. 1. import the `AnnaCognitoLibModule` module and pass the configuration to root `AnnaCognitoLibModule.forRoot(AnnaCognitoLibraryConfig)`
11
- 2. configuration const should be:
12
- <kbd>
13
- const AnnaCognitoLibraryConfig = {
10
+ If using the library locally (library from your system locally not npm),then in angular json file you have to set `preserveSymlinks: true`.
11
+
12
+ ## Adding Configuration
13
+ 1. import the `AnnaCognitoLibModule` module and pass the configuration to root `AnnaCognitoLibModule.forRoot(AnnaCognitoLibraryConfig)`
14
+ 2. configuration const should be:
15
+ ``` const AnnaCognitoLibraryConfig = {
14
16
  cognito : {
15
17
  userPoolId: "",
16
18
  clientId: "",
17
19
  },
18
20
  loginPageLogoImgUrl: ""
19
- }
20
- </kbd>
21
- 3. c. Default loginPageLogoImgUrl is ANNA logo image.
21
+ } ```
22
+ 3. Default loginPageLogoImgUrl is ANNA logo image.
22
23
  In case you want to add another Logo image, add the logo image file in library's asset folder and provide new loginPageLogoImgUrl.
23
24
  Note: for better loading of logo image, provide logo image in minified format.
24
25
 
25
26
 
26
- 4. Adding new custom function implemetation for any service file.
27
- 4. 1. Background Understanding - when we want to provide custom implemenetation - We write the custom implementation in a service file of consuming project and that is injected in the library. Injection is taken care by library itself. You just need to provide the definition and implementation of new function added.
28
- 2. Ex: let's say we want to add a new function `onSuccessfulAuthenticatingUser() this function is called from library when user is succesfully authenticated and logged in. (Note: this function is already present in lib).
29
- 3. Then In library add the new function declaration `onSuccessfulAuthenticatingUser()` in interface file `IAuthService` of `auth-service.token.ts` file.
30
- 4. In consuming project, for `onSuccessfulAuthenticatingUser()` provide the implementation in the service file say `AuthService` of `auth.service.ts`.
31
- 5. Then In consuming project, app.module.ts file add following in providers array.
32
- `{ provide: AUTH_SERVICE_TOKEN, useExisting: AuthService }`
33
- i.e. your consuming project's existing AuthService will be injected in Library's auth-service file with the help of AUTH_SERVICE_TOKEN.
34
- 6. Now you're good to go!
27
+ ## Adding new custom function implemetation for any service file.
28
+ 1. Background Understanding - when we want to provide custom implemenetation - We write the custom implementation in a service file of consuming project and that is injected in the library. Injection is taken care by library itself. You just need to provide the definition and implementation of new function added.
29
+ 2. Ex: let's say we want to add a new function `onSuccessfulAuthenticatingUser() this function is called from library when user is succesfully authenticated and logged in. (Note: this function is already present in lib).
30
+ 3. Then In library add the new function declaration `onSuccessfulAuthenticatingUser()` in interface file `IAuthService` of `auth-service.token.ts` file.
31
+ 4. In consuming project, for `onSuccessfulAuthenticatingUser()` provide the implementation in the service file say `AuthService` of `auth.service.ts`.
32
+ 5. Then In consuming project, app.module.ts file add following in providers array.
33
+ `{ provide: AUTH_SERVICE_TOKEN, useExisting: AuthService }`
34
+ i.e. your consuming project's existing AuthService will be injected in Library's auth-service file with the help of AUTH_SERVICE_TOKEN.
35
+ 6. Now you're good to go!
35
36
 
36
- 5. Also make sure to Install the Roboto font locally in assets folder of your consuming project.
37
-
38
- If using the library locally (library from your system locally not npm),then in angular json file you have to set `preserveSymlinks: true`.
39
-
40
37
 
41
38
  ## List of function implementation we need to provide in consuming project.
42
39
  1. `onSuccessfulAuthenticatingUser()` - provide the implementation of what happens when user is succefully logged in. (any API call or routing you need to provide).
43
-
44
40
  2. `isUsernameAvailable()` - in thie implementation call an backend API to find out if username is already present in Database or not. format of response should be `{"isUsernameAvailable":true}`. This is used in forgot-password page before calling forgot-password cognito sdk call, we need to check thorough backend db if the username is actually available.
45
-
46
41
  3. `isLoggingIn` - set this variable to false. this will stop the spinner on top on button.
47
42
  use case: after successful login i.e. when we are done with all API call we need to call post succesfull calling or when we have routed to home page.
48
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annalib/anna-cognito-lib",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^13.2.0",
6
6
  "@angular/core": "^13.2.0",