@btffamily/vacepey 1.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 (51) hide show
  1. package/build/brokers/nats/listener.ev.d.ts +29 -0
  2. package/build/brokers/nats/listener.ev.js +44 -0
  3. package/build/brokers/nats/publisher.ev.d.ts +19 -0
  4. package/build/brokers/nats/publisher.ev.js +28 -0
  5. package/build/brokers/nats/subjects.ev.d.ts +84 -0
  6. package/build/brokers/nats/subjects.ev.js +91 -0
  7. package/build/brokers/rabbitMQ/consumer.d.ts +35 -0
  8. package/build/brokers/rabbitMQ/consumer.js +74 -0
  9. package/build/brokers/rabbitMQ/exchanges.d.ts +36 -0
  10. package/build/brokers/rabbitMQ/exchanges.js +43 -0
  11. package/build/brokers/rabbitMQ/producer.d.ts +17 -0
  12. package/build/brokers/rabbitMQ/producer.js +40 -0
  13. package/build/dtos/word.dto.d.ts +11 -0
  14. package/build/dtos/word.dto.js +2 -0
  15. package/build/events/listener.ev.d.ts +29 -0
  16. package/build/events/listener.ev.js +44 -0
  17. package/build/events/publisher.ev.d.ts +19 -0
  18. package/build/events/publisher.ev.js +28 -0
  19. package/build/events/subjects.ev.d.ts +84 -0
  20. package/build/events/subjects.ev.js +91 -0
  21. package/build/index.d.ts +14 -0
  22. package/build/index.js +109 -0
  23. package/build/middleware/async.mw.d.ts +3 -0
  24. package/build/middleware/async.mw.js +4 -0
  25. package/build/middleware/auth.mw.d.ts +24 -0
  26. package/build/middleware/auth.mw.js +98 -0
  27. package/build/middleware/db.mw.d.ts +6 -0
  28. package/build/middleware/db.mw.js +43 -0
  29. package/build/middleware/redis.mw.d.ts +19 -0
  30. package/build/middleware/redis.mw.js +28 -0
  31. package/build/middleware/role.mw.d.ts +4 -0
  32. package/build/middleware/role.mw.js +19 -0
  33. package/build/services/mongo.service.d.ts +7 -0
  34. package/build/services/mongo.service.js +14 -0
  35. package/build/services/random.service.d.ts +8 -0
  36. package/build/services/random.service.js +30 -0
  37. package/build/services/word.service.d.ts +8 -0
  38. package/build/services/word.service.js +73 -0
  39. package/build/src/ca-certificate.crt +32 -0
  40. package/build/src/index.ts +192 -0
  41. package/build/utils/cache.util.d.ts +3 -0
  42. package/build/utils/cache.util.js +7 -0
  43. package/build/utils/encryption.util.d.ts +66 -0
  44. package/build/utils/encryption.util.js +208 -0
  45. package/build/utils/functions.util.d.ts +133 -0
  46. package/build/utils/functions.util.js +1032 -0
  47. package/build/utils/snippets/decryption.snippet.d.ts +0 -0
  48. package/build/utils/snippets/decryption.snippet.js +255 -0
  49. package/build/utils/types.util.d.ts +58 -0
  50. package/build/utils/types.util.js +2 -0
  51. package/package.json +49 -0
