@hivedev/hivesdk 1.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.
Files changed (41) hide show
  1. package/Client/Utility/DisableAllButtons.js +4 -0
  2. package/Client/Utility/GenerateUUID.js +23 -0
  3. package/Client/Utility/GetDeviceId.js +21 -0
  4. package/Client/Utility/IsInApp.js +4 -0
  5. package/Client/Utility/SetupAppUsage.js +65 -0
  6. package/Common/Constants.js +6 -0
  7. package/Common/Enumerations/AppWebViewInteractions.js +5 -0
  8. package/Common/Enumerations/ApprovalTypes.js +5 -0
  9. package/Common/Enumerations/FileTreeNodeTypes.js +5 -0
  10. package/Common/Enumerations/FilterOperators.js +5 -0
  11. package/Common/Enumerations/FilterTypes.js +6 -0
  12. package/Common/Enumerations/UserDataFetchFilterComparision.js +11 -0
  13. package/Common/Enumerations/UserFieldFormats.js +12 -0
  14. package/Common/Enumerations/UserFieldTypes.js +6 -0
  15. package/Common/Enumerations/UserPrivileges.js +12 -0
  16. package/Common/Utility/ConvertEnumerationKeyToTitleCase.js +8 -0
  17. package/Common/Utility/Delay.js +4 -0
  18. package/Common/Utility/ExtractIpFromUrl.js +18 -0
  19. package/Common/Utility/GenerateRandomId.js +12 -0
  20. package/Common/Utility/GetDirectoryName.js +8 -0
  21. package/Common/Utility/GetSha512Hash.js +6 -0
  22. package/Common/Utility/NormalizeIp.js +12 -0
  23. package/Common/Utility/Sha256.js +98 -0
  24. package/README.md +1 -0
  25. package/Server/Utility/DecryptDataWithPassword.js +13 -0
  26. package/Server/Utility/DecryptFileWithPassword.js +18 -0
  27. package/Server/Utility/EncryptDataWithPassword.js +12 -0
  28. package/Server/Utility/EncryptFileWithPassword.js +13 -0
  29. package/Server/Utility/ExtractConfigurationForService.js +11 -0
  30. package/Server/Utility/GetAppdataDirectory.js +16 -0
  31. package/Server/Utility/GetHostIp.js +19 -0
  32. package/Server/Utility/IsLocalRequest.js +21 -0
  33. package/Server/Utility/IsRequestOriginatingFromService.js +55 -0
  34. package/Server/Utility/LoadConfiguration.js +62 -0
  35. package/Server/Utility/PromptPassword.js +24 -0
  36. package/Server/Utility/SendMail.js +33 -0
  37. package/Server/Utility/SetupPassword.js +56 -0
  38. package/client.js +0 -0
  39. package/dist/server/index.js +11479 -0
  40. package/package.json +41 -0
  41. package/server.js +3 -0
@@ -0,0 +1,33 @@
1
+ import nodemailer from 'nodemailer';
2
+
3
+ export async function sendMail(sender, receiver, subject, text)
4
+ {
5
+ const transporter = nodemailer.createTransport({
6
+ host: 'smtp.gmail.com',
7
+ port: 587,
8
+ secure: false,
9
+ auth:
10
+ {
11
+ user: 'fatbeluuga@gmail.com',
12
+ pass: ''
13
+ }
14
+ });
15
+
16
+ const mailOptions =
17
+ {
18
+ from: sender,
19
+ to: receiver,
20
+ subject: subject,
21
+ text: text
22
+ }
23
+
24
+ try
25
+ {
26
+ const info = await transporter.sendMail(mailOptions);
27
+ console.log('Email sent:', info.response);
28
+ }
29
+ catch (error)
30
+ {
31
+ console.error('Error:', error);
32
+ }
33
+ }
@@ -0,0 +1,56 @@
1
+ import fs from "fs";
2
+ import os from "os";
3
+ import path from "path";
4
+ import { getHiveAppDataDirectory } from "./GetHiveAppdataDirectory.js";
5
+ import { encryptAndStoreFile } from "./EncryptFileWithPassword.js";
6
+ import { decryptFileWithPassword } from "./DecryptFileWithPassword.js";
7
+ import { promptPassword } from "./PromptPassword.js";
8
+ import { getSha512Hash } from "../../Common/Utility/GetSha512Hash.js";
9
+
10
+ export async function setupPassword()
11
+ {
12
+ const appDataDirectory = getHiveAppDataDirectory();
13
+ const passwordFilePath = path.join(appDataDirectory, "password.dat");
14
+ let correctPassword = null;
15
+
16
+ if(!fs.existsSync(passwordFilePath))
17
+ {
18
+
19
+ while(true)
20
+ {
21
+ const password = await promptPassword("Create a password: ");
22
+ const confirm = await promptPassword("Confirm password: ");
23
+
24
+ if(password === confirm)
25
+ {
26
+ correctPassword = password;
27
+ const hashedPassword = getSha512Hash(password);
28
+ await encryptAndStoreFile(hashedPassword, passwordFilePath, password);
29
+ break;
30
+ }
31
+
32
+ console.log("Passwords do not match! Try again!");
33
+ }
34
+
35
+ }
36
+ else
37
+ {
38
+ while(true)
39
+ {
40
+ const password = await promptPassword("Enter your password: ");
41
+ const storedPasswordHash = await decryptFileWithPassword(passwordFilePath, password);
42
+
43
+ if(storedPasswordHash !== getSha512Hash(password))
44
+ {
45
+ console.log("Incorrect password! Please try again.");
46
+ }
47
+ else
48
+ {
49
+ correctPassword = password;
50
+ break;
51
+ }
52
+ }
53
+ }
54
+
55
+ return correctPassword;
56
+ }
package/client.js ADDED
File without changes