@almadar/std 14.8.0 → 14.9.0

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 (57) hide show
  1. package/behaviors/registry/app/organisms/std-api-gateway.orb +1167 -4114
  2. package/behaviors/registry/app/organisms/std-booking-system.orb +2627 -4281
  3. package/behaviors/registry/app/organisms/std-cicd-pipeline.orb +1313 -3724
  4. package/behaviors/registry/app/organisms/std-cms.orb +1658 -4903
  5. package/behaviors/registry/app/organisms/std-coding-academy.orb +686 -1238
  6. package/behaviors/registry/app/organisms/std-crm.orb +1778 -5995
  7. package/behaviors/registry/app/organisms/std-devops-dashboard.orb +1918 -5539
  8. package/behaviors/registry/app/organisms/std-finance-tracker.orb +1064 -3721
  9. package/behaviors/registry/app/organisms/std-healthcare.orb +2810 -7215
  10. package/behaviors/registry/app/organisms/std-helpdesk.orb +1065 -4161
  11. package/behaviors/registry/app/organisms/std-hr-portal.orb +2300 -6322
  12. package/behaviors/registry/app/organisms/std-iot-dashboard.orb +1582 -3721
  13. package/behaviors/registry/app/organisms/std-lms.orb +1885 -3952
  14. package/behaviors/registry/app/organisms/std-project-manager.orb +1226 -5123
  15. package/behaviors/registry/app/organisms/std-realtime-chat.orb +1147 -3794
  16. package/behaviors/registry/app/organisms/std-social-feed.orb +1044 -1728
  17. package/behaviors/registry/app/organisms/std-trading-dashboard.orb +1208 -3186
  18. package/behaviors/registry/core/atoms/std-graphs.orb +40 -41
  19. package/behaviors/registry/core/atoms/std-stats.orb +131 -110
  20. package/behaviors/registry/service/atoms/std-service-custom-bearer.orb +351 -345
  21. package/behaviors/registry/service/atoms/std-service-email.orb +334 -328
  22. package/behaviors/registry/service/atoms/std-service-github.orb +308 -365
  23. package/behaviors/registry/service/atoms/std-service-llm.orb +329 -437
  24. package/behaviors/registry/service/atoms/std-service-oauth.orb +261 -564
  25. package/behaviors/registry/service/atoms/std-service-redis.orb +299 -405
  26. package/behaviors/registry/service/atoms/std-service-storage.orb +293 -505
  27. package/behaviors/registry/service/atoms/std-service-twilio.orb +315 -393
  28. package/behaviors/registry/service/atoms/std-service-youtube.orb +266 -547
  29. package/dist/behaviors/registry/app/organisms/std-api-gateway.orb +1167 -4114
  30. package/dist/behaviors/registry/app/organisms/std-booking-system.orb +2627 -4281
  31. package/dist/behaviors/registry/app/organisms/std-cicd-pipeline.orb +1313 -3724
  32. package/dist/behaviors/registry/app/organisms/std-cms.orb +1658 -4903
  33. package/dist/behaviors/registry/app/organisms/std-coding-academy.orb +686 -1238
  34. package/dist/behaviors/registry/app/organisms/std-crm.orb +1778 -5995
  35. package/dist/behaviors/registry/app/organisms/std-devops-dashboard.orb +1918 -5539
  36. package/dist/behaviors/registry/app/organisms/std-finance-tracker.orb +1064 -3721
  37. package/dist/behaviors/registry/app/organisms/std-healthcare.orb +2810 -7215
  38. package/dist/behaviors/registry/app/organisms/std-helpdesk.orb +1065 -4161
  39. package/dist/behaviors/registry/app/organisms/std-hr-portal.orb +2300 -6322
  40. package/dist/behaviors/registry/app/organisms/std-iot-dashboard.orb +1582 -3721
  41. package/dist/behaviors/registry/app/organisms/std-lms.orb +1885 -3952
  42. package/dist/behaviors/registry/app/organisms/std-project-manager.orb +1226 -5123
  43. package/dist/behaviors/registry/app/organisms/std-realtime-chat.orb +1147 -3794
  44. package/dist/behaviors/registry/app/organisms/std-social-feed.orb +1044 -1728
  45. package/dist/behaviors/registry/app/organisms/std-trading-dashboard.orb +1208 -3186
  46. package/dist/behaviors/registry/core/atoms/std-graphs.orb +40 -41
  47. package/dist/behaviors/registry/core/atoms/std-stats.orb +131 -110
  48. package/dist/behaviors/registry/service/atoms/std-service-custom-bearer.orb +351 -345
  49. package/dist/behaviors/registry/service/atoms/std-service-email.orb +334 -328
  50. package/dist/behaviors/registry/service/atoms/std-service-github.orb +308 -365
  51. package/dist/behaviors/registry/service/atoms/std-service-llm.orb +329 -437
  52. package/dist/behaviors/registry/service/atoms/std-service-oauth.orb +261 -564
  53. package/dist/behaviors/registry/service/atoms/std-service-redis.orb +299 -405
  54. package/dist/behaviors/registry/service/atoms/std-service-storage.orb +293 -505
  55. package/dist/behaviors/registry/service/atoms/std-service-twilio.orb +315 -393
  56. package/dist/behaviors/registry/service/atoms/std-service-youtube.orb +266 -547
  57. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "std-service-oauth",
