@explorins/pers-shared 2.1.10 → 2.1.11
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 +0 -0
- package/dist/cjs/index.d.ts +1 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/token-transaction-input-data.interface.d.ts +2 -1
- package/dist/cjs/interfaces/token-transaction-input-data.interface.d.ts.map +1 -1
- package/dist/cjs/internal/database/index.d.ts +6 -0
- package/dist/cjs/internal/database/index.d.ts.map +1 -0
- package/dist/cjs/internal/database/index.js +24 -0
- package/dist/cjs/internal/database/index.js.map +1 -0
- package/dist/cjs/internal/database/models/base.model.d.ts +7 -0
- package/dist/cjs/internal/database/models/base.model.d.ts.map +1 -0
- package/dist/cjs/internal/database/models/base.model.js +11 -0
- package/dist/cjs/internal/database/models/base.model.js.map +1 -0
- package/dist/cjs/internal/database/models/fixture.model.d.ts +4 -0
- package/dist/cjs/internal/database/models/fixture.model.d.ts.map +1 -0
- package/dist/cjs/internal/database/models/fixture.model.js +8 -0
- package/dist/cjs/internal/database/models/fixture.model.js.map +1 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.d.ts +5 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.d.ts.map +1 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.js +11 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.js.map +1 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.d.ts +44 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.d.ts.map +1 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.js +64 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.js.map +1 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.d.ts +51 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.d.ts.map +1 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.js +57 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.js.map +1 -0
- package/dist/cjs/internal/enums/lambda.enum.d.ts +28 -0
- package/dist/cjs/internal/enums/lambda.enum.d.ts.map +1 -0
- package/dist/cjs/internal/enums/lambda.enum.js +34 -0
- package/dist/cjs/internal/enums/lambda.enum.js.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.d.ts +118 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.js +111 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.js.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.d.ts +48 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.js +6 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.js.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.d.ts +23 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.js +149 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.js.map +1 -0
- package/dist/cjs/internal/exceptions/index.d.ts +3 -0
- package/dist/cjs/internal/exceptions/index.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/index.js +24 -0
- package/dist/cjs/internal/exceptions/index.js.map +1 -0
- package/dist/cjs/internal/functions/crypto.functions.d.ts +16 -0
- package/dist/cjs/internal/functions/crypto.functions.d.ts.map +1 -0
- package/dist/cjs/internal/functions/crypto.functions.js +110 -0
- package/dist/cjs/internal/functions/crypto.functions.js.map +1 -0
- package/dist/cjs/internal/functions/helper.functions.d.ts +10 -0
- package/dist/cjs/internal/functions/helper.functions.d.ts.map +1 -0
- package/dist/cjs/internal/functions/helper.functions.js +38 -0
- package/dist/cjs/internal/functions/helper.functions.js.map +1 -0
- package/dist/cjs/internal/functions/index.d.ts +4 -0
- package/dist/cjs/internal/functions/index.d.ts.map +1 -0
- package/dist/cjs/internal/functions/index.js +21 -0
- package/dist/cjs/internal/functions/index.js.map +1 -0
- package/dist/cjs/internal/functions/request.functions.d.ts +14 -0
- package/dist/cjs/internal/functions/request.functions.d.ts.map +1 -0
- package/dist/cjs/internal/functions/request.functions.js +69 -0
- package/dist/cjs/internal/functions/request.functions.js.map +1 -0
- package/dist/cjs/internal/index.d.ts +14 -0
- package/dist/cjs/internal/index.d.ts.map +1 -0
- package/dist/cjs/internal/index.js +42 -0
- package/dist/cjs/internal/index.js.map +1 -0
- package/dist/cjs/internal/interfaces/index.d.ts +3 -0
- package/dist/cjs/internal/interfaces/index.d.ts.map +1 -0
- package/dist/cjs/internal/interfaces/index.js +19 -0
- package/dist/cjs/internal/interfaces/index.js.map +1 -0
- package/dist/cjs/internal/interfaces/request.interface.d.ts +21 -0
- package/dist/cjs/internal/interfaces/request.interface.d.ts.map +1 -0
- package/dist/cjs/internal/interfaces/request.interface.js +15 -0
- package/dist/cjs/internal/interfaces/request.interface.js.map +1 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts +9 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts.map +1 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.js +3 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.js.map +1 -0
- package/dist/cjs/internal/internal-index.d.ts +8 -0
- package/dist/cjs/internal/internal-index.d.ts.map +1 -0
- package/dist/cjs/internal/internal-index.js +33 -0
- package/dist/cjs/internal/internal-index.js.map +1 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.d.ts +90 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.d.ts.map +1 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.js +124 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.js.map +1 -0
- package/dist/cjs/internal/orchestrators/base-workflow.d.ts +50 -0
- package/dist/cjs/internal/orchestrators/base-workflow.d.ts.map +1 -0
- package/dist/cjs/internal/orchestrators/base-workflow.js +68 -0
- package/dist/cjs/internal/orchestrators/base-workflow.js.map +1 -0
- package/dist/cjs/internal/orchestrators/index.d.ts +26 -0
- package/dist/cjs/internal/orchestrators/index.d.ts.map +1 -0
- package/dist/cjs/internal/orchestrators/index.js +46 -0
- package/dist/cjs/internal/orchestrators/index.js.map +1 -0
- package/dist/cjs/internal/utils/index.d.ts +2 -0
- package/dist/cjs/internal/utils/index.d.ts.map +1 -0
- package/dist/cjs/internal/utils/index.js +19 -0
- package/dist/cjs/internal/utils/index.js.map +1 -0
- package/dist/cjs/internal/utils/validation.utils.d.ts +49 -0
- package/dist/cjs/internal/utils/validation.utils.d.ts.map +1 -0
- package/dist/cjs/internal/utils/validation.utils.js +76 -0
- package/dist/cjs/internal/utils/validation.utils.js.map +1 -0
- package/dist/esm/index.d.ts +1 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/token-transaction-input-data.interface.d.ts +2 -1
- package/dist/esm/interfaces/token-transaction-input-data.interface.d.ts.map +1 -1
- package/dist/esm/internal/database/index.d.ts +6 -0
- package/dist/esm/internal/database/index.d.ts.map +1 -0
- package/dist/esm/internal/database/index.js +8 -0
- package/dist/esm/internal/database/index.js.map +1 -0
- package/dist/esm/internal/database/models/base.model.d.ts +7 -0
- package/dist/esm/internal/database/models/base.model.d.ts.map +1 -0
- package/dist/esm/internal/database/models/base.model.js +7 -0
- package/dist/esm/internal/database/models/base.model.js.map +1 -0
- package/dist/esm/internal/database/models/fixture.model.d.ts +4 -0
- package/dist/esm/internal/database/models/fixture.model.d.ts.map +1 -0
- package/dist/esm/internal/database/models/fixture.model.js +4 -0
- package/dist/esm/internal/database/models/fixture.model.js.map +1 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.d.ts +5 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.d.ts.map +1 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.js +8 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.js.map +1 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.d.ts +44 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.d.ts.map +1 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.js +61 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.js.map +1 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.d.ts +51 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.d.ts.map +1 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.js +54 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.js.map +1 -0
- package/dist/esm/internal/enums/lambda.enum.d.ts +28 -0
- package/dist/esm/internal/enums/lambda.enum.d.ts.map +1 -0
- package/dist/esm/internal/enums/lambda.enum.js +31 -0
- package/dist/esm/internal/enums/lambda.enum.js.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.d.ts +118 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.js +108 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.js.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.d.ts +48 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.js +5 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.js.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classifier.d.ts +23 -0
- package/dist/esm/internal/exceptions/base/error-classifier.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classifier.js +145 -0
- package/dist/esm/internal/exceptions/base/error-classifier.js.map +1 -0
- package/dist/esm/internal/exceptions/index.d.ts +3 -0
- package/dist/esm/internal/exceptions/index.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/index.js +6 -0
- package/dist/esm/internal/exceptions/index.js.map +1 -0
- package/dist/esm/internal/functions/crypto.functions.d.ts +16 -0
- package/dist/esm/internal/functions/crypto.functions.d.ts.map +1 -0
- package/dist/esm/internal/functions/crypto.functions.js +67 -0
- package/dist/esm/internal/functions/crypto.functions.js.map +1 -0
- package/dist/esm/internal/functions/helper.functions.d.ts +10 -0
- package/dist/esm/internal/functions/helper.functions.d.ts.map +1 -0
- package/dist/esm/internal/functions/helper.functions.js +32 -0
- package/dist/esm/internal/functions/helper.functions.js.map +1 -0
- package/dist/esm/internal/functions/index.d.ts +4 -0
- package/dist/esm/internal/functions/index.d.ts.map +1 -0
- package/dist/esm/internal/functions/index.js +5 -0
- package/dist/esm/internal/functions/index.js.map +1 -0
- package/dist/esm/internal/functions/request.functions.d.ts +14 -0
- package/dist/esm/internal/functions/request.functions.d.ts.map +1 -0
- package/dist/esm/internal/functions/request.functions.js +61 -0
- package/dist/esm/internal/functions/request.functions.js.map +1 -0
- package/dist/esm/internal/index.d.ts +14 -0
- package/dist/esm/internal/index.d.ts.map +1 -0
- package/dist/esm/internal/index.js +26 -0
- package/dist/esm/internal/index.js.map +1 -0
- package/dist/esm/internal/interfaces/index.d.ts +3 -0
- package/dist/esm/internal/interfaces/index.d.ts.map +1 -0
- package/dist/esm/internal/interfaces/index.js +3 -0
- package/dist/esm/internal/interfaces/index.js.map +1 -0
- package/dist/esm/internal/interfaces/request.interface.d.ts +21 -0
- package/dist/esm/internal/interfaces/request.interface.d.ts.map +1 -0
- package/dist/esm/internal/interfaces/request.interface.js +11 -0
- package/dist/esm/internal/interfaces/request.interface.js.map +1 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts +9 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts.map +1 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.js +2 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.js.map +1 -0
- package/dist/esm/internal/internal-index.d.ts +8 -0
- package/dist/esm/internal/internal-index.d.ts.map +1 -0
- package/dist/esm/internal/internal-index.js +17 -0
- package/dist/esm/internal/internal-index.js.map +1 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.d.ts +90 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.d.ts.map +1 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.js +116 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.js.map +1 -0
- package/dist/esm/internal/orchestrators/base-workflow.d.ts +50 -0
- package/dist/esm/internal/orchestrators/base-workflow.d.ts.map +1 -0
- package/dist/esm/internal/orchestrators/base-workflow.js +64 -0
- package/dist/esm/internal/orchestrators/base-workflow.js.map +1 -0
- package/dist/esm/internal/orchestrators/index.d.ts +26 -0
- package/dist/esm/internal/orchestrators/index.d.ts.map +1 -0
- package/dist/esm/internal/orchestrators/index.js +30 -0
- package/dist/esm/internal/orchestrators/index.js.map +1 -0
- package/dist/esm/internal/utils/index.d.ts +2 -0
- package/dist/esm/internal/utils/index.d.ts.map +1 -0
- package/dist/esm/internal/utils/index.js +3 -0
- package/dist/esm/internal/utils/index.js.map +1 -0
- package/dist/esm/internal/utils/validation.utils.d.ts +49 -0
- package/dist/esm/internal/utils/validation.utils.d.ts.map +1 -0
- package/dist/esm/internal/utils/validation.utils.js +70 -0
- package/dist/esm/internal/utils/validation.utils.js.map +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.functions.d.ts","sourceRoot":"","sources":["../../../../src/internal/functions/crypto.functions.ts"],"names":[],"mappings":"AAKA,KAAK,SAAS,GAAG,KAAK,CAAE;AACxB,KAAK,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjC,MAAM,WAAW,mBAAmB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAEC,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,YAAW,MAAM,GAAG,IAAW,EAAE,YAAW,QAAQ,GAAG,QAAQ,GAAG,KAAgB,KAAG,MAO9H,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,aAAa,MAAM,EAAE,cAAc,MAAM,iBAG5E,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,UAAU,MAAM,EAAE,aAAY,MAA0B,KAAG,OAAO,CAAC,MAAM,CAE3G,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,OAAM,MAAW,WAKzD,CAAA;AAED,eAAO,MAAM,2BAA2B,GACpC,YAAY,MAAM,EAClB,YAAY,MAAM,GAAG,SAAS,EAC9B,UAAS,OAAiB,EAC1B,YAAW,SAAiB,KAC7B,MAWJ,CAAA;AAEH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,eAAe,MAAM,KAAG,mBAmBjE,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,qBAAqB,mBAAmB,EAAE,eAAe,MAAM,KAAG,MAgB7F,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as crypto from 'crypto';
|
|
2
|
+
import { randomBytes } from 'crypto';
|
|
3
|
+
const bcrypt = require('bcryptjs');
|
|
4
|
+
const defaultSaltRounds = 10;
|
|
5
|
+
export const hashString = (input, maxLength = null, algorithm = 'sha256') => {
|
|
6
|
+
// Generate a hash of the input string
|
|
7
|
+
let hash = crypto.createHash(algorithm).update(input).digest('hex');
|
|
8
|
+
if (typeof maxLength === 'number' && hash.length > maxLength) {
|
|
9
|
+
hash = hash.substring(0, maxLength);
|
|
10
|
+
}
|
|
11
|
+
return hash;
|
|
12
|
+
};
|
|
13
|
+
export const checkMatching = async (plainString, hashedString) => {
|
|
14
|
+
const match = await bcrypt.compare(plainString, hashedString);
|
|
15
|
+
return match;
|
|
16
|
+
};
|
|
17
|
+
export const hashPassword = async (password, saltRounds = defaultSaltRounds) => {
|
|
18
|
+
return await bcrypt.hash(password, saltRounds);
|
|
19
|
+
};
|
|
20
|
+
export const generatePseudoRandomData = (size = 32) => {
|
|
21
|
+
// Convert the byte array into a hexadecimal string
|
|
22
|
+
let salt = randomBytes(size).toString('hex');
|
|
23
|
+
return salt;
|
|
24
|
+
};
|
|
25
|
+
export const generateDecryptedPrivateKey = (privateKey, passphrase, keyType = 'pkcs8', keyFormat = 'pem') => {
|
|
26
|
+
const decryptedPrivateKey = crypto.createPrivateKey({
|
|
27
|
+
key: privateKey,
|
|
28
|
+
format: keyFormat,
|
|
29
|
+
type: keyType,
|
|
30
|
+
passphrase: passphrase,
|
|
31
|
+
});
|
|
32
|
+
return decryptedPrivateKey.export({ format: keyFormat, type: keyType }).toString();
|
|
33
|
+
};
|
|
34
|
+
export const encryptData = (data, encryptionKey) => {
|
|
35
|
+
try {
|
|
36
|
+
const key = Buffer.from(encryptionKey, 'hex');
|
|
37
|
+
const iv = crypto.randomBytes(16);
|
|
38
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
|
|
39
|
+
let encryptedData = cipher.update(data, 'utf8', 'hex');
|
|
40
|
+
encryptedData += cipher.final('hex');
|
|
41
|
+
const authTag = cipher.getAuthTag().toString('hex');
|
|
42
|
+
return {
|
|
43
|
+
encryptedData,
|
|
44
|
+
iv: iv.toString('hex'),
|
|
45
|
+
authTag
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new Error('Error encrypting data: ' + error.message);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const decryptData = (encryptedDataObject, encryptionKey) => {
|
|
53
|
+
try {
|
|
54
|
+
const key = Buffer.from(encryptionKey, 'hex');
|
|
55
|
+
const ivBuffer = Buffer.from(encryptedDataObject.iv, 'hex');
|
|
56
|
+
const authTagBuffer = Buffer.from(encryptedDataObject.authTag, 'hex');
|
|
57
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', key, ivBuffer);
|
|
58
|
+
decipher.setAuthTag(authTagBuffer);
|
|
59
|
+
let decryptedData = decipher.update(encryptedDataObject.encryptedData, 'hex', 'utf8');
|
|
60
|
+
decryptedData += decipher.final('utf8');
|
|
61
|
+
return decryptedData;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new Error('Error decrypting data: ' + error.message);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=crypto.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.functions.js","sourceRoot":"","sources":["../../../../src/internal/functions/crypto.functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAClC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAWzB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,YAA2B,IAAI,EAAE,YAAyC,QAAQ,EAAU,EAAE;IACpI,sCAAsC;IACtC,IAAI,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACnE,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAC/D,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,WAAmB,EAAE,YAAoB,EAAE,EAAE;IAC7E,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAC7D,OAAO,KAAK,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,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@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a comma-separated string into an array of strings.
|
|
3
|
+
*
|
|
4
|
+
* @param commaSeparatedString - The string to parse.
|
|
5
|
+
* @returns An array of trimmed, non-empty strings.
|
|
6
|
+
*/
|
|
7
|
+
export declare const parseCommaSeparatedStringToStringArray: (commaSeparatedString: string | null) => string[];
|
|
8
|
+
export declare const checkIfTokenIdIsUri: (tokenId: string | null) => boolean;
|
|
9
|
+
export declare const compareVersions: (version1: string, version2: string) => number;
|
|
10
|
+
//# sourceMappingURL=helper.functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.functions.d.ts","sourceRoot":"","sources":["../../../../src/internal/functions/helper.functions.ts"],"names":[],"mappings":"AAEA;;;;;KAKK;AACL,eAAO,MAAM,sCAAsC,GAAI,sBAAsB,MAAM,GAAG,IAAI,KAAG,MAAM,EAI9F,CAAA;AAGL,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,GAAG,IAAI,KAAG,OAM5D,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,KAAG,MAWpE,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a comma-separated string into an array of strings.
|
|
3
|
+
*
|
|
4
|
+
* @param commaSeparatedString - The string to parse.
|
|
5
|
+
* @returns An array of trimmed, non-empty strings.
|
|
6
|
+
*/
|
|
7
|
+
export const parseCommaSeparatedStringToStringArray = (commaSeparatedString) => {
|
|
8
|
+
return commaSeparatedString
|
|
9
|
+
? commaSeparatedString.split(',').map((s) => s.trim()).filter(Boolean)
|
|
10
|
+
: [];
|
|
11
|
+
};
|
|
12
|
+
export const checkIfTokenIdIsUri = (tokenId) => {
|
|
13
|
+
const uriRegex = /^(https?|ipfs):\/\/.*/;
|
|
14
|
+
if (!tokenId || !uriRegex.test(tokenId)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
export const compareVersions = (version1, version2) => {
|
|
20
|
+
const v1 = version1.split('.').map(Number);
|
|
21
|
+
const v2 = version2.split('.').map(Number);
|
|
22
|
+
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
|
|
23
|
+
const num1 = v1[i] || 0;
|
|
24
|
+
const num2 = v2[i] || 0;
|
|
25
|
+
if (num1 > num2)
|
|
26
|
+
return 1;
|
|
27
|
+
if (num1 < num2)
|
|
28
|
+
return -1;
|
|
29
|
+
}
|
|
30
|
+
return 0;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=helper.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.functions.js","sourceRoot":"","sources":["../../../../src/internal/functions/helper.functions.ts"],"names":[],"mappings":"AAEA;;;;;KAKK;AACL,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,oBAAmC,EAAY,EAAE;IACpG,OAAO,oBAAoB;QACzB,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QACtE,CAAC,CAAC,EAAE,CAAC;AACP,CAAC,CAAA;AAGL,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAsB,EAAW,EAAE;IACnE,MAAM,QAAQ,GAAG,uBAAuB,CAAC;IAC3C,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,QAAgB,EAAU,EAAE;IAC5E,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,IAAI,GAAG,IAAI;YAAE,OAAO,CAAC,CAAC;QAC1B,IAAI,IAAI,GAAG,IAAI;YAAE,OAAO,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/functions/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/functions/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AllowedAppRequestHeaders, ExtendedAppRequest } from "../interfaces/request.interface";
|
|
2
|
+
export declare const extractTokenFromHeader: (request: Request, tokenName: keyof AllowedAppRequestHeaders) => string | undefined;
|
|
3
|
+
export declare const getIpFromRequest: (request: Request | ExtendedAppRequest) => string | null;
|
|
4
|
+
/**
|
|
5
|
+
* Anonymize IP address for privacy compliance (GDPR/CCPA)
|
|
6
|
+
* Removes last octet for IPv4, last 80 bits for IPv6
|
|
7
|
+
*/
|
|
8
|
+
export declare const anonymizeIp: (ip: string | null) => string | null;
|
|
9
|
+
export declare const getTenantFromStripeRequest: (req: Request) => {
|
|
10
|
+
tenantId: string;
|
|
11
|
+
isTestnet: boolean;
|
|
12
|
+
} | undefined;
|
|
13
|
+
export declare const setRequestValue: (request: Request, key: keyof ExtendedAppRequest, value: any) => void;
|
|
14
|
+
//# sourceMappingURL=request.functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.functions.d.ts","sourceRoot":"","sources":["../../../../src/internal/functions/request.functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAI/F,eAAO,MAAM,sBAAsB,GAAI,SAAS,OAAO,EAAE,WAAW,MAAM,wBAAwB,KAAG,MAAM,GAAG,SAI3G,CAAA;AAGH,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,GAAG,kBAAkB,KAAG,MAAM,GAAG,IAejF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,IAoBxD,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,KAAK,OAAO;cASnB,MAAM;eACJ,OAAO;aAE5C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,SAAS,OAAO,EAAE,KAAK,MAAM,kBAAkB,EAAE,OAAO,GAAG,SAE1F,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const extractTokenFromHeader = (request, tokenName) => {
|
|
2
|
+
// get key from header
|
|
3
|
+
const token = request?.headers ? (request?.headers)[tokenName] || '' : '';
|
|
4
|
+
return token;
|
|
5
|
+
};
|
|
6
|
+
// Enhanced IP extraction with better proxy support
|
|
7
|
+
export const getIpFromRequest = (request) => {
|
|
8
|
+
// Try multiple IP sources in order of preference
|
|
9
|
+
const ip = request.ip ||
|
|
10
|
+
request.headers['x-forwarded-for']?.split(',')[0]?.trim() ||
|
|
11
|
+
request.headers['x-real-ip']?.trim() ||
|
|
12
|
+
request.connection?.remoteAddress?.trim() ||
|
|
13
|
+
request.socket?.remoteAddress?.trim() ||
|
|
14
|
+
null;
|
|
15
|
+
// Clean IPv6 mapped IPv4 addresses
|
|
16
|
+
if (ip?.startsWith('::ffff:')) {
|
|
17
|
+
return ip.substring(7);
|
|
18
|
+
}
|
|
19
|
+
return ip;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Anonymize IP address for privacy compliance (GDPR/CCPA)
|
|
23
|
+
* Removes last octet for IPv4, last 80 bits for IPv6
|
|
24
|
+
*/
|
|
25
|
+
export const anonymizeIp = (ip) => {
|
|
26
|
+
if (!ip)
|
|
27
|
+
return null;
|
|
28
|
+
// IPv4 anonymization - remove last octet
|
|
29
|
+
if (ip.includes('.') && !ip.includes(':')) {
|
|
30
|
+
const parts = ip.split('.');
|
|
31
|
+
if (parts.length === 4) {
|
|
32
|
+
return `${parts[0]}.${parts[1]}.${parts[2]}.0`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// IPv6 anonymization - remove last 80 bits (keep first 48 bits)
|
|
36
|
+
if (ip.includes(':')) {
|
|
37
|
+
const parts = ip.split(':');
|
|
38
|
+
if (parts.length >= 3) {
|
|
39
|
+
return `${parts[0]}:${parts[1]}:${parts[2]}::`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return ip; // Return as-is if format not recognized
|
|
43
|
+
};
|
|
44
|
+
export const getTenantFromStripeRequest = (req) => {
|
|
45
|
+
const sig = req?.headers ? (req?.headers)['stripe-signature'] || '' : '';
|
|
46
|
+
if (!sig)
|
|
47
|
+
return;
|
|
48
|
+
const body = req?.body;
|
|
49
|
+
const data = body?.data;
|
|
50
|
+
const object = data?.object;
|
|
51
|
+
const metadata = object?.metadata;
|
|
52
|
+
return {
|
|
53
|
+
tenantId: metadata?.tenantId,
|
|
54
|
+
isTestnet: metadata?.isTestnet,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export const setRequestValue = (request, key, value) => {
|
|
58
|
+
if (request)
|
|
59
|
+
request[key] = value;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=request.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.functions.js","sourceRoot":"","sources":["../../../../src/internal/functions/request.functions.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAgB,EAAE,SAAyC,EAAsB,EAAE;IACtH,sBAAsB;IACtB,MAAM,KAAK,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAe,CAAA,CAAC,SAAS,CAAW,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3F,OAAO,KAAK,CAAC;AACf,CAAC,CAAA;AAEH,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAqC,EAAiB,EAAE;IACvF,iDAAiD;IACjD,MAAM,EAAE,GAAI,OAAe,CAAC,EAAE;QACnB,OAAe,CAAC,OAAO,CAAC,iBAAiB,CAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE;QAC5E,OAAe,CAAC,OAAO,CAAC,WAAW,CAAY,EAAE,IAAI,EAAE;QACvD,OAAe,CAAC,UAAU,EAAE,aAAwB,EAAE,IAAI,EAAE;QAC5D,OAAe,CAAC,MAAM,EAAE,aAAwB,EAAE,IAAI,EAAE;QAC1D,IAAI,CAAC;IAEd,mCAAmC;IACnC,IAAI,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED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C;IAC9B,MAAM,IAAI,GAAG,IAAI,EAAE,IAAW,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,EAAE,MAAa,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAuC,CAAC;IAEjE,OAAO;QACL,QAAQ,EAAE,QAAQ,EAAE,QAAkB;QACtC,SAAS,EAAE,QAAQ,EAAE,SAAoB;KAC1C,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,GAA6B,EAAE,KAAU,EAAE,EAAE;IAC7F,IAAG,OAAO;QAAE,OAAqC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACjE,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './orchestrators';
|
|
2
|
+
export * from './database';
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export * from './exceptions';
|
|
5
|
+
export * from './enums/lambda.enum';
|
|
6
|
+
export * from './functions';
|
|
7
|
+
export * from './interfaces';
|
|
8
|
+
export * from '../enum';
|
|
9
|
+
export * from '../value-objects';
|
|
10
|
+
export * from '../interfaces';
|
|
11
|
+
export * from '../types';
|
|
12
|
+
export * from '../dto';
|
|
13
|
+
export * from '../errors';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAGhC,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAK7B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAGvB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// PERS Shared Patterns Library - Internal Architecture Components
|
|
2
|
+
// 🔒 PRIVATE: For internal PERS microservices only
|
|
3
|
+
// Orchestrators - Business coordination patterns
|
|
4
|
+
export * from './orchestrators';
|
|
5
|
+
// Database - Shared entity models and schemas
|
|
6
|
+
export * from './database';
|
|
7
|
+
// Utils - Validation and utility functions
|
|
8
|
+
export * from './utils';
|
|
9
|
+
// Exceptions - Business and technical error classes
|
|
10
|
+
export * from './exceptions';
|
|
11
|
+
// Enums - Internal business enums for microservice communication
|
|
12
|
+
export * from './enums/lambda.enum';
|
|
13
|
+
export * from './functions';
|
|
14
|
+
export * from './interfaces';
|
|
15
|
+
// Shared Pattern
|
|
16
|
+
// Core domain contracts
|
|
17
|
+
export * from '../enum';
|
|
18
|
+
export * from '../value-objects';
|
|
19
|
+
export * from '../interfaces';
|
|
20
|
+
export * from '../types';
|
|
21
|
+
export * from '../dto';
|
|
22
|
+
// Error handling system
|
|
23
|
+
export * from '../errors';
|
|
24
|
+
// Note: This library contains proprietary business logic and architecture patterns
|
|
25
|
+
// It should only be used within PERS internal microservices
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,mDAAmD;AAEnD,iDAAiD;AACjD,cAAc,iBAAiB,CAAC;AAEhC,8CAA8C;AAC9C,cAAc,YAAY,CAAC;AAE3B,2CAA2C;AAC3C,cAAc,SAAS,CAAC;AAExB,oDAAoD;AACpD,cAAc,cAAc,CAAC;AAE7B,iEAAiE;AACjE,cAAc,qBAAqB,CAAC;AAEpC,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAG7B,iBAAiB;AACjB,wBAAwB;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,wBAAwB;AACxB,cAAc,WAAW,CAAC;AAE1B,mFAAmF;AACnF,4DAA4D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/interfaces/index.ts"],"names":[],"mappings":"AAEA,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/interfaces/index.ts"],"names":[],"mappings":"AAEA,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UserDTO, TenantDTO, BusinessDTO, AdminDTO } from '@explorins/pers-shared';
|
|
2
|
+
export interface ExtendedAppRequest extends Request {
|
|
3
|
+
tenant?: TenantDTO;
|
|
4
|
+
business?: BusinessDTO;
|
|
5
|
+
user?: UserDTO;
|
|
6
|
+
admin?: AdminDTO;
|
|
7
|
+
isVerifiedTenantAdmin?: boolean;
|
|
8
|
+
originalIp?: string;
|
|
9
|
+
anonymizedIp?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class AllowedAppRequestHeaders {
|
|
12
|
+
'x-project-key': string;
|
|
13
|
+
'x-api-key': string;
|
|
14
|
+
'Authorization': string;
|
|
15
|
+
'Origin': string;
|
|
16
|
+
'X-Requested-With': string;
|
|
17
|
+
'Content-Type': string;
|
|
18
|
+
'Accept': string;
|
|
19
|
+
'stripe-signature': string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=request.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.interface.d.ts","sourceRoot":"","sources":["../../../../src/internal/interfaces/request.interface.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEjF,MAAM,WAAW,kBAAmB,SAAQ,OAAO;IAC/C,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAE/B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB;AACD,qBAAa,wBAAwB;IACjC,eAAe,EAAE,MAAM,CAAkB;IACzC,WAAW,EAAE,MAAM,CAAc;IACjC,eAAe,EAAE,MAAM,CAAkB;IACzC,QAAQ,EAAE,MAAM,CAAW;IAC3B,kBAAkB,EAAE,MAAM,CAAqB;IAC/C,cAAc,EAAE,MAAM,CAAiB;IACvC,QAAQ,EAAE,MAAM,CAAW;IAC3B,kBAAkB,EAAE,MAAM,CAAqB;CAClD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class AllowedAppRequestHeaders {
|
|
2
|
+
'x-project-key' = 'x-project-key';
|
|
3
|
+
'x-api-key' = 'x-api-key';
|
|
4
|
+
'Authorization' = 'Authorization';
|
|
5
|
+
'Origin' = 'Origin';
|
|
6
|
+
'X-Requested-With' = 'X-Requested-With';
|
|
7
|
+
'Content-Type' = 'Content-Type';
|
|
8
|
+
'Accept' = 'Accept';
|
|
9
|
+
'stripe-signature' = 'stripe-signature';
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=request.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.interface.js","sourceRoot":"","sources":["../../../../src/internal/interfaces/request.interface.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,wBAAwB;IACjC,eAAe,GAAW,eAAe,CAAA;IACzC,WAAW,GAAW,WAAW,CAAA;IACjC,eAAe,GAAW,eAAe,CAAA;IACzC,QAAQ,GAAW,QAAQ,CAAA;IAC3B,kBAAkB,GAAW,kBAAkB,CAAA;IAC/C,cAAc,GAAW,cAAc,CAAA;IACvC,QAAQ,GAAW,QAAQ,CAAA;IAC3B,kBAAkB,GAAW,kBAAkB,CAAA;CAClD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface StripePaymentIntentMetadata {
|
|
2
|
+
accountAddress: string;
|
|
3
|
+
tokenAddress: string;
|
|
4
|
+
tokenId: string | null;
|
|
5
|
+
minterAddress: string;
|
|
6
|
+
tenantId: string;
|
|
7
|
+
isTestnet: boolean;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=stripe-payment-intent-metadata.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-payment-intent-metadata.interface.d.ts","sourceRoot":"","sources":["../../../../src/internal/interfaces/stripe-payment-intent-metadata.interface.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,2BAA2B;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-payment-intent-metadata.interface.js","sourceRoot":"","sources":["../../../../src/internal/interfaces/stripe-payment-intent-metadata.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './orchestrators';
|
|
2
|
+
export * from './database';
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export * from './exceptions';
|
|
5
|
+
export * from './enums/lambda.enum';
|
|
6
|
+
export * from './functions';
|
|
7
|
+
export * from './interfaces';
|
|
8
|
+
//# sourceMappingURL=internal-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-index.d.ts","sourceRoot":"","sources":["../../../src/internal/internal-index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAGhC,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// PERS Shared Patterns Library - Internal Architecture Components
|
|
2
|
+
// 🔒 PRIVATE: For internal PERS microservices only
|
|
3
|
+
// Orchestrators - Business coordination patterns
|
|
4
|
+
export * from './orchestrators';
|
|
5
|
+
// Database - Shared entity models and schemas
|
|
6
|
+
export * from './database';
|
|
7
|
+
// Utils - Validation and utility functions
|
|
8
|
+
export * from './utils';
|
|
9
|
+
// Exceptions - Business and technical error classes
|
|
10
|
+
export * from './exceptions';
|
|
11
|
+
// Enums - Internal business enums for microservice communication
|
|
12
|
+
export * from './enums/lambda.enum';
|
|
13
|
+
export * from './functions';
|
|
14
|
+
export * from './interfaces';
|
|
15
|
+
// Note: This library contains proprietary business logic and architecture patterns
|
|
16
|
+
// It should only be used within PERS internal microservices
|
|
17
|
+
//# sourceMappingURL=internal-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-index.js","sourceRoot":"","sources":["../../../src/internal/internal-index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,mDAAmD;AAEnD,iDAAiD;AACjD,cAAc,iBAAiB,CAAC;AAEhC,8CAA8C;AAC9C,cAAc,YAAY,CAAC;AAE3B,2CAA2C;AAC3C,cAAc,SAAS,CAAC;AAExB,oDAAoD;AACpD,cAAc,cAAc,CAAC;AAE7B,iEAAiE;AACjE,cAAc,qBAAqB,CAAC;AAEpC,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAE7B,mFAAmF;AACnF,4DAA4D"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
|
3
|
+
import { OrchestrationError } from '@explorins/pers-shared';
|
|
4
|
+
/**
|
|
5
|
+
* BaseOrchestrator - Centralized Application Layer Orchestration Pattern
|
|
6
|
+
*
|
|
7
|
+
* @description Foundation for all domain orchestrators following PERS DDD principles:
|
|
8
|
+
* - Application layer orchestrates cross-domain operations via CQRS
|
|
9
|
+
* - Domain services contain pure business logic only
|
|
10
|
+
* - Microservice boundary preparation through clean abstractions
|
|
11
|
+
* - Consistent patterns across all domains (transaction, user, wallet, token, etc.)
|
|
12
|
+
* - Smart error handling that preserves business context
|
|
13
|
+
*
|
|
14
|
+
* @usage Extend this class in domain-specific orchestrators:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* @Injectable()
|
|
17
|
+
* export class UserOrchestrator extends BaseOrchestrator {
|
|
18
|
+
* constructor(commandBus: CommandBus, queryBus: QueryBus) {
|
|
19
|
+
* super(commandBus, queryBus, UserOrchestrator.name);
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @library @explorins/pers-shared
|
|
25
|
+
* @version 2.0.0
|
|
26
|
+
* @since August 2025
|
|
27
|
+
*/
|
|
28
|
+
export declare abstract class BaseOrchestrator {
|
|
29
|
+
protected readonly commandBus: CommandBus;
|
|
30
|
+
protected readonly queryBus: QueryBus;
|
|
31
|
+
protected readonly logger: Logger;
|
|
32
|
+
protected constructor(commandBus: CommandBus, queryBus: QueryBus, loggerContext: string);
|
|
33
|
+
/**
|
|
34
|
+
* Enhanced error handling that preserves business errors while wrapping technical errors
|
|
35
|
+
* Business errors (with category: DOMAIN_RULE) are passed through unchanged
|
|
36
|
+
* Technical errors are wrapped in OrchestrationError for consistent handling
|
|
37
|
+
*/
|
|
38
|
+
protected executeWithErrorHandling<T>(operation: () => Promise<T>, operationName: string, context?: Record<string, any>): Promise<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Execute CQRS command with consistent error handling and logging
|
|
41
|
+
* Standardizes command execution across all orchestrators
|
|
42
|
+
*/
|
|
43
|
+
protected executeCommand<T>(command: any, operationName?: string): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Execute CQRS query with consistent error handling and logging
|
|
46
|
+
* Standardizes query execution across all orchestrators
|
|
47
|
+
*/
|
|
48
|
+
protected executeQuery<T>(query: any, operationName?: string): Promise<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Execute multiple operations in parallel with error handling
|
|
51
|
+
* Useful for batch operations across domains
|
|
52
|
+
*/
|
|
53
|
+
protected executeParallel<T>(operations: (() => Promise<T>)[], operationName: string): Promise<T[]>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Result pattern for orchestrator operations (optional - for complex flows)
|
|
57
|
+
* Provides type-safe error handling without exceptions
|
|
58
|
+
*/
|
|
59
|
+
export type OrchestrationResult<T> = {
|
|
60
|
+
success: true;
|
|
61
|
+
data: T;
|
|
62
|
+
operation?: string;
|
|
63
|
+
} | {
|
|
64
|
+
success: false;
|
|
65
|
+
error: OrchestrationError;
|
|
66
|
+
operation?: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Helper function to create success result
|
|
70
|
+
*/
|
|
71
|
+
export declare function createSuccessResult<T>(data: T, operation?: string): OrchestrationResult<T>;
|
|
72
|
+
/**
|
|
73
|
+
* Helper function to create error result
|
|
74
|
+
*/
|
|
75
|
+
export declare function createErrorResult<T>(error: OrchestrationError, operation?: string): OrchestrationResult<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Utility function to check if result is successful
|
|
78
|
+
* Provides type guard for TypeScript
|
|
79
|
+
*/
|
|
80
|
+
export declare function isSuccessResult<T>(result: OrchestrationResult<T>): result is {
|
|
81
|
+
success: true;
|
|
82
|
+
data: T;
|
|
83
|
+
operation?: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Utility function to extract data from result or throw error
|
|
87
|
+
* Useful for converting result pattern back to exception-based flow
|
|
88
|
+
*/
|
|
89
|
+
export declare function unwrapResult<T>(result: OrchestrationResult<T>): T;
|
|
90
|
+
//# sourceMappingURL=base-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-orchestrator.d.ts","sourceRoot":"","sources":["../../../../src/internal/orchestrators/base-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAiB,MAAM,wBAAwB,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,gBAAgB;IAIlC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU;IACzC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ;IAJvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAElC,SAAS,aACY,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EACrC,aAAa,EAAE,MAAM;IAKvB;;;;OAIG;cACa,wBAAwB,CAAC,CAAC,EACxC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC;IAwBb;;;OAGG;cACa,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IASnF;;;OAGG;cACa,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAS/E;;;OAGG;cACa,eAAe,CAAC,CAAC,EAC/B,UAAU,EAAE,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAChC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,CAAC,EAAE,CAAC;CAOhB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IACnC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG;IACF,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,kBAAkB,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAE1F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAE1G;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAE3H;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAKjE"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Logger, HttpException } from '@nestjs/common';
|
|
2
|
+
import { OrchestrationError, ErrorCategory } from '@explorins/pers-shared';
|
|
3
|
+
/**
|
|
4
|
+
* BaseOrchestrator - Centralized Application Layer Orchestration Pattern
|
|
5
|
+
*
|
|
6
|
+
* @description Foundation for all domain orchestrators following PERS DDD principles:
|
|
7
|
+
* - Application layer orchestrates cross-domain operations via CQRS
|
|
8
|
+
* - Domain services contain pure business logic only
|
|
9
|
+
* - Microservice boundary preparation through clean abstractions
|
|
10
|
+
* - Consistent patterns across all domains (transaction, user, wallet, token, etc.)
|
|
11
|
+
* - Smart error handling that preserves business context
|
|
12
|
+
*
|
|
13
|
+
* @usage Extend this class in domain-specific orchestrators:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @Injectable()
|
|
16
|
+
* export class UserOrchestrator extends BaseOrchestrator {
|
|
17
|
+
* constructor(commandBus: CommandBus, queryBus: QueryBus) {
|
|
18
|
+
* super(commandBus, queryBus, UserOrchestrator.name);
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @library @explorins/pers-shared
|
|
24
|
+
* @version 2.0.0
|
|
25
|
+
* @since August 2025
|
|
26
|
+
*/
|
|
27
|
+
export class BaseOrchestrator {
|
|
28
|
+
commandBus;
|
|
29
|
+
queryBus;
|
|
30
|
+
logger;
|
|
31
|
+
constructor(commandBus, queryBus, loggerContext) {
|
|
32
|
+
this.commandBus = commandBus;
|
|
33
|
+
this.queryBus = queryBus;
|
|
34
|
+
this.logger = new Logger(loggerContext);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Enhanced error handling that preserves business errors while wrapping technical errors
|
|
38
|
+
* Business errors (with category: DOMAIN_RULE) are passed through unchanged
|
|
39
|
+
* Technical errors are wrapped in OrchestrationError for consistent handling
|
|
40
|
+
*/
|
|
41
|
+
async executeWithErrorHandling(operation, operationName, context) {
|
|
42
|
+
try {
|
|
43
|
+
this.logger.debug(`🚀 Starting ${operationName}`, context);
|
|
44
|
+
const result = await operation();
|
|
45
|
+
this.logger.debug(`✅ Completed ${operationName}`, context);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
50
|
+
// Preserve business errors - don't wrap them
|
|
51
|
+
if (error instanceof HttpException) {
|
|
52
|
+
const response = error.getResponse();
|
|
53
|
+
if (typeof response === 'object' && response?.category === ErrorCategory.DOMAIN_RULE) {
|
|
54
|
+
this.logger.warn(`⚠️ Business logic error in ${operationName}: ${errorMessage}`, { ...context, error });
|
|
55
|
+
throw error; // Pass through unchanged
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Wrap technical errors
|
|
59
|
+
this.logger.error(`❌ Failed ${operationName}: ${errorMessage}`, { ...context, error });
|
|
60
|
+
throw new OrchestrationError(operationName, error instanceof Error ? error : new Error(errorMessage));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Execute CQRS command with consistent error handling and logging
|
|
65
|
+
* Standardizes command execution across all orchestrators
|
|
66
|
+
*/
|
|
67
|
+
async executeCommand(command, operationName) {
|
|
68
|
+
const operation = operationName || `Command: ${command.constructor.name}`;
|
|
69
|
+
return this.executeWithErrorHandling(() => this.commandBus.execute(command), operation, { commandType: command.constructor.name });
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Execute CQRS query with consistent error handling and logging
|
|
73
|
+
* Standardizes query execution across all orchestrators
|
|
74
|
+
*/
|
|
75
|
+
async executeQuery(query, operationName) {
|
|
76
|
+
const operation = operationName || `Query: ${query.constructor.name}`;
|
|
77
|
+
return this.executeWithErrorHandling(() => this.queryBus.execute(query), operation, { queryType: query.constructor.name });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Execute multiple operations in parallel with error handling
|
|
81
|
+
* Useful for batch operations across domains
|
|
82
|
+
*/
|
|
83
|
+
async executeParallel(operations, operationName) {
|
|
84
|
+
return this.executeWithErrorHandling(() => Promise.all(operations.map(op => op())), `Parallel: ${operationName}`, { operationCount: operations.length });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Helper function to create success result
|
|
89
|
+
*/
|
|
90
|
+
export function createSuccessResult(data, operation) {
|
|
91
|
+
return { success: true, data, operation };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Helper function to create error result
|
|
95
|
+
*/
|
|
96
|
+
export function createErrorResult(error, operation) {
|
|
97
|
+
return { success: false, error, operation };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Utility function to check if result is successful
|
|
101
|
+
* Provides type guard for TypeScript
|
|
102
|
+
*/
|
|
103
|
+
export function isSuccessResult(result) {
|
|
104
|
+
return result.success === true;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Utility function to extract data from result or throw error
|
|
108
|
+
* Useful for converting result pattern back to exception-based flow
|
|
109
|
+
*/
|
|
110
|
+
export function unwrapResult(result) {
|
|
111
|
+
if (isSuccessResult(result)) {
|
|
112
|
+
return result.data;
|
|
113
|
+
}
|
|
114
|
+
throw result.error;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=base-orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-orchestrator.js","sourceRoot":"","sources":["../../../../src/internal/orchestrators/base-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAgB,gBAAgB;IAIf;IACA;IAJF,MAAM,CAAS;IAElC,YACqB,UAAsB,EACtB,QAAkB,EACrC,aAAqB;QAFF,eAAU,GAAV,UAAU,CAAY;QACtB,aAAQ,GAAR,QAAQ,CAAU;QAGrC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,wBAAwB,CACtC,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