@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
@@ -0,0 +1,179 @@
1
+ ### User Migration Test - Import user from Provider_Bff
2
+ ###
3
+ ### Prerequisites:
4
+ ### 1. Person instance must exist
5
+ ### 2. Password data from Provider_Bff (Id, HashedPassword, CreatedAt, etc.)
6
+ ###
7
+ ### Note: Migration happens AUTOMATICALLY when passwords array is provided
8
+ ### The workflow will auto-route: START → draft → auto-migrate → active
9
+ ###
10
+ ### Variables
11
+ @workflow = user
12
+
13
+ @migrationKey = user-migration-{{$timestamp}}
14
+ @personKey = person-migration-test2
15
+
16
+ ### 1. Create Person (if not exists)
17
+ # @name createPerson
18
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/person/instances/start?sync=true
19
+ Accept-Language: tr-TR
20
+ X-Request-Id: {{$guid}}
21
+ X-Device-Id: {{$guid}}
22
+ X-Token-Id: {{$guid}}
23
+ X-Device-Info: Thunder Client/1.0
24
+ X-Forwarded-For: 192.168.2.1
25
+ user_reference: {{personKey}}
26
+ Content-Type: application/json
27
+
28
+ {
29
+ "key": "{{personKey}}",
30
+ "tags": ["migration", "provider-bff"],
31
+ "attributes": {
32
+ "mobilePhonesNumbers": [{
33
+ "countryCode": "90",
34
+ "areaCode": "532",
35
+ "number": "1234567",
36
+ "useForOTP": true
37
+ }]
38
+ }
39
+ }
40
+
41
+ ###
42
+ @personInstanceId = {{createPerson.response.body.id}}
43
+
44
+ ### 2. Publish Person to Active State
45
+ # @name publishPerson
46
+ PATCH {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/person/instances/{{personInstanceId}}/transitions/publish?sync=true
47
+ Accept-Language: tr-TR
48
+ X-Request-Id: {{$guid}}
49
+ X-Device-Id: {{$guid}}
50
+ X-Token-Id: {{$guid}}
51
+ X-Device-Info: Thunder Client/1.0
52
+ X-Forwarded-For: 192.168.2.1
53
+ user_reference: {{personKey}}
54
+ Content-Type: application/json
55
+
56
+ {}
57
+
58
+ ### 3. Migrate User with Passwords from Provider_Bff
59
+ # AUTO MIGRATION: Will automatically go draft → active when passwords array is present
60
+ # @name migrateUser
61
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start?sync=true
62
+ Accept-Language: tr-TR
63
+ X-Request-Id: {{$guid}}
64
+ X-Device-Id: {{$guid}}
65
+ X-Token-Id: {{$guid}}
66
+ X-Device-Info: Thunder Client/1.0
67
+ X-Forwarded-For: 192.168.2.1
68
+ user_reference: {{personKey}}
69
+ Content-Type: application/json
70
+
71
+ {
72
+ "key": "{{migrationKey}}",
73
+ "tags": ["migration", "provider-bff", "imported"],
74
+ "attributes": {
75
+ "type": "person",
76
+ "person": {
77
+ "domain": "morph-idm",
78
+ "workflow": "person",
79
+ "key": "{{personKey}}",
80
+ "version": "1.0.0"
81
+ },
82
+ "passwords": [
83
+ {
84
+ "type": "Password",
85
+ "passwordId": "{{$guid}}",
86
+ "accessFailedCount": 0,
87
+ "mustResetPassword": false,
88
+ "source": {
89
+ "password": "hashed-password-from-provider-bff",
90
+ "algorithm": "pbkdf2-hmacsha256",
91
+ "lastUpdatedDate": "2024-01-15T10:30:00Z"
92
+ },
93
+ "audit": {
94
+ "createdByUserName": "migration-service",
95
+ "createdByIP": "10.0.0.1",
96
+ "createdByInstanceId": "{{$guid}}",
97
+ "createdByInstanceState": "active",
98
+ "createdBehalfOf": "admin"
99
+ }
100
+ }
101
+ ],
102
+ "forceActionsAfterSuccessLogin": {
103
+ "mustChangePassword": false,
104
+ "mustRenewSecurityQuestion": "validateThenSetNew",
105
+ "mustRenewAntiPishingImage": "setNew"
106
+ }
107
+ }
108
+ }
109
+
110
+ ###
111
+ @migrationInstanceId = {{migrateUser.response.body.id}}
112
+
113
+ ### 4. Check Final State (should be 'active' automatically)
114
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{migrationInstanceId}}/functions/state
115
+ Accept-Language: tr-TR
116
+ X-Request-Id: {{$guid}}
117
+ X-Device-Id: {{$guid}}
118
+ X-Token-Id: {{$guid}}
119
+ user_reference: {{personKey}}
120
+
121
+ ### 5. Verify Migration Data
122
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{migrationInstanceId}}/functions/data
123
+ Accept-Language: tr-TR
124
+ X-Request-Id: {{$guid}}
125
+ X-Device-Id: {{$guid}}
126
+ X-Token-Id: {{$guid}}
127
+ user_reference: {{personKey}}
128
+
129
+ ### 6. Test Normal Flow (no passwords array)
130
+ # Should auto-route: START → draft → auto-normal-flow → phone-fetched
131
+ # @name normalUser
132
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start?sync=true
133
+ Accept-Language: tr-TR
134
+ X-Request-Id: {{$guid}}
135
+ X-Device-Id: {{$guid}}
136
+ X-Token-Id: {{$guid}}
137
+ X-Device-Info: Thunder Client/1.0
138
+ X-Forwarded-For: 192.168.2.1
139
+ user_reference: {{personKey}}
140
+ Content-Type: application/json
141
+
142
+ {
143
+ "key": "user-normal-test",
144
+ "tags": ["normal", "test"],
145
+ "attributes": {
146
+ "type": "person",
147
+ "person": {
148
+ "domain": "morph-idm",
149
+ "workflow": "person",
150
+ "key": "{{personKey}}",
151
+ "version": "1.0.0"
152
+ },
153
+ "forceActionsAfterSuccessLogin": {
154
+ "mustChangePassword": false,
155
+ "mustRenewSecurityQuestion": "validateThenSetNew",
156
+ "mustRenewAntiPishingImage": "setNew"
157
+ }
158
+ }
159
+ }
160
+
161
+ ###
162
+ @normalInstanceId = {{normalUser.response.body.id}}
163
+
164
+ ### 7. Check Normal Flow State (should be 'phone-fetched' automatically)
165
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{normalInstanceId}}/functions/state
166
+ Accept-Language: tr-TR
167
+ X-Request-Id: {{$guid}}
168
+ X-Device-Id: {{$guid}}
169
+ X-Token-Id: {{$guid}}
170
+ user_reference: {{personKey}}
171
+
172
+ ### 8. Get Normal Flow Data
173
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{normalInstanceId}}/functions/data
174
+ Accept-Language: tr-TR
175
+ X-Request-Id: {{$guid}}
176
+ X-Device-Id: {{$guid}}
177
+ X-Token-Id: {{$guid}}
178
+ user_reference: {{personKey}}
179
+
@@ -1,10 +1,59 @@
1
+ ### User Creation with Person and Password Workflow Tests
2
+ ###
3
+ ### Prerequisites:
4
+ ### 1. morph-idm-api Mockoon should be running on port 3030 (for SMS mock)
5
+ ### Command: cd morph-idm-api/mock && docker-compose up -d
6
+ ### 2. Vault configuration for mock SMS:
7
+ ### - Key: MessagingService:BaseUrl
8
+ ### - Value: http://host.docker.internal:3030 (for Docker) or http://localhost:3030 (for local)
9
+ ### 3. For SMS mock tests, see: morph-idm-api/mock/execute/otp-send.http
10
+ ### 4. UtilBaseAddress should point to: http://host.docker.internal:5288/api
11
+ ###
1
12
  ### Variables