3
- "version": "1.0.0",
4
- "description": "std-service-oauth as a Function",
3
+ "version": "2.0.0",
4
+ "description": "std-service-oauth OAuth sign-in service. Bind via `uses Oauth from \"std/behaviors/std-service-oauth\"` and configure `provider` / `scopes` / `redirectUri` at the call site. Pass `uiTrait: \"@trait.YourLoginForm\"` to inject your own provider button; leave unset to render the atom's default sign-in form (standalone surface).",
5
5
  "orbitals": [
6
6
  {
7
7
  "name": "ServiceOauthOrbital",
@@ -19,21 +19,11 @@
19
19
  "type": "string",
20
20
  "default": "google"
21
21
  },
22
- {
23
- "name": "authUrl",
24
- "type": "string",
25
- "default": ""
26
- },
27
22
  {
28
23
  "name": "accessToken",
29
24
  "type": "string",
30
25
  "default": ""
31
26
  },
32
- {
33
- "name": "refreshToken",
34
- "type": "string",
35
- "default": ""
36
- },
37
27
  {
38
28
  "name": "authStatus",
39
29
  "type": "string",
@@ -69,6 +59,110 @@
69
59
  ]
70
60
  },
71
61
  "traits": [
62
+ {
63
+ "name": "ServiceOauthDefaultForm",
64
+ "category": "interaction",
65
+ "emits": [
66
+ {
67
+ "event": "LOGIN",
68
+ "scope": "external",
69
+ "payloadSchema": [
70
+ {
71
+ "name": "source",
72
+ "type": "string"
73
+ }
74
+ ]
75
+ }
76
+ ],
77
+ "stateMachine": {
78
+ "states": [
79
+ {
80
+ "name": "ready",
81
+ "isInitial": true
82
+ }
83
+ ],
84
+ "events": [
85
+ {
86
+ "key": "INIT",
87
+ "name": "Initialize"
88
+ },
89
+ {
90
+ "key": "LOGIN",
91
+ "name": "Login"
92
+ }
93
+ ],
94
+ "transitions": [
95
+ {
96
+ "from": "ready",
97
+ "to": "ready",
98
+ "event": "INIT",
99
+ "effects": [
100
+ [
101
+ "render-ui",
102
+ "main",
103
+ {
104
+ "direction": "vertical",
105
+ "type": "stack",
106
+ "children": [
107
+ {
108
+ "direction": "horizontal",
109
+ "gap": "md",
110
+ "align": "center",
111
+ "children": [
112
+ {
113
+ "name": "lock",
114
+ "type": "icon"
115
+ },
116
+ {
117
+ "content": "Sign In",
118
+ "variant": "h2",
119
+ "type": "typography"
120
+ }
121
+ ],
122
+ "type": "stack"
123
+ },
124
+ {
125
+ "type": "divider"
126
+ },
127
+ {
128
+ "type": "select",
129
+ "options": [
130
+ {
131
+ "label": "Google",
132
+ "value": "google"
133
+ },
134
+ {
135
+ "value": "github",
136
+ "label": "GitHub"
137
+ },
138
+ {
139
+ "value": "microsoft",
140
+ "label": "Microsoft"
141
+ },
142
+ {
143
+ "label": "Okta",
144
+ "value": "okta"
145
+ }
146
+ ]
147
+ },
148
+ {
149
+ "variant": "primary",
150
+ "action": "LOGIN",
151
+ "label": "Sign in with provider",
152
+ "icon": "log-in",
153
+ "type": "button"
154
+ }
155
+ ],
156
+ "align": "center",
157
+ "gap": "lg"
158
+ }
159
+ ]
160
+ ]
161
+ }
162
+ ]
163
+ },
164
+ "scope": "instance"
165
+ },
72
166
  {
73
167
  "name": "ServiceOauthOauth",
74
168
  "category": "interaction",
@@ -95,12 +189,16 @@
95
189
  ]
96
190
  },
