@tatil/crypto 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.
Files changed (3) hide show
  1. package/README.md +37 -0
  2. package/index.js +42 -0
  3. package/package.json +12 -0
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @tatil/crypto
2
+
3
+ Tatilsepeti crypto utilities for encryption and decryption operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ yarn add @tatil/crypto
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```javascript
14
+ import { encryption, decryption } from '@tatil/crypto';
15
+
16
+ // Encrypt a reservation sales ID
17
+ const encryptedId = await encryption(12345);
18
+
19
+ // Decrypt a reservation sales ID
20
+ const decryptedId = await decryption('encrypted_value');
21
+ ```
22
+
23
+ ## API
24
+
25
+ ### `encryption(value)`
26
+
27
+ Encrypts a value using the reservation encryption endpoint.
28
+
29
+ - **Parameters:** `value` (string | number) - The value to encrypt
30
+ - **Returns:** Promise<string> - The encrypted value
31
+
32
+ ### `decryption(value)`
33
+
34
+ Decrypts a value using the reservation decryption endpoint.
35
+
36
+ - **Parameters:** `value` (string | number) - The value to decrypt
37
+ - **Returns:** Promise<number> - The decrypted number value
package/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import ClientApi from '@tatil/client-api';
2
+
3
+ /**
4
+ * Encrypts a value using the reservation encryption endpoint
5
+ * @param {string|number} value - The value to encrypt
6
+ * @returns {Promise<string>} The encrypted value
7
+ */
8
+ export const encryption = async (value) => {
9
+ try {
10
+ const response = await ClientApi.post('/common/reservationEncryption', {
11
+ text: value.toString(),
12
+ });
13
+
14
+ if (response) return response?.data?.data;
15
+ } catch (error) {
16
+ console.error('Encryption error:', error);
17
+ throw error;
18
+ }
19
+ };
20
+
21
+ /**
22
+ * Decrypts a value using the reservation decryption endpoint
23
+ * @param {string|number} value - The value to decrypt
24
+ * @returns {Promise<number>} The decrypted number value
25
+ */
26
+ export const decryption = async (value) => {
27
+ try {
28
+ const response = await ClientApi.post('/common/reservationDecryption', {
29
+ text: value.toString(),
30
+ });
31
+
32
+ if (response) return Number(response?.data?.data);
33
+ } catch (error) {
34
+ console.error('Decryption error:', error);
35
+ throw error;
36
+ }
37
+ };
38
+
39
+ export default {
40
+ encryption,
41
+ decryption,
42
+ };
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@tatil/crypto",
3
+ "version": "0.0.1",
4
+ "description": "Tatilsepeti Crypto utilities for encryption and decryption",
5
+ "main": "index.js",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "dependencies": {
10
+ "@tatil/client-api": "^0.0.2"
11
+ }
12
+ }