@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.
Files changed (169) hide show
  1. package/burgan-tech-morph-idm-runtime-0.0.2.tgz +0 -0
  2. package/morph-idm/Schemas/{user → person}/person-master-1.0.0.json +1 -1
  3. package/morph-idm/Schemas/token/token-start-1.0.0.json +6 -19
  4. package/morph-idm/Schemas/user/user-master-1.0.0.json +46 -1
  5. package/morph-idm/Schemas/user-login/retry-login-1.0.0.json +39 -0
  6. package/morph-idm/Tasks/call-device-start-1.0.0.json +1 -1
  7. package/morph-idm/Tasks/call-device-update-1.0.0.json +1 -1
  8. package/morph-idm/Tasks/consent/consent-auto-select-script.json +16 -0
  9. package/morph-idm/Tasks/device/search-device-task.json +22 -0
  10. package/morph-idm/Tasks/get-device-1.0.0.json +1 -1
  11. package/morph-idm/Tasks/person/get-person-by-task.json +19 -0
  12. package/morph-idm/Tasks/person/person-update-direct-transition.json +23 -0
  13. package/morph-idm/Tasks/token/token-create-jwt.json +0 -1
  14. package/morph-idm/Tasks/token/token-redeem-trigger.json +22 -0
  15. package/morph-idm/Tasks/token/user-login-get-as-filterable.json +22 -0
  16. package/morph-idm/Tasks/user/evaluate-failed-login-script.json +18 -0
  17. package/morph-idm/Tasks/user/get-phone-from-person-task.json +20 -0
  18. package/morph-idm/Tasks/user/otp-code-generator.json +15 -0
  19. package/morph-idm/Tasks/user/send-otp-sms-task.json +26 -0
  20. package/morph-idm/Tasks/user/send-push-task.json +4 -1
  21. package/morph-idm/Tasks/user/user-update-password-fail-count.json +24 -0
  22. package/morph-idm/Tasks/user-login/auth-code-generator.json +17 -0
  23. package/morph-idm/Tasks/user-login/increment-local-fail-count.json +17 -0
  24. package/morph-idm/Tasks/user-login/password-verify.json +26 -0
  25. package/morph-idm/TestCases/test-123/.httpyac.json +15 -0
  26. package/morph-idm/TestCases/test-123/01-person.http +95 -0
  27. package/morph-idm/TestCases/test-123/02-user.http +83 -0
  28. package/morph-idm/TestCases/test-123/03-scope.http +65 -0
  29. package/morph-idm/TestCases/test-123/04-consent.http +66 -0
  30. package/morph-idm/TestCases/test-123/05-device.http +86 -0
  31. package/morph-idm/TestCases/test-123/06-user-login.http +206 -0
  32. package/morph-idm/TestCases/test-123/README.md +112 -0
  33. package/morph-idm/TestCases/test-123/cleanup.js +49 -0
  34. package/morph-idm/TestCases/test-123/cleanup.sh +20 -0
  35. package/morph-idm/TestCases/test-123/cleanup.sql +45 -0
  36. package/morph-idm/TestCases/test-123/http-client.env.json +13 -0
  37. package/morph-idm/TestCases/test-123/run-setup.sh +42 -0
  38. package/morph-idm/TestCases/test-auto-consent/.httpyac.json +14 -0
  39. package/morph-idm/TestCases/test-auto-consent/01-person.http +72 -0
  40. package/morph-idm/TestCases/test-auto-consent/02-user.http +74 -0
  41. package/morph-idm/TestCases/test-auto-consent/03-scope.http +66 -0
  42. package/morph-idm/TestCases/test-auto-consent/04-device.http +56 -0
  43. package/morph-idm/TestCases/test-auto-consent/05-user-login.http +132 -0
  44. package/morph-idm/TestCases/test-auto-consent/README.md +36 -0
  45. package/morph-idm/TestCases/test-auto-consent/cleanup.js +47 -0
  46. package/morph-idm/TestCases/test-auto-consent/run-setup.sh +50 -0
  47. package/morph-idm/TestCases/test-multiple-consent/.httpyac.json +17 -0
  48. package/morph-idm/TestCases/test-multiple-consent/01-person.http +103 -0
  49. package/morph-idm/TestCases/test-multiple-consent/02-user.http +83 -0
  50. package/morph-idm/TestCases/test-multiple-consent/03-scope-2.http +66 -0
  51. package/morph-idm/TestCases/test-multiple-consent/03-scope.http +66 -0
  52. package/morph-idm/TestCases/test-multiple-consent/04-consent-1.http +67 -0
  53. package/morph-idm/TestCases/test-multiple-consent/04-consent-2.http +66 -0
  54. package/morph-idm/TestCases/test-multiple-consent/05-device.http +87 -0
  55. package/morph-idm/TestCases/test-multiple-consent/06-user-login.http +183 -0
  56. package/morph-idm/TestCases/test-multiple-consent/README.md +37 -0
  57. package/morph-idm/TestCases/test-multiple-consent/cleanup.js +46 -0
  58. package/morph-idm/TestCases/test-multiple-consent/cleanup.sh +20 -0
  59. package/morph-idm/TestCases/test-multiple-consent/run-setup.sh +53 -0
  60. package/morph-idm/Views/user-login/push-waiting.json +28 -0
  61. package/morph-idm/Views/user-login/start.json +28 -0
  62. package/morph-idm/Workflows/client/client-1.0.0.json +1 -1
  63. package/morph-idm/Workflows/client/execute/client.http +1 -1
  64. package/morph-idm/Workflows/client/src/PasswordGeneratorMapping.csx +0 -1
  65. package/morph-idm/Workflows/consent-selection/consent-selection-1.0.0.json +37 -6
  66. package/morph-idm/Workflows/consent-selection/execute/multi-consent-selection.http +209 -0
  67. package/morph-idm/Workflows/consent-selection/src/ConsentSelectedMapping.csx +18 -22
  68. package/morph-idm/Workflows/consent-selection/src/CreateAutoConsentMapping.csx +45 -45
  69. package/morph-idm/Workflows/consent-selection/src/MultipleConsentsRule.csx +12 -8
  70. package/morph-idm/Workflows/consent-selection/src/NoConsentEligibleRule.csx +6 -22
  71. package/morph-idm/Workflows/consent-selection/src/SingleConsentAutoSelectMapping.csx +63 -0
  72. package/morph-idm/Workflows/consent-selection/src/SingleConsentRule.csx +11 -22
  73. package/morph-idm/Workflows/device/execute/device-ios.http +0 -6
  74. package/morph-idm/Workflows/device/execute/search.http +32 -0
  75. package/morph-idm/Workflows/person/execute/person-123.http +191 -0
  76. package/morph-idm/Workflows/person/execute/person.http +196 -0
  77. package/morph-idm/Workflows/{user → person}/person-1.0.0.json +24 -1
  78. package/morph-idm/Workflows/token/execute/token.http +14 -3
  79. package/morph-idm/Workflows/token/password-subflow.json +1 -1
  80. package/morph-idm/Workflows/token/src/AuthCodeRedeemMapping.csx +114 -0
  81. package/morph-idm/Workflows/token/src/AuthCodeValidationRule.csx +27 -0
  82. package/morph-idm/Workflows/token/src/CreateRsaJwtMapping.csx +28 -16
  83. package/morph-idm/Workflows/token/src/StatusSuccessRule.csx +27 -0
  84. package/morph-idm/Workflows/token/src/TokenCreatedRule.csx +32 -0
  85. package/morph-idm/Workflows/token/src/UserLoginGetAsFilterableMapping.csx +204 -0
  86. package/morph-idm/Workflows/token/token-1.0.0.json +109 -41
  87. package/morph-idm/Workflows/user/execute/create-user-1234567890.http +16 -4
  88. package/morph-idm/Workflows/user/execute/create-user-migration.http +179 -0
  89. package/morph-idm/Workflows/user/execute/create-user-person-password.http +78 -32
  90. package/morph-idm/Workflows/user/src/EvaluateFailedLoginMapping.csx +75 -0
  91. package/morph-idm/Workflows/user/src/FailCountMaxRule.csx +33 -0
  92. package/morph-idm/Workflows/user/src/GetPhoneFromPersonMapping.csx +139 -0
  93. package/morph-idm/Workflows/user/src/HasPasswordsRule.csx +43 -0
  94. package/morph-idm/Workflows/user/src/OtpSentSuccessRule.csx +46 -0
  95. package/morph-idm/Workflows/user/src/PasswordGeneratedSuccessRule.csx +73 -0
  96. package/morph-idm/Workflows/user/src/PhoneFetchedSuccessRule.csx +35 -0
  97. package/morph-idm/Workflows/user/src/ResetPasswordFailCountMapping.csx +88 -0
  98. package/morph-idm/Workflows/user/src/SendOtpSmsMapping.csx +356 -0
  99. package/morph-idm/Workflows/user/src/UserPasswordGeneratorMapping.csx +33 -6
  100. package/morph-idm/Workflows/user/user-1.0.0.json +365 -5
  101. package/morph-idm/Workflows/{user → user-login}/execute/user-login.http +155 -32
  102. package/morph-idm/Workflows/user-login/src/AuthCodeGeneratorMapping.csx +44 -0
  103. package/morph-idm/Workflows/{user/src/GetClientMapping.csx → user-login/src/ClientGetMapping.csx} +6 -4
  104. package/morph-idm/Workflows/{user/src/TriggerConsentSelectionAsSubFlowMapping.csx → user-login/src/ConsentSelectionSubFlowMapping.csx} +19 -20
  105. package/morph-idm/Workflows/user-login/src/DeviceSearchMapping.csx +120 -0
  106. package/morph-idm/Workflows/{user → user-login}/src/GrantValidationRule.csx +5 -1
  107. package/morph-idm/Workflows/user-login/src/HasFailCountRule.csx +32 -0
  108. package/morph-idm/Workflows/user-login/src/MaxRetriesReachedRule.csx +32 -0
  109. package/morph-idm/Workflows/user-login/src/NoSecurityImageRule.csx +33 -0
  110. package/morph-idm/Workflows/user-login/src/NoSecurityQuestionRule.csx +65 -0
  111. package/morph-idm/Workflows/user-login/src/OtpCodeGenerateMapping.csx +37 -0
  112. package/morph-idm/Workflows/{user/src/SendOtpMapping.csx → user-login/src/OtpSendMapping.csx} +13 -7
  113. package/morph-idm/Workflows/user-login/src/OtpVerifiedRule.csx +35 -0
  114. package/morph-idm/Workflows/user-login/src/PasswordFailCountResetMapping.csx +77 -0
  115. package/morph-idm/Workflows/user-login/src/PasswordFailCountUpdateMapping.csx +80 -0
  116. package/morph-idm/Workflows/user-login/src/PasswordVerifyMapping.csx +169 -0
  117. package/morph-idm/Workflows/user-login/src/PersonFetchedRule.csx +32 -0
  118. package/morph-idm/Workflows/user-login/src/PersonGetMapping.csx +61 -0
  119. package/morph-idm/Workflows/user-login/src/PersonUpdateMapping.csx +105 -0
  120. package/morph-idm/Workflows/user-login/src/PersonUpdatedRule.csx +32 -0
  121. package/morph-idm/Workflows/user-login/src/PushVerifiedRule.csx +31 -0
  122. package/morph-idm/Workflows/{user/src/GetScopesByUserMapping.csx → user-login/src/ScopesByUserGetMapping.csx} +17 -17
  123. package/morph-idm/Workflows/user-login/src/TokenGenerationSuccessRule.csx +33 -0
  124. package/morph-idm/Workflows/{user/src/TriggerTokenWorkflowAsSubFlowMapping.csx → user-login/src/TokenSubFlowMapping.csx} +7 -13
  125. package/morph-idm/Workflows/user-login/src/UserFoundRule.csx +19 -0
  126. package/morph-idm/Workflows/{user/src/GetUserMapping.csx → user-login/src/UserGetMapping.csx} +5 -3
  127. package/morph-idm/Workflows/user-login/src/UserStatusActiveRule.csx +34 -0
  128. package/morph-idm/Workflows/user-login/src/UserValidHasFailCountRule.csx +39 -0
  129. package/morph-idm/Workflows/user-login/src/UserValidNoFailCountRule.csx +39 -0
  130. package/morph-idm/Workflows/user-login/user-login.1.0.0.json +1827 -0
  131. package/package.json +1 -1
  132. package/vnext.config.json +3 -3
  133. package/burgan-tech-morph-idm-runtime-0.0.0.tgz +0 -0
  134. package/morph-idm/Workflows/user/src/ApproveRule.csx +0 -16
  135. package/morph-idm/Workflows/user/src/AutoConsentCreatedRule.csx +0 -20
  136. package/morph-idm/Workflows/user/src/AutoConsentRequiredRule.csx +0 -77
  137. package/morph-idm/Workflows/user/src/CheckDeviceByUserReferenceMapping.csx +0 -66
  138. package/morph-idm/Workflows/user/src/ClientValidationFailRule.csx +0 -28
  139. package/morph-idm/Workflows/user/src/ConsentValidationRule.csx +0 -36
  140. package/morph-idm/Workflows/user/src/CreateAutoConsentMapping.csx +0 -171
  141. package/morph-idm/Workflows/user/src/DeviceFoundForLoginRule.csx +0 -32
  142. package/morph-idm/Workflows/user/src/DeviceNotFoundForLoginRule.csx +0 -31
  143. package/morph-idm/Workflows/user/src/GetConsentMapping.csx +0 -27
  144. package/morph-idm/Workflows/user/src/GetDeviceMapping.csx +0 -52
  145. package/morph-idm/Workflows/user/src/GetScopeMapping.csx +0 -139
  146. package/morph-idm/Workflows/user/src/GrantValidationFailRule.csx +0 -48
  147. package/morph-idm/Workflows/user/src/OtpVerifiedRule.csx +0 -31
  148. package/morph-idm/Workflows/user/src/PushVerifiedRule.csx +0 -31
  149. package/morph-idm/Workflows/user/src/RejectRule.csx +0 -16
  150. package/morph-idm/Workflows/user/src/ScopeValidationFailRule.csx +0 -67
  151. package/morph-idm/Workflows/user/src/ScopeValidationRule.csx +0 -67
  152. package/morph-idm/Workflows/user/src/SendPushMapping.csx +0 -90
  153. package/morph-idm/Workflows/user/src/TokenGenerationSuccessRule.csx +0 -28
  154. package/morph-idm/Workflows/user/src/UserValidationFailRule.csx +0 -36
  155. package/morph-idm/Workflows/user/src/VerifyOtpMapping.csx +0 -65
  156. package/morph-idm/Workflows/user/src/VerifyPushMapping.csx +0 -65
  157. package/morph-idm/Workflows/user/user-login.1.0.0.json +0 -1144
  158. /package/morph-idm/Workflows/{user → person}/person-cdc-worker.1.0.0.json +0 -0
  159. /package/morph-idm/Workflows/{user → person}/person-upsert-1.0.0.json +0 -0
  160. /package/morph-idm/Workflows/scope/execute/{scope-individual.http → scope-individual-1234567890-1234567890.http} +0 -0
  161. /package/morph-idm/Workflows/{user → user-login}/execute/README-LOGIN.md +0 -0
  162. /package/morph-idm/Workflows/{user → user-login}/src/ClientValidationRule.csx +0 -0
  163. /package/morph-idm/Workflows/{user → user-login}/src/ConsentSelectedRule.csx +0 -0
  164. /package/morph-idm/Workflows/{user → user-login}/src/IsIbWebClientWithDeviceRule.csx +0 -0
  165. /package/morph-idm/Workflows/{user → user-login}/src/NonIbWebClientWithDeviceRule.csx +0 -0
  166. /package/morph-idm/Workflows/{user → user-login}/src/OtpSentRule.csx +0 -0
  167. /package/morph-idm/Workflows/{user → user-login}/src/PushSentRule.csx +0 -0
  168. /package/morph-idm/Workflows/{user → user-login}/src/ScopeFetchedRule.csx +0 -0
  169. /package/morph-idm/Workflows/{user → user-login}/src/UserValidationRule.csx +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burgan-tech/morph-idm-runtime",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "description": "Morph IDM Domain - Runtime Package for engine deployment",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/vnext.config.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "0.0.0",