97
191
  {
98
- "event": "ServiceOauthOauthCompleted",
192
+ "event": "OAuthLoggedIn",
99
193
  "scope": "external",
100
194
  "payloadSchema": [
101
195
  {
102
- "name": "result",
103
- "type": "object"
196
+ "name": "id",
197
+ "type": "string"
198
+ },
199
+ {
200
+ "name": "accessToken",
201
+ "type": "string"
104
202
  }
105
203
  ]
106
204
  },
@@ -117,23 +215,40 @@
117
215
  "type": "string"
118
216
  }
119
217
  ]
218
+ },
219
+ {
220
+ "event": "FAILED",
221
+ "payloadSchema": [
222
+ {
223
+ "name": "error",
224
+ "type": "string",
225
+ "required": true
226
+ }
227
+ ]
228
+ }
229
+ ],
230
+ "listens": [
231
+ {
232
+ "event": "LOGIN",
233
+ "triggers": "LOGIN",
234
+ "source": {
235
+ "kind": "trait",
236
+ "trait": "ServiceOauthDefaultForm"
237
+ }
120
238
  }
121
239
  ],
122
240
  "stateMachine": {
123
241
  "states": [
124
242
  {
125
- "name": "unauthenticated",
243
+ "name": "idle",
126
244
  "isInitial": true
127
245
  },
128
246
  {
129
- "name": "authorizing"
247
+ "name": "authenticating"
130
248
  },
131
249
  {
132
250
  "name": "authenticated"
133
251
  },
134
- {
135
- "name": "refreshing"
136
- },
137
252
  {
138
253
  "name": "error"
139
254
  }
@@ -148,147 +263,53 @@
148
263
  "name": "Login"
149
264
  },
150
265
  {
151
- "key": "AUTH_URL_RECEIVED",
152
- "name": "Auth Url Received",
153
- "payloadSchema": [
154
- {
155
- "name": "authUrl",
156
- "type": "string",
157
- "required": true
158
- }
159
- ]
160
- },
161
- {
162
- "key": "CALLBACK",
163
- "name": "Callback",
164
- "payloadSchema": [
165
- {
166
- "name": "code",
167
- "type": "string",
168
- "required": true
169
- }
170
- ]
171
- },
172
- {
173
- "key": "FAILED",
174
- "name": "Failed",
175
- "payloadSchema": [
176
- {
177
- "name": "error",
178
- "type": "string",
179
- "required": true
180
- }
181
- ]
182
- },
183
- {
184
- "key": "TOKEN_RECEIVED",
185
- "name": "Token Received",
266
+ "key": "ServiceOauthLoaded",
267
+ "name": "ServiceOauth loaded",
186
268
  "payloadSchema": [
187
269
  {
188
- "name": "accessToken",
189
- "type": "string",
190
- "required": true
191
- },
192
- {
193
- "name": "refreshToken",
194
- "type": "string",
195
- "required": true
270
+ "name": "id",
271
+ "type": "string"
196
272
  }
197
273
  ]
198
274
  },
199
275
  {
200
- "key": "REFRESH",
201
- "name": "Refresh"
202
- },
203
- {
204
- "key": "LOGOUT",
205
- "name": "Logout"
206
- },
207
- {
208
- "key": "TOKEN_REFRESHED",
209
- "name": "Token Refreshed",
276
+ "key": "ServiceOauthLoadFailed",
277
+ "name": "ServiceOauth load failed",
210
278
  "payloadSchema": [
211
279
  {
212
- "name": "accessToken",
213
- "type": "string",
214
- "required": true
280
+ "name": "message",
281
+ "type": "string"
215
282
  }
216
283
  ]
217
284
  },
218
285
  {
219
- "key": "RETRY",
220
- "name": "Retry"
221
- },
222
- {
223
- "key": "ServiceOauthLoaded",
224
- "name": "ServiceOauth loaded",
286
+ "key": "OAuthLoggedIn",
287
+ "name": "OAuth logged in",
225
288
  "payloadSchema": [
226
289
  {
227
290
  "name": "id",
228
- "type": "string",
229
- "required": true
230
- },
231
- {
232
- "name": "provider",
233
- "type": "string"
234
- },
235
- {
236
- "name": "authUrl",
237
291
  "type": "string"
238
292
  },
239
293
  {
240
294
  "name": "accessToken",
241
295
  "type": "string"
242
- },
243
- {
244
- "name": "refreshToken",
245
- "type": "string"
246
- },
247
- {
248
- "name": "authStatus",
249
- "type": "string"
250
- },
251
- {
252
- "name": "error",
253
- "type": "string"
254
- },
255
- {
256
- "name": "name",
257
- "type": "string"
258
- },
259
- {
260
- "name": "description",
261
- "type": "string"
262
- },
263
- {
264
- "name": "status",
265
- "type": "string"
266
- },
267
- {
268
- "name": "createdAt",
269
- "type": "string"
270
296
  }
271
297
  ]
272
298
  },
273
299
  {
274
- "key": "ServiceOauthLoadFailed",
275
- "name": "ServiceOauth load failed",
300
+ "key": "FAILED",
301
+ "name": "Failed",
276
302
  "payloadSchema": [
277
303
  {
278
- "name": "message",
279
- "type": "string"
304
+ "name": "error",
305
+ "type": "string",
306
+ "required": true
280
307
  }
281
308
  ]
282
309
  },
283
310
  {
284
- "key": "ServiceOauthOauthCompleted",
285
- "name": "ServiceOauth oauth completed",
286
- "payloadSchema": [
287
- {
288
- "name": "result",
289
- "type": "object"
290
- }
291
- ]
311
+ "key": "RESET",
312
+ "name": "Reset"
292
313
  },
293
314
  {
294
315
  "key": "ServiceOauthOauthFailed",
@@ -303,26 +324,30 @@
303
324
  "type": "string"
304
325
  }
305
326
  ]
