@burgan-tech/morph-idm-runtime 0.0.0 → 0.0.2
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/burgan-tech-morph-idm-runtime-0.0.2.tgz +0 -0
- package/morph-idm/Schemas/{user → person}/person-master-1.0.0.json +1 -1
- package/morph-idm/Schemas/token/token-start-1.0.0.json +6 -19
- package/morph-idm/Schemas/user/user-master-1.0.0.json +46 -1
- package/morph-idm/Schemas/user-login/retry-login-1.0.0.json +39 -0
- package/morph-idm/Tasks/call-device-start-1.0.0.json +1 -1
- package/morph-idm/Tasks/call-device-update-1.0.0.json +1 -1
- package/morph-idm/Tasks/consent/consent-auto-select-script.json +16 -0
- package/morph-idm/Tasks/device/search-device-task.json +22 -0
- package/morph-idm/Tasks/get-device-1.0.0.json +1 -1
- package/morph-idm/Tasks/person/get-person-by-task.json +19 -0
- package/morph-idm/Tasks/person/person-update-direct-transition.json +23 -0
- package/morph-idm/Tasks/token/token-create-jwt.json +0 -1
- package/morph-idm/Tasks/token/token-redeem-trigger.json +22 -0
- package/morph-idm/Tasks/token/user-login-get-as-filterable.json +22 -0
- package/morph-idm/Tasks/user/evaluate-failed-login-script.json +18 -0
- package/morph-idm/Tasks/user/get-phone-from-person-task.json +20 -0
- package/morph-idm/Tasks/user/otp-code-generator.json +15 -0
- package/morph-idm/Tasks/user/send-otp-sms-task.json +26 -0
- package/morph-idm/Tasks/user/send-push-task.json +4 -1
- package/morph-idm/Tasks/user/user-update-password-fail-count.json +24 -0
- package/morph-idm/Tasks/user-login/auth-code-generator.json +17 -0
- package/morph-idm/Tasks/user-login/increment-local-fail-count.json +17 -0
- package/morph-idm/Tasks/user-login/password-verify.json +26 -0
- package/morph-idm/TestCases/test-123/.httpyac.json +15 -0
- package/morph-idm/TestCases/test-123/01-person.http +95 -0
- package/morph-idm/TestCases/test-123/02-user.http +83 -0
- package/morph-idm/TestCases/test-123/03-scope.http +65 -0
- package/morph-idm/TestCases/test-123/04-consent.http +66 -0
- package/morph-idm/TestCases/test-123/05-device.http +86 -0
- package/morph-idm/TestCases/test-123/06-user-login.http +206 -0
- package/morph-idm/TestCases/test-123/README.md +112 -0
- package/morph-idm/TestCases/test-123/cleanup.js +49 -0
- package/morph-idm/TestCases/test-123/cleanup.sh +20 -0
- package/morph-idm/TestCases/test-123/cleanup.sql +45 -0
- package/morph-idm/TestCases/test-123/http-client.env.json +13 -0
- package/morph-idm/TestCases/test-123/run-setup.sh +42 -0
- package/morph-idm/TestCases/test-auto-consent/.httpyac.json +14 -0
- package/morph-idm/TestCases/test-auto-consent/01-person.http +72 -0
- package/morph-idm/TestCases/test-auto-consent/02-user.http +74 -0
- package/morph-idm/TestCases/test-auto-consent/03-scope.http +66 -0
- package/morph-idm/TestCases/test-auto-consent/04-device.http +56 -0
- package/morph-idm/TestCases/test-auto-consent/05-user-login.http +132 -0
- package/morph-idm/TestCases/test-auto-consent/README.md +36 -0
- package/morph-idm/TestCases/test-auto-consent/cleanup.js +47 -0
- package/morph-idm/TestCases/test-auto-consent/run-setup.sh +50 -0
- package/morph-idm/TestCases/test-multiple-consent/.httpyac.json +17 -0
- package/morph-idm/TestCases/test-multiple-consent/01-person.http +103 -0
- package/morph-idm/TestCases/test-multiple-consent/02-user.http +83 -0
- package/morph-idm/TestCases/test-multiple-consent/03-scope-2.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/03-scope.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/04-consent-1.http +67 -0
- package/morph-idm/TestCases/test-multiple-consent/04-consent-2.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/05-device.http +87 -0
- package/morph-idm/TestCases/test-multiple-consent/06-user-login.http +183 -0
- package/morph-idm/TestCases/test-multiple-consent/README.md +37 -0
- package/morph-idm/TestCases/test-multiple-consent/cleanup.js +46 -0
- package/morph-idm/TestCases/test-multiple-consent/cleanup.sh +20 -0
- package/morph-idm/TestCases/test-multiple-consent/run-setup.sh +53 -0
- package/morph-idm/Views/user-login/push-waiting.json +28 -0
- package/morph-idm/Views/user-login/start.json +28 -0
- package/morph-idm/Workflows/client/client-1.0.0.json +1 -1
- package/morph-idm/Workflows/client/execute/client.http +1 -1
- package/morph-idm/Workflows/client/src/PasswordGeneratorMapping.csx +0 -1
- package/morph-idm/Workflows/consent-selection/consent-selection-1.0.0.json +37 -6
- package/morph-idm/Workflows/consent-selection/execute/multi-consent-selection.http +209 -0
- package/morph-idm/Workflows/consent-selection/src/ConsentSelectedMapping.csx +18 -22
- package/morph-idm/Workflows/consent-selection/src/CreateAutoConsentMapping.csx +45 -45
- package/morph-idm/Workflows/consent-selection/src/MultipleConsentsRule.csx +12 -8
- package/morph-idm/Workflows/consent-selection/src/NoConsentEligibleRule.csx +6 -22
- package/morph-idm/Workflows/consent-selection/src/SingleConsentAutoSelectMapping.csx +63 -0
- package/morph-idm/Workflows/consent-selection/src/SingleConsentRule.csx +11 -22
- package/morph-idm/Workflows/device/execute/device-ios.http +0 -6
- package/morph-idm/Workflows/device/execute/search.http +32 -0
- package/morph-idm/Workflows/person/execute/person-123.http +191 -0
- package/morph-idm/Workflows/person/execute/person.http +196 -0
- package/morph-idm/Workflows/{user → person}/person-1.0.0.json +24 -1
- package/morph-idm/Workflows/token/execute/token.http +14 -3
- package/morph-idm/Workflows/token/password-subflow.json +1 -1
- package/morph-idm/Workflows/token/src/AuthCodeRedeemMapping.csx +114 -0
- package/morph-idm/Workflows/token/src/AuthCodeValidationRule.csx +27 -0
- package/morph-idm/Workflows/token/src/CreateRsaJwtMapping.csx +28 -16
- package/morph-idm/Workflows/token/src/StatusSuccessRule.csx +27 -0
- package/morph-idm/Workflows/token/src/TokenCreatedRule.csx +32 -0
- package/morph-idm/Workflows/token/src/UserLoginGetAsFilterableMapping.csx +204 -0
- package/morph-idm/Workflows/token/token-1.0.0.json +109 -41
- package/morph-idm/Workflows/user/execute/create-user-1234567890.http +16 -4
- package/morph-idm/Workflows/user/execute/create-user-migration.http +179 -0
- package/morph-idm/Workflows/user/execute/create-user-person-password.http +78 -32
- package/morph-idm/Workflows/user/src/EvaluateFailedLoginMapping.csx +75 -0
- package/morph-idm/Workflows/user/src/FailCountMaxRule.csx +33 -0
- package/morph-idm/Workflows/user/src/GetPhoneFromPersonMapping.csx +139 -0
- package/morph-idm/Workflows/user/src/HasPasswordsRule.csx +43 -0
- package/morph-idm/Workflows/user/src/OtpSentSuccessRule.csx +46 -0
- package/morph-idm/Workflows/user/src/PasswordGeneratedSuccessRule.csx +73 -0
- package/morph-idm/Workflows/user/src/PhoneFetchedSuccessRule.csx +35 -0
- package/morph-idm/Workflows/user/src/ResetPasswordFailCountMapping.csx +88 -0
- package/morph-idm/Workflows/user/src/SendOtpSmsMapping.csx +356 -0
- package/morph-idm/Workflows/user/src/UserPasswordGeneratorMapping.csx +33 -6
- package/morph-idm/Workflows/user/user-1.0.0.json +365 -5
- package/morph-idm/Workflows/{user → user-login}/execute/user-login.http +155 -32
- package/morph-idm/Workflows/user-login/src/AuthCodeGeneratorMapping.csx +44 -0
- package/morph-idm/Workflows/{user/src/GetClientMapping.csx → user-login/src/ClientGetMapping.csx} +6 -4
- package/morph-idm/Workflows/{user/src/TriggerConsentSelectionAsSubFlowMapping.csx → user-login/src/ConsentSelectionSubFlowMapping.csx} +19 -20
- package/morph-idm/Workflows/user-login/src/DeviceSearchMapping.csx +120 -0
- package/morph-idm/Workflows/{user → user-login}/src/GrantValidationRule.csx +5 -1
- package/morph-idm/Workflows/user-login/src/HasFailCountRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/MaxRetriesReachedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/NoSecurityImageRule.csx +33 -0
- package/morph-idm/Workflows/user-login/src/NoSecurityQuestionRule.csx +65 -0
- package/morph-idm/Workflows/user-login/src/OtpCodeGenerateMapping.csx +37 -0
- package/morph-idm/Workflows/{user/src/SendOtpMapping.csx → user-login/src/OtpSendMapping.csx} +13 -7
- package/morph-idm/Workflows/user-login/src/OtpVerifiedRule.csx +35 -0
- package/morph-idm/Workflows/user-login/src/PasswordFailCountResetMapping.csx +77 -0
- package/morph-idm/Workflows/user-login/src/PasswordFailCountUpdateMapping.csx +80 -0
- package/morph-idm/Workflows/user-login/src/PasswordVerifyMapping.csx +169 -0
- package/morph-idm/Workflows/user-login/src/PersonFetchedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/PersonGetMapping.csx +61 -0
- package/morph-idm/Workflows/user-login/src/PersonUpdateMapping.csx +105 -0
- package/morph-idm/Workflows/user-login/src/PersonUpdatedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/PushVerifiedRule.csx +31 -0
- package/morph-idm/Workflows/{user/src/GetScopesByUserMapping.csx → user-login/src/ScopesByUserGetMapping.csx} +17 -17
- package/morph-idm/Workflows/user-login/src/TokenGenerationSuccessRule.csx +33 -0
- package/morph-idm/Workflows/{user/src/TriggerTokenWorkflowAsSubFlowMapping.csx → user-login/src/TokenSubFlowMapping.csx} +7 -13
- package/morph-idm/Workflows/user-login/src/UserFoundRule.csx +19 -0
- package/morph-idm/Workflows/{user/src/GetUserMapping.csx → user-login/src/UserGetMapping.csx} +5 -3
- package/morph-idm/Workflows/user-login/src/UserStatusActiveRule.csx +34 -0
- package/morph-idm/Workflows/user-login/src/UserValidHasFailCountRule.csx +39 -0
- package/morph-idm/Workflows/user-login/src/UserValidNoFailCountRule.csx +39 -0
- package/morph-idm/Workflows/user-login/user-login.1.0.0.json +1827 -0
- package/package.json +1 -1
- package/vnext.config.json +3 -3
- package/burgan-tech-morph-idm-runtime-0.0.0.tgz +0 -0
- package/morph-idm/Workflows/user/src/ApproveRule.csx +0 -16
- package/morph-idm/Workflows/user/src/AutoConsentCreatedRule.csx +0 -20
- package/morph-idm/Workflows/user/src/AutoConsentRequiredRule.csx +0 -77
- package/morph-idm/Workflows/user/src/CheckDeviceByUserReferenceMapping.csx +0 -66
- package/morph-idm/Workflows/user/src/ClientValidationFailRule.csx +0 -28
- package/morph-idm/Workflows/user/src/ConsentValidationRule.csx +0 -36
- package/morph-idm/Workflows/user/src/CreateAutoConsentMapping.csx +0 -171
- package/morph-idm/Workflows/user/src/DeviceFoundForLoginRule.csx +0 -32
- package/morph-idm/Workflows/user/src/DeviceNotFoundForLoginRule.csx +0 -31
- package/morph-idm/Workflows/user/src/GetConsentMapping.csx +0 -27
- package/morph-idm/Workflows/user/src/GetDeviceMapping.csx +0 -52
- package/morph-idm/Workflows/user/src/GetScopeMapping.csx +0 -139
- package/morph-idm/Workflows/user/src/GrantValidationFailRule.csx +0 -48
- package/morph-idm/Workflows/user/src/OtpVerifiedRule.csx +0 -31
- package/morph-idm/Workflows/user/src/PushVerifiedRule.csx +0 -31
- package/morph-idm/Workflows/user/src/RejectRule.csx +0 -16
- package/morph-idm/Workflows/user/src/ScopeValidationFailRule.csx +0 -67
- package/morph-idm/Workflows/user/src/ScopeValidationRule.csx +0 -67
- package/morph-idm/Workflows/user/src/SendPushMapping.csx +0 -90
- package/morph-idm/Workflows/user/src/TokenGenerationSuccessRule.csx +0 -28
- package/morph-idm/Workflows/user/src/UserValidationFailRule.csx +0 -36
- package/morph-idm/Workflows/user/src/VerifyOtpMapping.csx +0 -65
- package/morph-idm/Workflows/user/src/VerifyPushMapping.csx +0 -65
- package/morph-idm/Workflows/user/user-login.1.0.0.json +0 -1144
- /package/morph-idm/Workflows/{user → person}/person-cdc-worker.1.0.0.json +0 -0
- /package/morph-idm/Workflows/{user → person}/person-upsert-1.0.0.json +0 -0
- /package/morph-idm/Workflows/scope/execute/{scope-individual.http → scope-individual-1234567890-1234567890.http} +0 -0
- /package/morph-idm/Workflows/{user → user-login}/execute/README-LOGIN.md +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ClientValidationRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ConsentSelectedRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/IsIbWebClientWithDeviceRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/NonIbWebClientWithDeviceRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/OtpSentRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/PushSentRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ScopeFetchedRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/UserValidationRule.csx +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Scripting.Functions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Rule: Check if security question is missing
|
|
9
|
+
/// Returns true if personSnapshot.securityQuestion array is empty or not set - triggers security question change flow
|
|
10
|
+
/// securityQuestion format: [{ answer, question, algorithm, lastUpdatedDate }]
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class NoSecurityQuestionRule : ScriptBase, IConditionMapping
|
|
13
|
+
{
|
|
14
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
// Check if personSnapshot exists
|
|
17
|
+
if (!HasProperty(context.Instance?.Data, "personSnapshot"))
|
|
18
|
+
{
|
|
19
|
+
LogWarning("NoSecurityQuestionRule: personSnapshot not found");
|
|
20
|
+
return true; // No person data, needs to set security question
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var personSnapshot = context.Instance?.Data?.personSnapshot;
|
|
24
|
+
|
|
25
|
+
// Check if securityQuestion property exists
|
|
26
|
+
if (!HasProperty(personSnapshot, "securityQuestion"))
|
|
27
|
+
{
|
|
28
|
+
LogWarning("NoSecurityQuestionRule: securityQuestion property not found, needs to be set");
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var securityQuestion = personSnapshot?.securityQuestion;
|
|
33
|
+
|
|
34
|
+
// Check if securityQuestion is null
|
|
35
|
+
if (securityQuestion == null)
|
|
36
|
+
{
|
|
37
|
+
LogWarning("NoSecurityQuestionRule: securityQuestion is null, needs to be set");
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Cast to enumerable and check if array has items
|
|
42
|
+
try
|
|
43
|
+
{
|
|
44
|
+
var securityQuestionList = securityQuestion as IEnumerable<dynamic>;
|
|
45
|
+
if (securityQuestionList == null)
|
|
46
|
+
{
|
|
47
|
+
LogWarning("NoSecurityQuestionRule: securityQuestion is not an array, needs to be set");
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var count = securityQuestionList.Count();
|
|
52
|
+
if (count == 0)
|
|
53
|
+
{
|
|
54
|
+
LogWarning("NoSecurityQuestionRule: securityQuestion array is empty, needs to be set");
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
catch
|
|
60
|
+
{
|
|
61
|
+
LogWarning("NoSecurityQuestionRule: Failed to parse securityQuestion as array");
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
using BBT.Workflow.Scripting.Functions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Script task mapping for generating OTP code
|
|
9
|
+
/// Generates a 6-digit random OTP code and stores it in instance data
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class OtpCodeGenerateMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
return Task.FromResult(new ScriptResponse());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Generate a 6-digit OTP code and store it in instance data
|
|
20
|
+
/// </summary>
|
|
21
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
22
|
+
{
|
|
23
|
+
// Generate 6-digit OTP code
|
|
24
|
+
var otpCode = Random.Shared.Next(100000, 999999);
|
|
25
|
+
|
|
26
|
+
LogInformation($"OtpCodeGenerateMapping: Generated OTP code for user");
|
|
27
|
+
|
|
28
|
+
return new ScriptResponse
|
|
29
|
+
{
|
|
30
|
+
Data = new
|
|
31
|
+
{
|
|
32
|
+
otpCode = otpCode,
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
package/morph-idm/Workflows/{user/src/SendOtpMapping.csx → user-login/src/OtpSendMapping.csx}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
2
3
|
using System.Threading.Tasks;
|
|
3
4
|
using BBT.Workflow.Definitions;
|
|
4
5
|
using BBT.Workflow.Scripting;
|
|
@@ -7,8 +8,9 @@ using BBT.Workflow.Scripting.Functions;
|
|
|
7
8
|
/// <summary>
|
|
8
9
|
/// Mapping for sending OTP via HTTP task
|
|
9
10
|
/// Calls Mockoon mock server at port 3030
|
|
11
|
+
/// OTP code is generated by otp-code-generator task and stored in instance data
|
|
10
12
|
/// </summary>
|
|
11
|
-
public class
|
|
13
|
+
public class OtpSendMapping : ScriptBase, IMapping
|
|
12
14
|
{
|
|
13
15
|
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
16
|
{
|
|
@@ -17,14 +19,18 @@ public class SendOtpMapping : ScriptBase, IMapping
|
|
|
17
19
|
// Get user phone from instance data
|
|
18
20
|
var userName = context.Instance?.Data?.userName?.ToString() ?? string.Empty;
|
|
19
21
|
var phone = HasProperty(context.Instance?.Data.userSnapshot.person, "phone") ? context.Instance.Data.userSnapshot.person.phone.ToString() : "+905551234567";
|
|
20
|
-
|
|
22
|
+
|
|
23
|
+
// Get OTP code from instance data (generated by otp-code-generator task)
|
|
24
|
+
var otpCode = HasProperty(context.Instance?.Data, "otpCode") ? context.Instance.Data.otpCode : 0;
|
|
25
|
+
|
|
21
26
|
// Set request body
|
|
22
27
|
context.SetBody(new
|
|
23
28
|
{
|
|
24
29
|
userName = userName,
|
|
25
30
|
phone = phone,
|
|
26
31
|
channel = "sms",
|
|
27
|
-
purpose = "login"
|
|
32
|
+
purpose = "login",
|
|
33
|
+
code = otpCode
|
|
28
34
|
});
|
|
29
35
|
// Set Headers
|
|
30
36
|
var headers = new Dictionary<string, string?>
|
|
@@ -34,7 +40,7 @@ public class SendOtpMapping : ScriptBase, IMapping
|
|
|
34
40
|
|
|
35
41
|
httpTask.SetHeaders(headers);
|
|
36
42
|
|
|
37
|
-
LogInformation($"
|
|
43
|
+
LogInformation($"OtpSendMapping InputHandler: Sending OTP to {phone} for user {userName}");
|
|
38
44
|
|
|
39
45
|
return new ScriptResponse();
|
|
40
46
|
}
|
|
@@ -43,7 +49,7 @@ public class SendOtpMapping : ScriptBase, IMapping
|
|
|
43
49
|
{
|
|
44
50
|
if (!HasProperty(context.Body, "data"))
|
|
45
51
|
{
|
|
46
|
-
LogWarning("
|
|
52
|
+
LogWarning("OtpSendMapping OutputHandler: Invalid response - missing data");
|
|
47
53
|
return new ScriptResponse
|
|
48
54
|
{
|
|
49
55
|
Data = new
|
|
@@ -57,7 +63,7 @@ public class SendOtpMapping : ScriptBase, IMapping
|
|
|
57
63
|
}
|
|
58
64
|
if (!HasProperty(context.Body.data, "success"))
|
|
59
65
|
{
|
|
60
|
-
LogWarning("
|
|
66
|
+
LogWarning("OtpSendMapping OutputHandler: Invalid response - missing data.success");
|
|
61
67
|
return new ScriptResponse
|
|
62
68
|
{
|
|
63
69
|
Data = new
|
|
@@ -70,7 +76,7 @@ public class SendOtpMapping : ScriptBase, IMapping
|
|
|
70
76
|
}
|
|
71
77
|
if (context.Body.data.success != true)
|
|
72
78
|
{
|
|
73
|
-
LogWarning("
|
|
79
|
+
LogWarning("OtpSendMapping OutputHandler: OTP send failed");
|
|
74
80
|
return new ScriptResponse
|
|
75
81
|
{
|
|
76
82
|
Data = new
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
using BBT.Workflow.Scripting.Functions;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Rule: OTP verified successfully
|
|
7
|
+
/// Returns true if OTP was verified successfully
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class OtpVerifiedRule : ScriptBase, IConditionMapping
|
|
10
|
+
{
|
|
11
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
if (!HasProperty(context.Instance.Data, "otpCode"))
|
|
14
|
+
{
|
|
15
|
+
LogWarning("VerifyOtpMapping InputHandler: otpCode is missing");
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (!HasProperty(context.Instance.Data, "otpReference"))
|
|
19
|
+
{
|
|
20
|
+
LogWarning("VerifyOtpMapping InputHandler: otpReference is missing");
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Get OTP code from request body and reference from instance
|
|
25
|
+
var otpCode = context.Instance.Data.otpCode.ToString();
|
|
26
|
+
var otpReference = context.Instance.Data.otpReference.ToString();
|
|
27
|
+
if (otpReference == otpCode)
|
|
28
|
+
{
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
LogWarning($"OtpVerifiedRule: OTP verification failed. otpReference={otpReference} != otpCode={otpCode}");
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Scripting.Functions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping to reset password fail count in user instance after successful login.
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class PasswordFailCountResetMapping : ScriptBase, IMapping
|
|
10
|
+
{
|
|
11
|
+
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
var directTask = (task as DirectTriggerTask)!;
|
|
14
|
+
|
|
15
|
+
// Get user key from userSnapshot
|
|
16
|
+
var userKey = string.Empty;
|
|
17
|
+
|
|
18
|
+
if (HasProperty(context.Instance?.Data, "userName"))
|
|
19
|
+
{
|
|
20
|
+
// Fallback to userName if userSnapshot is not available
|
|
21
|
+
userKey = context.Instance?.Data?.userName?.ToString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (string.IsNullOrEmpty(userKey))
|
|
25
|
+
{
|
|
26
|
+
LogWarning("PasswordFailCountResetMapping: User key not found in instance data");
|
|
27
|
+
return new ScriptResponse
|
|
28
|
+
{
|
|
29
|
+
Data = new { error = "User key not found" }
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Set the instance key to update
|
|
34
|
+
directTask.SetKey(userKey);
|
|
35
|
+
|
|
36
|
+
// Build update body with password fail count increment
|
|
37
|
+
dynamic updateBody = new ExpandoObject();
|
|
38
|
+
updateBody.failCount = 0;
|
|
39
|
+
|
|
40
|
+
directTask.SetBody(updateBody);
|
|
41
|
+
|
|
42
|
+
LogInformation($"PasswordFailCountResetMapping: Resetting password fail count for user={userKey}");
|
|
43
|
+
|
|
44
|
+
return new ScriptResponse();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
48
|
+
{
|
|
49
|
+
// Check if update was successful
|
|
50
|
+
if (HasProperty(context.Body, "data"))
|
|
51
|
+
{
|
|
52
|
+
LogInformation("PasswordFailCountResetMapping: Password fail count updated successfully");
|
|
53
|
+
|
|
54
|
+
return new ScriptResponse
|
|
55
|
+
{
|
|
56
|
+
Data = new
|
|
57
|
+
{
|
|
58
|
+
userResetPasswordFailCount = true,
|
|
59
|
+
updatedAt = DateTime.UtcNow
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
{
|
|
65
|
+
LogWarning("PasswordFailCountResetMapping: Failed to update password fail count");
|
|
66
|
+
|
|
67
|
+
return new ScriptResponse
|
|
68
|
+
{
|
|
69
|
+
Data = new
|
|
70
|
+
{
|
|
71
|
+
passwordFailCountUpdated = false,
|
|
72
|
+
error = "Failed to update password fail count"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Dynamic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
using BBT.Workflow.Scripting.Functions;
|
|
7
|
+
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Mapping for updating password fail count on user workflow.
|
|
10
|
+
/// Uses DirectTriggerTask to call the "update-password-fail-count" transition on user workflow.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class PasswordFailCountUpdateMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var directTask = (task as DirectTriggerTask)!;
|
|
17
|
+
|
|
18
|
+
// Get user key from userSnapshot
|
|
19
|
+
var userKey = string.Empty;
|
|
20
|
+
|
|
21
|
+
if (HasProperty(context.Instance?.Data, "userName"))
|
|
22
|
+
{
|
|
23
|
+
// Fallback to userName if userSnapshot is not available
|
|
24
|
+
userKey = context.Instance?.Data?.userName?.ToString();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (string.IsNullOrEmpty(userKey))
|
|
28
|
+
{
|
|
29
|
+
LogWarning("PasswordFailCountUpdateMapping: User key not found in instance data");
|
|
30
|
+
return new ScriptResponse
|
|
31
|
+
{
|
|
32
|
+
Data = new { error = "User key not found" }
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Set the instance key to update
|
|
37
|
+
directTask.SetKey(userKey);
|
|
38
|
+
|
|
39
|
+
// Build update body with password fail count increment
|
|
40
|
+
dynamic updateBody = new ExpandoObject();
|
|
41
|
+
updateBody.failCount = context.Instance?.Data?.failCount;
|
|
42
|
+
|
|
43
|
+
directTask.SetBody(updateBody);
|
|
44
|
+
|
|
45
|
+
LogInformation($"PasswordFailCountUpdateMapping: Updating password fail count for user={userKey}");
|
|
46
|
+
|
|
47
|
+
return new ScriptResponse();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
51
|
+
{
|
|
52
|
+
// Check if update was successful
|
|
53
|
+
if (HasProperty(context.Body, "data"))
|
|
54
|
+
{
|
|
55
|
+
LogInformation("UpdatePasswordFailCountMapping: Password fail count updated successfully");
|
|
56
|
+
|
|
57
|
+
return new ScriptResponse
|
|
58
|
+
{
|
|
59
|
+
Data = new
|
|
60
|
+
{
|
|
61
|
+
passwordFailCountUpdated = true,
|
|
62
|
+
updatedAt = DateTime.UtcNow
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
{
|
|
68
|
+
LogWarning("UpdatePasswordFailCountMapping: Failed to update password fail count");
|
|
69
|
+
|
|
70
|
+
return new ScriptResponse
|
|
71
|
+
{
|
|
72
|
+
Data = new
|
|
73
|
+
{
|
|
74
|
+
passwordFailCountUpdated = false,
|
|
75
|
+
error = "Failed to update password fail count"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Definitions;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Scripting.Functions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for password verification HTTP task.
|
|
9
|
+
/// Sends encrypted password to verification endpoint.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class PasswordVerifyMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
var httpTask = (task as HttpTask)!;
|
|
16
|
+
if (httpTask == null)
|
|
17
|
+
{
|
|
18
|
+
throw new InvalidOperationException("Task must be an HttpTask");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var utilBaseAddress = await GetSecretAsync("vnext-secret", "workflow-secret", "UtilBaseAddress");
|
|
22
|
+
if (string.IsNullOrEmpty(utilBaseAddress))
|
|
23
|
+
{
|
|
24
|
+
utilBaseAddress = "http://localhost:5288/api";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Replace placeholders in URL
|
|
28
|
+
httpTask.Url = httpTask.Url.Replace("{UtilBaseAddress}", utilBaseAddress);
|
|
29
|
+
|
|
30
|
+
// Get encrypted password from instance data
|
|
31
|
+
var encryptedPassword = HasProperty(context.Instance?.Data, "password")
|
|
32
|
+
? context.Instance?.Data?.password?.ToString()
|
|
33
|
+
: string.Empty;
|
|
34
|
+
|
|
35
|
+
// Get user flow key (userName / TC kimlik no)
|
|
36
|
+
var userFlowKey = HasProperty(context.Instance?.Data, "userName")
|
|
37
|
+
? context.Instance?.Data?.userName?.ToString()
|
|
38
|
+
: string.Empty;
|
|
39
|
+
|
|
40
|
+
// Get private key from client snapshot
|
|
41
|
+
var privateKey = string.Empty;
|
|
42
|
+
if (HasProperty(context.Instance?.Data, "clientSnapshot") &&
|
|
43
|
+
HasProperty(context.Instance?.Data?.clientSnapshot, "privateKey"))
|
|
44
|
+
{
|
|
45
|
+
privateKey = context.Instance?.Data?.clientSnapshot?.privateKey?.ToString() ?? string.Empty;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
LogInformation($"PasswordVerifyMapping InputHandler: userFlowKey={userFlowKey}, hasPrivateKey={!string.IsNullOrEmpty(privateKey)}, url={httpTask.Url}");
|
|
49
|
+
|
|
50
|
+
// Build request body
|
|
51
|
+
var requestBody = new
|
|
52
|
+
{
|
|
53
|
+
encryptedPassword = encryptedPassword,
|
|
54
|
+
privateKey = privateKey,
|
|
55
|
+
userFlowKey = userFlowKey
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
httpTask.SetBody(requestBody);
|
|
59
|
+
|
|
60
|
+
return await Task.FromResult(new ScriptResponse());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
64
|
+
{
|
|
65
|
+
LogInformation("PasswordVerifyMapping OutputHandler: Processing password verification response");
|
|
66
|
+
|
|
67
|
+
try
|
|
68
|
+
{
|
|
69
|
+
int failCount = 0;
|
|
70
|
+
// Check if we got a response with data
|
|
71
|
+
if (!HasProperty(context.Body, "data"))
|
|
72
|
+
{
|
|
73
|
+
LogWarning("PasswordVerifyMapping OutputHandler: Invalid response - missing data");
|
|
74
|
+
|
|
75
|
+
failCount = GetFailCount(context);
|
|
76
|
+
failCount++;
|
|
77
|
+
|
|
78
|
+
return new ScriptResponse
|
|
79
|
+
{
|
|
80
|
+
Data = new
|
|
81
|
+
{
|
|
82
|
+
userValid = false,
|
|
83
|
+
failCount = failCount,
|
|
84
|
+
passwordVerified = false,
|
|
85
|
+
validationError = "Invalid response from password verification service"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var responseData = context.Body.data;
|
|
91
|
+
|
|
92
|
+
// Check if response indicates success
|
|
93
|
+
bool isValid = false;
|
|
94
|
+
|
|
95
|
+
if (HasProperty(responseData, "success"))
|
|
96
|
+
{
|
|
97
|
+
LogWarning($"PasswordVerifyMapping OutputHandler: Password verification failed, failCount={failCount}, error={responseData.success}");
|
|
98
|
+
isValid = responseData.success == true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
// Get fail count from instance data
|
|
103
|
+
failCount = GetFailCount(context);
|
|
104
|
+
|
|
105
|
+
if (isValid)
|
|
106
|
+
{
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
return new ScriptResponse
|
|
110
|
+
{
|
|
111
|
+
Data = new
|
|
112
|
+
{
|
|
113
|
+
userValid = true,
|
|
114
|
+
failCount = failCount,
|
|
115
|
+
passwordVerified = true
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
{
|
|
121
|
+
// Increment fail count on failed verification
|
|
122
|
+
failCount++;
|
|
123
|
+
var errorMessage = HasProperty(responseData, "error") ? responseData.error?.ToString() : "Invalid password";
|
|
124
|
+
|
|
125
|
+
LogWarning($"PasswordVerifyMapping OutputHandler: Password verification failed, failCount={failCount}, error={errorMessage}");
|
|
126
|
+
|
|
127
|
+
return new ScriptResponse
|
|
128
|
+
{
|
|
129
|
+
Data = new
|
|
130
|
+
{
|
|
131
|
+
userValid = false,
|
|
132
|
+
failCount = failCount,
|
|
133
|
+
passwordVerified = false,
|
|
134
|
+
validationError = errorMessage,
|
|
135
|
+
passwordVerificationResponse = responseData
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (Exception ex)
|
|
141
|
+
{
|
|
142
|
+
LogError($"PasswordVerifyMapping OutputHandler: Error processing response - {ex.Message}");
|
|
143
|
+
|
|
144
|
+
int failCount = GetFailCount(context);
|
|
145
|
+
failCount++;
|
|
146
|
+
|
|
147
|
+
return new ScriptResponse
|
|
148
|
+
{
|
|
149
|
+
Data = new
|
|
150
|
+
{
|
|
151
|
+
userValid = false,
|
|
152
|
+
failCount = failCount,
|
|
153
|
+
passwordVerified = false,
|
|
154
|
+
validationError = $"Password verification error: {ex.Message}"
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private int GetFailCount(ScriptContext context)
|
|
161
|
+
{
|
|
162
|
+
int failCount = 0;
|
|
163
|
+
if (HasProperty(context.Instance?.Data, "failCount"))
|
|
164
|
+
{
|
|
165
|
+
int.TryParse(context.Instance?.Data?.failCount?.ToString() ?? "0", out failCount);
|
|
166
|
+
}
|
|
167
|
+
return failCount;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
using BBT.Workflow.Scripting.Functions;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Rule: Check if person was fetched successfully
|
|
7
|
+
/// Returns true if personSnapshot exists and is not null
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class PersonFetchedRule : ScriptBase, IConditionMapping
|
|
10
|
+
{
|
|
11
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
// Check if person snapshot exists
|
|
14
|
+
if (!HasProperty(context.Instance?.Data, "personSnapshot"))
|
|
15
|
+
{
|
|
16
|
+
LogWarning("PersonFetchedRule: personSnapshot property not found");
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var personSnapshot = context.Instance?.Data?.personSnapshot;
|
|
21
|
+
|
|
22
|
+
if (personSnapshot != null)
|
|
23
|
+
{
|
|
24
|
+
LogInformation("PersonFetchedRule: Person fetched successfully");
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
LogWarning("PersonFetchedRule: personSnapshot is null");
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Definitions;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Scripting.Functions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for fetching person instance data from person workflow.
|
|
8
|
+
/// Uses the person key from userSnapshot to get person details.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class PersonGetMapping : ScriptBase, IMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
var triggerTask = (task as GetInstanceDataTask)!;
|
|
15
|
+
|
|
16
|
+
// Get person key from userSnapshot.person.key
|
|
17
|
+
var personKey = string.Empty;
|
|
18
|
+
|
|
19
|
+
if (HasProperty(context.Instance?.Data, "userSnapshot") &&
|
|
20
|
+
HasProperty(context.Instance?.Data?.userSnapshot, "person") &&
|
|
21
|
+
HasProperty(context.Instance?.Data?.userSnapshot?.person, "key"))
|
|
22
|
+
{
|
|
23
|
+
personKey = context.Instance?.Data?.userSnapshot?.person?.key?.ToString() ?? string.Empty;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
LogInformation($"PersonGetMapping InputHandler: Fetching person with key={personKey}");
|
|
27
|
+
|
|
28
|
+
triggerTask.SetKey(personKey);
|
|
29
|
+
return Task.FromResult(new ScriptResponse());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
33
|
+
{
|
|
34
|
+
if (HasProperty(context.Body, "data") && HasProperty(context.Body.data, "data"))
|
|
35
|
+
{
|
|
36
|
+
LogInformation("PersonGetMapping OutputHandler: Person data fetched successfully");
|
|
37
|
+
|
|
38
|
+
return new ScriptResponse
|
|
39
|
+
{
|
|
40
|
+
Data = new
|
|
41
|
+
{
|
|
42
|
+
personSnapshot = context.Body.data.data
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
{
|
|
48
|
+
LogWarning("PersonGetMapping OutputHandler: Person not found");
|
|
49
|
+
|
|
50
|
+
return new ScriptResponse
|
|
51
|
+
{
|
|
52
|
+
Data = new
|
|
53
|
+
{
|
|
54
|
+
personSnapshot = (object?)null,
|
|
55
|
+
personFetchError = "Person not found"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|