@things-factory/oauth2-client 7.0.1-beta.6 → 7.0.1-beta.7

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.
@@ -48,7 +48,7 @@ export class Oauth2ClientRegister extends connect(store)(PageView) {
48
48
  }
49
49
  label {
50
50
  font: var(--label-font);
51
- color: var(--label-color);
51
+ color: var(--label-color, var(--md-sys-color-on-surface));
52
52
  text-transform: var(--label-text-transform);
53
53
  }
54
54
  input,
@@ -91,7 +91,7 @@ export class Oauth2Client extends connect(store)(PageView) {
91
91
  }
92
92
  label {
93
93
  font: var(--label-font);
94
- color: var(--label-color);
94
+ color: var(--label-color, var(--md-sys-color-on-surface));
95
95
  text-transform: var(--label-text-transform);
96
96
  }
97
97
  input,
@@ -134,7 +134,7 @@ Oauth2ClientRegister.styles = [
134
134
  }
135
135
  label {
136
136
  font: var(--label-font);
137
- color: var(--label-color);
137
+ color: var(--label-color, var(--md-sys-color-on-surface));
138
138
  text-transform: var(--label-text-transform);
139
139
  }
140
140
  input,
@@ -1 +1 @@
1
- {"version":3,"file":"oauth2-client-register.js","sourceRoot":"","sources":["../../client/pages/oauth2-client-register.ts"],"names":[],"mappings":";AAAA,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,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAGnD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,OAAO,CAAC,KAAK,CAAC,C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B,CAAC,EAAE,CAAA;YAC9C,QAAQ,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;SAChC;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM;QAC1C,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;SAClB;IACH,CAAC;;AA9KM,2BAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyEF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAe;AAE1C;IAAC,KAAK,CAAC,MAAM,CAAC;8BAAQ,eAAe;kDAAA;AAjF1B,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CAgLhC;SAhLY,oBAAoB","sourcesContent":["import gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView, store } from '@operato/shell'\n\n@customElement('oauth2-client-register')\nexport class Oauth2ClientRegister extends connect(store)(PageView) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--md-sys-color-background);\n padding: var(--padding-wide);\n\n position: relative;\n\n overflow: auto;\n }\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n }\n [page-description] {\n margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n }\n [icon] {\n position: absolute;\n top: 10px;\n right: 10px;\n\n max-width: 80px;\n }\n [icon] img {\n max-width: 100%;\n max-height: 100%;\n }\n\n :host * {\n display: block;\n }\n label {\n font: var(--label-font);\n color: var(--label-color);\n text-transform: var(--label-text-transform);\n }\n input,\n select {\n border: var(--border-dark-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 select:focus,\n input:focus {\n outline: none;\n }\n\n [field-2column] {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n }\n [field] {\n display: flex;\n flex-direction: column;\n }\n [grid-span] {\n grid-column: span 2;\n }\n @media screen and (max-width: 480px) {\n [field] {\n grid-column: span 2;\n }\n }\n `\n ]\n\n @property({ type: Object }) application: any\n @property({ type: String }) _icon?: string\n\n @query('form') form!: HTMLFormElement\n\n get context() {\n return {\n title: `oauth2 client registration`\n }\n }\n\n render() {\n return html`\n <h2>Register new oauth2 client</h2>\n <p page-description>You can register new oauth2 client here</p>\n\n ${this._icon\n ? html`\n <div icon>\n <img src=${this._icon} />\n </div>\n `\n : html``}\n\n <form>\n <div field-2column>\n <div field grid-span>\n <label for=\"name\">name</label>\n <input type=\"text\" id=\"name\" name=\"name\" />\n </div>\n\n <div field grid-span>\n <label for=\"description\">description</label>\n <input type=\"text\" id=\"description\" name=\"description\" />\n </div>\n\n <div field grid-span>\n <label for=\"icon\">icon</label>\n <input type=\"text\" id=\"icon\" name=\"icon\" @change=${e => (this._icon = e.target.value)} />\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\" />\n The client identifier issued to the client during the application registration process.\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\" />\n The client secret issued to the client during the application registration process.\n </div>\n </div>\n\n <mwc-button raised @click=${this.createOauth2Client.bind(this)}>register</mwc-button>\n </form>\n `\n }\n\n async createOauth2Client(e) {\n e.preventDefault()\n\n const formData = new FormData(this.form)\n\n const oauth2Client = Array.from(formData.entries()).reduce((oauth2Client, [key, value]) => {\n oauth2Client[key] = value\n return oauth2Client\n }, {})\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($oauth2Client: NewOauth2Client!) {\n createOauth2Client(oauth2Client: $oauth2Client) {\n id\n }\n }\n `,\n variables: {\n oauth2Client\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'create oauth2 client fail'\n })\n } else {\n const id = response.data.createOauth2Client.id\n navigate(`oauth2-client/${id}`)\n }\n }\n\n async pageUpdated(changes, lifecycle, before) {\n if (this.active) {\n this.form.reset()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"oauth2-client-register.js","sourceRoot":"","sources":["../../client/pages/oauth2-client-register.ts"],"names":[],"mappings":";AAAA,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,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAGnD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;IAmFhE,IAAI,OAAO;QACT,OAAO;YACL,KAAK,EAAE,4BAA4B;SACpC,CAAA;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;QAIP,IAAI,CAAC,KAAK;YACV,CAAC,CAAC,IAAI,CAAA;;yBAEW,IAAI,CAAC,KAAK;;WAExB;YACH,CAAC,CAAC,IAAI,CAAA,EAAE;;;;;;;;;;;;;;;;+DAgB+C,CAAC,CAAC,EAAE,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyEF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAe;AAE1C;IAAC,KAAK,CAAC,MAAM,CAAC;8BAAQ,eAAe;kDAAA;AAjF1B,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CAgLhC;SAhLY,oBAAoB","sourcesContent":["import gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView, store } from '@operato/shell'\n\n@customElement('oauth2-client-register')\nexport class Oauth2ClientRegister extends connect(store)(PageView) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--md-sys-color-background);\n padding: var(--padding-wide);\n\n position: relative;\n\n overflow: auto;\n }\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n }\n [page-description] {\n margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n }\n [icon] {\n position: absolute;\n top: 10px;\n right: 10px;\n\n max-width: 80px;\n }\n [icon] img {\n max-width: 100%;\n max-height: 100%;\n }\n\n :host * {\n display: block;\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 input,\n select {\n border: var(--border-dark-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 select:focus,\n input:focus {\n outline: none;\n }\n\n [field-2column] {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n }\n [field] {\n display: flex;\n flex-direction: column;\n }\n [grid-span] {\n grid-column: span 2;\n }\n @media screen and (max-width: 480px) {\n [field] {\n grid-column: span 2;\n }\n }\n `\n ]\n\n @property({ type: Object }) application: any\n @property({ type: String }) _icon?: string\n\n @query('form') form!: HTMLFormElement\n\n get context() {\n return {\n title: `oauth2 client registration`\n }\n }\n\n render() {\n return html`\n <h2>Register new oauth2 client</h2>\n <p page-description>You can register new oauth2 client here</p>\n\n ${this._icon\n ? html`\n <div icon>\n <img src=${this._icon} />\n </div>\n `\n : html``}\n\n <form>\n <div field-2column>\n <div field grid-span>\n <label for=\"name\">name</label>\n <input type=\"text\" id=\"name\" name=\"name\" />\n </div>\n\n <div field grid-span>\n <label for=\"description\">description</label>\n <input type=\"text\" id=\"description\" name=\"description\" />\n </div>\n\n <div field grid-span>\n <label for=\"icon\">icon</label>\n <input type=\"text\" id=\"icon\" name=\"icon\" @change=${e => (this._icon = e.target.value)} />\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\" />\n The client identifier issued to the client during the application registration process.\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\" />\n The client secret issued to the client during the application registration process.\n </div>\n </div>\n\n <mwc-button raised @click=${this.createOauth2Client.bind(this)}>register</mwc-button>\n </form>\n `\n }\n\n async createOauth2Client(e) {\n e.preventDefault()\n\n const formData = new FormData(this.form)\n\n const oauth2Client = Array.from(formData.entries()).reduce((oauth2Client, [key, value]) => {\n oauth2Client[key] = value\n return oauth2Client\n }, {})\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($oauth2Client: NewOauth2Client!) {\n createOauth2Client(oauth2Client: $oauth2Client) {\n id\n }\n }\n `,\n variables: {\n oauth2Client\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'create oauth2 client fail'\n })\n } else {\n const id = response.data.createOauth2Client.id\n navigate(`oauth2-client/${id}`)\n }\n }\n\n async pageUpdated(changes, lifecycle, before) {\n if (this.active) {\n this.form.reset()\n }\n }\n}\n"]}
@@ -470,7 +470,7 @@ Oauth2Client.styles = [
470
470
  }
471
471
  label {
472
472
  font: var(--label-font);
473
- color: var(--label-color);
473
+ color: var(--label-color, var(--md-sys-color-on-surface));
474
474
  text-transform: var(--label-text-transform);
475
475
  }
476
476
  input,
@@ -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,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBpB,CAAA;AAGM,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;IA2JxD,IAAI,OAAO;;QACT,OAAO;YACL,KAAK,EAAE;gBACL,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI;aAC9B;SAC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;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAkB;AAC7C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAoB;AAE/C;IAAC,KAAK,CAAC,MAAM,CAAC;8BAAQ,eAAe;0CAAA;AACrC;IAAC,QAAQ,CAAC,kBAAkB,CAAC;;iDAAY;AAtJ9B,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAsjBxB;SAtjBY,YAAY","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 { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView, store } 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 connect(store)(PageView) {\n static styles = [\n css`\n :host {\n 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(--padding-wide);\n }\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n }\n [page-description] {\n margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n }\n [icon] {\n position: absolute;\n top: 10px;\n right: 10px;\n max-width: 80px;\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 [button-primary]:hover {\n background-color: var(--button-primary-active-background-color);\n box-shadow: var(--button-active-box-shadow);\n }\n label {\n font: var(--label-font);\n color: var(--label-color);\n text-transform: var(--label-text-transform);\n }\n input,\n select {\n border: var(--border-dark-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 select:focus,\n input:focus,\n button {\n outline: none;\n }\n form {\n max-width: var(--content-container-max-width);\n }\n [fieldset-container] {\n background-color: var(--md-sys-color-surface);\n margin: var(--margin-wide) 0 var(--margin-default) 0;\n padding: var(--padding-default);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n }\n [fieldset-container] fieldset {\n margin: 0;\n margin-top: -15px;\n }\n fieldset {\n border-radius: var(--border-radius);\n border: var(--border-dark-color);\n margin: var(--fieldset-margin);\n padding: var(--fieldset-padding);\n }\n legend {\n padding: var(--legend-padding);\n font-weight: bold;\n color: var(--legend-color);\n }\n [field-2column] {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n }\n [field] {\n display: flex;\n flex-direction: column;\n position: relative;\n }\n [grid-span] {\n grid-column: span 2;\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(--margin-default) 0 var(--margin-default) var(--margin-default);\n float: right;\n text-decoration: none;\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 [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 [input-hint] {\n font: var(--input-hint-font);\n color: var(--input-hint-color);\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 return {\n title: {\n icon: 'apps',\n text: this.oauth2Client?.name\n }\n }\n }\n\n render() {\n var oauth2Client = this.oauth2Client || {}\n\n return html`\n <div>\n <h2><md-icon>apps</md-icon>&nbsp;${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=${\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 <button @click=${e => this.deleteOauth2Client(e)}>delete this app</button>\n <button @click=${async e => {\n e.preventDefault()\n await this.updateOauth2Client()\n await this.generateOauth2AccessToken()\n }}>get new access token</button>\n <button @click=${async e => {\n 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 => {\n e.preventDefault()\n await this.updateOauth2Client()\n }}>\n </form>\n `\n }\n\n updated(changes) {\n if (changes.has('oauth2Client')) {\n this._grantType = this.oauth2Client?.grantType\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!) {\n oauth2Client(id: $id) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id: this.lifecycle.resourceId\n }\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!) {\n updateOauth2Client(id: $id, patch: $patch) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id,\n patch\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'update oauth2 client fail'\n })\n } else {\n this.oauth2Client = response.data.updateOauth2Client\n }\n }\n\n async deleteOauth2Client(e) {\n e.preventDefault()\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: {\n id\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'delete oauth2 client fail'\n })\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: {\n id: this.lifecycle.resourceId\n }\n })\n\n if (!response.errors) {\n location.href = response.data.getOauth2AuthUrl\n } else {\n notify({\n level: 'error',\n message: 'getting application access token fail'\n })\n }\n } else {\n const response = await client.mutate({\n mutation: gql`\n mutation($id: String!) {\n getOauth2AccessToken(id: $id) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id: this.lifecycle.resourceId\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'getting application access token fail'\n })\n } else {\n this.oauth2Client = response.data.getOauth2AccessToken\n notify({\n level: 'info',\n message: 'got application access token successfully'\n })\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!) {\n refreshOauth2AccessToken(id: $id) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id: this.lifecycle.resourceId\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'getting application access token fail'\n })\n } else {\n this.oauth2Client = response.data.refreshOauth2AccessToken\n notify({\n level: 'info',\n message: 'got application access token successfully'\n })\n }\n }\n}\n"]}
1
+ {"version":3,"file":"oauth2-client.js","sourceRoot":"","sources":["../../client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,eAAe,CAAC;GAClB,YAAY,CAsjBxB;SAtjBY,YAAY","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 { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView, store } 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 connect(store)(PageView) {\n static styles = [\n css`\n :host {\n 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(--padding-wide);\n }\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n }\n [page-description] {\n margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n }\n [icon] {\n position: absolute;\n top: 10px;\n right: 10px;\n max-width: 80px;\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 [button-primary]:hover {\n background-color: var(--button-primary-active-background-color);\n box-shadow: var(--button-active-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 input,\n select {\n border: var(--border-dark-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 select:focus,\n input:focus,\n button {\n outline: none;\n }\n form {\n max-width: var(--content-container-max-width);\n }\n [fieldset-container] {\n background-color: var(--md-sys-color-surface);\n margin: var(--margin-wide) 0 var(--margin-default) 0;\n padding: var(--padding-default);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n }\n [fieldset-container] fieldset {\n margin: 0;\n margin-top: -15px;\n }\n fieldset {\n border-radius: var(--border-radius);\n border: var(--border-dark-color);\n margin: var(--fieldset-margin);\n padding: var(--fieldset-padding);\n }\n legend {\n padding: var(--legend-padding);\n font-weight: bold;\n color: var(--legend-color);\n }\n [field-2column] {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n }\n [field] {\n display: flex;\n flex-direction: column;\n position: relative;\n }\n [grid-span] {\n grid-column: span 2;\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(--margin-default) 0 var(--margin-default) var(--margin-default);\n float: right;\n text-decoration: none;\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 [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 [input-hint] {\n font: var(--input-hint-font);\n color: var(--input-hint-color);\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 return {\n title: {\n icon: 'apps',\n text: this.oauth2Client?.name\n }\n }\n }\n\n render() {\n var oauth2Client = this.oauth2Client || {}\n\n return html`\n <div>\n <h2><md-icon>apps</md-icon>&nbsp;${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=${\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 <button @click=${e => this.deleteOauth2Client(e)}>delete this app</button>\n <button @click=${async e => {\n e.preventDefault()\n await this.updateOauth2Client()\n await this.generateOauth2AccessToken()\n }}>get new access token</button>\n <button @click=${async e => {\n 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 => {\n e.preventDefault()\n await this.updateOauth2Client()\n }}>\n </form>\n `\n }\n\n updated(changes) {\n if (changes.has('oauth2Client')) {\n this._grantType = this.oauth2Client?.grantType\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!) {\n oauth2Client(id: $id) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id: this.lifecycle.resourceId\n }\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!) {\n updateOauth2Client(id: $id, patch: $patch) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id,\n patch\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'update oauth2 client fail'\n })\n } else {\n this.oauth2Client = response.data.updateOauth2Client\n }\n }\n\n async deleteOauth2Client(e) {\n e.preventDefault()\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: {\n id\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'delete oauth2 client fail'\n })\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: {\n id: this.lifecycle.resourceId\n }\n })\n\n if (!response.errors) {\n location.href = response.data.getOauth2AuthUrl\n } else {\n notify({\n level: 'error',\n message: 'getting application access token fail'\n })\n }\n } else {\n const response = await client.mutate({\n mutation: gql`\n mutation($id: String!) {\n getOauth2AccessToken(id: $id) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id: this.lifecycle.resourceId\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'getting application access token fail'\n })\n } else {\n this.oauth2Client = response.data.getOauth2AccessToken\n notify({\n level: 'info',\n message: 'got application access token successfully'\n })\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!) {\n refreshOauth2AccessToken(id: $id) {\n ${OAUTH2CLIENT}\n }\n }\n `,\n variables: {\n id: this.lifecycle.resourceId\n }\n })\n\n if (response.errors) {\n notify({\n level: 'error',\n message: 'getting application access token fail'\n })\n } else {\n this.oauth2Client = response.data.refreshOauth2AccessToken\n notify({\n level: 'info',\n message: 'got application access token successfully'\n })\n }\n }\n}\n"]}