@things-factory/auth-ui 8.0.0 → 9.0.0-beta.3

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 (99) hide show
  1. package/dist-client/components/abstract-auth-page.js +10 -10
  2. package/dist-client/components/abstract-auth-page.js.map +1 -1
  3. package/dist-client/components/abstract-password-reset.d.ts +1 -2
  4. package/dist-client/components/abstract-password-reset.js +7 -14
  5. package/dist-client/components/abstract-password-reset.js.map +1 -1
  6. package/dist-client/components/abstract-sign.js +12 -11
  7. package/dist-client/components/abstract-sign.js.map +1 -1
  8. package/dist-client/components/contact-us.d.ts +1 -1
  9. package/dist-client/components/contact-us.js +10 -7
  10. package/dist-client/components/contact-us.js.map +1 -1
  11. package/dist-client/components/create-user.js +28 -5
  12. package/dist-client/components/create-user.js.map +1 -1
  13. package/dist-client/components/invite-user.js +19 -11
  14. package/dist-client/components/invite-user.js.map +1 -1
  15. package/dist-client/components/ownership-transfer-popup.js +3 -3
  16. package/dist-client/components/ownership-transfer-popup.js.map +1 -1
  17. package/dist-client/components/profile-component.d.ts +5 -1
  18. package/dist-client/components/profile-component.js +64 -4
  19. package/dist-client/components/profile-component.js.map +1 -1
  20. package/dist-client/components/role-privilege-editor.js +2 -1
  21. package/dist-client/components/role-privilege-editor.js.map +1 -1
  22. package/dist-client/components/user-role-editor.js +18 -18
  23. package/dist-client/components/user-role-editor.js.map +1 -1
  24. package/dist-client/entries/auth/checkin.js +1 -1
  25. package/dist-client/entries/auth/checkin.js.map +1 -1
  26. package/dist-client/entries/auth/forgot-password.js +11 -2
  27. package/dist-client/entries/auth/forgot-password.js.map +1 -1
  28. package/dist-client/entries/auth/signup.js +13 -7
  29. package/dist-client/entries/auth/signup.js.map +1 -1
  30. package/dist-client/index.js +1 -1
  31. package/dist-client/index.js.map +1 -1
  32. package/dist-client/pages/user/user-management.d.ts +5 -1
  33. package/dist-client/pages/user/user-management.js +6 -7
  34. package/dist-client/pages/user/user-management.js.map +1 -1
  35. package/dist-client/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +12 -12
  37. package/translations/en.json +6 -2
  38. package/translations/ja.json +6 -2
  39. package/translations/ko.json +6 -2
  40. package/translations/ms.json +6 -2
  41. package/translations/zh.json +6 -2
  42. package/client/auth-style-sign.ts +0 -194
  43. package/client/bootstrap.ts +0 -51
  44. package/client/components/abstract-auth-page.ts +0 -301
  45. package/client/components/abstract-password-reset.ts +0 -168
  46. package/client/components/abstract-sign.ts +0 -127
  47. package/client/components/change-password.ts +0 -153
  48. package/client/components/contact-us.ts +0 -113
  49. package/client/components/create-domain-popup.ts +0 -141
  50. package/client/components/create-role.ts +0 -123
  51. package/client/components/create-user.ts +0 -95
  52. package/client/components/credential-manager.ts +0 -64
  53. package/client/components/delete-user-popup.ts +0 -117
  54. package/client/components/domain-switch.ts +0 -127
  55. package/client/components/invite-customer.ts +0 -104
  56. package/client/components/invite-user.ts +0 -96
  57. package/client/components/my-login-history.ts +0 -101
  58. package/client/components/ownership-transfer-popup.ts +0 -110
  59. package/client/components/partner-info-card.ts +0 -89
  60. package/client/components/partner-role-editor.ts +0 -153
  61. package/client/components/profile-component.ts +0 -332
  62. package/client/components/role-edit-form.ts +0 -92
  63. package/client/components/role-privilege-editor.ts +0 -267
  64. package/client/components/role-selector.ts +0 -102
  65. package/client/components/user-role-editor.ts +0 -499
  66. package/client/constants/application.ts +0 -9
  67. package/client/constants/index.ts +0 -1
  68. package/client/entries/auth/activate.ts +0 -272
  69. package/client/entries/auth/checkin.ts +0 -190
  70. package/client/entries/auth/forgot-password.ts +0 -103
  71. package/client/entries/auth/reset-password.ts +0 -22
  72. package/client/entries/auth/result.ts +0 -193
  73. package/client/entries/auth/signin.ts +0 -18
  74. package/client/entries/auth/signup.ts +0 -109
  75. package/client/entries/auth/unlock-user.ts +0 -22
  76. package/client/entries/oauth2/oauth2-decision-error-page.ts +0 -50
  77. package/client/entries/oauth2/oauth2-decision-page.ts +0 -196
  78. package/client/entries/public/home.ts +0 -246
  79. package/client/index.ts +0 -124
  80. package/client/pages/app-binding/app-binding.ts +0 -423
  81. package/client/pages/app-binding/app-bindings.ts +0 -171
  82. package/client/pages/appliance/appliance.ts +0 -452
  83. package/client/pages/appliance/home.ts +0 -177
  84. package/client/pages/appliance/register.ts +0 -183
  85. package/client/pages/application/application.ts +0 -428
  86. package/client/pages/application/applications.ts +0 -182
  87. package/client/pages/application/register.ts +0 -211
  88. package/client/pages/attribute/attribute-set-item-list.ts +0 -237
  89. package/client/pages/attribute/attribute-set-management.ts +0 -282
  90. package/client/pages/auth-provider/auth-provider-management.ts +0 -381
  91. package/client/pages/domain/domain-management.ts +0 -410
  92. package/client/pages/partner/partner-management.ts +0 -112
  93. package/client/pages/profile.ts +0 -32
  94. package/client/pages/role/role-management.ts +0 -134
  95. package/client/pages/user/user-management.ts +0 -224
  96. package/client/route.ts +0 -67
  97. package/client/themes/auth-theme.css +0 -65
  98. package/client/utils/password-rule.ts +0 -37
  99. package/server/index.ts +0 -0
