@things-factory/auth-ui 8.0.5 → 9.0.0-beta.12

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 (146) hide show
  1. package/dist-client/components/abstract-auth-page.d.ts +1 -1
  2. package/dist-client/components/abstract-auth-page.js +12 -10
  3. package/dist-client/components/abstract-auth-page.js.map +1 -1
  4. package/dist-client/components/abstract-password-reset.d.ts +2 -3
  5. package/dist-client/components/abstract-password-reset.js +10 -17
  6. package/dist-client/components/abstract-password-reset.js.map +1 -1
  7. package/dist-client/components/abstract-sign.js +12 -11
  8. package/dist-client/components/abstract-sign.js.map +1 -1
  9. package/dist-client/components/change-password.js +1 -1
  10. package/dist-client/components/change-password.js.map +1 -1
  11. package/dist-client/components/contact-us.d.ts +1 -1
  12. package/dist-client/components/contact-us.js +10 -7
  13. package/dist-client/components/contact-us.js.map +1 -1
  14. package/dist-client/components/create-user.js +28 -5
  15. package/dist-client/components/create-user.js.map +1 -1
  16. package/dist-client/components/invite-user.d.ts +1 -1
  17. package/dist-client/components/invite-user.js +19 -12
  18. package/dist-client/components/invite-user.js.map +1 -1
  19. package/dist-client/components/ownership-transfer-popup.js +3 -3
  20. package/dist-client/components/ownership-transfer-popup.js.map +1 -1
  21. package/dist-client/components/partner-role-editor.js +1 -1
  22. package/dist-client/components/partner-role-editor.js.map +1 -1
  23. package/dist-client/components/profile-component.d.ts +8 -4
  24. package/dist-client/components/profile-component.js +67 -7
  25. package/dist-client/components/profile-component.js.map +1 -1
  26. package/dist-client/components/role-privilege-editor.js +2 -1
  27. package/dist-client/components/role-privilege-editor.js.map +1 -1
  28. package/dist-client/components/user-role-editor.d.ts +2 -2
  29. package/dist-client/components/user-role-editor.js +20 -20
  30. package/dist-client/components/user-role-editor.js.map +1 -1
  31. package/dist-client/constants/index.d.ts +1 -1
  32. package/dist-client/constants/index.js +1 -1
  33. package/dist-client/constants/index.js.map +1 -1
  34. package/dist-client/entries/auth/activate.d.ts +1 -1
  35. package/dist-client/entries/auth/activate.js +1 -1
  36. package/dist-client/entries/auth/activate.js.map +1 -1
  37. package/dist-client/entries/auth/checkin.js +2 -2
  38. package/dist-client/entries/auth/checkin.js.map +1 -1
  39. package/dist-client/entries/auth/forgot-password.d.ts +2 -2
  40. package/dist-client/entries/auth/forgot-password.js +13 -4
  41. package/dist-client/entries/auth/forgot-password.js.map +1 -1
  42. package/dist-client/entries/auth/reset-password.d.ts +1 -1
  43. package/dist-client/entries/auth/reset-password.js +1 -1
  44. package/dist-client/entries/auth/reset-password.js.map +1 -1
  45. package/dist-client/entries/auth/result.d.ts +1 -1
  46. package/dist-client/entries/auth/result.js +1 -1
  47. package/dist-client/entries/auth/result.js.map +1 -1
  48. package/dist-client/entries/auth/signin.d.ts +1 -1
  49. package/dist-client/entries/auth/signin.js +1 -1
  50. package/dist-client/entries/auth/signin.js.map +1 -1
  51. package/dist-client/entries/auth/signup.d.ts +3 -1
  52. package/dist-client/entries/auth/signup.js +45 -9
  53. package/dist-client/entries/auth/signup.js.map +1 -1
  54. package/dist-client/entries/auth/unlock-user.d.ts +1 -1
  55. package/dist-client/entries/auth/unlock-user.js +1 -1
  56. package/dist-client/entries/auth/unlock-user.js.map +1 -1
  57. package/dist-client/entries/oauth2/oauth2-decision-page.d.ts +1 -1
  58. package/dist-client/entries/oauth2/oauth2-decision-page.js +1 -1
  59. package/dist-client/entries/oauth2/oauth2-decision-page.js.map +1 -1
  60. package/dist-client/entries/public/home.js +2 -2
  61. package/dist-client/entries/public/home.js.map +1 -1
  62. package/dist-client/index.js +1 -1
  63. package/dist-client/index.js.map +1 -1
  64. package/dist-client/pages/application/application.js +1 -1
  65. package/dist-client/pages/application/application.js.map +1 -1
  66. package/dist-client/pages/domain/domain-management.d.ts +1 -1
  67. package/dist-client/pages/domain/domain-management.js +1 -1
  68. package/dist-client/pages/domain/domain-management.js.map +1 -1
  69. package/dist-client/pages/partner/partner-management.d.ts +3 -3
  70. package/dist-client/pages/partner/partner-management.js +3 -3
  71. package/dist-client/pages/partner/partner-management.js.map +1 -1
  72. package/dist-client/pages/profile.d.ts +1 -1
  73. package/dist-client/pages/profile.js +1 -1
  74. package/dist-client/pages/profile.js.map +1 -1
  75. package/dist-client/pages/role/role-management.d.ts +3 -3
  76. package/dist-client/pages/role/role-management.js +3 -3
  77. package/dist-client/pages/role/role-management.js.map +1 -1
  78. package/dist-client/pages/user/user-management.d.ts +9 -5
  79. package/dist-client/pages/user/user-management.js +10 -11
  80. package/dist-client/pages/user/user-management.js.map +1 -1
  81. package/dist-client/tsconfig.tsbuildinfo +1 -1
  82. package/dist-server/tsconfig.tsbuildinfo +1 -1
  83. package/package.json +12 -12
  84. package/translations/en.json +6 -2
  85. package/translations/ja.json +6 -2
  86. package/translations/ko.json +6 -2
  87. package/translations/ms.json +6 -2
  88. package/translations/zh.json +6 -2
  89. package/client/auth-style-sign.ts +0 -194
  90. package/client/bootstrap.ts +0 -51
  91. package/client/components/abstract-auth-page.ts +0 -301
  92. package/client/components/abstract-password-reset.ts +0 -168
  93. package/client/components/abstract-sign.ts +0 -127
  94. package/client/components/change-password.ts +0 -153
  95. package/client/components/contact-us.ts +0 -113
  96. package/client/components/create-domain-popup.ts +0 -141
  97. package/client/components/create-role.ts +0 -123
  98. package/client/components/create-user.ts +0 -95
  99. package/client/components/credential-manager.ts +0 -64
  100. package/client/components/delete-user-popup.ts +0 -117
  101. package/client/components/domain-switch.ts +0 -127
  102. package/client/components/invite-customer.ts +0 -104
  103. package/client/components/invite-user.ts +0 -96
  104. package/client/components/my-login-history.ts +0 -101
  105. package/client/components/ownership-transfer-popup.ts +0 -110
  106. package/client/components/partner-info-card.ts +0 -89
  107. package/client/components/partner-role-editor.ts +0 -153
  108. package/client/components/profile-component.ts +0 -332
  109. package/client/components/role-edit-form.ts +0 -92
  110. package/client/components/role-privilege-editor.ts +0 -267
  111. package/client/components/role-selector.ts +0 -102
  112. package/client/components/user-role-editor.ts +0 -499
  113. package/client/constants/application.ts +0 -9
  114. package/client/constants/index.ts +0 -1
  115. package/client/entries/auth/activate.ts +0 -272
  116. package/client/entries/auth/checkin.ts +0 -190
  117. package/client/entries/auth/forgot-password.ts +0 -103
  118. package/client/entries/auth/reset-password.ts +0 -22
  119. package/client/entries/auth/result.ts +0 -193
  120. package/client/entries/auth/signin.ts +0 -18
  121. package/client/entries/auth/signup.ts +0 -109
  122. package/client/entries/auth/unlock-user.ts +0 -22
  123. package/client/entries/oauth2/oauth2-decision-error-page.ts +0 -50
  124. package/client/entries/oauth2/oauth2-decision-page.ts +0 -196
  125. package/client/entries/public/home.ts +0 -246
  126. package/client/index.ts +0 -124
  127. package/client/pages/app-binding/app-binding.ts +0 -423
  128. package/client/pages/app-binding/app-bindings.ts +0 -171
  129. package/client/pages/appliance/appliance.ts +0 -452
  130. package/client/pages/appliance/home.ts +0 -177
  131. package/client/pages/appliance/register.ts +0 -183
  132. package/client/pages/application/application.ts +0 -428
  133. package/client/pages/application/applications.ts +0 -182
  134. package/client/pages/application/register.ts +0 -211
  135. package/client/pages/attribute/attribute-set-item-list.ts +0 -237
  136. package/client/pages/attribute/attribute-set-management.ts +0 -282
  137. package/client/pages/auth-provider/auth-provider-management.ts +0 -381
  138. package/client/pages/domain/domain-management.ts +0 -410
  139. package/client/pages/partner/partner-management.ts +0 -112
  140. package/client/pages/profile.ts +0 -32
  141. package/client/pages/role/role-management.ts +0 -134
  142. package/client/pages/user/user-management.ts +0 -224
  143. package/client/route.ts +0 -67
  144. package/client/themes/auth-theme.css +0 -65
  145. package/client/utils/password-rule.ts +0 -37
  146. package/server/index.ts +0 -0
