@things-factory/oauth2-client 10.1.27 → 10.1.29
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/dist-client/pages/oauth2-client/oauth2-client-list-page.d.ts +4 -0
- package/dist-client/pages/oauth2-client/oauth2-client-list-page.js +19 -13
- package/dist-client/pages/oauth2-client/oauth2-client-list-page.js.map +1 -1
- package/dist-client/pages/oauth2-client-register.d.ts +16 -3
- package/dist-client/pages/oauth2-client-register.js +83 -99
- package/dist-client/pages/oauth2-client-register.js.map +1 -1
- package/dist-client/pages/oauth2-client.d.ts +26 -2
- package/dist-client/pages/oauth2-client.js +151 -137
- package/dist-client/pages/oauth2-client.js.map +1 -1
- package/dist-client/pages/oauth2-clients.d.ts +1 -2
- package/dist-client/pages/oauth2-clients.js +85 -92
- package/dist-client/pages/oauth2-clients.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
- package/translations/en.json +7 -1
- package/translations/ja.json +7 -1
- package/translations/ko.json +7 -1
- package/translations/ms.json +7 -1
- package/translations/zh.json +7 -1
|
@@ -9,6 +9,9 @@ import { asyncReplace } from 'lit/directives/async-replace.js';
|
|
|
9
9
|
import { client } from '@operato/graphql';
|
|
10
10
|
import { notify } from '@operato/layout';
|
|
11
11
|
import { navigate, PageView } from '@operato/shell';
|
|
12
|
+
import { i18next, localize } from '@operato/i18n';
|
|
13
|
+
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
14
|
+
import { CommonButtonStyles, DocumentPageStyles } from '@operato/styles';
|
|
12
15
|
import { sleep } from '@operato/utils';
|
|
13
16
|
const OAUTH2CLIENT = `
|
|
14
17
|
id
|
|
@@ -35,39 +38,23 @@ tokenType
|
|
|
35
38
|
updatedAt
|
|
36
39
|
createdAt
|
|
37
40
|
`;
|
|
38
|
-
let Oauth2Client = class Oauth2Client extends PageView {
|
|
41
|
+
let Oauth2Client = class Oauth2Client extends localize(i18next)(PageView) {
|
|
39
42
|
static { this.styles = [
|
|
43
|
+
/* Read and edited down one column (ADR-0060 decision 8). */
|
|
44
|
+
DocumentPageStyles,
|
|
40
45
|
css `
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
overflow-y: auto;
|
|
44
|
-
position: relative;
|
|
45
|
-
|
|
46
|
-
background-color: var(--md-sys-color-background);
|
|
47
|
-
padding: var(--spacing-large);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
h2 { margin: var(--title-margin);
|
|
51
|
-
font: var(--title-font);
|
|
52
|
-
color: var(--title-text-color);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
[page-description] { margin: var(--page-description-margin);
|
|
56
|
-
font: var(--page-description-font);
|
|
57
|
-
color: var(--page-description-color);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[icon] { position: absolute;
|
|
61
|
-
top: 10px;
|
|
62
|
-
right: 10px;
|
|
46
|
+
[icon] {
|
|
47
|
+
float: right;
|
|
63
48
|
max-width: 80px;
|
|
64
|
-
|
|
49
|
+
}
|
|
65
50
|
|
|
66
|
-
[icon] img {
|
|
51
|
+
[icon] img {
|
|
52
|
+
max-width: 100%;
|
|
67
53
|
max-height: 100%;
|
|
68
|
-
|
|
54
|
+
}
|
|
69
55
|
|
|
70
|
-
[button-primary] {
|
|
56
|
+
[button-primary] {
|
|
57
|
+
background-color: var(--button-primary-background-color);
|
|
71
58
|
border: var(--button-border);
|
|
72
59
|
border-radius: var(--button-border-radius);
|
|
73
60
|
margin: var(--button-margin);
|
|
@@ -77,22 +64,25 @@ let Oauth2Client = class Oauth2Client extends PageView {
|
|
|
77
64
|
text-transform: var(--button-text-transform);
|
|
78
65
|
|
|
79
66
|
text-decoration: none;
|
|
80
|
-
|
|
67
|
+
}
|
|
81
68
|
|
|
82
|
-
[button-primary]:hover {
|
|
69
|
+
[button-primary]:hover {
|
|
70
|
+
background-color: var(--button-primary-active-background-color);
|
|
83
71
|
box-shadow: var(--button-active-box-shadow);
|
|
84
|
-
|
|
72
|
+
}
|
|
85
73
|
|
|
86
|
-
[fieldset-container] {
|
|
74
|
+
[fieldset-container] {
|
|
75
|
+
background-color: var(--md-sys-color-surface);
|
|
87
76
|
margin: var(--spacing-large) 0 var(--spacing-medium) 0;
|
|
88
77
|
padding: var(--spacing-medium);
|
|
89
78
|
border-radius: var(--border-radius);
|
|
90
79
|
box-shadow: var(--box-shadow);
|
|
91
80
|
|
|
92
|
-
label {
|
|
81
|
+
label {
|
|
82
|
+
font: var(--label-font);
|
|
93
83
|
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
94
84
|
text-transform: var(--label-text-transform);
|
|
95
|
-
|
|
85
|
+
}
|
|
96
86
|
|
|
97
87
|
input,
|
|
98
88
|
select {
|
|
@@ -105,53 +95,63 @@ let Oauth2Client = class Oauth2Client extends PageView {
|
|
|
105
95
|
font: var(--input-font);
|
|
106
96
|
|
|
107
97
|
flex: 1;
|
|
108
|
-
|
|
98
|
+
}
|
|
109
99
|
|
|
110
100
|
select:focus,
|
|
111
101
|
input:focus,
|
|
112
|
-
button {
|
|
113
|
-
|
|
102
|
+
button {
|
|
103
|
+
outline: none;
|
|
104
|
+
}
|
|
114
105
|
|
|
115
|
-
form {
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
form {
|
|
107
|
+
max-width: var(--content-container-max-width);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
118
110
|
|
|
119
|
-
[fieldset-container] fieldset {
|
|
111
|
+
[fieldset-container] fieldset {
|
|
112
|
+
margin: 0;
|
|
120
113
|
margin-top: -15px;
|
|
121
|
-
|
|
114
|
+
}
|
|
122
115
|
|
|
123
|
-
fieldset {
|
|
116
|
+
fieldset {
|
|
117
|
+
border-radius: var(--border-radius);
|
|
124
118
|
border: var(--border-dim-color);
|
|
125
119
|
margin: var(--fieldset-margin);
|
|
126
120
|
padding: var(--fieldset-padding);
|
|
127
|
-
|
|
121
|
+
}
|
|
128
122
|
|
|
129
|
-
legend {
|
|
123
|
+
legend {
|
|
124
|
+
padding: var(--legend-padding);
|
|
130
125
|
font-weight: bold;
|
|
131
126
|
color: var(--legend-color);
|
|
132
|
-
|
|
127
|
+
}
|
|
133
128
|
|
|
134
|
-
[field-2column] {
|
|
129
|
+
[field-2column] {
|
|
130
|
+
display: grid;
|
|
135
131
|
grid-template-columns: 1fr 1fr;
|
|
136
132
|
grid-gap: 15px;
|
|
137
|
-
|
|
133
|
+
}
|
|
138
134
|
|
|
139
|
-
[field] {
|
|
135
|
+
[field] {
|
|
136
|
+
display: flex;
|
|
140
137
|
flex-direction: column;
|
|
141
138
|
position: relative;
|
|
142
|
-
|
|
139
|
+
}
|
|
143
140
|
|
|
144
|
-
[grid-span] {
|
|
145
|
-
|
|
141
|
+
[grid-span] {
|
|
142
|
+
grid-column: span 2;
|
|
143
|
+
}
|
|
146
144
|
|
|
147
|
-
button {
|
|
145
|
+
button {
|
|
146
|
+
display: flex;
|
|
148
147
|
align-items: center;
|
|
149
148
|
gap: var(--spacing-small);
|
|
150
|
-
|
|
149
|
+
}
|
|
151
150
|
|
|
152
151
|
button,
|
|
153
152
|
input[type='submit'],
|
|
154
|
-
[button-in-field] {
|
|
153
|
+
[button-in-field] {
|
|
154
|
+
background-color: var(--button-background-color);
|
|
155
155
|
border: var(--button-border);
|
|
156
156
|
border-radius: var(--button-border-radius);
|
|
157
157
|
padding: var(--button-padding);
|
|
@@ -162,46 +162,81 @@ let Oauth2Client = class Oauth2Client extends PageView {
|
|
|
162
162
|
margin: var(--spacing-medium) 0 var(--spacing-medium) var(--spacing-medium);
|
|
163
163
|
float: right;
|
|
164
164
|
text-decoration: none;
|
|
165
|
-
|
|
165
|
+
}
|
|
166
166
|
|
|
167
167
|
button:hover,
|
|
168
|
-
input[type='submit']:hover {
|
|
168
|
+
input[type='submit']:hover {
|
|
169
|
+
border: var(--button-activ-border);
|
|
169
170
|
box-shadow: var(--button-active-box-shadow);
|
|
170
|
-
|
|
171
|
+
}
|
|
171
172
|
|
|
172
|
-
[button-in-field] {
|
|
173
|
+
[button-in-field] {
|
|
174
|
+
border-radius: 0 var(--button-border-radius) var(--button-border-radius) 0;
|
|
173
175
|
position: absolute;
|
|
174
176
|
top: 12px;
|
|
175
177
|
right: 0;
|
|
176
178
|
max-height: 36px;
|
|
177
|
-
|
|
179
|
+
}
|
|
178
180
|
|
|
179
|
-
[input-hint] {
|
|
181
|
+
[input-hint] {
|
|
182
|
+
font: var(--input-hint-font);
|
|
180
183
|
color: var(--input-hint-color);
|
|
181
|
-
|
|
184
|
+
}
|
|
182
185
|
|
|
183
|
-
@media screen and (max-width: 480px) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
@media screen and (max-width: 480px) {
|
|
187
|
+
[field] {
|
|
188
|
+
grid-column: span 2;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
186
191
|
`
|
|
187
192
|
]; }
|
|
188
193
|
get context() {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
/*
|
|
195
|
+
* The name and the line under it are the title bar's (ADR-0060 decision 8), and everything this
|
|
196
|
+
* screen commits is in the page action bar. The bar calls action() with no arguments
|
|
197
|
+
* (decision 9), so these take none.
|
|
198
|
+
*/
|
|
199
|
+
return {
|
|
200
|
+
/*
|
|
201
|
+
* 이 화면이 어떤 틀인가 — 동작 줄이 이것을 읽고 자기 오른쪽 끝을 내용에 맞춘다
|
|
202
|
+
* (ADR-0060 결정 9 보탬). 안 적으면 창 폭이고, 그것은 작업면의 모양이다.
|
|
203
|
+
*/
|
|
204
|
+
frame: 'document',
|
|
205
|
+
title: { icon: 'apps', text: this.oauth2Client?.name },
|
|
206
|
+
description: this.oauth2Client?.description,
|
|
207
|
+
actions: [
|
|
208
|
+
{
|
|
209
|
+
title: i18next.t('button.update'),
|
|
210
|
+
action: async () => {
|
|
211
|
+
await this.updateOauth2Client();
|
|
212
|
+
},
|
|
213
|
+
...CommonButtonStyles.save
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
title: i18next.t('button.new-access-token'),
|
|
217
|
+
action: async () => {
|
|
218
|
+
await this.updateOauth2Client();
|
|
219
|
+
await this.generateOauth2AccessToken();
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
title: i18next.t('button.refresh-access-token'),
|
|
224
|
+
disabled: !this.oauth2Client?.refreshToken,
|
|
225
|
+
action: async () => {
|
|
226
|
+
await this.updateOauth2Client();
|
|
227
|
+
await this.refreshOauth2AccessToken();
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
{ title: i18next.t('button.delete'), action: () => this.deleteOauth2Client(), ...CommonButtonStyles.delete }
|
|
231
|
+
]
|
|
192
232
|
};
|
|
193
233
|
}
|
|
194
234
|
render() {
|
|
195
235
|
var oauth2Client = this.oauth2Client || {};
|
|
236
|
+
/* The name and description are in the title bar, so they are not drawn here a second time. */
|
|
196
237
|
return html `
|
|
197
|
-
<div>
|
|
198
|
-
|
|
199
|
-
<p page-description>${oauth2Client.description || ''}</p>
|
|
200
|
-
</div>
|
|
201
|
-
|
|
202
|
-
<div icon>
|
|
203
|
-
<img src=${oauth2Client.icon}>
|
|
204
|
-
</div>
|
|
238
|
+
<div class="page">
|
|
239
|
+
${oauth2Client.icon ? html `<div icon><img src=${oauth2Client.icon} /></div>` : html ``}
|
|
205
240
|
|
|
206
241
|
<form>
|
|
207
242
|
<div fieldset-container>
|
|
@@ -365,31 +400,20 @@ let Oauth2Client = class Oauth2Client extends PageView {
|
|
|
365
400
|
</fieldset>
|
|
366
401
|
</div>
|
|
367
402
|
|
|
368
|
-
<button @click=${e => this.deleteOauth2Client(e)}>delete this app</button>
|
|
369
|
-
<button @click=${async (e) => {
|
|
370
|
-
e.preventDefault();
|
|
371
|
-
await this.updateOauth2Client();
|
|
372
|
-
await this.generateOauth2AccessToken();
|
|
373
|
-
}}>get new access token</button>
|
|
374
|
-
<button @click=${async (e) => {
|
|
375
|
-
e.preventDefault();
|
|
376
|
-
await this.updateOauth2Client();
|
|
377
|
-
await this.refreshOauth2AccessToken();
|
|
378
|
-
}} ?disabled=${!oauth2Client.refreshToken}>refresh access token</button>
|
|
379
|
-
<input type="submit" value="update" @click=${async (e) => {
|
|
380
|
-
e.preventDefault();
|
|
381
|
-
await this.updateOauth2Client();
|
|
382
|
-
}}>
|
|
383
403
|
</form>
|
|
404
|
+
</div>
|
|
384
405
|
`;
|
|
385
406
|
}
|
|
386
407
|
updated(changes) {
|
|
387
408
|
if (changes.has('oauth2Client')) {
|
|
388
409
|
this._grantType = this.oauth2Client?.grantType;
|
|
410
|
+
/* The name, the line under it and the actions all read the client, so the shell redraws them. */
|
|
411
|
+
this.updateContext();
|
|
389
412
|
}
|
|
390
413
|
}
|
|
391
414
|
firstUpdated() {
|
|
392
|
-
this.clipboard = new Clipboard(this.copybuttons, {
|
|
415
|
+
this.clipboard = new Clipboard(this.copybuttons, {
|
|
416
|
+
target: (trigger => trigger.parentElement.querySelector('input'))
|
|
393
417
|
});
|
|
394
418
|
}
|
|
395
419
|
async pageUpdated(changes, lifecycle, before) {
|
|
@@ -414,13 +438,13 @@ let Oauth2Client = class Oauth2Client extends PageView {
|
|
|
414
438
|
}
|
|
415
439
|
}
|
|
416
440
|
async fetchOauth2Client() {
|
|
417
|
-
const response = await client.query({
|
|
441
|
+
const response = await client.query({
|
|
442
|
+
query: gql `
|
|
418
443
|
query($id: String!) { oauth2Client(id: $id) { ${OAUTH2CLIENT}
|
|
419
444
|
}
|
|
420
445
|
}
|
|
421
446
|
`,
|
|
422
|
-
variables: { id: this.lifecycle.resourceId
|
|
423
|
-
}
|
|
447
|
+
variables: { id: this.lifecycle.resourceId }
|
|
424
448
|
});
|
|
425
449
|
this.oauth2Client = response.data.oauth2Client;
|
|
426
450
|
}
|
|
@@ -431,38 +455,37 @@ let Oauth2Client = class Oauth2Client extends PageView {
|
|
|
431
455
|
return patch;
|
|
432
456
|
}, {});
|
|
433
457
|
const id = this.lifecycle.resourceId;
|
|
434
|
-
const response = await client.mutate({
|
|
458
|
+
const response = await client.mutate({
|
|
459
|
+
mutation: gql `
|
|
435
460
|
mutation($id: String!, $patch: Oauth2ClientPatch!) { updateOauth2Client(id: $id, patch: $patch) { ${OAUTH2CLIENT}
|
|
436
461
|
}
|
|
437
462
|
}
|
|
438
463
|
`,
|
|
439
|
-
variables: { id,
|
|
440
|
-
patch
|
|
441
|
-
}
|
|
464
|
+
variables: { id, patch }
|
|
442
465
|
});
|
|
443
466
|
if (response.errors) {
|
|
444
|
-
notify({ level: 'error',
|
|
445
|
-
message: 'update oauth2 client fail'
|
|
446
|
-
});
|
|
467
|
+
notify({ level: 'error', message: 'update oauth2 client fail' });
|
|
447
468
|
}
|
|
448
469
|
else {
|
|
449
470
|
this.oauth2Client = response.data.updateOauth2Client;
|
|
450
471
|
}
|
|
451
472
|
}
|
|
452
|
-
async deleteOauth2Client(
|
|
453
|
-
|
|
473
|
+
async deleteOauth2Client() {
|
|
474
|
+
/* Deleting took the app away with no question asked. */
|
|
475
|
+
if (!(await OxPrompt.confirmDelete())) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
454
478
|
const id = this.lifecycle.resourceId;
|
|
455
|
-
const response = await client.mutate({
|
|
456
|
-
|
|
457
|
-
|
|
479
|
+
const response = await client.mutate({
|
|
480
|
+
mutation: gql `
|
|
481
|
+
mutation ($id: String!) {
|
|
482
|
+
deleteOauth2Client(id: $id)
|
|
483
|
+
}
|
|
458
484
|
`,
|
|
459
|
-
variables: { id
|
|
460
|
-
}
|
|
485
|
+
variables: { id }
|
|
461
486
|
});
|
|
462
487
|
if (response.errors) {
|
|
463
|
-
notify({ level: 'error',
|
|
464
|
-
message: 'delete oauth2 client fail'
|
|
465
|
-
});
|
|
488
|
+
notify({ level: 'error', message: 'delete oauth2 client fail' });
|
|
466
489
|
}
|
|
467
490
|
else {
|
|
468
491
|
navigate('oauth2-clients');
|
|
@@ -471,64 +494,55 @@ let Oauth2Client = class Oauth2Client extends PageView {
|
|
|
471
494
|
async generateOauth2AccessToken() {
|
|
472
495
|
const id = this.lifecycle.resourceId;
|
|
473
496
|
if (this.oauth2Client.grantType == 'code') {
|
|
474
|
-
const response = await client.mutate({
|
|
475
|
-
|
|
476
|
-
|
|
497
|
+
const response = await client.mutate({
|
|
498
|
+
mutation: gql `
|
|
499
|
+
mutation ($id: String!) {
|
|
500
|
+
getOauth2AuthUrl(id: $id)
|
|
501
|
+
}
|
|
477
502
|
`,
|
|
478
|
-
variables: { id: this.lifecycle.resourceId
|
|
479
|
-
}
|
|
503
|
+
variables: { id: this.lifecycle.resourceId }
|
|
480
504
|
});
|
|
481
505
|
if (!response.errors) {
|
|
482
506
|
location.href = response.data.getOauth2AuthUrl;
|
|
483
507
|
}
|
|
484
508
|
else {
|
|
485
|
-
notify({ level: 'error',
|
|
486
|
-
message: 'getting application access token fail'
|
|
487
|
-
});
|
|
509
|
+
notify({ level: 'error', message: 'getting application access token fail' });
|
|
488
510
|
}
|
|
489
511
|
}
|
|
490
512
|
else {
|
|
491
|
-
const response = await client.mutate({
|
|
513
|
+
const response = await client.mutate({
|
|
514
|
+
mutation: gql `
|
|
492
515
|
mutation($id: String!) { getOauth2AccessToken(id: $id) { ${OAUTH2CLIENT}
|
|
493
516
|
}
|
|
494
517
|
}
|
|
495
518
|
`,
|
|
496
|
-
variables: { id: this.lifecycle.resourceId
|
|
497
|
-
}
|
|
519
|
+
variables: { id: this.lifecycle.resourceId }
|
|
498
520
|
});
|
|
499
521
|
if (response.errors) {
|
|
500
|
-
notify({ level: 'error',
|
|
501
|
-
message: 'getting application access token fail'
|
|
502
|
-
});
|
|
522
|
+
notify({ level: 'error', message: 'getting application access token fail' });
|
|
503
523
|
}
|
|
504
524
|
else {
|
|
505
525
|
this.oauth2Client = response.data.getOauth2AccessToken;
|
|
506
|
-
notify({ level: 'info',
|
|
507
|
-
message: 'got application access token successfully'
|
|
508
|
-
});
|
|
526
|
+
notify({ level: 'info', message: 'got application access token successfully' });
|
|
509
527
|
}
|
|
510
528
|
}
|
|
511
529
|
}
|
|
512
530
|
async refreshOauth2AccessToken() {
|
|
513
531
|
const id = this.lifecycle.resourceId;
|
|
514
|
-
const response = await client.mutate({
|
|
532
|
+
const response = await client.mutate({
|
|
533
|
+
mutation: gql `
|
|
515
534
|
mutation($id: String!) { refreshOauth2AccessToken(id: $id) { ${OAUTH2CLIENT}
|
|
516
535
|
}
|
|
517
536
|
}
|
|
518
537
|
`,
|
|
519
|
-
variables: { id: this.lifecycle.resourceId
|
|
520
|
-
}
|
|
538
|
+
variables: { id: this.lifecycle.resourceId }
|
|
521
539
|
});
|
|
522
540
|
if (response.errors) {
|
|
523
|
-
notify({ level: 'error',
|
|
524
|
-
message: 'getting application access token fail'
|
|
525
|
-
});
|
|
541
|
+
notify({ level: 'error', message: 'getting application access token fail' });
|
|
526
542
|
}
|
|
527
543
|
else {
|
|
528
544
|
this.oauth2Client = response.data.refreshOauth2AccessToken;
|
|
529
|
-
notify({ level: 'info',
|
|
530
|
-
message: 'got application access token successfully'
|
|
531
|
-
});
|
|
545
|
+
notify({ level: 'info', message: 'got application access token successfully' });
|
|
532
546
|
}
|
|
533
547
|
}
|
|
534
548
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2-client.js","sourceRoot":"","sources":["../../client/pages/oauth2-client.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,+BAA+B,CAAA;AAEtC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO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D,CAAC;IAEA,KAAK,CAAC,wBAAwB;QAAS,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAA;QAEzE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,EAAQ,QAAQ,EAAE,GAAG,CAAA;6FAC+B,YAAY;;;OAGlG;YACD,SAAS,EAAE,EAAU,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU;aACtD;SACA,CAAC,CAAA;QAEC,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YAAO,MAAM,CAAC,EAAU,KAAK,EAAE,OAAO;gBACxD,OAAO,EAAE,uCAAuC;aACtD,CAAC,CAAA;QACF,CAAC;aAAM,CAAC;YAAO,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,wBAAwB,CAAA;YACpE,MAAM,CAAC,EAAU,KAAK,EAAE,MAAM;gBAC5B,OAAO,EAAE,2CAA2C;aAC1D,CAAC,CAAA;QACF,CAAC;IACD,CAAC;;AA/V4B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAoB;AAEhC;IAAd,KAAK,CAAC,MAAM,CAAC;8BAAQ,eAAe;0CAAA;AACP;IAA7B,QAAQ,CAAC,kBAAkB,CAAC;;iDAAY;AA1J9B,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAsfxB","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/help/ox-help-icon.js'\n\nimport Clipboard from 'clipboard'\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, queryAll } from 'lit/decorators.js'\nimport { asyncReplace } from 'lit/directives/async-replace.js'\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { sleep } from '@operato/utils'\n\nconst OAUTH2CLIENT = `\nid\nname\ndescription\nicon\ngrantType\nclientId\nclientSecret\ncallbackUrl\nauthUrl\naccessTokenUrl\nwebhook\nusername\npassword\ncodeChallengeMethod\ncodeVerifier\nscopes\naccessToken\nrefreshToken\njwtToken\nexpires\ntokenType\nupdatedAt\ncreatedAt\n`\n\n@customElement('oauth2-client')\nexport class Oauth2Client extends PageView { static styles = [\n css`\n :host { display: flex;\n flex-direction: column;\n overflow-y: auto;\n position: relative;\n\n background-color: var(--md-sys-color-background);\n padding: var(--spacing-large);\n }\n\n h2 { margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n }\n\n [page-description] { margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n }\n\n [icon] { position: absolute;\n top: 10px;\n right: 10px;\n max-width: 80px;\n }\n\n [icon] img { max-width: 100%;\n max-height: 100%;\n }\n\n [button-primary] { background-color: var(--button-primary-background-color);\n border: var(--button-border);\n border-radius: var(--button-border-radius);\n margin: var(--button-margin);\n padding: var(--button-primary-padding);\n color: var(--button-primary-color);\n font: var(--button-primary-font);\n text-transform: var(--button-text-transform);\n\n text-decoration: none;\n }\n\n [button-primary]:hover { background-color: var(--button-primary-active-background-color);\n box-shadow: var(--button-active-box-shadow);\n }\n\n [fieldset-container] { background-color: var(--md-sys-color-surface);\n margin: var(--spacing-large) 0 var(--spacing-medium) 0;\n padding: var(--spacing-medium);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n\n label { font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n text-transform: var(--label-text-transform);\n }\n\n input,\n select {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n font: var(--input-font);\n\n flex: 1;\n }\n\n select:focus,\n input:focus,\n button { outline: none;\n }\n\n form { max-width: var(--content-container-max-width);\n }\n }\n\n [fieldset-container] fieldset { margin: 0;\n margin-top: -15px;\n }\n\n fieldset { border-radius: var(--border-radius);\n border: var(--border-dim-color);\n margin: var(--fieldset-margin);\n padding: var(--fieldset-padding);\n }\n\n legend { padding: var(--legend-padding);\n font-weight: bold;\n color: var(--legend-color);\n }\n\n [field-2column] { display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n }\n\n [field] { display: flex;\n flex-direction: column;\n position: relative;\n }\n\n [grid-span] { grid-column: span 2;\n }\n\n button { display: flex;\n align-items: center;\n gap: var(--spacing-small);\n }\n\n button,\n input[type='submit'],\n [button-in-field] { background-color: var(--button-background-color);\n border: var(--button-border);\n border-radius: var(--button-border-radius);\n padding: var(--button-padding);\n color: var(--button-color);\n font: var(--button-font);\n text-transform: var(--button-text-transform);\n\n margin: var(--spacing-medium) 0 var(--spacing-medium) var(--spacing-medium);\n float: right;\n text-decoration: none;\n }\n\n button:hover,\n input[type='submit']:hover { border: var(--button-activ-border);\n box-shadow: var(--button-active-box-shadow);\n }\n\n [button-in-field] { border-radius: 0 var(--button-border-radius) var(--button-border-radius) 0;\n position: absolute;\n top: 12px;\n right: 0;\n max-height: 36px;\n }\n\n [input-hint] { font: var(--input-hint-font);\n color: var(--input-hint-color);\n }\n\n @media screen and (max-width: 480px) { [field] { grid-column: span 2;\n }\n }\n `\n ]\n\n @property({ type: Object }) oauth2Client: any\n @property({ type: String }) _grantType?: string\n\n @query('form') form!: HTMLFormElement\n @queryAll('[clipboard-copy]') copybuttons\n\n private clipboard?: Clipboard\n private _icon?: string\n\n get context() { return { title: { icon: 'apps',\n text: this.oauth2Client?.name\n }\n }\n }\n\n render() { var oauth2Client = this.oauth2Client || {}\n\n return html`\n <div>\n <h2><md-icon>apps</md-icon> ${oauth2Client.name || ''}</h2>\n <p page-description>${oauth2Client.description || ''}</p>\n </div>\n\n <div icon>\n <img src=${oauth2Client.icon}>\n </div>\n\n <form>\n <div fieldset-container>\n <fieldset>\n <legend>oauth2 client</legend>\n <div field-2column>\n <div field grid-span>\n <label for='name'>name</label>\n <input type='text' id=\"name\" name=\"name\" .value=${oauth2Client.name || ''}>\n </div>\n\n <div field grid-span>\n <label for='description'>description</label>\n <input type='text' id=\"description\" name=\"description\" .value=${oauth2Client.description || ''}>\n </div>\n\n <div field grid-span>\n <label for='icon'>icon</label>\n <input type='text' id=\"icon\" name=\"icon\" \n @change=${e => (this._icon = e.target.value)} \n .value=${oauth2Client.icon || ''}\n >\n </div>\n </div>\n </fieldset>\n </div>\n\n <div fieldset-container>\n <fieldset>\n <legend>authorization</legend>\n <div field-2column>\n <div field grid-span>\n <label for='grant-type'>grant type\n <ox-help-icon topic='/oauth2-client/grant-type'></ox-help-icon>\n </label>\n <select type='text' id=\"grant-type\" name=\"grantType\" .value=${oauth2Client.grantType || 'code'} \n @change=${e => (this._grantType = e.target.value)}>\n <option></option>\n <option value='code'>Authorization Code Grant</option>\n <option value='jwt'>JWT As Authorization Grant</option>\n <option value='owner'>Resource Owner Password Credentials Grant</option>\n <option value='credentials'>Client Credentials Grant</option>\n </select>\n </div>\n\n <div field grid-span>\n <label for='auth-url'>auth url</label>\n <input type='text' id=\"auth-url\" name=\"authUrl\" .value=${oauth2Client.authUrl || ''}>\n <div input-hint>The endpoint for authorization server. This is used to get the authorization code.</div>\n </div>\n\n <div field grid-span>\n <label for='access-token-url'>access token url</label>\n <input type='text' id=\"access-token-url\" name=\"accessTokenUrl\" .value=${ oauth2Client.accessTokenUrl || ''\n }>\n <div input-hint>The endpoint for authentication server. This is used to exchange the authorization code for an access token.</div>\n </div>\n\n <div field grid-span>\n <label for='callback-url'>callback url</label>\n <input type='text' id=\"callback-url\" name=\"callbackUrl\" .value=${oauth2Client.callbackUrl || ''}>\n <div input-hint>This is the callback url that you will be redirected to, after your application is authorized.\n This is used to extract the authorization code or access token.\n Normally, this callback url should match the one you use during the application registration process.\n If you leave this field empty, default callback url(${ location.origin\n }/oauth2-client/callback</label>) will be used.</div>\n </div>\n \n <div field grid-span>\n <label for='client-id'>client id</label>\n <input type='text' id=\"client-id\" name=\"clientId\" .value=${oauth2Client.clientId || ''}>\n <div input-hint>The client identifier issued to the client during the application registration process.</div>\n </div>\n\n <div field grid-span>\n <label for='client-secret'>client secret</label>\n <input type='text' id=\"client-secret\" name=\"clientSecret\" .value=${oauth2Client.clientSecret || ''}>\n <div input-hint>The client secret issued to the client during the application registration process.</div>\n </div>\n\n ${ this._grantType == 'owner'\n ? html`\n <div field grid-span>\n <label for=\"username\">user name</label>\n <input type=\"text\" id=\"username\" name=\"username\" .value=${oauth2Client.username || ''} />\n </div>\n\n <div field grid-span>\n <label for=\"password\">password</label>\n <input type=\"password\" id=\"password\" name=\"password\" .value=${oauth2Client.password || ''} />\n </div>\n `\n : html``\n }\n\n ${ this._grantType == 'jwt'\n ? html`\n <div field grid-span>\n <label for=\"jwt-token\">jwt-token</label>\n <input type=\"text\" id=\"jwt-token\" name=\"jwtToken\" .value=${oauth2Client.jwtToken || ''} />\n <div input-hint>The JWT Bearer Token for JWT As Authorization Grant</div>\n </div>\n `\n : html``\n }\n\n <!-- code PKCE grant type not supported yet\n <div field grid-span>\n <label for='code-challenge-method'>code challenge method</label>\n <select type='text' id=\"code-challenge-method\" name=\"codeChallengeMethod\" .value=${ oauth2Client.codeChallengeMethod\n }>\n <option></option>\n <option>SHA-256</option>\n <option>Plain</option>\n </select>\n <div input-hint>Algorithm used for generating the code challenge</div>\n </div>\n\n <div field grid-span>\n <label for='code-verifier'>code verifier\n <ox-help-icon topic='/oauth2-client/code-verifier'></ox-help-icon>\n </label>\n <input type='text' id=\"code-verifier\" name=\"codeVerifier\" .value=${oauth2Client.codeVerifier || ''}>\n <div input-hint>A random, 43-128 character string used to connect the authorization request to the token request.\n Uses the following characters: [A-Z]/[a-z]/[0-9]/\"-\"/\".\"/\"_\"/\"~\".</div>\n </div>\n -->\n \n <div field grid-span>\n <label for='scopes'>scopes</label>\n <input type='text' id=\"scopes\" name=\"scopes\" .value=${oauth2Client.scopes || ''}>\n <div input-hint>The scopes of the access request. It may have multiple space-delimited values.</div>\n </div>\n </div>\n </fieldset>\n </div>\n\n <div fieldset-container>\n <fieldset>\n <div field grid-span>\n <label for='token-type'>token type</label>\n <input type='text' id=\"token-type\" .value=${oauth2Client.tokenType || ''} readonly>\n <div input-hint>Added to the authorization header before the access token.</div>\n </div>\n\n <legend>access token</legend>\n <div field-2column>\n <div field grid-span>\n <label for=\"access-token\">access token</label>\n <input id=\"access-token\" type=\"text\" .value=${oauth2Client.accessToken || ''} readonly />\n <button button-in-field clipboard-copy @click=${e => e.preventDefault()}>copy</button>\n ${ oauth2Client.expires\n ? html`<div input-hint>\n expired in ${new Date(Number(oauth2Client.expires))} :\n ${asyncReplace(this.expTimer(oauth2Client.expires))}\n </div>`\n : html``\n }\n </div>\n\n <div field grid-span>\n <label for=\"refresh-token\">refresh token</label>\n <input id=\"refresh-token\" type=\"text\" .value=${oauth2Client.refreshToken || ''} readonly />\n <button button-in-field clipboard-copy @click=${e => e.preventDefault()}>copy</button>\n </div>\n </div>\n </fieldset>\n </div>\n\n <button @click=${e => this.deleteOauth2Client(e)}>delete this app</button>\n <button @click=${async e => { e.preventDefault()\n await this.updateOauth2Client()\n await this.generateOauth2AccessToken()\n }}>get new access token</button>\n <button @click=${async e => { e.preventDefault()\n await this.updateOauth2Client()\n await this.refreshOauth2AccessToken()\n }} ?disabled=${!oauth2Client.refreshToken}>refresh access token</button>\n <input type=\"submit\" value=\"update\" @click=${async e => { e.preventDefault()\n await this.updateOauth2Client()\n }}>\n </form>\n `\n }\n\n updated(changes) { if (changes.has('oauth2Client')) { this._grantType = this.oauth2Client?.grantType\n }\n }\n\n firstUpdated() { this.clipboard = new Clipboard(this.copybuttons, { target: (trigger => trigger.parentElement.querySelector('input')) as any\n })\n }\n\n async pageUpdated(changes, lifecycle, before) { if (this.active) { await this.fetchOauth2Client()\n }\n }\n\n async *expTimer(exp) { const DAY = 24 * 60 * 60\n const HOUR = 60 * 60\n const MIN = 60\n\n while (this.active) { var remain = Math.floor((Number(exp) - Date.now()) / 1000)\n const days = Math.floor(remain / DAY)\n remain -= days * DAY\n const hours = Math.floor(remain / HOUR)\n remain -= hours * HOUR\n const mins = Math.floor(remain / MIN)\n const secs = remain - mins * MIN\n\n yield `${days} days ${hours} hours ${mins} mins ${secs} seconds remain`\n\n await sleep(1000)\n }\n }\n\n async fetchOauth2Client() { const response = await client.query({ query: gql`\n query($id: String!) { oauth2Client(id: $id) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id: this.lifecycle.resourceId\n }\n })\n\n this.oauth2Client = response.data.oauth2Client\n }\n\n async updateOauth2Client() { const formData = new FormData(this.form)\n\n const patch = Array.from(formData.entries()).reduce((patch, [key, value]) => { patch[key] = value\n return patch\n }, {})\n\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({ mutation: gql`\n mutation($id: String!, $patch: Oauth2ClientPatch!) { updateOauth2Client(id: $id, patch: $patch) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id,\n patch\n }\n })\n\n if (response.errors) { notify({ level: 'error',\n message: 'update oauth2 client fail'\n })\n } else { this.oauth2Client = response.data.updateOauth2Client\n }\n }\n\n async deleteOauth2Client(e) { e.preventDefault()\n\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({ mutation: gql`\n mutation ($id: String!) { deleteOauth2Client(id: $id)\n }\n `,\n variables: { id\n }\n })\n\n if (response.errors) { notify({ level: 'error',\n message: 'delete oauth2 client fail'\n })\n } else { navigate('oauth2-clients')\n }\n }\n\n async generateOauth2AccessToken() { const id = this.lifecycle.resourceId\n\n if (this.oauth2Client.grantType == 'code') { const response = await client.mutate({ mutation: gql`\n mutation ($id: String!) { getOauth2AuthUrl(id: $id)\n }\n `,\n variables: { id: this.lifecycle.resourceId\n }\n })\n\n if (!response.errors) { location.href = response.data.getOauth2AuthUrl\n } else { notify({ level: 'error',\n message: 'getting application access token fail'\n })\n }\n } else { const response = await client.mutate({ mutation: gql`\n mutation($id: String!) { getOauth2AccessToken(id: $id) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id: this.lifecycle.resourceId\n }\n })\n\n if (response.errors) { notify({ level: 'error',\n message: 'getting application access token fail'\n })\n } else { this.oauth2Client = response.data.getOauth2AccessToken\n notify({ level: 'info',\n message: 'got application access token successfully'\n })\n }\n }\n }\n\n async refreshOauth2AccessToken() { const id = this.lifecycle.resourceId\n\n const response = await client.mutate({ mutation: gql`\n mutation($id: String!) { refreshOauth2AccessToken(id: $id) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id: this.lifecycle.resourceId\n }\n })\n\n if (response.errors) { notify({ level: 'error',\n message: 'getting application access token fail'\n })\n } else { this.oauth2Client = response.data.refreshOauth2AccessToken\n notify({ level: 'info',\n message: 'got application access token successfully'\n })\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"oauth2-client.js","sourceRoot":"","sources":["../../client/pages/oauth2-client.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,+BAA+B,CAAA;AAEtC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,kBAAkB,EA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AE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAoB;AAEhC;IAAd,KAAK,CAAC,MAAM,CAAC;8BAAQ,eAAe;0CAAA;AACP;IAA7B,QAAQ,CAAC,kBAAkB,CAAC;;iDAAY;AA7J9B,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAsiBxB","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/help/ox-help-icon.js'\n\nimport Clipboard from 'clipboard'\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, queryAll } from 'lit/decorators.js'\nimport { asyncReplace } from 'lit/directives/async-replace.js'\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { CommonButtonStyles, DocumentPageStyles } from '@operato/styles'\nimport { sleep } from '@operato/utils'\n\nconst OAUTH2CLIENT = `\nid\nname\ndescription\nicon\ngrantType\nclientId\nclientSecret\ncallbackUrl\nauthUrl\naccessTokenUrl\nwebhook\nusername\npassword\ncodeChallengeMethod\ncodeVerifier\nscopes\naccessToken\nrefreshToken\njwtToken\nexpires\ntokenType\nupdatedAt\ncreatedAt\n`\n\n@customElement('oauth2-client')\nexport class Oauth2Client extends localize(i18next)(PageView) {\n static styles = [\n /* Read and edited down one column (ADR-0060 decision 8). */\n DocumentPageStyles,\n css`\n [icon] {\n float: right;\n max-width: 80px;\n }\n\n [icon] img {\n max-width: 100%;\n max-height: 100%;\n }\n\n [button-primary] {\n background-color: var(--button-primary-background-color);\n border: var(--button-border);\n border-radius: var(--button-border-radius);\n margin: var(--button-margin);\n padding: var(--button-primary-padding);\n color: var(--button-primary-color);\n font: var(--button-primary-font);\n text-transform: var(--button-text-transform);\n\n text-decoration: none;\n }\n\n [button-primary]:hover {\n background-color: var(--button-primary-active-background-color);\n box-shadow: var(--button-active-box-shadow);\n }\n\n [fieldset-container] {\n background-color: var(--md-sys-color-surface);\n margin: var(--spacing-large) 0 var(--spacing-medium) 0;\n padding: var(--spacing-medium);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n\n label {\n font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n text-transform: var(--label-text-transform);\n }\n\n input,\n select {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n font: var(--input-font);\n\n flex: 1;\n }\n\n select:focus,\n input:focus,\n button {\n outline: none;\n }\n\n form {\n max-width: var(--content-container-max-width);\n }\n }\n\n [fieldset-container] fieldset {\n margin: 0;\n margin-top: -15px;\n }\n\n fieldset {\n border-radius: var(--border-radius);\n border: var(--border-dim-color);\n margin: var(--fieldset-margin);\n padding: var(--fieldset-padding);\n }\n\n legend {\n padding: var(--legend-padding);\n font-weight: bold;\n color: var(--legend-color);\n }\n\n [field-2column] {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n }\n\n [field] {\n display: flex;\n flex-direction: column;\n position: relative;\n }\n\n [grid-span] {\n grid-column: span 2;\n }\n\n button {\n display: flex;\n align-items: center;\n gap: var(--spacing-small);\n }\n\n button,\n input[type='submit'],\n [button-in-field] {\n background-color: var(--button-background-color);\n border: var(--button-border);\n border-radius: var(--button-border-radius);\n padding: var(--button-padding);\n color: var(--button-color);\n font: var(--button-font);\n text-transform: var(--button-text-transform);\n\n margin: var(--spacing-medium) 0 var(--spacing-medium) var(--spacing-medium);\n float: right;\n text-decoration: none;\n }\n\n button:hover,\n input[type='submit']:hover {\n border: var(--button-activ-border);\n box-shadow: var(--button-active-box-shadow);\n }\n\n [button-in-field] {\n border-radius: 0 var(--button-border-radius) var(--button-border-radius) 0;\n position: absolute;\n top: 12px;\n right: 0;\n max-height: 36px;\n }\n\n [input-hint] {\n font: var(--input-hint-font);\n color: var(--input-hint-color);\n }\n\n @media screen and (max-width: 480px) {\n [field] {\n grid-column: span 2;\n }\n }\n `\n ]\n\n @property({ type: Object }) oauth2Client: any\n @property({ type: String }) _grantType?: string\n\n @query('form') form!: HTMLFormElement\n @queryAll('[clipboard-copy]') copybuttons\n\n private clipboard?: Clipboard\n private _icon?: string\n\n get context() {\n /*\n * The name and the line under it are the title bar's (ADR-0060 decision 8), and everything this\n * screen commits is in the page action bar. The bar calls action() with no arguments\n * (decision 9), so these take none.\n */\n return {\n /*\n * 이 화면이 어떤 틀인가 — 동작 줄이 이것을 읽고 자기 오른쪽 끝을 내용에 맞춘다\n * (ADR-0060 결정 9 보탬). 안 적으면 창 폭이고, 그것은 작업면의 모양이다.\n */\n frame: 'document',\n title: { icon: 'apps', text: this.oauth2Client?.name },\n description: this.oauth2Client?.description,\n actions: [\n {\n title: i18next.t('button.update'),\n action: async () => {\n await this.updateOauth2Client()\n },\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.new-access-token'),\n action: async () => {\n await this.updateOauth2Client()\n await this.generateOauth2AccessToken()\n }\n },\n {\n title: i18next.t('button.refresh-access-token'),\n disabled: !this.oauth2Client?.refreshToken,\n action: async () => {\n await this.updateOauth2Client()\n await this.refreshOauth2AccessToken()\n }\n },\n { title: i18next.t('button.delete'), action: () => this.deleteOauth2Client(), ...CommonButtonStyles.delete }\n ]\n }\n }\n\n render() {\n var oauth2Client = this.oauth2Client || {}\n\n /* The name and description are in the title bar, so they are not drawn here a second time. */\n return html`\n <div class=\"page\">\n ${oauth2Client.icon ? html`<div icon><img src=${oauth2Client.icon} /></div>` : html``}\n\n <form>\n <div fieldset-container>\n <fieldset>\n <legend>oauth2 client</legend>\n <div field-2column>\n <div field grid-span>\n <label for='name'>name</label>\n <input type='text' id=\"name\" name=\"name\" .value=${oauth2Client.name || ''}>\n </div>\n\n <div field grid-span>\n <label for='description'>description</label>\n <input type='text' id=\"description\" name=\"description\" .value=${oauth2Client.description || ''}>\n </div>\n\n <div field grid-span>\n <label for='icon'>icon</label>\n <input type='text' id=\"icon\" name=\"icon\" \n @change=${e => (this._icon = e.target.value)} \n .value=${oauth2Client.icon || ''}\n >\n </div>\n </div>\n </fieldset>\n </div>\n\n <div fieldset-container>\n <fieldset>\n <legend>authorization</legend>\n <div field-2column>\n <div field grid-span>\n <label for='grant-type'>grant type\n <ox-help-icon topic='/oauth2-client/grant-type'></ox-help-icon>\n </label>\n <select type='text' id=\"grant-type\" name=\"grantType\" .value=${oauth2Client.grantType || 'code'} \n @change=${e => (this._grantType = e.target.value)}>\n <option></option>\n <option value='code'>Authorization Code Grant</option>\n <option value='jwt'>JWT As Authorization Grant</option>\n <option value='owner'>Resource Owner Password Credentials Grant</option>\n <option value='credentials'>Client Credentials Grant</option>\n </select>\n </div>\n\n <div field grid-span>\n <label for='auth-url'>auth url</label>\n <input type='text' id=\"auth-url\" name=\"authUrl\" .value=${oauth2Client.authUrl || ''}>\n <div input-hint>The endpoint for authorization server. This is used to get the authorization code.</div>\n </div>\n\n <div field grid-span>\n <label for='access-token-url'>access token url</label>\n <input type='text' id=\"access-token-url\" name=\"accessTokenUrl\" .value=${\n oauth2Client.accessTokenUrl || ''\n }>\n <div input-hint>The endpoint for authentication server. This is used to exchange the authorization code for an access token.</div>\n </div>\n\n <div field grid-span>\n <label for='callback-url'>callback url</label>\n <input type='text' id=\"callback-url\" name=\"callbackUrl\" .value=${oauth2Client.callbackUrl || ''}>\n <div input-hint>This is the callback url that you will be redirected to, after your application is authorized.\n This is used to extract the authorization code or access token.\n Normally, this callback url should match the one you use during the application registration process.\n If you leave this field empty, default callback url(${\n location.origin\n }/oauth2-client/callback</label>) will be used.</div>\n </div>\n \n <div field grid-span>\n <label for='client-id'>client id</label>\n <input type='text' id=\"client-id\" name=\"clientId\" .value=${oauth2Client.clientId || ''}>\n <div input-hint>The client identifier issued to the client during the application registration process.</div>\n </div>\n\n <div field grid-span>\n <label for='client-secret'>client secret</label>\n <input type='text' id=\"client-secret\" name=\"clientSecret\" .value=${oauth2Client.clientSecret || ''}>\n <div input-hint>The client secret issued to the client during the application registration process.</div>\n </div>\n\n ${\n this._grantType == 'owner'\n ? html`\n <div field grid-span>\n <label for=\"username\">user name</label>\n <input type=\"text\" id=\"username\" name=\"username\" .value=${oauth2Client.username || ''} />\n </div>\n\n <div field grid-span>\n <label for=\"password\">password</label>\n <input type=\"password\" id=\"password\" name=\"password\" .value=${oauth2Client.password || ''} />\n </div>\n `\n : html``\n }\n\n ${\n this._grantType == 'jwt'\n ? html`\n <div field grid-span>\n <label for=\"jwt-token\">jwt-token</label>\n <input type=\"text\" id=\"jwt-token\" name=\"jwtToken\" .value=${oauth2Client.jwtToken || ''} />\n <div input-hint>The JWT Bearer Token for JWT As Authorization Grant</div>\n </div>\n `\n : html``\n }\n\n <!-- code PKCE grant type not supported yet\n <div field grid-span>\n <label for='code-challenge-method'>code challenge method</label>\n <select type='text' id=\"code-challenge-method\" name=\"codeChallengeMethod\" .value=${\n oauth2Client.codeChallengeMethod\n }>\n <option></option>\n <option>SHA-256</option>\n <option>Plain</option>\n </select>\n <div input-hint>Algorithm used for generating the code challenge</div>\n </div>\n\n <div field grid-span>\n <label for='code-verifier'>code verifier\n <ox-help-icon topic='/oauth2-client/code-verifier'></ox-help-icon>\n </label>\n <input type='text' id=\"code-verifier\" name=\"codeVerifier\" .value=${oauth2Client.codeVerifier || ''}>\n <div input-hint>A random, 43-128 character string used to connect the authorization request to the token request.\n Uses the following characters: [A-Z]/[a-z]/[0-9]/\"-\"/\".\"/\"_\"/\"~\".</div>\n </div>\n -->\n \n <div field grid-span>\n <label for='scopes'>scopes</label>\n <input type='text' id=\"scopes\" name=\"scopes\" .value=${oauth2Client.scopes || ''}>\n <div input-hint>The scopes of the access request. It may have multiple space-delimited values.</div>\n </div>\n </div>\n </fieldset>\n </div>\n\n <div fieldset-container>\n <fieldset>\n <div field grid-span>\n <label for='token-type'>token type</label>\n <input type='text' id=\"token-type\" .value=${oauth2Client.tokenType || ''} readonly>\n <div input-hint>Added to the authorization header before the access token.</div>\n </div>\n\n <legend>access token</legend>\n <div field-2column>\n <div field grid-span>\n <label for=\"access-token\">access token</label>\n <input id=\"access-token\" type=\"text\" .value=${oauth2Client.accessToken || ''} readonly />\n <button button-in-field clipboard-copy @click=${e => e.preventDefault()}>copy</button>\n ${\n oauth2Client.expires\n ? html`<div input-hint>\n expired in ${new Date(Number(oauth2Client.expires))} :\n ${asyncReplace(this.expTimer(oauth2Client.expires))}\n </div>`\n : html``\n }\n </div>\n\n <div field grid-span>\n <label for=\"refresh-token\">refresh token</label>\n <input id=\"refresh-token\" type=\"text\" .value=${oauth2Client.refreshToken || ''} readonly />\n <button button-in-field clipboard-copy @click=${e => e.preventDefault()}>copy</button>\n </div>\n </div>\n </fieldset>\n </div>\n\n </form>\n </div>\n `\n }\n\n updated(changes) {\n if (changes.has('oauth2Client')) {\n this._grantType = this.oauth2Client?.grantType\n /* The name, the line under it and the actions all read the client, so the shell redraws them. */\n this.updateContext()\n }\n }\n\n firstUpdated() {\n this.clipboard = new Clipboard(this.copybuttons, {\n target: (trigger => trigger.parentElement.querySelector('input')) as any\n })\n }\n\n async pageUpdated(changes, lifecycle, before) {\n if (this.active) {\n await this.fetchOauth2Client()\n }\n }\n\n async *expTimer(exp) {\n const DAY = 24 * 60 * 60\n const HOUR = 60 * 60\n const MIN = 60\n\n while (this.active) {\n var remain = Math.floor((Number(exp) - Date.now()) / 1000)\n const days = Math.floor(remain / DAY)\n remain -= days * DAY\n const hours = Math.floor(remain / HOUR)\n remain -= hours * HOUR\n const mins = Math.floor(remain / MIN)\n const secs = remain - mins * MIN\n\n yield `${days} days ${hours} hours ${mins} mins ${secs} seconds remain`\n\n await sleep(1000)\n }\n }\n\n async fetchOauth2Client() {\n const response = await client.query({\n query: gql`\n query($id: String!) { oauth2Client(id: $id) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id: this.lifecycle.resourceId }\n })\n\n this.oauth2Client = response.data.oauth2Client\n }\n\n async updateOauth2Client() {\n const formData = new FormData(this.form)\n\n const patch = Array.from(formData.entries()).reduce((patch, [key, value]) => {\n patch[key] = value\n return patch\n }, {})\n\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({\n mutation: gql`\n mutation($id: String!, $patch: Oauth2ClientPatch!) { updateOauth2Client(id: $id, patch: $patch) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id, patch }\n })\n\n if (response.errors) {\n notify({ level: 'error', message: 'update oauth2 client fail' })\n } else {\n this.oauth2Client = response.data.updateOauth2Client\n }\n }\n\n async deleteOauth2Client() {\n /* Deleting took the app away with no question asked. */\n if (!(await OxPrompt.confirmDelete())) {\n return\n }\n\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!) {\n deleteOauth2Client(id: $id)\n }\n `,\n variables: { id }\n })\n\n if (response.errors) {\n notify({ level: 'error', message: 'delete oauth2 client fail' })\n } else {\n navigate('oauth2-clients')\n }\n }\n\n async generateOauth2AccessToken() {\n const id = this.lifecycle.resourceId\n\n if (this.oauth2Client.grantType == 'code') {\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!) {\n getOauth2AuthUrl(id: $id)\n }\n `,\n variables: { id: this.lifecycle.resourceId }\n })\n\n if (!response.errors) {\n location.href = response.data.getOauth2AuthUrl\n } else {\n notify({ level: 'error', message: 'getting application access token fail' })\n }\n } else {\n const response = await client.mutate({\n mutation: gql`\n mutation($id: String!) { getOauth2AccessToken(id: $id) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id: this.lifecycle.resourceId }\n })\n\n if (response.errors) {\n notify({ level: 'error', message: 'getting application access token fail' })\n } else {\n this.oauth2Client = response.data.getOauth2AccessToken\n notify({ level: 'info', message: 'got application access token successfully' })\n }\n }\n }\n\n async refreshOauth2AccessToken() {\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({\n mutation: gql`\n mutation($id: String!) { refreshOauth2AccessToken(id: $id) { ${OAUTH2CLIENT}\n }\n }\n `,\n variables: { id: this.lifecycle.resourceId }\n })\n\n if (response.errors) {\n notify({ level: 'error', message: 'getting application access token fail' })\n } else {\n this.oauth2Client = response.data.refreshOauth2AccessToken\n notify({ level: 'info', message: 'got application access token successfully' })\n }\n }\n}\n"]}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import '@material/web/button/outlined-button.js';
|
|
1
|
+
export {};
|