2
13
  @workflow = user
14
+
3
15
  @randomKey = test-user-{{$timestamp}}
4
- @personKey = person-{{$timestamp}}
16
+ @personKey = person-test-7
17
+
18
+ ### 1. Create Person with Mobile Phone
19
+ # Person instance is required for user creation
20
+ # Mobile phone number will be used for OTP sending
21
+ # Person key must be a valid TCKN (Turkish Identification Number)
22
+ # @name createPerson
23
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/person/instances/start?sync=true
24
+ Accept-Language: tr-TR
25
+ X-Request-Id: {{$guid}}
26
+ X-Device-Id: {{$guid}}
27
+ X-Token-Id: {{$guid}}
28
+ X-Device-Info: Thunder Client/1.0
29
+ X-Forwarded-For: 192.168.2.1
30
+ user_reference: {{personKey}}
31
+ Content-Type: application/json
32
+
33
+ {
34
+ "key": "{{personKey}}",
35
+ "tags": [
36
+ "test",
37
+ "demo"
38
+ ],
39
+ "attributes": {
40
+ "mobilePhonesNumbers": [
41
+ {
42
+ "countryCode": "90",
43
+ "areaCode": "532",
44
+ "number": "1111111",
45
+ "useForOTP": true
46
+ }
47
+ ]
48
+ }
49
+ }
50
+
51
+ ###
52
+ @personInstanceId = {{createPerson.response.body.id}}
5
53
 