@@ -1,499 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@material/web/button/elevated-button.js'
3
-
4
- import './ownership-transfer-popup'
5
- import './role-selector'
6
-
7
- import gql from 'graphql-tag'
8
- import { css, html, LitElement } from 'lit'
9
- import { customElement, property, state } from 'lit/decorators.js'
10
- import { connect } from 'pwa-helpers/connect-mixin'
11
-
12
- import { client, gqlContext } from '@operato/graphql'
13
- import { i18next } from '@operato/i18n'
14
- import { openPopup } from '@operato/layout'
15
- import { store } from '@operato/shell'
16
- import { OxPrompt } from '@operato/popup/ox-prompt.js'
17
- import { ButtonContainerStyles } from '@operato/styles'
18
- import { RoleSelector } from './role-selector'
19
- import { InheritedValueType } from '@operato/data-grist'
20
-
21
- @customElement('user-role-editor')
22
- class UserRoleEditor extends connect(store)(LitElement) {
23
- static styles = [
24
- ButtonContainerStyles,
25
- css`
26
- :host {
27
- display: flex;
28
- flex-direction: column;
29
-
30
- border: 1px solid var(--md-sys-color-primary);
31
- font: normal 15px var(--theme-font);
32
- color: var(--md-sys-color-secondary);
33
- }
34
- ul {
35
- flex: 1;
36
- display: grid;
37
- grid-template-columns: 1fr 1fr;
38
- column-gap: 20px;
39
-
40
- overflow: auto;
41
- margin: 0;
42
- padding: var(--spacing-medium);
43
- list-style: none;
44
- border: 1px dashed rgba(0, 0, 0, 0.1);
45
- border-width: 1px 0;
46
- }
47
- input[readonly] {
48
- border: none;
49
- background-color: transparent;
50
- color: var(--md-sys-color-secondary);
51
- font: var(--input-font);
52
- }
53
- li {
54
- padding: var(--spacing-small);
55
- }
56
- [detail] {
57
- background-color: var(--md-sys-color-surface);
58
- }
59
- [detail] md-icon {
60
- --md-icon-size: var(--fontsize-default);
61
- vertical-align: middle;
62
- color: var(--md-sys-color-primary);
63
- }
64
- [detail] li {
65
- display: flex;
66
- }
67
- [detail] li input {
68
- flex: 1;
69
- }
70
-
71
- md-elevated-button {
72
- margin: 5px;
73
- }
74
-
75
- md-outlined-button {
76
- background-color: var(--md-sys-color-surface-variant);
77
- }
78
-
79
- @media screen and (max-width: 480px) {
80
- ul {
81
- grid-template-columns: 1fr;
82
- }
83
- }
84
- `
85
- ]
86
-
87
- @property({ type: Object }) user: any = {}
88
- @property({ type: Boolean }) activate: boolean = false
89
- @property({ type: Object }) domainOwner: any
90
-
91
- @state() domainRoles: any[] = []
92
- @state() grantedRoles: any = {}
93
- @state() userRoles: any[] = []
94
- @state() isSuperOwner: boolean = false
95
- @state() isDomainOwner: boolean = false
96
-
97
- private me: any
98
-
99
- render() {
100
- const user = this.user || {}
101
- const domainRoles = this.domainRoles || []
102
- const grantedRoles = this.grantedRoles || {}
103
- let currentDomainName = 'roles'
104
- if (domainRoles?.length) {
105
- currentDomainName = domainRoles[0].domain.name
106
- }
107
-
108
- return html`
109
- ${this.activate
110
- ? html`
111
- <ul detail>
112
- ${user.userType === 'user'
113
- ? html`
114
- <li>
115
- <span>
116
- <md-icon>email</md-icon>
117
- ${user.email}
118
- </span>
119
- </li>
120
- `
121
- : ''}
122
- </ul>
123
-
124
- <role-selector .user=${this.user} .roles=${domainRoles} .userRoles=${this.userRoles}></role-selector>
125
-
126
- ${Object.keys(grantedRoles).map(
127
- partnerName => html`
128
- <role-selector
129
- .roleCategory=${partnerName}
130
- .user=${this.user}
131
- .roles=${this.grantedRoles[partnerName]}
132
- .userRoles=${this.userRoles}
133
- >
134
- </role-selector>
135
- `
136
- )}
137
- `
138
- : ''}
139
-
140
- <div class="button-container">
141
- ${this.isRoleEditable()
142
- ? html` <md-elevated-button
143
- @click=${() => {
144
- const { availableRoles, selectedRoles } = Array.from(
145
- this.renderRoot.querySelectorAll('role-selector') as NodeListOf<RoleSelector>
146
- ).reduce(
147
- (roles, roleSelector) => {
148
- roles.availableRoles = roles.availableRoles.concat(
149
- roleSelector.roles.map(r => {
150
- delete r.domain
151
- return r
152
- })
153
- )
154
- roles.selectedRoles = roles.selectedRoles.concat(
155
- roleSelector.selectedRoles().map(r => {
156
- //@ts-ignore
157
- delete r.domain
158
- return r
159
- })
160
- )
161
- return roles
162
- },
163
- { availableRoles: [], selectedRoles: [] } as { availableRoles: any[]; selectedRoles: any[] }
164
- )
165
- this.onSave(user, availableRoles, selectedRoles)
166
- }}
167
- >${String(i18next.t('button.save'))}</md-elevated-button
168
- >`
169
- : ''}
170
- ${user.userType === 'user'
171
- ? html`
172
- ${this.isTransferable(user) && this.userRoles && this.userRoles.length > 0
173
- ? html`
174
- <md-elevated-button danger @click=${() => this.onTransfer(user)}
175
- >${String(i18next.t('button.transfer owner'))}</md-elevated-button
176
- >
177
- `
178
- : ''}
179
- ${this.isPasswordResettable(user)
180
- ? html`<md-elevated-button danger @click=${() => this.onResetPassword(user)}
181
- >${String(i18next.t('title.reset password'))}</md-elevated-button
182
- >`
183
- : ''}
184
- `
185
- : ''}
186
- ${this.isRemovable(user)
187
- ? html`
188
- <md-elevated-button danger @click=${() => this.onDelete(user)}
189
- >${String(i18next.t('button.delete user'))}</md-elevated-button
190
- >
191
- `
192
- : ''}
193
- ${this.isActivatable(user)
194
- ? html`<md-elevated-button danger @click=${() => this.onActivate(user)}
195
- >${String(i18next.t('button.activate'))}</md-elevated-button
196
- >`
197
- : ''}
198
- ${this.isInactivatable(user)
199
- ? html`<md-elevated-button danger @click=${() => this.onInactivate(user)}
200
- >${String(i18next.t('button.deactivate'))}</md-elevated-button
201
- >`
202
- : ''}
203
- </div>
204
- `
205
- }
206
-
207
- isRemovable(user) {
208
- return this.isDomainOwner && user.email !== this.me.email && !user.owner
209
- }
210
-
211
- isTransferable(user) {
212
- return this.activate && (this.isSuperOwner || this.isDomainOwner) && !user.owner
213
- }
214
-
215
- isRoleEditable() {
216
- return this.activate && (this.domainRoles?.length || Object.keys(this.grantedRoles || {}).length)
217
- }
218
-
219
- isPasswordResettable(user) {
220
- return (this.isSuperOwner || this.isDomainOwner) && user.email !== this.me.email
221
- }
222
-
223
- isActivatable(user) {
224
- return (this.isSuperOwner || this.isDomainOwner) && !this.activate
225
- }
226
-
227
- isInactivatable(user) {
228
- return (
229
- (this.isSuperOwner || this.isDomainOwner) &&
230
- user.id !== this.domainOwner.id &&
231
- user.userType !== 'admin' &&
232
- this.activate
233
- )
234
- }
235
-
236
- async updated(changedProps) {
237
- if (changedProps.has('user')) {
238
- this.fetchAvailableRoles()
239
-
240
- if (this.user?.email) {
241
- this.userRoles = await this.fetchRolesOnUser(this.user.email)
242
- } else {
243
- this.userRoles = []
244
- }
245
- }
246
- }
247
-
248
- async fetchRolesOnUser(email) {
249
- const response = await client.query({
250
- query: gql`
251
- query ($email: EmailAddress!) {
252
- user(email: $email) {
253
- id
254
- name
255
- email
256
- roles {
257
- id
258
- name
259
- description
260
- domain {
261
- id
262
- }
263
- }
264
- }
265
- }
266
- `,
267
- variables: { email },
268
- context: gqlContext()
269
- })
270
-
271
- if (!response.errors) {
272
- return response.data.user?.roles || []
273
- }
274
- }
275
-
276
- async fetchAvailableRoles() {
277
- const response = await client.query({
278
- query: gql`
279
- query roles($inherited: InheritedValueType) {
280
- roles(inherited: $inherited) {
281
- items {
282
- id
283
- domain {
284
- name
285
- }
286
- name
287
- description
288
- }
289
- total
290
- }
291
- grantedRoles {
292
- id
293
- role {
294
- id
295
- name
296
- description
297
- domain {
298
- name
299
- }
300
- }
301
- }
302
- }
303
- `,
304
- variables: {
305
- inherited: InheritedValueType.Include
306
- },
307
- context: gqlContext()
308
- })
309
-
310
- if (!response.errors?.length) {
311
- this.domainRoles = response.data.roles.items || []
312
- this.grantedRoles = response.data.grantedRoles.reduce((grantedRoles, grantedRole) => {
313
- const { role } = grantedRole
314
- const { domain } = role
315
- if (grantedRoles[domain.name]) {
316
- grantedRoles[domain.name].push(role)
317
- } else {
318
- grantedRoles[domain.name] = [role]
319
- }
320
-
321
- return grantedRoles
322
- }, {})
323
- } else {
324
- this.domainRoles = []
325
- this.grantedRoles = []
326
- }
327
- }
328
-
329
- async onSave(user, availableRoles, selectedRoles) {
330
- if (user?.id) {
331
- const response = await client.mutate({
332
- mutation: gql`
333
- mutation ($userId: String!, $availableRoles: [ObjectRef!]!, $selectedRoles: [ObjectRef!]!) {
334
- updateUserRoles(userId: $userId, availableRoles: $availableRoles, selectedRoles: $selectedRoles) {
335
- id
336
- name
337
- roles {
338
- id
339
- description
340
- }
341
- }
342
- }
343
- `,
344
- variables: { userId: user.id, availableRoles, selectedRoles },
345
- context: gqlContext()
346
- })
347
-
348
- if (!response.errors) {
349
- this.showToast(i18next.t('text.data_updated_successfully'))
350
- this.dispatchUserUpdated()
351
- }
352
- }
353
- }
354
-
355
- async onActivate(user) {
356
- const response = await client.mutate({
357
- mutation: gql`
358
- mutation activateUser($userId: String!) {
359
- activateUser(userId: $userId)
360
- }
361
- `,
362
- variables: { userId: user.id },
363
- context: gqlContext()
364
- })
365
-
366
- if (!response.errors) {
367
- this.showToast(i18next.t('text.user activated successfully'))
368
-
369
- this.dispatchUserUpdated()
370
- }
371
- }
372
-
373
- async onInactivate(user) {
374
- const response = await client.mutate({
375
- mutation: gql`
376
- mutation inactivateUser($userId: String!) {
377
- inactivateUser(userId: $userId)
378
- }
379
- `,
380
- variables: { userId: user.id },
381
- context: gqlContext()
382
- })
383
-
384
- if (!response.errors) {
385
- this.showToast(i18next.t('text.user activated successfully'))
386
-
387
- this.dispatchUserUpdated()
388
- }
389
- }
390
-
391
- async onDelete(user) {
392
- if (user.owner) {
393
- await OxPrompt.open({
394
- type: 'warning',
395
- title: i18next.t('text.cannot_delete'),
396
- text: i18next.t('text.x_cannot_delete', {
397
- x: i18next.t('label.domain-owner')
398
- }),
399
- confirmButton: { text: i18next.t('button.confirm') }
400
- })
401
-
402
- return
403
- }
404
-
405
- if (
406
- await OxPrompt.open({
407
- title: i18next.t('text.are_you_sure'),
408
- text: i18next.t('text.are_you_sure_to_x_user', {
409
- x: i18next.t('button.delete')
410
- }),
411
- confirmButton: { text: i18next.t('button.delete') },
412
- cancelButton: { text: i18next.t('button.cancel') }
413
- })
414
- ) {
415
- const response = await client.mutate({
416
- mutation: gql`
417
- mutation deleteDomaineUser($email: EmailAddress!) {
418
- deleteDomainUser(email: $email)
419
- }
420
- `,
421
- variables: { email: user.email },
422
- context: gqlContext()
423
- })
424
-
425
- if (!response.errors) {
426
- await OxPrompt.open({
427
- type: 'success',
428
- title: i18next.t('text.completed'),
429
- confirmButton: { text: i18next.t('button.confirm') }
430
- })
431
-
432
- this.dispatchUserUpdated()
433
- }
434
- }
435
- }
436
-
437
- async onTransfer(user) {
438
- openPopup(
439
- html`
440
- <ownership-transfer-popup
441
- .user=${user}
442
- @ownershipTransferred="${this.dispatchOwnershipTransferred.bind(this)}"
443
- ></ownership-transfer-popup>
444
- `,
445
- {
446
- size: 'small',
447
- title: `${i18next.t('title.owner_transfer')}`
448
- }
449
- )
450
- }
451
-
452
- async onResetPassword(user) {
453
- if (
454
- await OxPrompt.open({
455
- title: i18next.t('text.are_you_sure'),
456
- text: i18next.t('text.are_you_sure_to_x', { x: i18next.t('title.reset password') }),
457
- confirmButton: { text: i18next.t('button.confirm') },
458
- cancelButton: { text: i18next.t('button.cancel') }
459
- })
460
- ) {
461
- const response = await client.mutate({
462
- mutation: gql`
463
- mutation resetPasswordToDefault($userId: String!) {
464
- resetPasswordToDefault(userId: $userId)
465
- }
466
- `,
467
- variables: { userId: user.id },
468
- context: gqlContext()
469
- })
470
-
471
- if (!response.errors) {
472
- await OxPrompt.open({
473
- type: 'success',
474
- title: i18next.t('text.completed'),
475
- text: i18next.t('text.password reset succeed'),
476
- confirmButton: { text: i18next.t('button.confirm') }
477
- })
478
- }
479
- }
480
- }
481
-
482
- dispatchUserUpdated() {
483
- this.dispatchEvent(new CustomEvent('userUpdated'))
484
- }
485
-
486
- dispatchOwnershipTransferred() {
487
- this.dispatchEvent(new CustomEvent('ownershipTransferred'))
488
- }
489
-
490
- showToast(message) {
491
- document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
492
- }
493
-
494
- stateChanged(state) {
495
- this.me = state.auth?.user || {}
496
- this.isSuperOwner = this.me.super || false
497
- this.isDomainOwner = this.me.email === this.domainOwner.email || false
498
- }
499
- }
@@ -1,9 +0,0 @@
1
- export const APPLICATION_TYPE = {
2
- SELLERCRAFT: 'SELLERCRAFT',
3
- XILNEX: 'XILNEX',
4
- MMS: 'MMS',
5
- XERO: 'XERO',
6
- OTHERS: 'OTHERS'
7
- }
8
-
9
- export const APPLICATION_TYPES = ['SELLERCRAFT', 'XILNEX', 'MMS', 'XERO', 'OTHERS']
@@ -1 +0,0 @@
1
- export * from './application'