File without changes
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ //** PYTHON DECRYPT for 'encryptAESGCM' function */
3
+ // from Crypto.Cipher import AES
4
+ // from Crypto.Util.Padding import unpad
5
+ // from Crypto.Protocol.KDF import PBKDF2
6
+ // from Crypto.Hash import SHA256
7
+ // import binascii
8
+ // # You must change this to match your Node.js key derivation function, salt, and iterations.
9
+ // # This is a crucial step!
10
+ // def derive_key(password: str, salt: bytes):
11
+ // # Example: PBKDF2 with SHA256, a fixed salt, and 100000 iterations
12
+ // return PBKDF2(password, salt, dkLen=32, count=100000, hmac_hash_module=SHA256)
13
+ // def decrypt_aes_cbc(encrypted_hex: str, iv_hex: str, password: str):
14
+ // try:
15
+ // # 1. Decode hex strings to bytes
16
+ // encrypted_bytes = binascii.unhexlify(encrypted_hex)
17
+ // iv_bytes = binascii.unhexlify(iv_hex)
18
+ // # A placeholder salt. You need to use the same salt as your Node.js code.
19
+ // salt = b'\x00' * 16
20
+ // # 2. Derive the key using the same function as Node.js
21
+ // key = derive_key(password, salt)
22
+ // # 3. Create the AES cipher object with CBC mode
23
+ // cipher = AES.new(key, AES.MODE_CBC, iv=iv_bytes)
24
+ // # 4. Decrypt the data and remove the padding
25
+ // decrypted_bytes = cipher.decrypt(encrypted_bytes)
26
+ // # Unpad the decrypted data (assumes PKCS7 padding)
27
+ // unpadded_bytes = unpad(decrypted_bytes, AES.block_size)
28
+ // return unpadded_bytes.decode('utf-8')
29
+ // except Exception as e:
30
+ // print(f"Decryption failed: {e}")
31
+ // return None
32
+ // if __name__ == '__main__':
33
+ // # Replace these with actual values from your Node.js encryption
34
+ // encrypted_data = "your_encrypted_hex_string"
35
+ // iv_string = "your_iv_hex_string"
36
+ // password = "your_password"
37
+ // decrypted_text = decrypt_aes_cbc(encrypted_data, iv_string, password)
38
+ // if decrypted_text:
39
+ // print("Decrypted Data:", decrypted_text)
40
+ // >> ================================================================================================
41
+ //** GOLANG DECRYPT for 'encryptAESGCM' function */
42
+ // package main
43
+ // import (
44
+ // "bytes"
45
+ // "crypto/aes"
46
+ // "crypto/cipher"
47
+ // "crypto/rand"
48
+ // "crypto/sha256"
49
+ // "encoding/hex"
50
+ // "fmt"
51
+ // "io"
52
+ // "log"
53
+ // "golang.org/x/crypto/pbkdf2"
54
+ // )
55
+ // // You must change this to match your Node.js key derivation function, salt, and iterations.
56
+ // // This is a crucial step!
57
+ // func deriveKey(password string, salt []byte) []byte {
58
+ // // Example: PBKDF2 with a fixed salt and 100000 iterations
59
+ // return pbkdf2.Key([]byte(password), salt, 100000, 32, sha256.New)
60
+ // }
61
+ // // pkcs7Unpad removes PKCS7 padding from the data.
62
+ // func pkcs7Unpad(data []byte) ([]byte, error) {
63
+ // if len(data) == 0 {
64
+ // return nil, fmt.Errorf("pkcs7: data is empty")
65
+ // }
66
+ // padSize := int(data[len(data)-1])
67
+ // if padSize > len(data) {
68
+ // return nil, fmt.Errorf("pkcs7: invalid padding size")
69
+ // }
70
+ // return data[:len(data)-padSize], nil
71
+ // }
72
+ // func decryptAESCBC(encryptedHex string, ivHex string, password string) (string, error) {
73
+ // // 1. Decode hex strings to byte slices
74
+ // encrypted, err := hex.DecodeString(encryptedHex)
75
+ // if err != nil {
76
+ // return "", fmt.Errorf("could not decode encrypted data: %w", err)
77
+ // }
78
+ // iv, err := hex.DecodeString(ivHex)
79
+ // if err != nil {
80
+ // return "", fmt.Errorf("could not decode IV: %w", err)
81
+ // }
82
+ // // A placeholder salt. You need to use the same salt as your Node.js code.
83
+ // salt := make([]byte, 16)
84
+ // if _, err := io.ReadFull(rand.Reader, salt); err != nil {
85
+ // log.Fatal(err)
86
+ // }
87
+ // // 2. Derive the key using the same function as Node.js
88
+ // key := deriveKey(password, salt)
89
+ // // 3. Create a new AES cipher block
90
+ // block, err := aes.NewCipher(key)
91
+ // if err != nil {
92
+ // return "", fmt.Errorf("could not create AES cipher: %w", err)
93
+ // }
94
+ // // 4. Create a new CBC decrypter
95
+ // mode := cipher.NewCBCDecrypter(block, iv)
96
+ // // 5. Decrypt the data
97
+ // decrypted := make([]byte, len(encrypted))
98
+ // mode.CryptBlocks(decrypted, encrypted)
99
+ // // 6. Remove the padding
100
+ // unpadded, err := pkcs7Unpad(decrypted)
101
+ // if err != nil {
102
+ // return "", fmt.Errorf("could not remove padding: %w", err)
103
+ // }
104
+ // return string(unpadded), nil
105
+ // }
106
+ // func main() {
107
+ // // Replace these with actual values from your Node.js encryption
108
+ // encryptedData := "your_encrypted_hex_string"
109
+ // ivString := "your_iv_hex_string"
110
+ // password := "your_password"
111
+ // decryptedText, err := decryptAESCBC(encryptedData, ivString, password)
112
+ // if err != nil {
113
+ // log.Fatalf("Decryption failed: %v", err)
114
+ // }
115
+ // fmt.Println("Decrypted Data:", decryptedText)
116
+ // }
117
+ // >> ================================================================================================
118
+ //** PYTHON DECRYPT FOR 'encryptAESGCM2' function */
119
+ // # decrypt.py
120
+ // import base64
121
+ // from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
122
+ // from cryptography.hazmat.primitives import hashes
123
+ // from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
124
+ // from cryptography.hazmat.backends import default_backend
125
+ // def decrypt(data: dict) -> str:
126
+ // """
127
+ // Decrypts an AES-256-GCM encrypted data dictionary.
128
+ // """
129
+ // try:
130
+ // salt = base64.b64decode(data['salt'])
131
+ // iv = base64.b64decode(data['vector'])
132
+ // auth_tag = base64.b64decode(data['authTag'])
133
+ // ciphertext = base64.b64decode(data['encrypted'])
134
+ // passphrase = data['password']
135
+ // except (KeyError, base64.binascii.Error) as e:
136
+ // raise ValueError(f"Invalid input data format: {e}")
137
+ // # Derive the key using the same parameters as Node.js
138
+ // kdf = PBKDF2HMAC(
139
+ // algorithm=hashes.SHA512(),
140
+ // salt=salt,
141
+ // iterations=100000,
142
+ // length=32,
143
+ // backend=default_backend()
144
+ // )
145
+ // key = kdf.derive(passphrase.encode('utf-8'))
146
+ // # Decrypt the data
147
+ // cipher = Cipher(algorithms.AES(key), modes.GCM(iv, auth_tag), backend=default_backend())
148
+ // decryptor = cipher.decryptor()
149
+ // plaintext = decryptor.update(ciphertext) + decryptor.finalize()
150
+ // return plaintext.decode('utf-8')
151
+ // if __name__ == '__main__':
152
+ // # IMPORTANT: Paste the actual result dictionary from your Node.js function here.
153
+ // # You will need to `console.log` the full result object.
154
+ // node_js_result = {
155
+ // "error": False,
156
+ // "message": "encryption successful",
157
+ // "salt": "YOUR_BASE64_SALT_HERE",
158
+ // "vector": "YOUR_BASE64_IV_HERE",
159
+ // "authTag": "YOUR_BASE64_AUTH_TAG_HERE",
160
+ // "data": "YOUR_BASE64_CIPHERTEXT_HERE"
161
+ // }
162
+ // node_js_result['password'] = "my-super-secret-passphrase"
163
+ // try:
164
+ // decrypted_message = decrypt(node_js_result)
165
+ // print("Python Decrypted:", decrypted_message)
166
+ // except Exception as e:
167
+ // print("Decryption error:", e)
168
+ // >> ================================================================================================
169
+ //** GOLANG DECRYPT FOR 'encryptAESGCM2' function */
170
+ // decrypt.go
171
+ // package main
172
+ // import (
173
+ // "crypto/aes"
174
+ // "crypto/cipher"
175
+ // "crypto/pbkdf2"
176
+ // "crypto/sha512"
177
+ // "encoding/base64"
178
+ // "encoding/json"
179
+ // "fmt"
180
+ // )
181
+ // // Define a struct that matches the format of your Node.js encryption output.
182
+ // type EncryptedData struct {
183
+ // Salt string `json:"salt"`
184
+ // Vector string `json:"vector"`
185
+ // AuthTag string `json:"authTag"`
186
+ // Encrypted string `json:"data"`
187
+ // Password string `json:"password"` // Assuming this would be passed separately
188
+ // }
189
+ // const (
190
+ // pbkdf2Iterations = 100000
191
+ // keyLength = 32
192
+ // )
193
+ // // DeriveKey from a passphrase and salt using PBKDF2.
194
+ // func deriveKey(password, salt []byte) []byte {
195
+ // return pbkdf2.Key(password, salt, pbkdf2Iterations, keyLength, sha512.New)
196
+ // }
197
+ // // Decrypts an AES-256-GCM encrypted data object.
198
+ // func decrypt(data EncryptedData) (string, error) {
199
+ // salt, err := base64.StdEncoding.DecodeString(data.Salt)
200
+ // if err != nil {
201
+ // return "", fmt.Errorf("invalid salt encoding: %v", err)
202
+ // }
203
+ // iv, err := base64.StdEncoding.DecodeString(data.Vector)
204
+ // if err != nil {
205
+ // return "", fmt.Errorf("invalid vector (IV) encoding: %v", err)
206
+ // }
207
+ // authTag, err := base64.StdEncoding.DecodeString(data.AuthTag)
208
+ // if err != nil {
209
+ // return "", fmt.Errorf("invalid authTag encoding: %v", err)
210
+ // }
211
+ // ciphertext, err := base64.StdEncoding.DecodeString(data.Encrypted)
212
+ // if err != nil {
213
+ // return "", fmt.Errorf("invalid encrypted data encoding: %v", err)
214
+ // }
215
+ // key := deriveKey([]byte(data.Password), salt)
216
+ // block, err := aes.NewCipher(key)
217
+ // if err != nil {
218
+ // return "", err
219
+ // }
220
+ // aesGCM, err := cipher.NewGCM(block)
221
+ // if err != nil {
222
+ // return "", err
223
+ // }
224
+ // plaintext, err := aesGCM.Open(nil, iv, ciphertext, authTag)
225
+ // if err != nil {
226
+ // return "", fmt.Errorf("decryption failed, possibly due to incorrect password or corrupted data: %v", err)
227
+ // }
228
+ // return string(plaintext), nil
229
+ // }
230
+ // func main() {
231
+ // // IMPORTANT: Replace this with the actual JSON output from your Node.js function.
232
+ // // You will need to print the full result object from your JS function.
233
+ // nodeJsResultJSON := `{
234
+ // "error": false,
235
+ // "message": "encryption successful",
236
+ // "salt": "YOUR_BASE64_SALT_HERE",
237
+ // "vector": "YOUR_BASE64_IV_HERE",
238
+ // "authTag": "YOUR_BASE64_AUTH_TAG_HERE",
239
+ // "data": "YOUR_BASE64_CIPHERTEXT_HERE"
240
+ // }`
241
+ // passphrase := "my-super-secret-passphrase"
242
+ // var encryptedData EncryptedData
243
+ // err := json.Unmarshal([]byte(nodeJsResultJSON), &encryptedData)
244
+ // if err != nil {
245
+ // fmt.Println("Error parsing JSON:", err)
246
+ // return
247
+ // }
248
+ // encryptedData.Password = passphrase // Add the password to the struct for the decrypt function
249
+ // decrypted, err := decrypt(encryptedData)
250
+ // if err != nil {
251
+ // fmt.Println("Decryption error:", err)
252
+ // return
253
+ // }
254
+ // fmt.Println("Go Decrypted:", decrypted)
255
+ // }
@@ -0,0 +1,58 @@
1
+ export type SyncAction = 'user.updated' | 'user.deleted' | 'user.created' | 'country.found' | 'user.apikey' | 'action.update' | 'action.create' | 'audit.created' | 'audit.updated' | 'audit.deleted' | 'notification.created' | 'notification.updated' | 'notification.deleted' | 'action.delete' | 'kyc.updated' | 'kyb.updated';
2
+ export type SyncType = 'type.compliance' | 'type.register' | 'type.login' | 'type.update' | 'typ.delete' | 'type.create' | 'type.audit' | 'type.noitfy' | 'type.password.changed' | 'type.forgot.password' | 'type.invite.user';
3
+ export type SyncNotify = 'notify.sms.otp' | 'notify.email.otp' | 'notify.welcome.email' | 'notify.email.link' | 'notify.compliance' | 'notify.password.changed' | 'notify.forgot.password' | 'notify.invite.user' | 'notify.create' | 'notify.read' | 'notify.delete';
4
+ export type DateCompare = 'equal' | 'greaterthan' | 'lessthan' | 'greaterequal' | 'lessequal';
5
+ export type SentcompPattern = 'in-order' | 'random';
6
+ export type SentcompLikely = 'equal' | 'not-equal' | 'mostly-equal' | 'less-equal' | 'almost-different' | 'different';
7
+ export type FormatDateType = 'basic' | 'datetime' | 'datetime-slash' | 'datetime-separated' | 'separated' | 'localtime' | 'slashed';
8
+ export interface IDateToday {
9
+ year: number;
10
+ month: number;
11
+ monthName: any;
12
+ date: number;
13
+ week: number;
14
+ day: number;
15
+ dayName: any;
16
+ hour: number;
17
+ min: number;
18
+ sec: number;
19
+ milli: number;
20
+ ISO: string;
21
+ dayjs: any;
22
+ dateTime: number;
23
+ }
24
+ export interface IMonthsSplit {
25
+ start: number;
26
+ end: number;
27
+ dates: Array<number>;
28
+ }
29
+ export interface IDatesSplit {
30
+ label: string;
31
+ start: string;
32
+ end: string;
33
+ dates: Array<string>;
34
+ }
35
+ export interface IStringToBase64 {
36
+ type: 'buffer' | 'direct';
37
+ payload: string;
38
+ }
39
+ export interface IBase64ToString {
40
+ type: 'buffer' | 'direct';
41
+ payload: string;
42
+ }
43
+ export interface IArrayToObject {
44
+ type: string;
45
+ key: any;
46
+ value: any;
47
+ }
48
+ export interface ISlugit {
49
+ data: string;
50
+ options?: {
51
+ lowercase?: boolean;
52
+ separator?: string;
53
+ };
54
+ }
55
+ export interface IDateIsPast {
56
+ currentDate: string;
57
+ compareDate: string;
58
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@btffamily/vacepey",
3
+ "version": "1.0.1",
4
+ "description": "common node.js codebase for vacepay platform",
5
+ "main": "./build/index.js",
6
+ "types": "./build/index.d.ts",
7
+ "files": [
8
+ "build/**/*",
9
+ "build/middleware/*",
10
+ "build/middleware/ca-certificate.crt"
11
+ ],
12
+ "scripts": {
13
+ "clean": "del-cli ./build/*",
14
+ "copy": "copyfiles -a src/* build",
15
+ "build": "npm run clean && npm run copy && tsc",
16
+ "pub": "npm run build && npm publish --access public"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": ""
21
+ },
22
+ "keywords": [
23
+ "software",
24
+ "common"
25
+ ],
26
+ "author": "BTF Inc.",
27
+ "license": "MIT",
28
+ "homepage": "",
29
+ "dependencies": {
30
+ "@types/amqplib": "^0.10.3",
31
+ "@types/colors": "^1.2.1",
32
+ "@types/express": "^4.17.13",
33
+ "@types/jsonwebtoken": "^8.5.5",
34
+ "amqplib": "^0.10.3",
35
+ "axios": "^1.12.2",
36
+ "colors": "^1.4.0",
37
+ "copyfiles": "^2.4.1",
38
+ "dayjs": "^1.10.7",
39
+ "del-cli": "^4.0.1",
40
+ "express": "^4.17.1",
41
+ "jsonwebtoken": "^8.5.1",
42
+ "moment": "^2.30.1",
43
+ "mongoose": "^8.14.2",
44
+ "node-nats-streaming": "^0.3.2",
45
+ "redis": "^4.0.6",
46
+ "slugify": "^1.6.6",
47
+ "typescript": "^4.4.3"
48
+ }
49
+ }