327
+ },
328
+ {
329
+ "key": "RETRY",
330
+ "name": "Retry"
306
331
  }
307
332
  ],
308
333
  "transitions": [
309
334
  {
310
- "from": "unauthenticated",
311
- "to": "unauthenticated",
335
+ "from": "idle",
336
+ "to": "idle",
312
337
  "event": "INIT",
313
338
  "effects": [
314
339
  [
315
340
  "set",
316
341
  "@entity.provider",
317
- "google"
342
+ "@config.provider"
318
343
  ],
319
344
  [
320
345
  "fetch",
321
346
  "ServiceOauth",
322
347
  {
323
348
  "emit": {
324
- "success": "ServiceOauthLoaded",
325
- "failure": "ServiceOauthLoadFailed"
349
+ "failure": "ServiceOauthLoadFailed",
350
+ "success": "ServiceOauthLoaded"
326
351
  }
327
352
  }
328
353
  ],
@@ -331,71 +356,27 @@
331
356
  "main",
332
357
  {
333
358
  "type": "stack",
359
+ "direction": "vertical",
334
360
  "children": [
335
- {
336
- "type": "stack",
337
- "children": [
338
- {
339
- "name": "lock",
340
- "type": "icon"
341
- },
342
- {
343
- "content": "Sign In",
344
- "variant": "h2",
345
- "type": "typography"
346
- }
347
- ],
348
- "gap": "md",
349
- "align": "center",
350
- "direction": "horizontal"
351
- },
352
- {
353
- "type": "divider"
354
- },
355
- {
356
- "type": "select",
357
- "options": [
358
- {
359
- "label": "Google",
360
- "value": "google"
361
- },
362
- {
363
- "value": "github",
364
- "label": "GitHub"
365
- },
366
- {
367
- "label": "Microsoft",
368
- "value": "microsoft"
369
- }
370
- ]
371
- },
372
- {
373
- "action": "LOGIN",
374
- "type": "button",
375
- "variant": "primary",
376
- "label": "Login",
377
- "icon": "log-in"
378
- }
361
+ "@config.uiTrait"
379
362
  ],
380
- "gap": "lg",
381
- "direction": "vertical",
382
- "align": "center"
363
+ "gap": "md"
383
364
  }
384
365
  ]
385
366
  ]
386
367
  },
