@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 +57 -0
- package/bundles/sambath999-localize-token.umd.js +1112 -0
- package/bundles/sambath999-localize-token.umd.js.map +1 -0
- package/esm2015/lib/index.js +6 -0
- package/esm2015/lib/localize.api.service.js +152 -0
- package/esm2015/lib/localize.token.js +59 -0
- package/esm2015/lib/localize.token.module.js +10 -0
- package/esm2015/lib/localize.token.service.js +62 -0
- package/esm2015/lib/localize.token.storage.js +101 -0
- package/esm2015/public-api.js +2 -0
- package/esm2015/sambath999-localize-token.js +5 -0
- package/fesm2015/sambath999-localize-token.js +379 -0
- package/fesm2015/sambath999-localize-token.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/localize.api.service.d.ts +59 -0
- package/lib/localize.token.d.ts +35 -0
- package/lib/localize.token.module.d.ts +2 -0
- package/lib/localize.token.service.d.ts +26 -0
- package/lib/localize.token.storage.d.ts +61 -0
- package/package.json +36 -0
- package/public-api.d.ts +1 -0
- package/sambath999-localize-token.d.ts +4 -0
- package/sambath999-localize-token.metadata.json +1 -0
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).
|