@sambath999/localize-token 12.0.3

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 ADDED
@@ -0,0 +1,57 @@
1
+
2
+ ## Usage
3
+
4
+ To use the `LocalizeCryptoService` in your Angular project, follow these steps:
5
+
6
+ 1. Install the `localize-crypto` library by running the following command:
7
+
8
+ ```bash
9
+ npm install @sambath999/localize-crypto
10
+ ```
11
+
12
+ 2. Import the `LocalizeCryptoService` in your Angular module:
13
+
14
+ ```typescript
15
+ import { LocalizeCryptoService } from 'localize-crypto';
16
+ ```
17
+
18
+ 3. Add the `LocalizeCryptoService` to the providers array in your module:
19
+
20
+ ```typescript
21
+ @NgModule({
22
+ providers: [LocalizeCryptoService]
23
+ })
24
+ export class AppModule { }
25
+ ```
26
+
27
+ 4. Inject the `LocalizeCryptoService` into your component or service:
28
+
29
+ ```typescript
30
+ constructor(private localizeCryptoService: LocalizeCryptoService) { }
31
+ ```
32
+
33
+ 5. Use the `request` method of the `LocalizeCryptoService` to perform encryption and send the encrypted payload to the server:
34
+
35
+ ```typescript
36
+ const path = '/api/encrypt';
37
+ const body = { message: 'Hello, World!' };
38
+
39
+ this.localizeCryptoService.request(path, body, {
40
+ requestKey: async () => {
41
+ // Implement your logic to fetch the RSA public key from the server
42
+ // and return it as a Promise
43
+ },
44
+ request: async (payload: object) => {
45
+ // Implement your logic to send the encrypted payload to the server
46
+ // and return the response as a Promise
47
+ }
48
+ }).then(response => {
49
+ // Handle the response from the server
50
+ }).catch(error => {
51
+ // Handle any errors that occur during the encryption or request process
52
+ });
53
+ ```
54
+
55
+ 6. Make sure to handle any errors that may occur during the encryption or request process.
56
+
57
+ For more information on how to use the `LocalizeCryptoService`, refer to the [API documentation](https://github.com/localize-crypto/docs/api.md).