@things-factory/auth-ui 8.0.0-beta.1 → 8.0.0-beta.4

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 (59) hide show
  1. package/package.json +4 -4
  2. package/client/auth-style-sign.ts +0 -194
  3. package/client/bootstrap.ts +0 -51
  4. package/client/components/abstract-auth-page.ts +0 -301
  5. package/client/components/abstract-password-reset.ts +0 -163
  6. package/client/components/abstract-sign.ts +0 -127
  7. package/client/components/change-password.ts +0 -153
  8. package/client/components/contact-us.ts +0 -116
  9. package/client/components/create-domain-popup.ts +0 -141
  10. package/client/components/create-role.ts +0 -123
  11. package/client/components/create-user.ts +0 -117
  12. package/client/components/credential-manager.ts +0 -64
  13. package/client/components/delete-user-popup.ts +0 -117
  14. package/client/components/domain-switch.ts +0 -127
  15. package/client/components/invite-customer.ts +0 -104
  16. package/client/components/invite-user.ts +0 -104
  17. package/client/components/my-login-history.ts +0 -101
  18. package/client/components/ownership-transfer-popup.ts +0 -110
  19. package/client/components/partner-info-card.ts +0 -89
  20. package/client/components/partner-role-editor.ts +0 -153
  21. package/client/components/profile-component.ts +0 -392
  22. package/client/components/role-edit-form.ts +0 -92
  23. package/client/components/role-privilege-editor.ts +0 -268
  24. package/client/components/role-selector.ts +0 -102
  25. package/client/components/user-role-editor.ts +0 -499
  26. package/client/constants/application.ts +0 -9
  27. package/client/constants/index.ts +0 -1
  28. package/client/entries/auth/activate.ts +0 -272
  29. package/client/entries/auth/checkin.ts +0 -190
  30. package/client/entries/auth/forgot-password.ts +0 -112
  31. package/client/entries/auth/reset-password.ts +0 -22
  32. package/client/entries/auth/result.ts +0 -193
  33. package/client/entries/auth/signin.ts +0 -18
  34. package/client/entries/auth/signup.ts +0 -115
  35. package/client/entries/auth/unlock-user.ts +0 -22
  36. package/client/entries/oauth2/oauth2-decision-error-page.ts +0 -50
  37. package/client/entries/oauth2/oauth2-decision-page.ts +0 -196
  38. package/client/entries/public/home.ts +0 -246
  39. package/client/index.ts +0 -124
  40. package/client/pages/app-binding/app-binding.ts +0 -423
  41. package/client/pages/app-binding/app-bindings.ts +0 -171
  42. package/client/pages/appliance/appliance.ts +0 -452
  43. package/client/pages/appliance/home.ts +0 -177
  44. package/client/pages/appliance/register.ts +0 -183
  45. package/client/pages/application/application.ts +0 -428
  46. package/client/pages/application/applications.ts +0 -182
  47. package/client/pages/application/register.ts +0 -211
  48. package/client/pages/attribute/attribute-set-item-list.ts +0 -237
  49. package/client/pages/attribute/attribute-set-management.ts +0 -282
  50. package/client/pages/auth-provider/auth-provider-management.ts +0 -381
  51. package/client/pages/domain/domain-management.ts +0 -410
  52. package/client/pages/partner/partner-management.ts +0 -112
  53. package/client/pages/profile.ts +0 -32
  54. package/client/pages/role/role-management.ts +0 -134
  55. package/client/pages/user/user-management.ts +0 -223
  56. package/client/route.ts +0 -67
  57. package/client/themes/auth-theme.css +0 -65
  58. package/client/utils/password-rule.ts +0 -37
  59. package/server/index.ts +0 -0