387
368
  {
388
- "from": "unauthenticated",
389
- "to": "authorizing",
369
+ "from": "idle",
370
+ "to": "authenticating",
390
371
  "event": "LOGIN",
391
372
  "effects": [
392
373
  [
393
374
  "render-ui",
394
375
  "main",
395
376
  {
377
+ "title": "Signing in...",
396
378
  "type": "loading-state",
397
- "title": "Authorizing...",
398
- "message": "Redirecting to provider for authorization."
379
+ "message": "Authenticating with provider."
399
380
  }
400
381
  ],
401
382
  [
@@ -403,96 +384,51 @@
403
384
  "oauth",
404
385
  "authorize",
405
386
  {
406
- "provider": "@entity.provider",
407
- "scopes": [
408
- "openid",
409
- "email"
410
- ]
387
+ "redirectUri": "@config.redirectUri",
388
+ "provider": "@config.provider",
389
+ "scopes": "@config.scopes"
411
390
  },
412
391
  {
413
392
  "emit": {
414
- "failure": "ServiceOauthOauthFailed",
415
- "success": "ServiceOauthOauthCompleted"
393
+ "success": "OAuthLoggedIn",
394
+ "failure": "FAILED"
416
395
  }
417
396
  }
418
397
  ]
419
398
  ]
420
399
  },
421
400
  {
422
- "from": "authorizing",
423
- "to": "authorizing",
424
- "event": "AUTH_URL_RECEIVED",
425
- "effects": [
426
- [
427
- "set",
428
- "@entity.authUrl",
429
- "@payload.authUrl"
430
- ],
431
- [
432
- "render-ui",
433
- "main",
434
- {
435
- "align": "center",
436
- "children": [
437
- {
438
- "type": "icon",
439
- "name": "external-link"
440
- },
441
- {
442
- "variant": "h2",
443
- "type": "typography",
444
- "content": "Authorization Required"
445
- },
446
- {
447
- "variant": "body",
448
- "color": "muted",
449
- "type": "typography",
450
- "content": "@entity.authUrl"
451
- },
452
- {
453
- "placeholder": "Paste authorization code here",
454
- "type": "input"
455
- },
456
- {
457
- "type": "button",
458
- "label": "Submit",
459
- "variant": "primary",
460
- "icon": "check",
461
- "action": "CALLBACK"
462
- }
463
- ],
464
- "type": "stack",
465
- "gap": "lg",
466
- "direction": "vertical"
467
- }
468
- ]
469
- ]
401
+ "from": "idle",
402
+ "to": "idle",
403
+ "event": "ServiceOauthLoaded"
404
+ },
405
+ {
406
+ "from": "idle",
407
+ "to": "idle",
408
+ "event": "ServiceOauthLoadFailed"
470
409
  },