6
- ### Create User with Auto Password Generation
7
- # This user will get an auto-generated password in draft state
54
+ ### 2. Create User with Person Reference
55
+ # Workflow will automatically flow through all states (no manual transition needed)
56
+ # Flow: draft → [AUTO] phone-fetched → [AUTO] password-generated → [AUTO] otp-sent → [AUTO] active
8
57
  # @name createUserWithPassword
9
58
  POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start?sync=true
10
59
  Accept-Language: tr-TR
@@ -13,7 +62,7 @@ X-Device-Id: {{$guid}}
13
62
  X-Token-Id: {{$guid}}
14
63
  X-Device-Info: Thunder Client/1.0
15
64
  X-Forwarded-For: 192.168.2.1
16
- user_reference: 12345678900
65
+ user_reference: {{personKey}}
17
66
  Content-Type: application/json
18
67
 
19
68
  {
@@ -44,52 +93,49 @@ Content-Type: application/json
44
93
  @instanceId = {{createUserWithPassword.response.body.id}}
45
94
  @userKey = {{createUserWithPassword.response.body.key}}
46
95
 
47
- ### Get User Data (Check Password Generation Result)
48
- GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/data
49
- Accept-Language: tr-TR
50
- X-Request-Id: {{$guid}}
51
- X-Device-Id: {{$guid}}
52
- X-Token-Id: {{$guid}}
53
- user_reference: 12345678900
54
-
55
- ### Get User State
96
+ ### 3. Get User State (Should be 'active' after automatic flow)
97
+ # The workflow automatically:
98
+ # - Gets phone number from person instance
99
+ # - Generates password
100
+ # - Sends OTP SMS
101
+ # - Moves to active state
102
+ # All happens automatically after user creation
56
103
  GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/state
57
104
  Accept-Language: tr-TR
58
105
  X-Request-Id: {{$guid}}
59
106
  X-Device-Id: {{$guid}}
60
107
  X-Token-Id: {{$guid}}
61
- user_reference: 12345678900
108
+ user_reference: {{personKey}}
62
109
 
63
- ### Publish User (Move to Active State)
64
- PATCH {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/transitions/publish?sync=true
110
+ ### 4. Get User Data (Verify all data: phone, password, SMS)
111
+ # Should contain:
112
+ # - personPhoneNumber: Phone fetched from person instance
113
+ # - passwords: Array with generated password (schema-compliant format)
114
+ # - smsDelivery: SMS delivery status
115
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/data
65
116
  Accept-Language: tr-TR
66
117
  X-Request-Id: {{$guid}}
67
118
  X-Device-Id: {{$guid}}
68
119
  X-Token-Id: {{$guid}}
69
- X-Device-Info: Thunder Client/1.0
70
- X-Forwarded-For: 192.168.2.1
71
- user_reference: 12345678900
72
- Content-Type: application/json
73
-
74
- {}
120
+ user_reference: {{personKey}}
75
121
 
76
- ### Validate User
122
+ ### 5. Validate User
77
123
  GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/functions/function-validate-user
78
124
  Accept-Language: tr-TR
79
125
  X-Request-Id: {{$guid}}
80
126
  X-Device-Id: {{$guid}}
81
127
  X-Token-Id: {{$guid}}
82
- user_reference: 12345678900
128
+ user_reference: {{personKey}}
83
129
 
84
- ### Get Available Transitions
130
+ ### 6. Get Available Transitions
85
131
  GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/transitions
86
132
  Accept-Language: tr-TR
87
133
  X-Request-Id: {{$guid}}
88
134
  X-Device-Id: {{$guid}}
89
135
  X-Token-Id: {{$guid}}
90
- user_reference: 12345678900
136
+ user_reference: {{personKey}}
91
137
 
92
- ### Suspend User
138
+ ### 7. Suspend User
93
139
  POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/transitions/suspend?sync=true
94
140
  Accept-Language: tr-TR
95
141
  X-Request-Id: {{$guid}}
@@ -97,12 +143,12 @@ X-Device-Id: {{$guid}}
97
143
  X-Token-Id: {{$guid}}
98
144
  X-Device-Info: Thunder Client/1.0
99
145
  X-Forwarded-For: 192.168.2.1
100
- user_reference: 12345678900
146
+ user_reference: {{personKey}}
101
147
  Content-Type: application/json
102
148
 
103
149
  {}
104
150
 
105
- ### Reactivate User
151
+ ### 8. Reactivate User
106
152
  POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/transitions/reactivate?sync=true
107
153
  Accept-Language: tr-TR
108
154
  X-Request-Id: {{$guid}}
@@ -110,12 +156,12 @@ X-Device-Id: {{$guid}}
110
156
  X-Token-Id: {{$guid}}
111
157
  X-Device-Info: Thunder Client/1.0
112
158
  X-Forwarded-For: 192.168.2.1
113
- user_reference: 12345678900
159
+ user_reference: {{personKey}}
114
160
  Content-Type: application/json
115
161
 
116
162
  {}
117
163
 
118
- ### Delete User (Only in Draft State)
164
+ ### 9. Delete User (Only in Draft State)
119
165
  POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{instanceId}}/transitions/delete?sync=true
120
166
  Accept-Language: tr-TR
121
167
  X-Request-Id: {{$guid}}
@@ -123,7 +169,7 @@ X-Device-Id: {{$guid}}
123
169
  X-Token-Id: {{$guid}}
124
170
  X-Device-Info: Thunder Client/1.0
125
171
  X-Forwarded-For: 192.168.2.1
126
- user_reference: 12345678900
172
+ user_reference: {{personKey}}
127
173
  Content-Type: application/json
128
174
 
129
175
  {}
@@ -0,0 +1,75 @@
1
+ using System;
2
+ using System.Threading.Tasks;
3
+ using System.Collections.Generic;
4
+ using System.Linq;
5
+ using BBT.Workflow.Definitions;
6
+ using BBT.Workflow.Scripting;
7
+ using BBT.Workflow.Scripting.Functions;
8
+
9
+ /// <summary>
10
+ /// Mapping for evaluating failed login attempt.
11
+ /// Takes failCount from transition body and updates the latest password's failCount.
12
+ /// </summary>
13
+ public class EvaluateFailedLoginMapping : ScriptBase, IMapping
14
+ {
15
+ public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
16
+ {
17
+ return new ScriptResponse();
18
+ }
19
+
20
+ public async Task<ScriptResponse> OutputHandler(ScriptContext context)
21
+ {
22
+ // Get failCount from transition body
23
+ int failCount = 0;
24
+ if (HasProperty(context.Body, "failCount"))
25
+ {
26
+ int.TryParse(context.Body.failCount?.ToString() ?? "0", out failCount);
27
+ }
28
+
29
+ LogInformation($"EvaluateFailedLoginMapping: Received failCount={failCount} from body");
30
+
31
+ // Get existing passwords array
32
+ var existingPasswords = new List<dynamic>();
33
+ if (HasProperty(context.Instance?.Data, "passwords") &&
34
+ context.Instance?.Data?.passwords != null)
35
+ {
36
+ existingPasswords = ((IEnumerable<dynamic>)context.Instance.Data.passwords).ToList();
37
+ }
38
+
39
+ // Update latest password's failCount
40
+ if (existingPasswords.Count > 0)
41
+ {
42
+ var latestPassword = existingPasswords.Last();
43
+
44
+ // Create updated password entry with new failCount
45
+ var updatedPassword = new
46
+ {
47
+ type = HasProperty(latestPassword, "type") ? latestPassword.type : "Password",
48
+ passwordId = HasProperty(latestPassword, "passwordId") ? latestPassword.passwordId : null,
49
+ initialPassword = HasProperty(latestPassword, "initialPassword") ? latestPassword.initialPassword : null,
50
+ source = HasProperty(latestPassword, "source") ? latestPassword.source : null,
51
+ failCount = failCount,
52
+ lastFailedAt = failCount > 0 ? DateTime.UtcNow : (DateTime?)null
53
+ };
54
+
55
+ // Replace last password with updated one
56
+ existingPasswords[existingPasswords.Count - 1] = updatedPassword;
57
+
58
+ LogInformation($"EvaluateFailedLoginMapping: Updated latest password failCount to {failCount}");
59
+ }
60
+ else
61
+ {
62
+ LogWarning("EvaluateFailedLoginMapping: No passwords found in instance data");
63
+ }
64
+
65
+ return new ScriptResponse
66
+ {
67
+ Data = new
68
+ {
69
+ passwords = existingPasswords,
70
+ passwordFailCount = failCount,
71
+ lastPasswordFailUpdate = DateTime.UtcNow
72
+ }
73
+ };
74
+ }
75
+ }
@@ -0,0 +1,33 @@
1
+ using System.Threading.Tasks;
2
+ using BBT.Workflow.Scripting;
3
+ using BBT.Workflow.Scripting.Functions;
4
+
5
+ /// <summary>
6
+ /// Rule to check if password fail count has reached maximum (5).
7
+ /// Used for auto-transitioning to banned state.
8
+ /// </summary>
9
+ public class FailCountMaxRule : ScriptBase, IConditionMapping
10
+ {
11
+ private const int MAX_FAIL_COUNT = 5;
12
+
13
+ public async Task<bool> Handler(ScriptContext context)
14
+ {
15
+ int failCount = 0;
16
+
17
+ // Check failCount from instance data (set by UpdatePasswordFailCountMapping)
18
+ if (HasProperty(context.Instance?.Data, "passwordFailCount"))
19
+ {
20
+ var failCountValue = context.Instance?.Data?.passwordFailCount;
21
+ if (failCountValue != null)
22
+ {
23
+ int.TryParse(failCountValue.ToString(), out failCount);
24
+ }
25
+ }
26
+
27
+ bool maxReached = failCount >= MAX_FAIL_COUNT;
28
+
29
+ LogInformation($"FailCountMaxRule: failCount={failCount}, maxFailCount={MAX_FAIL_COUNT}, reached={maxReached}");
30
+
31
+ return maxReached;
32
+ }
33
+ }
@@ -0,0 +1,139 @@
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 getting phone number from Person workflow instance
9
+ /// Fetches person instance using GetInstanceDataTask and extracts mobile phone number
10
+ /// </summary>
11
+ public class GetPhoneFromPersonMapping : ScriptBase, IMapping
12
+ {
13
+ public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
14
+ {
15
+ var triggerTask = (task as GetInstanceDataTask)!;
16
+
17
+ // Get person key from instance data
18
+ // Person reference structure: context.Instance.Data.person = { domain, workflow, key, version }
19
+ string personKey = string.Empty;
20
+
21
+ if (HasProperty(context.Instance?.Data, "person") && HasProperty(context.Instance?.Data?.person, "key"))
22
+ {
23
+ personKey = context.Instance?.Data?.person?.key?.ToString() ?? string.Empty;
24
+ }
25
+
26
+ if (string.IsNullOrEmpty(personKey))
27
+ {
28
+ LogError("GetPhoneFromPersonMapping InputHandler: person.key not found in instance data");
29
+ throw new InvalidOperationException("Person reference not found in user instance. Cannot fetch phone number without person key.");
30
+ }
31
+
32
+ LogInformation($"GetPhoneFromPersonMapping InputHandler: Fetching person instance with key={personKey}");
33
+
34
+ // Set the key to fetch the person instance
35
+ triggerTask.SetKey(personKey);
36
+ return Task.FromResult(new ScriptResponse());
37
+ }
38
+
39
+ public async Task<ScriptResponse> OutputHandler(ScriptContext context)
40
+ {
41
+ // Check if person instance was found
42
+ if (HasProperty(context.Body, "data") && HasProperty(context.Body.data, "data"))
43
+ {
44
+ var personData = context.Body.data.data;
45
+
46
+ LogInformation("GetPhoneFromPersonMapping OutputHandler: Person instance data retrieved");
47
+
48
+ // Parse mobilePhonesNumbers array from person schema
49
+ if (!HasProperty(personData, "mobilePhonesNumbers"))
50
+ {
51
+ LogError("GetPhoneFromPersonMapping OutputHandler: mobilePhonesNumbers field not found in person instance");
52
+ throw new InvalidOperationException("Person found but mobilePhonesNumbers field is missing. Cannot send OTP without phone number.");
53
+ }
54
+
55
+ var mobilePhonesNumbers = personData.mobilePhonesNumbers;
56
+ if (mobilePhonesNumbers == null)
57
+ {
58
+ LogError("GetPhoneFromPersonMapping OutputHandler: mobilePhonesNumbers is null in person instance");
59
+ throw new InvalidOperationException("Person found but mobilePhonesNumbers is null. Cannot send OTP without phone number.");
60
+ }
61
+
62
+ // Convert to array-like structure
63
+ var phonesList = new List<dynamic>();
64
+ foreach (var phone in mobilePhonesNumbers)
65
+ {
66
+ phonesList.Add(phone);
67
+ }
68
+
69
+ if (phonesList.Count == 0)
70
+ {
71
+ LogError("GetPhoneFromPersonMapping OutputHandler: mobilePhonesNumbers array is empty in person instance");
72
+ throw new InvalidOperationException("Person found but mobilePhonesNumbers array is empty. Cannot send OTP without phone number.");
73
+ }
74
+
75
+ // Prefer phone with useForOTP: true, otherwise use first phone
76
+ dynamic selectedPhone = null;
77
+ foreach (var phone in phonesList)
78
+ {
79
+ if (HasProperty(phone, "useForOTP") && phone.useForOTP == true)
80
+ {
81
+ selectedPhone = phone;
82
+ break;
83
+ }
84
+ }
85
+
86
+ // If no phone with useForOTP: true, use first phone
87
+ if (selectedPhone == null)
88
+ {
89
+ selectedPhone = phonesList[0];
90
+ LogInformation($"GetPhoneFromPersonMapping OutputHandler: No phone with useForOTP=true found, using first phone");
91
+ }
92
+
93
+ // Extract phone components
94
+ var countryCode = HasProperty(selectedPhone, "countryCode") ? selectedPhone.countryCode?.ToString() : "90";
95
+ var areaCode = HasProperty(selectedPhone, "areaCode") ? selectedPhone.areaCode?.ToString() : null;
96
+ var number = HasProperty(selectedPhone, "number") ? selectedPhone.number?.ToString() : null;
97
+ var useForOTP = HasProperty(selectedPhone, "useForOTP") ? (bool?)selectedPhone.useForOTP : null;
98
+
99
+ if (string.IsNullOrEmpty(number))
100
+ {
101
+ LogError("GetPhoneFromPersonMapping OutputHandler: Phone number field is empty in selected phone");
102
+ throw new InvalidOperationException("Person found but phone number field is empty. Cannot send OTP without phone number.");
103
+ }
104
+
105
+ // Build full phone number (countryCode + areaCode + number)
106
+ var fullNumber = countryCode?.TrimStart('+') ?? "90";
107
+ if (!string.IsNullOrEmpty(areaCode))
108
+ {
109
+ fullNumber += areaCode;
110
+ }
111
+ fullNumber += number;
112
+
113
+ LogInformation($"GetPhoneFromPersonMapping OutputHandler: Phone number extracted successfully - countryCode={countryCode}, areaCode={areaCode}, number={number}, useForOTP={useForOTP}");
114
+
115
+ return new ScriptResponse
116
+ {
117
+ Data = new
118
+ {
119
+ personPhoneNumber = new
120
+ {
121
+ countryCode = countryCode,
122
+ areaCode = areaCode,
123
+ number = number,
124
+ fullNumber = fullNumber,
125
+ useForOTP = useForOTP,
126
+ source = "person-instance",
127
+ fetchedAt = DateTime.UtcNow
128
+ }
129
+ }
130
+ };
131
+ }
132
+ else
133
+ {
134
+ LogError("GetPhoneFromPersonMapping OutputHandler: Person instance not found");
135
+ throw new InvalidOperationException("Person instance not found. Ensure person exists before creating user.");
136
+ }
137
+ }
138
+ }
139
+
@@ -0,0 +1,43 @@
1
+ using System.Threading.Tasks;
2
+ using BBT.Workflow.Scripting;
3
+ using BBT.Workflow.Scripting.Functions;
4
+
5
+ public class HasPasswordsRule : ScriptBase, IConditionMapping
6
+ {
7
+ public async Task<bool> Handler(ScriptContext context)
8
+ {
9
+ // Check if passwords array exists and has items (migration scenario)
10
+ if (!HasProperty(context.Instance?.Data, "passwords"))
11
+ {
12
+ LogInformation("HasPasswordsRule: No passwords array - normal flow");
13
+ return false;
14
+ }
15
+
16
+ var passwords = context.Instance?.Data?.passwords;
17
+
18
+ if (passwords == null)
19
+ {
20
+ LogInformation("HasPasswordsRule: passwords is null - normal flow");
21
+ return false;
22
+ }
23
+
24
+ // Check if it's an array with at least one item
25
+ if (passwords is not IEnumerable<dynamic>)
26
+ {
27
+ LogWarning("HasPasswordsRule: passwords is not an array - normal flow");
28
+ return false;
29
+ }
30
+
31
+ var passwordList = ((IEnumerable<dynamic>)passwords).ToList();
32
+
33
+ if (passwordList.Count == 0)
34
+ {
35
+ LogInformation("HasPasswordsRule: passwords array is empty - normal flow");
36
+ return false;
37
+ }
38
+
39
+ LogInformation($"HasPasswordsRule: Migration detected - {passwordList.Count} password(s) found");
40
+ return true;
41
+ }
42
+ }
43
+