@@ -1,392 +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 }) username?: 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('#username') usernameEl!: HTMLInputElement
132
- @query('#name') nameEl!: HTMLInputElement
133
- @query('#email') emailEl!: HTMLInputElement
134
- @query('#locale') localeEl!: HTMLInputElement
135
-
136
- async connectedCallback(): Promise<void> {
137
- super.connectedCallback()
138
-
139
- const response = await client.query({
140
- query: gql`
141
- query {
142
- passwordRule {
143
- lowerCase
144
- upperCase
145
- digit
146
- specialCharacter
147
- allowRepeat
148
- useTightPattern
149
- useLoosePattern
150
- tightCharacterLength
151
- looseCharacterLength
152
- }
153
- }
154
- `
155
- })
156
-
157
- this.passwordRule = response.data
158
- }
159
-
160
- async firstUpdated() {
161
- auth.on('profile', ({ credential }) => {
162
- this.setCredential(credential)
163
- })
164
-
165
- this.setCredential(auth.credential)
166
-
167
- this.languages = await getLanguages()
168
- }
169
-
170
- setCredential(credential) {
171
- if (credential) {
172
- this.username = credential.username
173
- this.name = credential.name
174
- this.email = credential.email
175
- } else {
176
- this.username = ''
177
- this.name = ''
178
- this.email = ''
179
- }
180
- }
181
-
182
- render() {
183
- return html`
184
- <div class="wrap">
185
- <div class="user">${this.username || ''}</div>
186
-
187
- <label for="username"><ox-i18n slot="title" msgid="label.user-id"></ox-i18n></label>
188
- <input id="username" @change=${e => this.onUsernameChanged(e.target.value)} .value=${this.username || ''} />
189
-
190
- <hr />
191
-
192
- <label for="name"><ox-i18n slot="title" msgid="label.name"></ox-i18n></label>
193
- <input id="name" @change=${e => this.onNameChanged(e.target.value)} .value=${this.name || ''} />
194
-
195
- <hr />
196
-
197
- <label for="email"><ox-i18n slot="title" msgid="label.email"></ox-i18n></label>
198
- <input id="email" type="email" @change=${e => this.onEmailChanged(e.target.value)} .value=${this.email || ''} />
199
-
200
- <hr />
201
-
202
- <label for="locale"><ox-i18n slot="title" msgid="label.language"></ox-i18n></label>
203
- <ox-i18n-selector
204
- id="locale"
205
- @change=${e => this.onLocaleChanged(e.detail)}
206
- value=${i18next.language || 'en-US'}
207
- .languages=${this.languages}
208
- ></ox-i18n-selector>
209
-
210
- <hr />
211
-
212
- <label for="change-password">
213
- <ox-i18n msgid="label.password"></ox-i18n>
214
- </label>
215
-
216
- <change-password id="change-password" .passwordRule=${this.passwordRule}></change-password>
217
-
218
- ${isAvailableWebauthn
219
- ? html`
220
- <md-text-button @click=${() => this.registerUser()}
221
- >${i18next.t('button.security-key registration')}</md-text-button
222
- >
223
- `
224
- : nothing}
225
-
226
- <footer>
227
- <p>
228
- ${i18next.t('text.click login history')}
229
- <a href="javascript:void(0);" @click=${this.openLoginHistory.bind(this)}
230
- >${i18next.t('label.login_history')}</a
231
- >
232
- </p>
233
- </footer>
234
- </div>
235
- `
236
- }
237
-
238
- async onUsernameChanged(username) {
239
- if (!username) return
240
-
241
- var oldUsername = this.username
242
-
243
- try {
244
- const message = await auth.updateProfile({
245
- username
246
- })
247
-
248
- notify({
249
- level: 'info',
250
- message
251
- })
252
- } catch (e: any) {
253
- this.usernameEl.value = oldUsername || ''
254
-
255
- notify({
256
- level: 'error',
257
- message: 'message' in e ? e.message : e
258
- })
259
- }
260
- }
261
-
262
- async onNameChanged(name) {
263
- if (!name) return
264
-
265
- var oldName = this.name
266
-
267
- try {
268
- const message = await auth.updateProfile({
269
- name
270
- })
271
-
272
- notify({
273
- level: 'info',
274
- message
275
- })
276
- } catch (e: any) {
277
- this.nameEl.value = oldName || ''
278
-
279
- notify({
280
- level: 'error',
281
- message: 'message' in e ? e.message : e
282
- })
283
- }
284
- }
285
-
286
- async onEmailChanged(email) {
287
- if (!email) return
288
-
289
- var oldEmail = this.email
290
-
291
- try {
292
- const message = await auth.updateProfile({
293
- email
294
- })
295
-
296
- notify({
297
- level: 'info',
298
- message
299
- })
300
- } catch (e: any) {
301
- this.emailEl.value = oldEmail || ''
302
-
303
- notify({
304
- level: 'error',
305
- message: 'message' in e ? e.message : e
306
- })
307
- }
308
- }
309
-
310
- async onLocaleChanged(value) {
311
- if (!value) return
312
-
313
- var oldLocale = i18next.language
314
-
315
- try {
316
- const message = await auth.updateProfile({
317
- locale: value
318
- })
319
-
320
- i18next.changeLanguage(value)
321
-
322
- notify({
323
- level: 'info',
324
- message
325
- })
326
- } catch (e: any) {
327
- this.localeEl.value = oldLocale
328
-
329
- notify({
330
- level: 'error',
331
- message: 'message' in e ? e.message : e
332
- })
333
- }
334
- }
335
-
336
- openLoginHistory() {
337
- openPopup(html` <my-login-history></my-login-history> `, {
338
- title: i18next.t('label.login_history')
339
- })
340
- }
341
-
342
- deleteUser() {
343
- openPopup(html` <delete-user-popup></delete-user-popup> `, {
344
- title: i18next.t('label.delete account')
345
- })
346
- }
347
-
348
- async registerUser() {
349
- try {
350
- const options = await fetch('/auth/register-webauthn/challenge').then(res => res.json())
351
- const attResp = await startRegistration(options)
352
- const verification = await fetch('/auth/verify-registration', {
353
- method: 'POST',
354
- headers: {
355
- 'Content-Type': 'application/json'
356
- },
357
- body: JSON.stringify(attResp)
358
- }).then(res => res.json())
359
-
360
- if (verification.verified) {
361
- notify({
362
- level: 'info',
363
- message: i18next.t('text.user credential registered successfully')
364
- })
365
- } else {
366
- console.error(await verification.text())
367
-
368
- notify({
369
- level: 'error',
370
- message: i18next.t('error.user credential registeration not allowed')
371
- })
372
- }
373
- } catch (error) {
374
- notify({
375
- level: 'error',
376
- message: i18next.t('error.user credential registeration failed')
377
- })
378
- }
379
- }
380
-
381
- get applicationMeta() {
382
- var iconLink: HTMLLinkElement | null = document.querySelector('link[rel="application-icon"]')
383
- var titleMeta: HTMLMetaElement | null = document.querySelector('meta[name="application-name"]')
384
- var descriptionMeta: HTMLMetaElement | null = document.querySelector('meta[name="application-description"]')
385
-
386
- return {
387
- icon: iconLink?.href || '',
388
- title: titleMeta?.content || 'Things Factory',
389
- description: descriptionMeta?.content || 'Reimagining Software'
390
- }
391
- }
392
- }
@@ -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
- }