2
+ "version": "0.0.2",
3
3
  "description": "morph-idm Domain Definition Configuration",
4
4
  "domain": "morph-idm",
5
- "runtimeVersion": "0.0.29",
6
- "schemaVersion": "0.0.29",
5
+ "runtimeVersion": "0.0.31",
6
+ "schemaVersion": "0.0.31",
7
7
  "paths": {
8
8
  "componentsRoot": "morph-idm",
9
9
  "tasks": "Tasks",
@@ -1,16 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Scripting;
3
-
4
- /// <summary>
5
- /// Rule for approve transition
6
- /// Workflow: person-upsert
7
- /// State: draft
8
- /// </summary>
9
- public class ApproveRule : IConditionMapping
10
- {
11
- public async Task<bool> Handler(ScriptContext context)
12
- {
13
- // TODO: Implement actual rule logic
14
- return true;
15
- }
16
- }
@@ -1,20 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Scripting;
3
- using BBT.Workflow.Scripting.Functions;
4
-
5
- public class AutoConsentCreatedRule : ScriptBase, IConditionMapping
6
- {
7
- public async Task<bool> Handler(ScriptContext context)
8
- {
9
- // Check if auto-consent was successfully created
10
- if (HasProperty(context.Instance?.Data, "autoConsentCreated") && context.Instance?.Data?.autoConsentCreated == true)
11
- {
12
- LogInformation("AutoConsentCreatedRule: Auto-consent created successfully");
13
- return true;
14
- }
15
-
16
- LogWarning("AutoConsentCreatedRule: Auto-consent creation failed");
17
- return false;
18
- }
19
- }
20
-
@@ -1,77 +0,0 @@
1
- using System.Collections.Generic;
2
- using System.Threading.Tasks;
3
- using BBT.Workflow.Scripting;
4
- using BBT.Workflow.Scripting.Functions;
5
-
6
- /// <summary>
7
- /// Rule to check if auto-consent creation is required.
8
- /// Returns true if:
9
- /// 1. Consent was not found (no consentSnapshot)
10
- /// 2. AND the requested scope is in the autoConsentScopes list
11
- /// </summary>
12
- public class AutoConsentRequiredRule : ScriptBase, IConditionMapping
13
- {
14
- public async Task<bool> Handler(ScriptContext context)
15
- {
16
- // Check if consent was already found - if yes, no auto-consent needed
17
- if (HasProperty(context.Instance?.Data, "consentSnapshot") && context.Instance?.Data?.consentSnapshot != null)
18
- {
19
- LogInformation("AutoConsentRequiredRule: Consent already exists, no auto-consent needed");
20
- return false;
21
- }
22
-
23
- // Check if we have auto-consent eligible scopes
24
- if (!HasProperty(context.Instance?.Data, "autoConsentScopes"))
25
- {
26
- LogWarning("AutoConsentRequiredRule: No autoConsentScopes found in instance data");
27
- return false;
28
- }
29
-
30
- var autoConsentScopes = context.Instance?.Data?.autoConsentScopes;
31
- if (autoConsentScopes == null)
32
- {
33
- LogWarning("AutoConsentRequiredRule: autoConsentScopes is null");
34
- return false;
35
- }
36
-
37
- // Get the requested scopes
38
- var requestedScopes = context.Instance?.Data?.scopes;
39
- if (requestedScopes == null)
40
- {
41
- LogWarning("AutoConsentRequiredRule: No scopes in request");
42
- return false;
43
- }
44
-
45
- // Convert autoConsentScopes to a list for comparison
46
- var autoConsentList = new List<string>();
47
- foreach (var scope in autoConsentScopes)
48
- {
49
- var scopeStr = scope?.ToString();
50
- if (!string.IsNullOrEmpty(scopeStr))
51
- {
52
- autoConsentList.Add(scopeStr);
53
- }
54
- }
55
-
56
- if (autoConsentList.Count == 0)
57
- {
58
- LogInformation("AutoConsentRequiredRule: No scopes eligible for auto-consent");
59
- return false;
60
- }
61
-
62
- // Check if any requested scope is in the auto-consent list
63
- foreach (var requestedScope in requestedScopes)
64
- {
65
- var scopeStr = requestedScope?.ToString();
66
- if (!string.IsNullOrEmpty(scopeStr) && autoConsentList.Contains(scopeStr))
67
- {
68
- LogInformation($"AutoConsentRequiredRule: Scope '{scopeStr}' is eligible for auto-consent, creating consent");
69
- return true;
70
- }
71
- }
72
-
73
- LogInformation("AutoConsentRequiredRule: No requested scopes are eligible for auto-consent");
74
- return false;
75
- }
76
- }
77
-
@@ -1,66 +0,0 @@
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 checking device by user reference
8
- /// Uses GetInstanceData task to fetch device workflow instance by user_reference
9
- /// </summary>
10
- public class CheckDeviceByUserReferenceMapping : ScriptBase, IMapping
11
- {
12
- public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
13
- {
14
- var triggerTask = (task as GetInstanceDataTask)!;
15
-
16
- // Get user reference from user snapshot for device lookup
17
- var userReference = context.Instance?.Data?.userSnapshot?.person?.reference?.ToString() ?? string.Empty;
18
-
19
- // Fallback to deviceId if no user reference
20
- if (string.IsNullOrEmpty(userReference))
21
- {
22
- userReference = context.Instance?.Data?.deviceId?.ToString() ?? string.Empty;
23
- }
24
-
25
- LogInformation($"CheckDeviceByUserReferenceMapping InputHandler: Looking up device by userReference={userReference}");
26
-
27
- triggerTask.SetKey(userReference);
28
- return Task.FromResult(new ScriptResponse());
29
- }
30
-
31
- public async Task<ScriptResponse> OutputHandler(ScriptContext context)
32
- {
33
- // Check if device was found
34
- if (HasProperty(context.Body, "data") && HasProperty(context.Body.data, "data"))
35
- {
36
- var deviceData = context.Body.data.data;
37
- var instanceId = context.Body.data?.instanceId?.ToString();
38
-
39
- LogInformation($"CheckDeviceByUserReferenceMapping OutputHandler: Device found, instanceId={instanceId}");
40
-
41
- return new ScriptResponse
42
- {
43
- Data = new
44
- {
45
- deviceSnapshot = deviceData,
46
- deviceInstanceId = instanceId,
47
- deviceFound = true
48
- }
49
- };
50
- }
51
- else
52
- {
53
- LogInformation("CheckDeviceByUserReferenceMapping OutputHandler: Device not found");
54
-
55
- return new ScriptResponse
56
- {
57
- Data = new
58
- {
59
- deviceFound = false,
60
- message = "Device not found"
61
- }
62
- };
63
- }
64
- }
65
- }
66
-
@@ -1,28 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Scripting;
3
-
4
- public class ClientValidationFailRule : IConditionMapping
5
- {
6
- public async Task<bool> Handler(ScriptContext context)
7
- {
8
- try
9
- {
10
- // Get client data from task response
11
- var clientFromDb = context.Instance?.Data?.client;
12
-
13
- // Get client data from input
14
- var clientId = context.Instance?.Data?.clientId;
15
-
16
- if (clientFromDb == null)
17
- {
18
- return true;
19
- }
20
-
21
- return clientFromDb.clientId != clientId;
22
- }
23
- catch (Exception ex)
24
- {
25
- return true;
26
- }
27
- }
28
- }
@@ -1,36 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Scripting;
3
- using BBT.Workflow.Scripting.Functions;
4
- public class ConsentValidationRule : ScriptBase, IConditionMapping
5
- {
6
- public async Task<bool> Handler(ScriptContext context)
7
- {
8
- // Get consent data from task response
9
- var consentFromDb = context.Instance?.Data?.consent;
10
-
11
- // Get consent data from input
12
- var consentId = context.Instance?.Data?.consentId;
13
-
14
- if (consentFromDb == null || consentId == null)
15
- {
16
- LogWarning("Consent validation failed: Missing consent data");
17
- return false;
18
- }
19
-
20
- // Validate consent exists and is active
21
- var isActive = consentFromDb?.attributes?.state?.key == "active";
22
- var keyMatches = consentFromDb?.key == consentId;
23
-
24
- // Additional consent checks
25
- var notExpired = true;
26
- if (consentFromDb?.attributes?.expiresAt != null)
27
- {
28
- notExpired = DateTime.Parse(consentFromDb?.attributes?.expiresAt.ToString()) > DateTime.UtcNow;
29
- }
30
-
31
- LogInformation($"Consent validation: keyMatches={keyMatches}, isActive={isActive}, notExpired={notExpired}");
32
-
33
- return keyMatches && isActive && notExpired;
34
- }
35
- }
36
-
@@ -1,171 +0,0 @@
1
- using System;
2
- using System.Collections.Generic;
3
- using System.Dynamic;
4
- using System.Threading.Tasks;
5
- using BBT.Workflow.Definitions;
6
- using BBT.Workflow.Scripting;
7
- using BBT.Workflow.Scripting.Functions;
8
-
9
- /// <summary>
10
- /// Mapping for creating auto-consent via consent workflow subflow.
11
- /// Prepares the consent data from user-login instance data.
12
- /// </summary>
13
- public class CreateAutoConsentMapping : ScriptBase, ISubFlowMapping
14
- {
15
- public Task<ScriptResponse> InputHandler(ScriptContext context)
16
- {
17
- dynamic expandoObject = new ExpandoObject();
18
-
19
- // Get user key
20
- var userKey = context.Instance?.Data?.userName?.ToString() ?? string.Empty;
21
-
22
- // Get client key
23
- var clientId = context.Instance?.Data?.clientId?.ToString() ?? string.Empty;
24
-
25
- // Get the first auto-consent eligible scope
26
- var autoConsentScopes = context.Instance?.Data?.autoConsentScopes;
27
- var selectedScope = string.Empty;
28
-
29
- if (autoConsentScopes != null)
30
- {
31
- foreach (var scope in autoConsentScopes)
32
- {
33
- selectedScope = scope?.ToString();
34
- if (!string.IsNullOrEmpty(selectedScope))
35
- {
36
- break; // Use the first eligible scope
37
- }
38
- }
39
- }
40
-
41
- // Fallback to first requested scope if no auto-consent scope found
42
- if (string.IsNullOrEmpty(selectedScope))
43
- {
44
- var scopes = context.Instance?.Data?.scopes;
45
- if (scopes != null)
46
- {
47
- foreach (var scope in scopes)
48
- {
49
- selectedScope = scope?.ToString();
50
- if (!string.IsNullOrEmpty(selectedScope))
51
- {
52
- break;
53
- }
54
- }
55
- }
56
- }
57
-
58
- // Build consent key: {user}-{client}-{scope}
59
- var consentKey = $"{userKey}-{clientId}-{selectedScope}";
60
-
61
- // Get scope details for the selected scope
62
- var scopeDetails = context.Instance?.Data?.scopeDetails;
63
- dynamic selectedScopeDetail = null;
64
-
65
- if (scopeDetails != null)
66
- {
67
- foreach (var detail in scopeDetails)
68
- {
69
- if (detail?.key?.ToString() == selectedScope)
70
- {
71
- selectedScopeDetail = detail;
72
- break;
73
- }
74
- }
75
- }
76
-
77
- // Prepare consent data
78
- expandoObject.key = consentKey;
79
- expandoObject.tags = new List<string> { "auto-consent", "login-flow" };
80
-
81
- // Build attributes for consent
82
- var attributes = new ExpandoObject() as IDictionary<string, object>;
83
-
84
- // User reference
85
- attributes["user"] = new {
86
- domain = "morph-idm",
87
- workflow = "user",
88
- key = userKey,
89
- version = "1.0.0"
90
- };
91
-
92
- // Client reference
93
- attributes["client"] = new {
94
- domain = "morph-idm",
95
- workflow = "client",
96
- key = clientId,
97
- version = "1.0.0"
98
- };
99
-
100
- // Scope reference
101
- attributes["scope"] = new {
102
- domain = "morph-idm",
103
- workflow = "scope",
104
- key = selectedScope,
105
- version = "1.0.0"
106
- };
107
-
108
- // Set default position from scope organization if available
109
- if (selectedScopeDetail != null && HasProperty(selectedScopeDetail, "group"))
110
- {
111
- // Use default position - can be enhanced later
112
- attributes["position"] = "self-access";
113
- }
114
- else
115
- {
116
- attributes["position"] = "self-access";
117
- }
118
-
119
- // Default roles for auto-consent
120
- attributes["roles"] = new List<object>
121
- {
122
- new { role = "idm.self-access", allowance = "allow" }
123
- };
124
-
125
- // Set consent timestamps
126
- attributes["grantedAt"] = DateTime.UtcNow.ToString("o");
127
- attributes["expiresAt"] = DateTime.UtcNow.AddYears(1).ToString("o"); // 1 year default
128
-
129
- // Flag to indicate this is auto-consent (for AutoConsentRule in consent workflow)
130
- attributes["isAutoConsent"] = true;
131
-
132
- expandoObject.attributes = attributes;
133
-
134
- LogInformation($"CreateAutoConsentMapping InputHandler: Creating auto-consent for user={userKey}, client={clientId}, scope={selectedScope}, key={consentKey}");
135
-
136
- return Task.FromResult(new ScriptResponse
137
- {
138
- Data = expandoObject,
139
- Headers = null
140
- });
141
- }
142
-
143
- public async Task<ScriptResponse> OutputHandler(ScriptContext context)
144
- {
145
- // Extract the created consent info from subflow response
146
- var consentKey = context.Body?.key?.ToString();
147
- var consentState = context.Body?.state?.ToString();
148
-
149
- LogInformation($"CreateAutoConsentMapping OutputHandler: Auto-consent created - key={consentKey}, state={consentState}");
150
-
151
- // Store the created consent info for subsequent steps
152
- return new ScriptResponse
153
- {
154
- Data = new
155
- {
156
- autoConsentCreated = true,
157
- autoConsentKey = consentKey,
158
- autoConsentState = consentState,
159
- // Also set consentSnapshot for compatibility with existing flow
160
- consentSnapshot = new
161
- {
162
- key = consentKey,
163
- roles = context.Body?.data?.roles,
164
- expiresAt = context.Body?.data?.expiresAt
165
- }
166
- },
167
- Headers = null
168
- };
169
- }
170
- }
171
-
@@ -1,32 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Scripting;
3
- using BBT.Workflow.Scripting.Functions;
4
-
5
- /// <summary>
6
- /// Rule: Device found for login - skip OTP
7
- /// Returns true if device is found and trusted
8
- /// </summary>
9
- public class DeviceFoundForLoginRule : ScriptBase, IConditionMapping
10
- {
11
- public async Task<bool> Handler(ScriptContext context)
12
- {
13
- // Check if device was found
14
- if (!HasProperty(context.Instance?.Data, "deviceFound"))
15
- {
16
- LogWarning("DeviceFoundForLoginRule: deviceFound property not found");
17
- return false;
18
- }
19
-
20
- var deviceFound = context.Instance?.Data?.deviceFound;
21
-
22
- if (deviceFound == true)
23
- {
24
- LogInformation("DeviceFoundForLoginRule: Device found, skipping OTP");
25
- return true;
26
- }
27
-
28
- LogInformation("DeviceFoundForLoginRule: Device not found, OTP required");
29
- return false;
30
- }
31
- }
32
-
@@ -1,31 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Scripting;
3
- using BBT.Workflow.Scripting.Functions;
4
-
5
- /// <summary>
6
- /// Rule: Device not found for login - requires OTP
7
- /// Returns true if device is not found
8
- /// </summary>
9
- public class DeviceNotFoundForLoginRule : ScriptBase, IConditionMapping
10
- {
11
- public async Task<bool> Handler(ScriptContext context)
12
- {
13
- // Check if device was found
14
- if (!HasProperty(context.Instance?.Data, "deviceFound"))
15
- {
16
- LogWarning("DeviceNotFoundForLoginRule: deviceFound property not found, assuming OTP required");
17
- return true;
18
- }
19
-
20
- var deviceFound = context.Instance?.Data?.deviceFound;
21
-
22
- if (deviceFound != true)
23
- {
24
- LogInformation("DeviceNotFoundForLoginRule: Device not found, OTP required");
25
- return true;
26
- }
27
-
28
- return false;
29
- }
30
- }
31
-
@@ -1,27 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Scripting;
3
-
4
- public class GetConsentMapping : IMapping
5
- {
6
- public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
7
- {
8
- var triggerTask = (task as GetInstanceDataTask)!;
9
-
10
- LogInformation($"GetConsentMapping Instance InputHandler: {context.Instance?.Data?.consentId}");
11
-
12
- triggerTask.SetInstance(context.Instance?.Data?.consentId ?? string.Empty);
13
- return Task.FromResult(new ScriptResponse());
14
- }
15
-
16
- public async Task<ScriptResponse> OutputHandler(ScriptContext context)
17
- {
18
- return new ScriptResponse
19
- {
20
- Data = new
21
- {
22
- consent = context.Body
23
- }
24
- };
25
- }
26
- }
27
-
@@ -1,52 +0,0 @@
1
- using System.Threading.Tasks;
2
- using BBT.Workflow.Definitions;
3
- using BBT.Workflow.Scripting;
4
- using BBT.Workflow.Scripting.Functions;
5
-
6
- public class GetDeviceMapping : ScriptBase, IMapping
7
- {
8
- public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
9
- {
10
- var triggerTask = (task as GetInstanceDataTask)!;
11
-
12
- var deviceKey = HasProperty(context.Instance.Data, "deviceId") ? context.Instance.Data.deviceId : string.Empty;
13
- if (string.IsNullOrEmpty(deviceKey))
14
- {
15
- LogWarning($"GetDeviceMapping InputHandler: deviceId is not found");
16
- }
17
- triggerTask.SetKey(deviceKey);
18
- return Task.FromResult(new ScriptResponse());
19
- }
20
-
21
- public async Task<ScriptResponse> OutputHandler(ScriptContext context)
22
- {
23
- // Check if device was found
24
- if (HasProperty(context.Body, "data") && HasProperty(context.Body.data, "data"))
25
- {
26
- var deviceData = context.Body.data.data;
27
-
28
- return new ScriptResponse
29
- {
30
- Data = new
31
- {
32
- deviceSnapshot = deviceData,
33
- deviceFound = true
34
- }
35
- };
36
- }
37
- else
38
- {
39
- LogInformation("GetDeviceMapping OutputHandler: Device not found");
40
-
41
- return new ScriptResponse
42
- {
43
- Data = new
44
- {
45
- deviceFound = false,
46
- message = "Device not found - OTP required"
47
- }
48
- };
49
- }
50
- }
51
- }
52
-