@burgan-tech/morph-idm-runtime 0.0.1 → 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.1.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
@@ -0,0 +1,209 @@
1
+ ###############################################################################
2
+ # Consent Selection - Multi Consent Test
3
+ #
4
+ # Bu örnek consent-selection subflow'unu direkt test eder.
5
+ # 3 scope ile başlatılır, multiple-consents durumuna düşer,
6
+ # kullanıcıdan seçim beklenir.
7
+ ###############################################################################
8
+
9
+ @baseUrl = http://localhost:4201
10
+ @apiVersion = v1
11
+ @domain = morph-idm
12
+ @workflow = consent-selection
13
+
14
+ ### Start Consent Selection (Multiple Scopes)
15
+ # @name startConsentSelection
16
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start
17
+ Accept-Language: tr-TR
18
+ X-Request-Id: {{$guid}}
19
+ X-Device-Id: test-device
20
+ X-Token-Id: {{$guid}}
21
+ X-Device-Info: Test Suite/1.0
22
+ X-Forwarded-For: 192.168.1.100
23
+ user_reference: 1234
24
+ Content-Type: application/json
25
+
26
+ {
27
+ "key": "consent-selection-multi-{{$timestamp}}",
28
+ "tags": ["test", "consent-selection", "multi-consent"],
29
+ "attributes": {
30
+ "userName": "1234",
31
+ "clientId": "IbWeb",
32
+ "scopeSnapshot": {
33
+ "scopes": [
34
+ {
35
+ "key": "1234-1234",
36
+ "groupKey": "retail-customers",
37
+ "allowAutoConsent": true
38
+ },
39
+ {
40
+ "key": "1234567890-1234567890",
41
+ "groupKey": "retail-customers",
42
+ "allowAutoConsent": true
43
+ },
44
+ {
45
+ "key": "1234-Corporate",
46
+ "groupKey": "corporate-customers",
47
+ "allowAutoConsent": false
48
+ }
49
+ ],
50
+ "isValid": true,
51
+ "notFoundScopes": [],
52
+ "unauthorizedScopes": [],
53
+ "requestedScopeGroups": [
54
+ "retail-customers",
55
+ "corporate-customers"
56
+ ]
57
+ }
58
+ }
59
+ }
60
+
61
+ ###
62
+ @instanceId = {{startConsentSelection.response.body.id}}
63
+
64
+ ### Get Current State
65
+ # @name getState
66
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/state
67
+ Accept-Language: tr-TR
68
+ X-Request-Id: {{$guid}}
69
+ X-Device-Id: test-device
70
+ X-Token-Id: {{$guid}}
71
+ user_reference: 1234
72
+
73
+ ### Get Instance Data
74
+ # @name getData
75
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/data
76
+ Accept-Language: tr-TR
77
+ X-Request-Id: {{$guid}}
78
+ X-Device-Id: test-device
79
+ X-Token-Id: {{$guid}}
80
+ user_reference: 1234
81
+
82
+ ###############################################################################
83
+ # SCENARIO: Multiple Consents Found
84
+ # Flow should be at "waiting-selection" state waiting for user to pick one
85
+ ###############################################################################
86
+
87
+ ### Select Consent (from waiting-selection state)
88
+ # @name selectConsent
89
+ PATCH {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/transitions/select-consent
90
+ Accept-Language: tr-TR
91
+ X-Request-Id: {{$guid}}
92
+ X-Device-Id: test-device
93
+ X-Token-Id: {{$guid}}
94
+ X-Device-Info: Test Suite/1.0
95
+ X-Forwarded-For: 192.168.1.100
96
+ user_reference: 1234
97
+ Content-Type: application/json
98
+
99
+ {
100
+ "attributes": {
101
+ "selectedConsentKey": "1234-IbWeb-1234-1234"
102
+ }
103
+ }
104
+
105
+ ###
106
+
107
+ ### Get Final State (should be consent-selected)
108
+ # @name getFinalState
109
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/state
110
+ Accept-Language: tr-TR
111
+ X-Request-Id: {{$guid}}
112
+ X-Device-Id: test-device
113
+ X-Token-Id: {{$guid}}
114
+ user_reference: 1234
115
+
116
+ ### Get Final Data
117
+ # @name getFinalData
118
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/data
119
+ Accept-Language: tr-TR
120
+ X-Request-Id: {{$guid}}
121
+ X-Device-Id: test-device
122
+ X-Token-Id: {{$guid}}
123
+ user_reference: 1234
124
+
125
+ ###############################################################################
126
+ # ALTERNATIVE SCENARIOS
127
+ ###############################################################################
128
+
129
+ ### Start with Single Consent (auto-select)
130
+ # @name startSingleConsent
131
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start
132
+ Accept-Language: tr-TR
133
+ X-Request-Id: {{$guid}}
134
+ X-Device-Id: test-device
135
+ X-Token-Id: {{$guid}}
136
+ X-Device-Info: Test Suite/1.0
137
+ X-Forwarded-For: 192.168.1.100
138
+ user_reference: 1234
139
+ Content-Type: application/json
140
+
141
+ {
142
+ "key": "consent-selection-single-{{$timestamp}}",
143
+ "tags": ["test", "consent-selection", "single-consent"],
144
+ "attributes": {
145
+ "userName": "1234",
146
+ "clientId": "IbWeb",
147
+ "scopeSnapshot": {
148
+ "scopes": [
149
+ {
150
+ "key": "1234-1234",
151
+ "groupKey": "retail-customers",
152
+ "allowAutoConsent": true
153
+ }
154
+ ],
155
+ "isValid": true,
156
+ "notFoundScopes": [],
157
+ "unauthorizedScopes": [],
158
+ "requestedScopeGroups": [
159
+ "retail-customers"
160
+ ]
161
+ }
162
+ }
163
+ }
164
+
165
+ ###
166
+
167
+ ### Start with No Consent + Auto Eligible (auto-consent creation)
168
+ # @name startAutoConsent
169
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start
170
+ Accept-Language: tr-TR
171
+ X-Request-Id: {{$guid}}
172
+ X-Device-Id: test-device
173
+ X-Token-Id: {{$guid}}
174
+ X-Device-Info: Test Suite/1.0
175
+ X-Forwarded-For: 192.168.1.100
176
+ user_reference: 12345
177
+ Content-Type: application/json
178
+
179
+ {
180
+ "key": "consent-selection-auto-{{$timestamp}}",
181
+ "tags": ["test", "consent-selection", "auto-consent"],
182
+ "attributes": {
183
+ "userName": "12345",
184
+ "clientId": "IbWeb",
185
+ "scopeSnapshot": {
186
+ "scopes": [
187
+ {
188
+ "key": "12345-auto",
189
+ "groupKey": "retail-customers",
190
+ "allowAutoConsent": true
191
+ }
192
+ ],
193
+ "isValid": true,
194
+ "notFoundScopes": [],
195
+ "unauthorizedScopes": [],
196
+ "requestedScopeGroups": [
197
+ "retail-customers"
198
+ ]
199
+ },
200
+ "consentCount": 0,
201
+ "hasAutoConsentEligible": true,
202
+ "autoConsentEligibleScopes": [
203
+ {
204
+ "scopeKey": "12345-auto",
205
+ "groupKey": "retail-customers"
206
+ }
207
+ ]
208
+ }
209
+ }
@@ -1,4 +1,5 @@
1
1
  using System.Threading.Tasks;
2
+ using BBT.Workflow.Definitions;
2
3
  using BBT.Workflow.Scripting;
3
4
  using BBT.Workflow.Scripting.Functions;
4
5
 
@@ -8,38 +9,36 @@ using BBT.Workflow.Scripting.Functions;
8
9
  /// </summary>
9
10
  public class ConsentSelectedMapping : ScriptBase, ITransitionMapping
10
11
  {
11
- public async Task<ScriptResponse> Handler(ScriptContext context)
12
+
13
+ public async Task<dynamic> Handler(ScriptContext context)
12
14
  {
13
- // Get selected consent key from trigger data
14
- var selectedConsentKey = context.TriggerData?.selectedConsentKey?.ToString();
15
-
16
- if (string.IsNullOrEmpty(selectedConsentKey))
15
+ if (!HasProperty(context.Body, "selectedConsentKey"))
17
16
  {
18
- LogWarning("ConsentSelectedMapping: No consent key in selection");
17
+ LogWarning("ConsentSelectedMapping: selectedConsentKey not found");
19
18
  return new ScriptResponse
20
19
  {
21
20
  Data = new
22
21
  {
23
- selectionError = "No consent key provided"
22
+ selectionError = "No consent key provided",
23
+ body = context.Body
24
24
  }
25
25
  };
26
26
  }
27
+ // Get selected consent key from trigger data
28
+ var selectedConsentKey = context.Body?.selectedConsentKey?.ToString() ?? string.Empty;
27
29
 
28
30
  LogInformation($"ConsentSelectedMapping: User selected consent: {selectedConsentKey}");
29
31
 
30
32
  // Find the selected consent from the consents list
31
- var consents = context.Instance?.Data?.consents;
33
+ var consents = context.Instance?.Data.consentSnapshot.consents;
32
34
  dynamic selectedConsent = null;
33
-
34
- if (consents != null)
35
+
36
+ foreach (var consent in consents)
35
37
  {
36
- foreach (var consent in consents)
38
+ if (consent?.consentKey == selectedConsentKey)
37
39
  {
38
- if (consent?.key?.ToString() == selectedConsentKey)
39
- {
40
- selectedConsent = consent;
41
- break;
42
- }
40
+ selectedConsent = consent;
41
+ break;
43
42
  }
44
43
  }
45
44
 
@@ -57,13 +56,10 @@ public class ConsentSelectedMapping : ScriptBase, ITransitionMapping
57
56
 
58
57
  LogInformation($"ConsentSelectedMapping: Consent selected successfully: {selectedConsentKey}");
59
58
 
60
- return new ScriptResponse
59
+ return new
61
60
  {
62
- Data = new
63
- {
64
- selectedConsent = selectedConsent,
65
- selectedConsentKey = selectedConsentKey
66
- }
61
+ selectedConsent = selectedConsent,
62
+ selectedConsentKey = selectedConsentKey
67
63
  };
68
64
  }
69
65
  }
@@ -23,7 +23,7 @@ public class CreateAutoConsentMapping : ScriptBase, ISubFlowMapping
23
23
  var clientId = context.Instance?.Data?.clientId?.ToString() ?? string.Empty;
24
24
 
25
25
  // Get the first auto-consent eligible scope
26
- var autoConsentEligibleScopes = context.Instance?.Data?.autoConsentEligibleScopes;
26
+ var autoConsentEligibleScopes = context.Instance?.Data.consentSnapshot.autoConsentEligibleScopes;
27
27
  var selectedScopeKey = string.Empty;
28
28
  var selectedGroupKey = string.Empty;
29
29
 
@@ -31,8 +31,8 @@ public class CreateAutoConsentMapping : ScriptBase, ISubFlowMapping
31
31
  {
32
32
  foreach (var scope in autoConsentEligibleScopes)
33
33
  {
34
- selectedScopeKey = scope?.scopeKey?.ToString();
35
- selectedGroupKey = scope?.groupKey?.ToString();
34
+ selectedScopeKey = scope?.scopeKey?.ToString() ?? string.Empty;
35
+ selectedGroupKey = scope?.groupKey?.ToString() ?? string.Empty;
36
36
  if (!string.IsNullOrEmpty(selectedScopeKey))
37
37
  {
38
38
  break; // Use the first eligible scope
@@ -48,8 +48,8 @@ public class CreateAutoConsentMapping : ScriptBase, ISubFlowMapping
48
48
  {
49
49
  foreach (var scope in scopes)
50
50
  {
51
- selectedScopeKey = scope?.key?.ToString();
52
- selectedGroupKey = scope?.groupKey?.ToString();
51
+ selectedScopeKey = scope?.key?.ToString() ?? string.Empty;
52
+ selectedGroupKey = scope?.groupKey?.ToString() ?? string.Empty;
53
53
  if (!string.IsNullOrEmpty(selectedScopeKey))
54
54
  {
55
55
  break;
@@ -65,41 +65,41 @@ public class CreateAutoConsentMapping : ScriptBase, ISubFlowMapping
65
65
  expandoObject.key = consentKey;
66
66
  expandoObject.tags = new List<string> { "auto-consent", "consent-selection-flow" };
67
67
 
68
- // Build attributes for consent
68
+ // Build attributes for consent using ExpandoObject
69
69
  var attributes = new ExpandoObject() as IDictionary<string, object>;
70
70
 
71
71
  // User reference
72
- attributes["user"] = new {
73
- domain = "morph-idm",
74
- workflow = "user",
75
- key = userKey,
76
- version = "1.0.0"
77
- };
72
+ dynamic userRef = new ExpandoObject();
73
+ userRef.domain = "morph-idm";
74
+ userRef.workflow = "user";
75
+ userRef.key = userKey;
76
+ userRef.version = "1.0.0";
77
+ attributes["user"] = userRef;
78
78
 
79
79
  // Client reference
80
- attributes["client"] = new {
81
- domain = "morph-idm",
82
- workflow = "client",
83
- key = clientId,
84
- version = "1.0.0"
85
- };
80
+ dynamic clientRef = new ExpandoObject();
81
+ clientRef.domain = "morph-idm";
82
+ clientRef.workflow = "client";
83
+ clientRef.key = clientId;
84
+ clientRef.version = "1.0.0";
85
+ attributes["client"] = clientRef;
86
86
 
87
87
  // Scope reference
88
- attributes["scope"] = new {
89
- domain = "morph-idm",
90
- workflow = "scope",
91
- key = selectedScopeKey,
92
- version = "1.0.0"
93
- };
88
+ dynamic scopeRef = new ExpandoObject();
89
+ scopeRef.domain = "morph-idm";
90
+ scopeRef.workflow = "scope";
91
+ scopeRef.key = selectedScopeKey;
92
+ scopeRef.version = "1.0.0";
93
+ attributes["scope"] = scopeRef;
94
94
 
95
95
  // Default position
96
96
  attributes["position"] = "self-access";
97
97
 
98
98
  // Default roles for auto-consent
99
- attributes["roles"] = new List<object>
100
- {
101
- new { role = "idm.self-access", allowance = "allow" }
102
- };
99
+ dynamic roleItem = new ExpandoObject();
100
+ roleItem.role = "idm.self-access";
101
+ roleItem.allowance = "allow";
102
+ attributes["roles"] = new List<object> { roleItem };
103
103
 
104
104
  // Set consent timestamps
105
105
  attributes["grantedAt"] = DateTime.UtcNow.ToString("o");
@@ -122,29 +122,29 @@ public class CreateAutoConsentMapping : ScriptBase, ISubFlowMapping
122
122
  public async Task<ScriptResponse> OutputHandler(ScriptContext context)
123
123
  {
124
124
  // Extract the created consent info from subflow response
125
- var consentKey = context.Body?.key?.ToString();
126
- var consentState = context.Body?.state?.ToString();
125
+ var consentKey = context.Body?.key?.ToString() ?? string.Empty;
126
+ var consentState = context.Body?.state?.ToString() ?? string.Empty;
127
127
 
128
128
  LogInformation($"CreateAutoConsentMapping OutputHandler: Auto-consent created - key={consentKey}, state={consentState}");
129
129
 
130
- // Store the created consent info
130
+ // Store the created consent info using ExpandoObject
131
+ dynamic result = new ExpandoObject();
132
+ result.autoConsentCreated = true;
133
+ result.autoConsentKey = consentKey;
134
+ result.autoConsentState = consentState;
135
+
136
+ dynamic selectedConsent = new ExpandoObject();
137
+ selectedConsent.key = consentKey;
138
+ selectedConsent.roles = context.Body?.data?.roles;
139
+ selectedConsent.expiresAt = context.Body?.data?.expiresAt;
140
+
141
+ result.selectedConsent = selectedConsent;
142
+ result.selectedConsentKey = consentKey;
143
+
131
144
  return new ScriptResponse
132
145
  {
133
- Data = new
134
- {
135
- autoConsentCreated = true,
136
- autoConsentKey = consentKey,
137
- autoConsentState = consentState,
138
- selectedConsent = new
139
- {
140
- key = consentKey,
141
- roles = context.Body?.data?.roles,
142
- expiresAt = context.Body?.data?.expiresAt
143
- },
144
- selectedConsentKey = consentKey
145
- },
146
+ Data = result,
146
147
  Headers = null
147
148
  };
148
149
  }
149
150
  }
150
-
@@ -10,21 +10,25 @@ public class MultipleConsentsRule : ScriptBase, IConditionMapping
10
10
  {
11
11
  public async Task<bool> Handler(ScriptContext context)
12
12
  {
13
- if (!HasProperty(context.Instance?.Data, "consentCount"))
13
+ if (!HasProperty(context.Instance?.Data, "consentSnapshot"))
14
14
  {
15
- LogWarning("MultipleConsentsRule: consentCount not found");
15
+ LogWarning("MultipleConsentsRule: consentSnapshot not found");
16
+ return false;
17
+ }
18
+ if (!HasProperty(context.Instance?.Data.consentSnapshot, "consents"))
19
+ {
20
+ LogWarning("MultipleConsentsRule: consents not found");
16
21
  return false;
17
22
  }
18
23
 
19
- var consentCount = (int)(context.Instance?.Data?.consentCount ?? 0);
20
-
21
- if (consentCount > 1)
24
+ var consents = context.Instance?.Data.consentSnapshot.consents as List<object>;
25
+ if (consents?.Count > 1)
22
26
  {
23
- LogInformation($"MultipleConsentsRule: {consentCount} consents found, user selection required");
27
+ LogInformation($"MultipleConsentsRule: {consents?.Count ?? 0} consents found, user selection required");
24
28
  return true;
25
29
  }
26
-
27
- LogInformation($"MultipleConsentsRule: consentCount={consentCount}, not multiple");
30
+
31
+ LogInformation($"MultipleConsentsRule: consents={consents?.Count ?? 0}, not multiple");
28
32
  return false;
29
33
  }
30
34
  }
@@ -10,34 +10,18 @@ public class NoConsentEligibleRule : ScriptBase, IConditionMapping
10
10
  {
11
11
  public async Task<bool> Handler(ScriptContext context)
12
12
  {
13
- if (!HasProperty(context.Instance?.Data, "consentCount"))
13
+ if (!HasProperty(context.Instance?.Data, "consentSnapshot"))
14
14
  {
15
- LogWarning("NoConsentEligibleRule: consentCount not found");
16
- return false;
17
- }
18
-
19
- var consentCount = (int)(context.Instance?.Data?.consentCount ?? 0);
20
-
21
- if (consentCount > 0)
22
- {
23
- LogInformation($"NoConsentEligibleRule: consentCount={consentCount}, consents exist");
24
- return false;
25
- }
26
-
27
- // Check auto-consent eligibility
28
- var hasAutoConsentEligible = false;
29
- if (HasProperty(context.Instance?.Data, "hasAutoConsentEligible"))
30
- {
31
- hasAutoConsentEligible = context.Instance?.Data?.hasAutoConsentEligible == true;
15
+ LogWarning("NoConsentEligibleRule: consentSnapshot not found");
16
+ return true;
32
17
  }
33
-
34
- if (hasAutoConsentEligible)
18
+ if (!HasProperty(context.Instance?.Data.consentSnapshot, "consents"))
35
19
  {
36
- LogInformation("NoConsentEligibleRule: No consents but auto-consent eligible, creating auto-consent");
20
+ LogWarning("NoConsentEligibleRule: consents not found");
37
21
  return true;
38
22
  }
39
23
 
40
- LogInformation("NoConsentEligibleRule: No consents and not eligible for auto-consent");
24
+ LogInformation("NoConsentEligibleRule: There are consents available");
41
25
  return false;
42
26
  }
43
27
  }
@@ -0,0 +1,63 @@
1
+ using System.Dynamic;
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 auto-selecting the single consent.
9
+ /// When there's exactly one consent, this mapping automatically selects it.
10
+ /// </summary>
11
+ public class SingleConsentAutoSelectMapping : ScriptBase, IMapping
12
+ {
13
+ public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
14
+ {
15
+ // No input preparation needed for this mapping
16
+ return Task.FromResult(new ScriptResponse());
17
+ }
18
+
19
+ public async Task<ScriptResponse> OutputHandler(ScriptContext context)
20
+ {
21
+ dynamic result = new ExpandoObject();
22
+
23
+ if (!HasProperty(context.Instance?.Data, "consentSnapshot"))
24
+ {
25
+ LogWarning("SingleConsentAutoSelectMapping: consentSnapshot not found");
26
+ result.selectionError = "consentSnapshot not found";
27
+ return new ScriptResponse { Data = result };
28
+ }
29
+
30
+ if (!HasProperty(context.Instance?.Data?.consentSnapshot, "consents"))
31
+ {
32
+ LogWarning("SingleConsentAutoSelectMapping: consents not found");
33
+ result.selectionError = "consents not found";
34
+ return new ScriptResponse { Data = result };
35
+ }
36
+
37
+ var consents = context.Instance?.Data?.consentSnapshot.consents;
38
+ dynamic selectedConsent = null;
39
+ string selectedConsentKey = string.Empty;
40
+
41
+ // Get the first (and only) consent
42
+ foreach (var consent in consents)
43
+ {
44
+ selectedConsent = consent;
45
+ selectedConsentKey = consent?.consentKey?.ToString() ?? string.Empty;
46
+ break;
47
+ }
48
+
49
+ if (selectedConsent == null)
50
+ {
51
+ LogWarning("SingleConsentAutoSelectMapping: No consent found in list");
52
+ result.selectionError = "No consent found";
53
+ return new ScriptResponse { Data = result };
54
+ }
55
+
56
+ LogInformation($"SingleConsentAutoSelectMapping: Auto-selected single consent: {selectedConsentKey}");
57
+
58
+ result.selectedConsent = selectedConsent;
59
+ result.selectedConsentKey = selectedConsentKey;
60
+
61
+ return new ScriptResponse { Data = result };
62
+ }
63
+ }
@@ -10,35 +10,24 @@ public class SingleConsentRule : ScriptBase, IConditionMapping
10
10
  {
11
11
  public async Task<bool> Handler(ScriptContext context)
12
12
  {
13
- if (!HasProperty(context.Instance?.Data, "consentCount"))
13
+ if (!HasProperty(context.Instance?.Data, "consentSnapshot"))
14
14
  {
15
- LogWarning("SingleConsentRule: consentCount not found");
15
+ LogWarning("SingleConsentRule: consentSnapshot not found");
16
+ return false;
17
+ }
18
+ if (!HasProperty(context.Instance?.Data.consentSnapshot, "consents"))
19
+ {
20
+ LogWarning("SingleConsentRule: consents not found");
16
21
  return false;
17
22
  }
18
23
 
19
- var consentCount = (int)(context.Instance?.Data?.consentCount ?? 0);
20
-
21
- if (consentCount == 1)
24
+ var consents = context.Instance?.Data.consentSnapshot.consents as List<object>;
25
+ if (consents?.Count == 1)
22
26
  {
23
- // Auto-select the single consent
24
- var consents = context.Instance?.Data?.consents;
25
- if (consents != null)
26
- {
27
- foreach (var consent in consents)
28
- {
29
- var consentKey = consent?.key?.ToString();
30
- LogInformation($"SingleConsentRule: Auto-selecting single consent: {consentKey}");
31
-
32
- // Store selected consent
33
- context.Instance.Data.selectedConsent = consent;
34
- context.Instance.Data.selectedConsentKey = consentKey;
35
- break;
36
- }
37
- }
27
+
38
28
  return true;
39
29
  }
40
-
41
- LogInformation($"SingleConsentRule: consentCount={consentCount}, not single");
30
+ LogInformation($"SingleConsentRule: consents={consents?.Count ?? 0}, not single");
42
31
  return false;
43
32
  }
44
33
  }
@@ -44,12 +44,6 @@ Content-Type: application/json
44
44
  "environment": "production",
45
45
  "bundleId": "com.bank.mobilebanking",
46
46
  "updatedAt": "{{$datetime iso8601}}"
47
- },
48
- "registeredAt": "{{$datetime iso8601}}",
49
- "lastSeenAt": "{{$datetime iso8601}}",
50
- "metadata": {
51
- "appBuildNumber": "1234",
52
- "jailbroken": false
53
47
  }
54
48
  }
55
49
  }
@@ -0,0 +1,32 @@
1
+ ### Variables
2
+ @workflow = device
3
+
4
+ ### Search Device Instances (Current Filter Format)
5
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances?filter=attributes=deviceId=like:i1
6
+ Accept-Language: tr-TR
7
+ X-Request-Id: {{$guid}}
8
+ X-Device-Id: admin-portal
9
+ X-Token-Id: {{$guid}}
10
+ user_reference: admin-001
11
+
12
+ ### ============================================
13
+ ### NEW JSON FILTER FORMAT (Upcoming Version)
14
+ ### ============================================
15
+
16
+ ### Search Devices with OR condition - Active or Pending status
17
+ # Filter JSON: {"or":[{"attributes":{"status":{"eq":"active"}}},{"attributes":{"status":{"eq":"pending"}}}]}
18
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances?filter=%7B%22or%22%3A%5B%7B%22attributes%22%3A%7B%22status%22%3A%7B%22eq%22%3A%22active%22%7D%7D%7D%2C%7B%22attributes%22%3A%7B%22status%22%3A%7B%22eq%22%3A%22pending%22%7D%7D%7D%5D%7D&page=1&pageSize=10
19
+ Accept-Language: tr-TR
20
+ X-Request-Id: {{$guid}}
21
+ X-Device-Id: admin-portal
22
+ X-Token-Id: {{$guid}}
23
+ user_reference: admin-001
24
+
25
+ ### Search Devices with AND + OR conditions - iOS devices that are active or registered
26
+ # Filter JSON: {"and":[{"attributes":{"platform":{"eq":"iOS"}}},{"or":[{"attributes":{"status":{"eq":"active"}}},{"attributes":{"status":{"eq":"registered"}}}]}]}
27
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances?filter=%7B%22and%22%3A%5B%7B%22attributes%22%3A%7B%22platform%22%3A%7B%22eq%22%3A%22iOS%22%7D%7D%7D%2C%7B%22or%22%3A%5B%7B%22attributes%22%3A%7B%22status%22%3A%7B%22eq%22%3A%22active%22%7D%7D%7D%2C%7B%22attributes%22%3A%7B%22status%22%3A%7B%22eq%22%3A%22registered%22%7D%7D%7D%5D%7D%5D%7D&page=1&pageSize=10
28
+ Accept-Language: tr-TR
29
+ X-Request-Id: {{$guid}}
30
+ X-Device-Id: admin-portal
31
+ X-Token-Id: {{$guid}}
32
+ user_reference: admin-001