@@ -1,89 +0,0 @@
1
- import { css, html, LitElement } from 'lit'
2
- import { customElement, property } from 'lit/decorators.js'
3
-
4
- import { i18next } from '@operato/i18n'
5
-
6
- @customElement('partner-info-card')
7
- export class PartnerInfoCard extends LitElement {
8
- static styles = [
9
- css`
10
- input {
11
- border: var(--border-dim-color);
12
- border-radius: var(--border-radius);
13
- margin: var(--input-margin);
14
- padding: var(--input-padding);
15
- background-color: transparent;
16
- font: var(--input-font);
17
-
18
- flex: 1;
19
- }
20
- #vendors {
21
- display: flex;
22
- max-height: 45vh;
23
- flex-direction: row;
24
- background-color: var(--md-sys-color-surface-variant);
25
- margin: 0;
26
- padding: 0;
27
- border-radius: var(--border-radius);
28
- box-shadow: var(--box-shadow);
29
- overflow: hidden;
30
- }
31
- [field-2column] {
32
- overflow: auto;
33
- flex: 1;
34
- background-color: var(--md-sys-color-surface-variant);
35
- padding: var(--spacing-medium);
36
- border-radius: var(--border-radius);
37
- display: grid;
38
- grid-template-columns: 1fr 1fr;
39
- gap: 5px 15px;
40
- clear: both;
41
- max-width: var(--input-container-max-width);
42
- }
43
- [field] {
44
- display: flex;
45
- flex-direction: column;
46
- padding-bottom: var(--spacing-medium);
47
- }
48
- label {
49
- display: flex;
50
- flex-direction: column;
51
-
52
- font: var(--label-font);
53
- color: var(--label-color, var(--md-sys-color-on-surface));
54
- text-transform: var(--label-text-transform);
55
- }
56
- @media screen and (max-width: 480px) {
57
- [field] {
58
- grid-column: span 2;
59
- }
60
- }
61
- `
62
- ]
63
-
64
- @property({ type: Object }) partner: any
65
-
66
- render() {
67
- const partner = this.partner || {}
68
-
69
- return html`
70
- <div id="vendors">
71
- <div field-2column>
72
- <div field>
73
- <label
74
- >${i18next.t('label.name')}
75
- <input type="text" name="name" readonly .value=${partner.name || ''} />
76
- </label>
77
- </div>
78
-
79
- <div field>
80
- <label
81
- >${i18next.t('label.description')}
82
- <input type="text" name="description" readonly .value=${partner.description || ''} />
83
- </label>
84
- </div>
85
- </div>
86
- </div>
87
- `
88
- }
89
- }
@@ -1,153 +0,0 @@
1
- import '@material/web/button/elevated-button.js'
2
- import './role-selector.js'
3
-
4
- import gql from 'graphql-tag'
5
- import { css, html, LitElement } from 'lit'
6
- import { customElement, property, query } from 'lit/decorators.js'
7
-
8
- import { client, gqlContext } from '@operato/graphql'
9
- import { i18next, localize } from '@operato/i18n'
10
- import { OxPrompt } from '@operato/popup/ox-prompt.js'
11
- import { ButtonContainerStyles } from '@operato/styles'
12
-
13
- import { RoleSelector } from './role-selector'
14
-
15
- @customElement('partner-role-editor')
16
- class PartnerRoleEditor extends localize(i18next)(LitElement) {
17
- static styles = [
18
- ButtonContainerStyles,
19
- css`
20
- :host {
21
- display: flex;
22
- flex-direction: column;
23
-
24
- border: 1px solid var(--md-sys-color-primary);
25
- padding: var(--spacing-medium);
26
- font: normal 15px var(--theme-font);
27
- color: var(--md-sys-color-secondary);
28
- }
29
-
30
- md-elevated-button {
31
- margin-right: var(--spacing-small);
32
- }
33
- `
34
- ]
35
-
36
- @property({ type: Object }) customer: any
37
- @property({ type: Array }) roles: any[] = []
38
- @property({ type: Array }) grantingRoles: any[] = []
39
-
40
- @query('role-selector') roleSelector!: RoleSelector
41
-
42
- render() {
43
- const roles = this.roles || []
44
- const grantingRoles = this.grantingRoles || []
45
-
46
- return html`
47
- <role-selector .roles="${roles}" .userRoles="${grantingRoles}"></role-selector>
48
-
49
- <div class="button-container">
50
- <md-elevated-button @click=${this.onSave}>${i18next.t('button.save')}</md-elevated-button>
51
- <md-elevated-button @click=${this.onTerminateContract} danger
52
- >${i18next.t('button.terminate contract')}</md-elevated-button
53
- >
54
- </div>
55
- `
56
- }
57
-
58
- updated(changes) {
59
- if (changes.has('customer')) {
60
- this.refreshRoles()
61
- }
62
- }
63
-
64
- async refreshRoles() {
65
- const response = await client.query({
66
- query: gql`
67
- query roles($customerId: String!) {
68
- roles {
69
- items {
70
- id
71
- name
72
- description
73
- }
74
- total
75
- }
76
- grantingRoles(customerId: $customerId) {
77
- id
78
- role {
79
- id
80
- name
81
- description
82
- }
83
- }
84
- }
85
- `,
86
- variables: { customerId: this.customer.id },
87
- context: gqlContext()
88
- })
89
-
90
- if (!response.errors?.length) {
91
- this.roles = response.data.roles.items
92
- this.grantingRoles = response.data.grantingRoles.map(grantingRole => grantingRole.role)
93
- } else {
94
- this.roles = []
95
- this.grantingRoles = []
96
- }
97
- }
98
-
99
- async onSave() {
100
- const roles = this.roleSelector.selectedRoles()
101
-
102
- const response = await client.mutate({
103
- mutation: gql`
104
- mutation grantRoles($customerId: String!, $roles: [RolePatch!]!) {
105
- grantRoles(customerId: $customerId, roles: $roles)
106
- }
107
- `,
108
- variables: { customerId: this.customer.id, roles },
109
- context: gqlContext()
110
- })
111
-
112
- if (!response.errors?.length) {
113
- this.showToast(i18next.t('text.data_updated_successfully'))
114
- }
115
- }
116
-
117
- async onTerminateContract() {
118
- if (
119
- await OxPrompt.open({
120
- title: i18next.t('text.are_you_sure'),
121
- text: i18next.t('text.are_you_sure_to_terminate_contract'),
122
- confirmButton: { text: i18next.t('button.terminate contract') },
123
- cancelButton: { text: i18next.t('button.cancel') }
124
- })
125
- ) {
126
- const response = await client.mutate({
127
- mutation: gql`
128
- mutation terminateContract($partnerName: String!) {
129
- terminateContract(partnerName: $partnerName)
130
- }
131
- `,
132
- variables: { partnerName: this.customer.name },
133
- context: gqlContext()
134
- })
135
-
136
- if (!response.errors?.length) {
137
- const answer = this.dispatchEvent(new CustomEvent('contractTerminated'))
138
-
139
- if (answer) {
140
- await OxPrompt.open({
141
- type: 'success',
142
- title: i18next.t('text.completed'),
143
- confirmButton: { text: i18next.t('button.confirm') }
144
- })
145
- }
146
- }
147
- }
148
- }
149
-
150
- showToast(message) {
151
- document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
152
- }
153
- }
@@ -1,332 +0,0 @@
1
- import '@operato/i18n/ox-i18n.js'
2
- import '@operato/i18n/ox-i18n-selector.js'
3
- import './change-password'
4
- import './delete-user-popup'
5
- import './my-login-history'
6
-
7
- import { gql } from 'graphql-tag'
8
- import { css, html, LitElement, nothing } from 'lit'
9
- import { customElement, property, query, state } from 'lit/decorators.js'
10
- import { startRegistration } from '@simplewebauthn/browser'
11
-
12
- import { client } from '@operato/graphql'
13
- import { i18next, localize } from '@operato/i18n'
14
- import { notify, openPopup } from '@operato/layout'
15
- import { auth, getLanguages } from '@things-factory/auth-base/dist-client'
16
-
17
- const isAvailableWebauthn = 'PublicKeyCredential' in window
18
- @customElement('profile-component')
19
- export class ProfileComponent extends localize(i18next)(LitElement) {
20
- static styles = [
21
- css`
22
- :host {
23
- display: block;
24
- background-color: var(--md-sys-color-background);
25
- padding: 15px 0;
26
- }
27
- .wrap {
28
- max-width: var(--profile-wrap-max-width, 400px);
29
- margin: auto;
30
- display: grid;
31
- grid-template-columns: 1fr 1fr;
32
- }
33
-
34
- * {
35
- box-sizing: border-box;
36
- }
37
-
38
- *:focus {
39
- outline: none;
40
- }
41
-
42
- input {
43
- margin: var(--spacing-small) 0;
44
- border: 1px solid rgba(0, 0, 0, 0.2);
45
- padding: 9px;
46
- border-radius: var(--border-radius);
47
- font: var(--auth-input-field-font);
48
- width: var(--auth-input-field-width);
49
- }
50
- input:focus {
51
- border: 1px solid var(--focus-background-color);
52
- }
53
-
54
- .user {
55
- background: url(/assets/images/icon-profile.png) center top no-repeat;
56
- margin: var(--profile-icon-margin);
57
- padding: 180px 20px 20px 20px;
58
- color: var(--md-sys-color-secondary);
59
- font: var(--header-bar-title);
60
- text-align: center;
61
- }
62
-
63
- hr {
64
- width: 100%;
65
- border: dotted 1px rgba(0, 0, 0, 0.1);
66
- }
67
-
68
- .wrap * {
69
- grid-column: span 2;
70
- }
71
-
72
- label {
73
- font: bold 14px var(--theme-font);
74
- color: var(--md-sys-color-primary);
75
- text-transform: capitalize;
76
- grid-column: 1;
77
- }
78
-
79
- .wrap *.inline {
80
- grid-column: unset;
81
- }
82
-
83
- ox-i18n-selector {
84
- --i18n-selector-field-width: var(--auth-input-field-width);
85
- --i18n-selector-field-margin: var(--change-password-field-margin);
86
- --i18n-selector-field-padding: var(--spacing-medium);
87
- --i18n-selector-field-border-radius: var(--border-radius);
88
- margin: var(--change-password-field-margin);
89
- }
90
-
91
- md-text-button {
92
- text-transform: capitalize;
93
- }
94
-
95
- footer {
96
- padding: 20px;
97
- text-align: center;
98
- }
99
-
100
- footer p {
101
- font-size: 14px;
102
- margin-bottom: 5px;
103
- color: var(--md-sys-color-on-background);
104
- }
105
-
106
- footer a {
107
- color: var(--md-sys-color-primary);
108
- text-decoration: none;
109
- font-weight: bold;
110
- }
111
- `
112
- ]
113
-
114
- @property({ type: String }) userId?: string
115
- @property({ type: String }) email?: string
116
- @property({ type: String }) name?: string
117
-
118
- @state() languages: { code: string; display: string }[] = []
119
- @state() passwordRule: {
120
- lowerCase?: boolean
121
- upperCase?: boolean
122
- digit?: boolean
123
- specialCharacter?: boolean
124
- allowRepeat?: boolean
125
- useTightPattern?: boolean
126
- useLoosePattern?: boolean
127
- tightCharacterLength?: number
128
- looseCharacterLength?: number
129
- } = {}
130
-
131
- @query('#name') nameEl!: HTMLInputElement
132
- @query('#locale') localeEl!: HTMLInputElement
133
-
134
- async connectedCallback(): Promise<void> {
135
- super.connectedCallback()
136
-
137
- const response = await client.query({
138
- query: gql`
139
- query {
140
- passwordRule {
141
- lowerCase
142
- upperCase
143
- digit
144
- specialCharacter
145
- allowRepeat
146
- useTightPattern
147
- useLoosePattern
148
- tightCharacterLength
149
- looseCharacterLength
150
- }
151
- }
152
- `
153
- })
154
-
155
- this.passwordRule = response.data
156
- }
157
-
158
- async firstUpdated() {
159
- auth.on('profile', ({ credential }) => {
160
- this.setCredential(credential)
161
- })
162
-
163
- this.setCredential(auth.credential)
164
-
165
- this.languages = await getLanguages()
166
- }
167
-
168
- setCredential(credential) {
169
- if (credential) {
170
- this.userId = credential.id
171
- this.name = credential.name
172
- this.email = credential.email
173
- } else {
174
- this.userId = ''
175
- this.name = ''
176
- this.email = ''
177
- }
178
- }
179
-
180
- render() {
181
- return html`
182
- <div class="wrap">
183
- <div class="user">${this.email || ''}</div>
184
-
185
- <label for="name"><ox-i18n slot="title" msgid="label.name"></ox-i18n></label>
186
- <input id="name" @change=${e => this.onNameChanged(e.target.value)} .value=${this.name || ''} />
187
-
188
- <hr />
189
-
190
- <label for="locale"><ox-i18n slot="title" msgid="label.language"></ox-i18n></label>
191
- <ox-i18n-selector
192
- id="locale"
193
- @change=${e => this.onLocaleChanged(e.detail)}
194
- value=${i18next.language || 'en-US'}
195
- .languages=${this.languages}
196
- ></ox-i18n-selector>
197
-
198
- <hr />
199
-
200
- <label for="change-password">
201
- <ox-i18n msgid="label.password"></ox-i18n>
202
- </label>
203
-
204
- <change-password id="change-password" .passwordRule=${this.passwordRule}></change-password>
205
-
206
- ${isAvailableWebauthn
207
- ? html`
208
- <md-text-button @click=${() => this.registerUser()}
209
- >${i18next.t('button.security-key registration')}</md-text-button
210
- >
211
- `
212
- : nothing}
213
-
214
- <footer>
215
- <p>
216
- ${i18next.t('text.click login history')}
217
- <a href="javascript:void(0);" @click=${this.openLoginHistory.bind(this)}
218
- >${i18next.t('label.login_history')}</a
219
- >
220
- </p>
221
- </footer>
222
- </div>
223
- `
224
- }
225
-
226
- async onNameChanged(name) {
227
- if (!name) return
228
-
229
- var oldName = this.name
230
-
231
- try {
232
- const message = await auth.updateProfile({
233
- name
234
- })
235
-
236
- notify({
237
- level: 'info',
238
- message
239
- })
240
- } catch (e: any) {
241
- this.nameEl.value = oldName || ''
242
-
243
- notify({
244
- level: 'error',
245
- message: 'message' in e ? e.message : e
246
- })
247
- }
248
- }
249
-
250
- async onLocaleChanged(value) {
251
- if (!value) return
252
-
253
- var oldLocale = i18next.language
254
-
255
- try {
256
- const message = await auth.updateProfile({
257
- locale: value
258
- })
259
-
260
- i18next.changeLanguage(value)
261
-
262
- notify({
263
- level: 'info',
264
- message
265
- })
266
- } catch (e: any) {
267
- this.localeEl.value = oldLocale
268
-
269
- notify({
270
- level: 'error',
271
- message: 'message' in e ? e.message : e
272
- })
273
- }
274
- }
275
-
276
- openLoginHistory() {
277
- openPopup(html` <my-login-history></my-login-history> `, {
278
- title: i18next.t('label.login_history')
279
- })
280
- }
281
-
282
- deleteUser() {
283
- openPopup(html` <delete-user-popup></delete-user-popup> `, {
284
- title: i18next.t('label.delete account')
285
- })
286
- }
287
-
288
- async registerUser() {
289
- try {
290
- const options = await fetch('/auth/register-webauthn/challenge').then(res => res.json())
291
- const attResp = await startRegistration(options)
292
- const verification = await fetch('/auth/verify-registration', {
293
- method: 'POST',
294
- headers: {
295
- 'Content-Type': 'application/json'
296
- },
297
- body: JSON.stringify(attResp)
298
- }).then(res => res.json())
299
-
300
- if (verification.verified) {
301
- notify({
302
- level: 'info',
303
- message: i18next.t('text.user credential registered successfully')
304
- })
305
- } else {
306
- console.error(await verification.text())
307
-
308
- notify({
309
- level: 'error',
310
- message: i18next.t('error.user credential registeration not allowed')
311
- })
312
- }
313
- } catch (error) {
314
- notify({
315
- level: 'error',
316
- message: i18next.t('error.user credential registeration failed')
317
- })
318
- }
319
- }
320
-
321
- get applicationMeta() {
322
- var iconLink: HTMLLinkElement | null = document.querySelector('link[rel="application-icon"]')
323
- var titleMeta: HTMLMetaElement | null = document.querySelector('meta[name="application-name"]')
324
- var descriptionMeta: HTMLMetaElement | null = document.querySelector('meta[name="application-description"]')
325
-
326
- return {
327
- icon: iconLink?.href || '',
328
- title: titleMeta?.content || 'Things Factory',
329
- description: descriptionMeta?.content || 'Reimagining Software'
330
- }
331
- }
332
- }
@@ -1,92 +0,0 @@
1
- import { css, html, LitElement } from 'lit'
2
- import { customElement, property, query } from 'lit/decorators.js'
3
-
4
- import { i18next, localize } from '@operato/i18n'
5
-
6
- @customElement('role-edit-form')
7
- class RoleEditForm extends localize(i18next)(LitElement) {
8
- static styles = css`
9
- [field-2column] {
10
- border-radius: var(--border-radius);
11
- display: grid;
12
- grid-template-columns: 1fr 1fr;
13
- gap: 5px 15px;
14
- clear: both;
15
- max-width: var(--input-container-max-width);
16
- }
17
- [field] {
18
- display: flex;
19
- flex-direction: column;
20
- padding-bottom: var(--spacing-medium);
21
- }
22
- input {
23
- border: var(--border-dim-color);
24
- border-radius: var(--border-radius);
25
- margin: var(--input-margin);
26
- padding: var(--input-padding);
27
- min-width: 250px;
28
- font: var(--input-font);
29
- }
30
- label {
31
- display: flex;
32
- flex-direction: column;
33
- font: var(--label-font);
34
- color: var(--md-sys-color-on-primary);
35
- text-transform: var(--label-text-transform);
36
- }
37
- @media screen and (max-width: 480px) {
38
- [field] {
39
- grid-column: span 2;
40
- }
41
- }
42
- `
43
- @property({ type: Object }) role: any
44
-
45
- render() {
46
- const role = this.role || { name: '', description: '' }
47
-
48
- return html`
49
- <form field-2column @input="${this.dispatchRoleChanged.bind(this)}">
50
- <div field>
51
- <label
52
- >role name
53
- <input name="name" value="${role.name}" @click="${e => e.stopPropagation()}" />
54
- </label>
55
- </div>
56
-
57
- <div field>
58
- <label
59
- >role description
60
- <input name="description" .value="${role.description}" @click="${e => e.stopPropagation()}" />
61
- </label>
62
- </div>
63
- </form>
64
- `
65
- }
66
-
67
- @query('input[name=name]') nameInput!: HTMLInputElement
68
- @query('input[name=description]') descriptionInput!: HTMLInputElement
69
-
70
- getRole() {
71
- const name = this.nameInput.value
72
- const description = this.descriptionInput.value
73
-
74
- if (!name) {
75
- return this.showToast(i18next.t('error.value is empty', { value: i18next.t('field.name') }))
76
- }
77
-
78
- return { name, description }
79
- }
80
-
81
- dispatchRoleChanged() {
82
- this.dispatchEvent(
83
- new CustomEvent('roleChanged', {
84
- detail: this.getRole()
85
- })
86
- )
87
- }
88
-
89
- showToast(message) {
90
- document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
91
- }
92
- }