@things-factory/auth-ui 6.1.186 → 6.1.189
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.
- package/client/pages/auth-provider/auth-provider-management.ts +30 -6
- package/client/route.ts +0 -4
- package/dist-client/pages/auth-provider/auth-provider-management.d.ts +0 -1
- package/dist-client/pages/auth-provider/auth-provider-management.js +26 -6
- package/dist-client/pages/auth-provider/auth-provider-management.js.map +1 -1
- package/dist-client/route.js +0 -3
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/things-factory.config.js +1 -2
- package/translations/en.json +4 -0
- package/translations/ja.json +4 -0
- package/translations/ko.json +4 -0
- package/translations/ms.json +4 -0
- package/translations/zh.json +4 -0
- package/client/pages/auth-provider/auth-provider.ts +0 -394
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
import Clipboard from 'clipboard'
|
|
2
|
-
import gql from 'graphql-tag'
|
|
3
|
-
import { css, html } from 'lit'
|
|
4
|
-
import { customElement, property, queryAll } from 'lit/decorators.js'
|
|
5
|
-
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
6
|
-
|
|
7
|
-
import { APPLICATION_TYPES } from '../../constants/application'
|
|
8
|
-
|
|
9
|
-
import { client } from '@operato/graphql'
|
|
10
|
-
import { navigate, PageView, store } from '@operato/shell'
|
|
11
|
-
|
|
12
|
-
@customElement('auth-provider')
|
|
13
|
-
class AuthProvider extends connect(store)(PageView) {
|
|
14
|
-
static styles = [
|
|
15
|
-
css`
|
|
16
|
-
:host {
|
|
17
|
-
display: flex;
|
|
18
|
-
flex-direction: column;
|
|
19
|
-
overflow-y: auto;
|
|
20
|
-
position: relative;
|
|
21
|
-
background-color: var(--main-section-background-color);
|
|
22
|
-
padding: var(--padding-wide);
|
|
23
|
-
}
|
|
24
|
-
h2 {
|
|
25
|
-
margin: var(--title-margin);
|
|
26
|
-
font: var(--title-font);
|
|
27
|
-
color: var(--title-text-color);
|
|
28
|
-
}
|
|
29
|
-
[page-description] {
|
|
30
|
-
margin: var(--page-description-margin);
|
|
31
|
-
font: var(--page-description-font);
|
|
32
|
-
color: var(--page-description-color);
|
|
33
|
-
}
|
|
34
|
-
[icon] {
|
|
35
|
-
position: absolute;
|
|
36
|
-
top: 10px;
|
|
37
|
-
right: 10px;
|
|
38
|
-
max-width: 80px;
|
|
39
|
-
}
|
|
40
|
-
[icon] img {
|
|
41
|
-
max-width: 100%;
|
|
42
|
-
max-height: 100%;
|
|
43
|
-
}
|
|
44
|
-
label {
|
|
45
|
-
font: var(--label-font);
|
|
46
|
-
color: var(--label-color);
|
|
47
|
-
text-transform: var(--label-text-transform);
|
|
48
|
-
}
|
|
49
|
-
input,
|
|
50
|
-
select {
|
|
51
|
-
border: var(--border-dark-color);
|
|
52
|
-
border-radius: var(--border-radius);
|
|
53
|
-
margin: var(--input-margin);
|
|
54
|
-
padding: var(--input-padding);
|
|
55
|
-
font: var(--input-font);
|
|
56
|
-
flex: 1;
|
|
57
|
-
}
|
|
58
|
-
select:focus,
|
|
59
|
-
input:focus,
|
|
60
|
-
button {
|
|
61
|
-
outline: none;
|
|
62
|
-
}
|
|
63
|
-
form {
|
|
64
|
-
max-width: var(--content-container-max-width);
|
|
65
|
-
}
|
|
66
|
-
[fieldset-container] {
|
|
67
|
-
background-color: var(--theme-white-color);
|
|
68
|
-
margin: var(--margin-wide) 0 var(--margin-default) 0;
|
|
69
|
-
padding: var(--padding-default);
|
|
70
|
-
border-radius: var(--border-radius);
|
|
71
|
-
box-shadow: var(--box-shadow);
|
|
72
|
-
}
|
|
73
|
-
[fieldset-container] fieldset {
|
|
74
|
-
margin: 0;
|
|
75
|
-
margin-top: -15px;
|
|
76
|
-
}
|
|
77
|
-
fieldset {
|
|
78
|
-
border-radius: var(--border-radius);
|
|
79
|
-
border: var(--border-dark-color);
|
|
80
|
-
margin: var(--fieldset-margin);
|
|
81
|
-
padding: var(--fieldset-padding);
|
|
82
|
-
}
|
|
83
|
-
legend {
|
|
84
|
-
padding: var(--legend-padding);
|
|
85
|
-
font-weight: bold;
|
|
86
|
-
color: var(--legend-color);
|
|
87
|
-
}
|
|
88
|
-
[field-2column] {
|
|
89
|
-
display: grid;
|
|
90
|
-
grid-template-columns: 1fr 1fr;
|
|
91
|
-
grid-gap: 15px;
|
|
92
|
-
}
|
|
93
|
-
[field] {
|
|
94
|
-
display: flex;
|
|
95
|
-
flex-direction: column;
|
|
96
|
-
position: relative;
|
|
97
|
-
}
|
|
98
|
-
[grid-span] {
|
|
99
|
-
grid-column: span 2;
|
|
100
|
-
}
|
|
101
|
-
[button-in-field] {
|
|
102
|
-
position: absolute;
|
|
103
|
-
top: 24px;
|
|
104
|
-
right: 4px;
|
|
105
|
-
}
|
|
106
|
-
[input-hint] {
|
|
107
|
-
font: var(--input-hint-font);
|
|
108
|
-
color: var(--input-hint-color);
|
|
109
|
-
}
|
|
110
|
-
[danger] {
|
|
111
|
-
--mdc-theme-primary: var(--mdc-danger-button-primary-color);
|
|
112
|
-
}
|
|
113
|
-
.button-container {
|
|
114
|
-
margin-top: var(--margin-wide);
|
|
115
|
-
text-align: right;
|
|
116
|
-
}
|
|
117
|
-
.button-container mwc-button {
|
|
118
|
-
margin-left: var(--margin-narrow);
|
|
119
|
-
}
|
|
120
|
-
@media screen and (max-width: 480px) {
|
|
121
|
-
[field] {
|
|
122
|
-
grid-column: span 2;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
`
|
|
126
|
-
]
|
|
127
|
-
|
|
128
|
-
@property({ type: Object }) application: any
|
|
129
|
-
@queryAll('[clipboard-copy]') copybuttons
|
|
130
|
-
private clipboard?: Clipboard
|
|
131
|
-
|
|
132
|
-
get context() {
|
|
133
|
-
return {
|
|
134
|
-
title: {
|
|
135
|
-
icon: 'apps',
|
|
136
|
-
text: this.application.name
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
render() {
|
|
142
|
-
var app = this.application || {}
|
|
143
|
-
|
|
144
|
-
return html`
|
|
145
|
-
<div>
|
|
146
|
-
<h2><mwc-icon>apps</mwc-icon> ${app.name}</h2>
|
|
147
|
-
<p page-description>${app.description}</p>
|
|
148
|
-
</div>
|
|
149
|
-
|
|
150
|
-
<div icon>
|
|
151
|
-
<img src=${app.icon} />
|
|
152
|
-
</div>
|
|
153
|
-
|
|
154
|
-
<form>
|
|
155
|
-
<div fieldset-container>
|
|
156
|
-
<fieldset>
|
|
157
|
-
<legend>application</legend>
|
|
158
|
-
<div field-2column>
|
|
159
|
-
<div field grid-span>
|
|
160
|
-
<label for="name">app name</label>
|
|
161
|
-
<input id="name" type="text" name="name" .value=${app.name} />
|
|
162
|
-
</div>
|
|
163
|
-
|
|
164
|
-
<div field grid-span>
|
|
165
|
-
<label for="description">description</label>
|
|
166
|
-
<input id="description" type="text" name="description" .value=${app.description} />
|
|
167
|
-
</div>
|
|
168
|
-
|
|
169
|
-
<div field grid-span>
|
|
170
|
-
<label for="email">contact email</label>
|
|
171
|
-
<input id="email" type="text" name="email" .value=${app.email} />
|
|
172
|
-
</div>
|
|
173
|
-
|
|
174
|
-
<div field grid-span>
|
|
175
|
-
<label for="type-selector">type</label>
|
|
176
|
-
<select id="type-selector" name="type">
|
|
177
|
-
${APPLICATION_TYPES.map(
|
|
178
|
-
type =>
|
|
179
|
-
html`<option value="${app.type}" ?selected="${type === app.type ? true : false}">${type}</option>`
|
|
180
|
-
)}
|
|
181
|
-
</select>
|
|
182
|
-
</div>
|
|
183
|
-
|
|
184
|
-
<div field grid-span>
|
|
185
|
-
<label for="url">application URL</label>
|
|
186
|
-
<input id="url" type="text" name="url" .value=${app.url} />
|
|
187
|
-
</div>
|
|
188
|
-
|
|
189
|
-
<div field grid-span>
|
|
190
|
-
<label for="icon">icon</label>
|
|
191
|
-
<input id="icon" type="text" name="icon" .value=${app.icon} />
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
<div field grid-span>
|
|
195
|
-
<label for="redirect-url">redirect URL</label>
|
|
196
|
-
<input id="redirect-url" type="text" name="redirectUrl" .value=${app.redirectUrl} />
|
|
197
|
-
</div>
|
|
198
|
-
|
|
199
|
-
<div field grid-span>
|
|
200
|
-
<label for="webhook">webhook</label>
|
|
201
|
-
<input id="webhook" type="text" name="webhook" .value=${app.webhook} />
|
|
202
|
-
</div>
|
|
203
|
-
|
|
204
|
-
<div field grid-span>
|
|
205
|
-
<label for="available-scopes">available-scopes</label>
|
|
206
|
-
<input id="available-scopes" type="text" .value=${app.availableScopes} readonly />
|
|
207
|
-
</div>
|
|
208
|
-
|
|
209
|
-
<div field grid-span>
|
|
210
|
-
<label for="auth-url">auth URL</label>
|
|
211
|
-
<input id="auth-url" type="text" .value=${app.authUrl} readonly />
|
|
212
|
-
<mwc-button
|
|
213
|
-
dense
|
|
214
|
-
unelevated
|
|
215
|
-
button-in-field
|
|
216
|
-
clipboard-copy
|
|
217
|
-
@click=${e => e.preventDefault()}
|
|
218
|
-
label="copy"
|
|
219
|
-
></mwc-button>
|
|
220
|
-
The endpoint for authorization server. This is used to get the authorization code.
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
<div field grid-span>
|
|
224
|
-
<label for="access-token-url">access token URL</label>
|
|
225
|
-
<input id="access-token-url" type="text" .value=${app.accessTokenUrl} readonly />
|
|
226
|
-
<mwc-button
|
|
227
|
-
dense
|
|
228
|
-
unelevated
|
|
229
|
-
button-in-field
|
|
230
|
-
clipboard-copy
|
|
231
|
-
@click=${e => e.preventDefault()}
|
|
232
|
-
label="copy"
|
|
233
|
-
></mwc-button>
|
|
234
|
-
The endpoint for authentication server. This is used to exchange the authorization code for an access
|
|
235
|
-
token.
|
|
236
|
-
</div>
|
|
237
|
-
</div>
|
|
238
|
-
</fieldset>
|
|
239
|
-
</div>
|
|
240
|
-
|
|
241
|
-
<div fieldset-container>
|
|
242
|
-
<fieldset>
|
|
243
|
-
<legend>credentials</legend>
|
|
244
|
-
<div field-2column>
|
|
245
|
-
<div field grid-span>
|
|
246
|
-
<label for="app-key">appKey</label>
|
|
247
|
-
<input id="app-key" type="text" .value=${app.appKey} readonly />
|
|
248
|
-
<mwc-button
|
|
249
|
-
dense
|
|
250
|
-
unelevated
|
|
251
|
-
button-in-field
|
|
252
|
-
clipboard-copy
|
|
253
|
-
@click=${e => e.preventDefault()}
|
|
254
|
-
label="copy"
|
|
255
|
-
></mwc-button>
|
|
256
|
-
</div>
|
|
257
|
-
|
|
258
|
-
<div field grid-span>
|
|
259
|
-
<label for="app-secret">appSecret</label>
|
|
260
|
-
<input id="app-secret" type="text" .value=${app.appSecret} readonly />
|
|
261
|
-
<mwc-button
|
|
262
|
-
dense
|
|
263
|
-
unelevated
|
|
264
|
-
button-in-field
|
|
265
|
-
clipboard-copy
|
|
266
|
-
@click=${e => e.preventDefault()}
|
|
267
|
-
label="copy"
|
|
268
|
-
></mwc-button>
|
|
269
|
-
</div>
|
|
270
|
-
</div>
|
|
271
|
-
</fieldset>
|
|
272
|
-
</div>
|
|
273
|
-
|
|
274
|
-
<div class="button-container">
|
|
275
|
-
<mwc-button raised danger label="delete this app" @click=${this.deleteApplication.bind(this)}></mwc-button>
|
|
276
|
-
<mwc-button raised label="update" @click=${this.updateApplication.bind(this)}></mwc-button>
|
|
277
|
-
<mwc-button outlined label="generate new secret"></mwc-button>
|
|
278
|
-
</div>
|
|
279
|
-
</form>
|
|
280
|
-
`
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
firstUpdated() {
|
|
284
|
-
this.clipboard = new Clipboard(this.copybuttons, {
|
|
285
|
-
target: (trigger => trigger.parentElement.querySelector('input')) as any
|
|
286
|
-
})
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
async pageUpdated(changes, lifecycle, before) {
|
|
290
|
-
if (this.active) {
|
|
291
|
-
await this.fetchApplication()
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
async fetchApplication() {
|
|
296
|
-
const response = await client.query({
|
|
297
|
-
query: gql`
|
|
298
|
-
query ($id: String!) {
|
|
299
|
-
application(id: $id) {
|
|
300
|
-
id
|
|
301
|
-
name
|
|
302
|
-
description
|
|
303
|
-
email
|
|
304
|
-
url
|
|
305
|
-
icon
|
|
306
|
-
redirectUrl
|
|
307
|
-
authUrl
|
|
308
|
-
accessTokenUrl
|
|
309
|
-
webhook
|
|
310
|
-
availableScopes
|
|
311
|
-
appKey
|
|
312
|
-
appSecret
|
|
313
|
-
type
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
`,
|
|
317
|
-
variables: {
|
|
318
|
-
id: this.lifecycle.resourceId
|
|
319
|
-
}
|
|
320
|
-
})
|
|
321
|
-
|
|
322
|
-
this.application = response.data.application
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
async updateApplication(e) {
|
|
326
|
-
e.preventDefault()
|
|
327
|
-
|
|
328
|
-
const form = this.renderRoot.querySelector('form') as HTMLFormElement
|
|
329
|
-
const formData = new FormData(form)
|
|
330
|
-
|
|
331
|
-
const patch = Array.from(formData.entries()).reduce((patch, [key, value]) => {
|
|
332
|
-
patch[key] = value
|
|
333
|
-
return patch
|
|
334
|
-
}, {})
|
|
335
|
-
|
|
336
|
-
const id = this.lifecycle.resourceId
|
|
337
|
-
|
|
338
|
-
const response = await client.mutate({
|
|
339
|
-
mutation: gql`
|
|
340
|
-
mutation ($id: String!, $patch: ApplicationPatch!) {
|
|
341
|
-
updateApplication(id: $id, patch: $patch) {
|
|
342
|
-
id
|
|
343
|
-
name
|
|
344
|
-
description
|
|
345
|
-
email
|
|
346
|
-
url
|
|
347
|
-
icon
|
|
348
|
-
redirectUrl
|
|
349
|
-
webhook
|
|
350
|
-
appKey
|
|
351
|
-
appSecret
|
|
352
|
-
type
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
`,
|
|
356
|
-
variables: {
|
|
357
|
-
id,
|
|
358
|
-
patch
|
|
359
|
-
}
|
|
360
|
-
})
|
|
361
|
-
|
|
362
|
-
if (response.errors) {
|
|
363
|
-
console.error('update fail')
|
|
364
|
-
} else {
|
|
365
|
-
this.application = { ...this.application, ...response.data.updateApplication }
|
|
366
|
-
console.log('update sucess')
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
async deleteApplication(e) {
|
|
371
|
-
e.preventDefault()
|
|
372
|
-
|
|
373
|
-
const id = this.lifecycle.resourceId
|
|
374
|
-
|
|
375
|
-
const response = await client.mutate({
|
|
376
|
-
mutation: gql`
|
|
377
|
-
mutation ($id: String!) {
|
|
378
|
-
deleteApplication(id: $id)
|
|
379
|
-
}
|
|
380
|
-
`,
|
|
381
|
-
variables: {
|
|
382
|
-
id
|
|
383
|
-
}
|
|
384
|
-
})
|
|
385
|
-
|
|
386
|
-
const result = response.data.deleteApplication
|
|
387
|
-
if (result) {
|
|
388
|
-
console.log('delete sucess')
|
|
389
|
-
navigate('applications')
|
|
390
|
-
} else {
|
|
391
|
-
console.error('delete fail')
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|