471
410
  {
472
- "from": "authorizing",
411
+ "from": "authenticating",
473
412
  "to": "authenticated",
474
- "event": "CALLBACK",
413
+ "event": "OAuthLoggedIn",
475
414
  "effects": [
476
415
  [
477
- "call-service",
478
- "oauth",
479
- "token",
480
- {
481
- "code": "@payload.code"
482
- },
483
- {
484
- "emit": {
485
- "success": "ServiceOauthOauthCompleted",
486
- "failure": "ServiceOauthOauthFailed"
487
- }
488
- }
416
+ "set",
417
+ "@entity.accessToken",
418
+ "@payload.accessToken"
419
+ ],
420
+ [
421
+ "set",
422
+ "@entity.authStatus",
423
+ "authenticated"
489
424
  ],
490
425
  [
491
426
  "render-ui",
492
427
  "main",
493
428
  {
494
- "align": "center",
429
+ "type": "stack",
495
430
  "direction": "vertical",
431
+ "align": "center",
496
432
  "children": [
497
433
  {
498
434
  "name": "check-circle",
@@ -500,40 +436,30 @@
500
436
  },
501
437
  {
502
438
  "variant": "success",
503
- "message": "Authenticated successfully",
504
- "type": "alert"
439
+ "type": "alert",
440
+ "message": "Signed in successfully"
505
441
  },
506
442
  {
507
- "justify": "center",
508
- "direction": "horizontal",
509
- "gap": "sm",
510
- "type": "stack",
511
- "children": [
512
- {
513
- "label": "Refresh Token",
514
- "type": "button",
515
- "variant": "ghost",
516
- "action": "REFRESH",
517
- "icon": "refresh-cw"
518
- },
519
- {
520
- "action": "LOGOUT",
521
- "variant": "ghost",
522
- "type": "button",
523
- "label": "Logout",
524
- "icon": "log-out"
525
- }
526
- ]
443
+ "type": "typography",
444
+ "content": "@entity.accessToken",
445
+ "variant": "body",
446
+ "color": "muted"
447
+ },
448
+ {
449
+ "icon": "log-out",
450
+ "type": "button",
451
+ "label": "Sign Out",
452
+ "action": "RESET",
453
+ "variant": "ghost"
527
454
  }
528
455
  ],
529
- "type": "stack",
530
456
  "gap": "lg"
531
457
  }
532
458
  ]
533
459
  ]
534
460
  },
535
461
  {
536
- "from": "authorizing",
462
+ "from": "authenticating",
537
463
  "to": "error",
538
464
  "event": "FAILED",
539
465
  "effects": [
@@ -543,131 +469,29 @@
543
469
  "@payload.error"
544
470
  ],
545
471
  [
546
- "render-ui",
547
- "main",
472
+ "emit",
473
+ "ServiceOauthOauthFailed",
548
474
  {
549
- "direction": "vertical",
550
- "children": [
551
- {
552
- "title": "Authentication Failed",
553
- "onRetry": "RETRY",
554
- "message": "@entity.error",
555
- "type": "error-state"
556
- },
557
- {
558
- "variant": "primary",
559
- "icon": "rotate-ccw",
560
- "type": "button",
561
- "action": "RETRY",
562
- "label": "Try Again"
563
- }
564
- ],
565
- "type": "stack",
566
- "gap": "lg",
567
- "align": "center"
475
+ "error": "@entity.error",
476
+ "code": "oauth_login_failed"
568
477
  }
569
- ]
570
- ]
571
- },
572
- {
573
- "from": "authenticated",
574
- "to": "authenticated",
575
- "event": "TOKEN_RECEIVED",
576
- "effects": [
577
- [
578
- "set",
579
- "@entity.accessToken",
580
- "@payload.accessToken"
581
- ],
582
- [
583
- "set",
584
- "@entity.refreshToken",
585
- "@payload.refreshToken"
586
- ],
587
- [
588
- "set",
589
- "@entity.authStatus",
590
- "authenticated"
591
478
  ],
592
479
  [
593
480
  "render-ui",
594
481
  "main",
595
482
  {
596
- "type": "stack",
597
- "children": [
598
- {
599
- "type": "icon",
600
- "name": "check-circle"
601
- },
602
- {
603
- "message": "Authenticated successfully",
604
- "variant": "success",
605
- "type": "alert"
606
- },
607
- {
608
- "direction": "horizontal",
609
- "type": "stack",
610
- "justify": "center",
611
- "children": [
612
- {
613
- "variant": "ghost",
614
- "action": "REFRESH",
615
- "type": "button",
616
- "icon": "refresh-cw",
617
- "label": "Refresh Token"
618
- },
619
- {
620
- "action": "LOGOUT",
621
- "type": "button",
622
- "variant": "ghost",
623
- "label": "Logout",
624
- "icon": "log-out"
625
- }
626
- ],
627
- "gap": "sm"
628
- }
629
- ],
630
- "direction": "vertical",
631
- "align": "center",
632
- "gap": "lg"
483
+ "message": "@entity.error",
484
+ "title": "Sign In Failed",
485
+ "onRetry": "RETRY",
486
+ "type": "error-state"
633
487
  }
634
488
  ]
635
489
  ]
636
490
  },
637
491
  {
638
492
  "from": "authenticated",
639
- "to": "refreshing",
640
- "event": "REFRESH",
641
- "effects": [
642
- [
643
- "render-ui",
644
- "main",
645
- {
646
- "message": "Obtaining a new access token.",
647
- "type": "loading-state",
648
- "title": "Refreshing token..."
649
- }
650
- ],
651
- [
652
- "call-service",
653
- "oauth",
654
- "refresh",
655
- {
656
- "refreshToken": "@entity.refreshToken"
657
- },
658
- {
659
- "emit": {
660
- "failure": "ServiceOauthOauthFailed",
661
- "success": "ServiceOauthOauthCompleted"
662
- }
663
- }
664
- ]
665
- ]
666
- },
667
- {
668
- "from": "authenticated",
669
- "to": "unauthenticated",
670
- "event": "LOGOUT",
493
+ "to": "idle",
494
+ "event": "RESET",
671
495
  "effects": [
672
496
  [
673
497
  "set",
@@ -678,146 +502,39 @@
678
502
  "render-ui",
679
503
  "main",
680
504
  {
681
- "gap": "lg",
682
- "align": "center",
683
- "type": "stack",
505
+ "gap": "md",
684
506
  "direction": "vertical",
507
+ "type": "stack",
685
508
  "children": [
686
- {
687
- "type": "stack",
688
- "children": [
689
- {
690
- "type": "icon",
691
- "name": "lock"
692
- },
693
- {
694
- "content": "Sign In",
695
- "variant": "h2",
696
- "type": "typography"
697
- }
698
- ],
699
- "direction": "horizontal",
700
- "gap": "md",
701
- "align": "center"
702
- },
703
- {
704
- "type": "divider"
705
- },
706
- {
707
- "options": [
708
- {
709
- "value": "google",
710
- "label": "Google"
711
- },
712
- {
713
- "value": "github",
714
- "label": "GitHub"
715
- },
716
- {
717
- "label": "Microsoft",
718
- "value": "microsoft"
719
- }
720
- ],
721
- "type": "select"
722
- },
723
- {
724
- "type": "button",
725
- "label": "Login",
726
- "variant": "primary",
727
- "action": "LOGIN",
728
- "icon": "log-in"
729
- }
509
+ "@config.uiTrait"
730
510
  ]
731
511
  }
732
512
  ]
733
513
  ]
734
514
  },
735
515
  {
736
- "from": "refreshing",
516
+ "from": "authenticated",
737
517
  "to": "authenticated",
738
- "event": "TOKEN_REFRESHED",
739
- "effects": [
740
- [
741
- "set",
742
- "@entity.accessToken",
743
- "@payload.accessToken"
744
- ],
745
- [
746
- "render-ui",
747
- "main",
748
- {
749
- "direction": "vertical",
750
- "children": [
751
- {
752
- "name": "check-circle",
753
- "type": "icon"
754
- },
755
- {
756
- "variant": "success",
757
- "message": "Authenticated successfully",
758
- "type": "alert"
759
- },
760
- {
761
- "justify": "center",
762
- "gap": "sm",
763
- "type": "stack",
764
- "children": [
765
- {
766
- "label": "Refresh Token",
767
- "type": "button",
768
- "action": "REFRESH",
769
- "variant": "ghost",
770
- "icon": "refresh-cw"
771
- },
772
- {
773
- "type": "button",
774
- "icon": "log-out",
775
- "action": "LOGOUT",
776
- "label": "Logout",
777
- "variant": "ghost"
778
- }
779
- ],
780
- "direction": "horizontal"
781
- }
782
- ],
783
- "type": "stack",
784
- "gap": "lg",
785
- "align": "center"
786
- }
787
- ]
788
- ]
518
+ "event": "OAuthLoggedIn"
789
519
  },
790
520
  {
791
- "from": "refreshing",
521
+ "from": "error",
792
522
  "to": "error",
793
- "event": "FAILED",
523
+ "event": "ServiceOauthOauthFailed"
524
+ },
525
+ {
526
+ "from": "error",
527
+ "to": "idle",
528
+ "event": "RETRY",
794
529
  "effects": [
795
- [
796
- "set",
797
- "@entity.error",
798
- "@payload.error"
799
- ],
800
530
  [
801
531
  "render-ui",
802
532
  "main",
803
533
  {
534
+ "gap": "md",
804
535
  "children": [
805
- {
806
- "type": "error-state",
807
- "message": "@entity.error",
808
- "title": "Authentication Failed",
809
- "onRetry": "RETRY"
810
- },
811
- {
812
- "action": "RETRY",
813
- "label": "Try Again",
814
- "variant": "primary",
815
- "type": "button",
816
- "icon": "rotate-ccw"
817
- }
536
+ "@config.uiTrait"
818
537
  ],
819
- "align": "center",
820
- "gap": "lg",
821
538
  "direction": "vertical",
822
539
  "type": "stack"
823
540
  }
@@ -826,69 +543,49 @@
826
543
  },
827
544
  {
828
545
  "from": "error",
829
- "to": "unauthenticated",
830
- "event": "RETRY",
546
+ "to": "idle",
547
+ "event": "RESET",
831
548
  "effects": [
832
549
  [
833
550
  "render-ui",
834
551
  "main",
835
552
  {
836
- "gap": "lg",
837
- "type": "stack",
838
553
  "direction": "vertical",
839
- "align": "center",
840
554
  "children": [
841
- {
842
- "children": [
843
- {
844
- "name": "lock",
845
- "type": "icon"
846
- },
847
- {
848
- "type": "typography",
849
- "content": "Sign In",
850
- "variant": "h2"
851
- }
852
- ],
853
- "direction": "horizontal",
854
- "gap": "md",
855
- "align": "center",
856
- "type": "stack"
857
- },
858
- {
859
- "type": "divider"
860
- },
861
- {
862
- "options": [
863
- {
864
- "label": "Google",
865
- "value": "google"
866
- },
867
- {
868
- "label": "GitHub",
869
- "value": "github"
870
- },
871
- {
872
- "value": "microsoft",
873
- "label": "Microsoft"
874
- }
875
- ],
876
- "type": "select"
877
- },
878
- {
879
- "type": "button",
880
- "icon": "log-in",
881
- "variant": "primary",
882
- "label": "Login",
883
- "action": "LOGIN"
884
- }
885
- ]
555
+ "@config.uiTrait"
556
+ ],
557
+ "type": "stack",
558
+ "gap": "md"
886
559
  }
887
560
  ]
888
561
  ]
889
562
  }
890
563
  ]
891
564
  },
565
+ "config": {
566
+ "uiTrait": {
567
+ "type": "trait",
568
+ "default": "@trait.ServiceOauthDefaultForm"
569
+ },
570
+ "redirectUri": {
571
+ "type": "string",
572
+ "default": ""
573
+ },
574
+ "scopes": {
575
+ "type": "[string]",
576
+ "default": []
577
+ },
578
+ "provider": {
579
+ "type": "string",
580
+ "default": "google",
581
+ "values": [
582
+ "google",
583
+ "github",
584
+ "microsoft",
585
+ "okta"
586
+ ]
587
+ }
588
+ },
892
589
  "scope": "instance"
893
590
  }
894
591
  ],