Skip to content

Commit fe93ec2

Browse files
committed
chore: updating ARC's dependency
Signed-off-by: Pawel Psztyc <[email protected]>
1 parent b4eaa7d commit fe93ec2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+14803
-1523
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This project replaces all `api-*` components from this organization and consolid
66

77
[![Published on NPM](https://img.shields.io/npm/v/@api-components/amf-components.svg)](https://www.npmjs.com/package/@api-components/amf-components)
88

9-
[![Tests and publishing](https://github.com/advanced-rest-client/amf-components/actions/workflows/deployment.yml/badge.svg)](https://github.com/advanced-rest-client/amf-components/actions/workflows/deployment.yml)
9+
[![Tests and publishing](https://github.com/api-components/amf-components/actions/workflows/deployment.yml/badge.svg)](https://github.com/api-components/amf-components/actions/workflows/deployment.yml)
1010

1111
## Usage
1212

@@ -84,7 +84,7 @@ await MonacoLoader.monacoReady();
8484
## Development
8585

8686
```sh
87-
git clone https://github.com/advanced-rest-client/amf-components
87+
git clone https://github.com/api-components/amf-components
8888
cd amf-components
8989
npm install
9090
```

demo/api-annotation.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class ComponentPage extends AmfDemoBase {
1515
this.shape = undefined;
1616
this.serializer = new AmfSerializer();
1717
this.componentName = 'api-annotation-document';
18-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
1918
}
2019

2120
/** @param {string} file */

demo/api-channel.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { html } from 'lit-html';
22
import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js';
3-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
43
import '@anypoint-web-components/awc/anypoint-checkbox.js';
54
import { AmfDemoBase } from './lib/AmfDemoBase.js';
65
import '../define/api-channel-document.js';
@@ -17,7 +16,6 @@ class ComponentPage extends AmfDemoBase {
1716
this.selectedType = undefined;
1817
this.selectedOperation = undefined;
1918
this.componentName = 'api-channel-document';
20-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
2119
}
2220

2321
/**

demo/api-console.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import '@anypoint-web-components/awc/anypoint-menu-button.js';
55
import '@anypoint-web-components/awc/anypoint-listbox.js';
66
import '@anypoint-web-components/awc/anypoint-item.js';
77
import '@advanced-rest-client/icons/arc-icon.js';
8-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
98
import { MonacoLoader } from "@advanced-rest-client/monaco-support";
109
import { ApplicationPage } from "./lib/ApplicationPage.js";
1110
import { findRoute, navigate } from './lib/route.js';
@@ -118,10 +117,6 @@ export class ApiConsole extends ApplicationPage {
118117
* When the current domain type is an operation this is the selected operation domain id.
119118
*/
120119
this.operationId = undefined;
121-
/**
122-
* The OAuth 2 redirect URI.
123-
*/
124-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
125120
/**
126121
* The title of the currently loaded API.
127122
* @type string
@@ -446,10 +441,9 @@ export class ApiConsole extends ApplicationPage {
446441
return html`
447442
<nav class="${classMap(classes)}">
448443
<api-navigation
449-
.amf="${model}"
450444
summary
451445
endpointsOpened
452-
noOverview
446+
layout="natural"
453447
></api-navigation>
454448
</nav>`;
455449
}
@@ -480,7 +474,6 @@ export class ApiConsole extends ApplicationPage {
480474
tryItPanel
481475
>
482476
</api-documentation>
483-
<oauth2-authorization></oauth2-authorization>
484477
<xhr-simple-request></xhr-simple-request>
485478
`;
486479
}

demo/api-documentation-partial.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js';
33
import '@anypoint-web-components/awc/anypoint-checkbox.js';
44
import '@anypoint-web-components/awc/anypoint-dialog.js';
55
import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js';
6-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
76
import { AmfDemoBase } from './lib/AmfDemoBase.js';
87
import { AmfPartialGraphStore } from './lib/AmfPartialGraphStore.js';
98
import '../define/api-documentation.js';
@@ -49,8 +48,6 @@ class ComponentDemo extends AmfDemoBase {
4948
this.tryItButton = true;
5049
this.tryItPanel = true;
5150
this.overrideBaseUri = false;
52-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
53-
// this.redirectUri = 'https://auth.advancedrestclient.com/oauth-popup.html';
5451
this.renderCustomServer = false;
5552
this.noServerSelector = false;
5653
this.allowCustomBaseUri = false;
@@ -167,7 +164,6 @@ class ComponentDemo extends AmfDemoBase {
167164

168165
contentTemplate() {
169166
return html`
170-
<oauth2-authorization></oauth2-authorization>
171167
<xhr-simple-request></xhr-simple-request>
172168
<h2>API documentation with partial model</h2>
173169
${this.demoTemplate()}
@@ -357,7 +353,6 @@ class ComponentDemo extends AmfDemoBase {
357353
return html`
358354
<api-navigation
359355
summary
360-
.amf="${this.amf}"
361356
endpointsOpened
362357
></api-navigation>`;
363358
}

demo/api-documentation.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js';
33
import '@anypoint-web-components/awc/anypoint-checkbox.js';
44
import '@anypoint-web-components/awc/anypoint-dialog.js';
55
import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js';
6-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
76
import { AmfDemoBase } from './lib/AmfDemoBase.js';
87
import '../define/api-request.js';
98
import '../define/xhr-simple-request.js';
@@ -35,8 +34,6 @@ class ComponentDemo extends AmfDemoBase {
3534
this.tryItButton = true;
3635
this.tryItPanel = false;
3736
this.overrideBaseUri = false;
38-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
39-
// this.redirectUri = 'https://auth.advancedrestclient.com/oauth-popup.html';
4037
this.renderCustomServer = false;
4138
this.noServerSelector = false;
4239
this.allowCustomBaseUri = false;
@@ -90,7 +87,6 @@ class ComponentDemo extends AmfDemoBase {
9087

9188
contentTemplate() {
9289
return html`
93-
<oauth2-authorization></oauth2-authorization>
9490
<xhr-simple-request></xhr-simple-request>
9591
<h2>API documentation</h2>
9692
${this.demoTemplate()}

demo/api-editor.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import '@anypoint-web-components/awc/anypoint-menu-button.js';
55
import '@anypoint-web-components/awc/anypoint-listbox.js';
66
import '@anypoint-web-components/awc/anypoint-item.js';
77
import '@advanced-rest-client/icons/arc-icon.js';
8-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
98
import { MonacoTheme, MonacoStyles, MonacoLoader } from '@advanced-rest-client/monaco-support';
109
import { DomEventsAmfStore } from "../src/store/DomEventsAmfStore.js";
1110
import { ApplicationPage } from "./lib/ApplicationPage.js";
@@ -81,10 +80,6 @@ export class ApiTextEditor extends ApplicationPage {
8180
* When the current domain type is an operation this is the selected operation domain id.
8281
*/
8382
this.operationId = undefined;
84-
/**
85-
* The OAuth 2 redirect URI.
86-
*/
87-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
8883
/** @type string */
8984
this.apiFormat = 'RAML 1.0';
9085
/** @type string */
@@ -712,9 +707,7 @@ export class ApiTextEditor extends ApplicationPage {
712707
</div>
713708
<api-navigation
714709
summary
715-
.amf="${model}"
716710
endpointsOpened
717-
noOverview
718711
></api-navigation>
719712
</nav>`;
720713
}
@@ -766,7 +759,6 @@ export class ApiTextEditor extends ApplicationPage {
766759
@tryit="${this.tryitHandler}"
767760
>
768761
</api-documentation>
769-
<oauth2-authorization></oauth2-authorization>
770762
<xhr-simple-request></xhr-simple-request>
771763
`;
772764
}

demo/api-operation.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js';
33
import '@anypoint-web-components/awc/anypoint-checkbox.js';
44
import '@anypoint-web-components/awc/anypoint-dialog.js';
55
import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js';
6-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
76
import { AmfDemoBase } from './lib/AmfDemoBase.js';
87
import '../define/api-operation-document.js';
98
import '../define/api-request.js';
@@ -33,7 +32,7 @@ class ComponentPage extends AmfDemoBase {
3332
this.renderSecurity = true;
3433
this.renderCodeSnippets = true;
3534
this.componentName = 'api-operation-document';
36-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
35+
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth/oauth-popup.html`;
3736
}
3837

3938
get baseUri() {
@@ -107,7 +106,6 @@ class ComponentPage extends AmfDemoBase {
107106

108107
contentTemplate() {
109108
return html`
110-
<oauth2-authorization></oauth2-authorization>
111109
<xhr-simple-request></xhr-simple-request>
112110
<h2>API operation</h2>
113111
${this.demoTemplate()}

demo/api-request.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { html } from 'lit-html';
22
import '@anypoint-web-components/awc/anypoint-checkbox.js';
33
import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js';
4-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
5-
import '@advanced-rest-client/app/define/oauth1-authorization.js';
6-
import '@advanced-rest-client/app/define/oidc-authorization.js';
74
import { AmfDemoBase } from './lib/AmfDemoBase.js';
85
import '../define/api-navigation.js';
96
import '../define/xhr-simple-request.js';
@@ -43,8 +40,6 @@ class ComponentDemo extends AmfDemoBase {
4340
this.urlEditor = true;
4441

4542
this.demoStates = ['Filled', 'Outlined', 'Anypoint'];
46-
/* eslint-disable-next-line no-restricted-globals */
47-
this.redirectUri = `${location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
4843
}
4944

5045
_demoStateHandler(e) {
@@ -131,9 +126,6 @@ class ComponentDemo extends AmfDemoBase {
131126

132127
contentTemplate() {
133128
return html`
134-
<oauth2-authorization></oauth2-authorization>
135-
<oauth1-authorization></oauth1-authorization>
136-
<oidc-authorization></oidc-authorization>
137129
<xhr-simple-request></xhr-simple-request>
138130
<h2 class="centered main">API request</h2>
139131
${this.demoTemplate()}

demo/api-resource.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js';
33
import '@anypoint-web-components/awc/anypoint-checkbox.js';
44
import '@anypoint-web-components/awc/anypoint-dialog.js';
55
import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js';
6-
import '@advanced-rest-client/app/define/oauth2-authorization.js';
76
import { AmfDemoBase } from './lib/AmfDemoBase.js';
87
import '../define/api-resource-document.js';
98
import '../define/api-request.js';
@@ -29,7 +28,6 @@ class ComponentPage extends AmfDemoBase {
2928
this.tryItPanel = false;
3029
this.overrideBaseUri = false;
3130
this.componentName = 'api-endpoint-document';
32-
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth-authorization/oauth-popup.html`;
3331
}
3432

3533
get baseUri() {
@@ -107,7 +105,6 @@ class ComponentPage extends AmfDemoBase {
107105

108106
contentTemplate() {
109107
return html`
110-
<oauth2-authorization></oauth2-authorization>
111108
<xhr-simple-request></xhr-simple-request>
112109
<h2>API endpoint</h2>
113110
${this.demoTemplate()}

demo/lib/AmfDemoBase.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { MonacoLoader } from "@advanced-rest-client/monaco-support";
44
import '@anypoint-web-components/awc/anypoint-dropdown-menu.js';
55
import '@anypoint-web-components/awc/anypoint-listbox.js';
66
import '@anypoint-web-components/awc/anypoint-item.js';
7+
import { EventTypes as ArcEventTypes } from '@advanced-rest-client/events';
8+
import { OAuth2Authorization, OidcAuthorization } from '@advanced-rest-client/oauth';
79
import { DomEventsAmfStore } from "../../src/store/DomEventsAmfStore.js";
810
import { AmfHelperMixin } from "../../src/helpers/AmfHelperMixin.js";
911
import { EventTypes } from '../../src/events/EventTypes.js';
@@ -13,6 +15,12 @@ import './ApiStyles.js';
1315

1416
/** @typedef {import('lit-html').TemplateResult} TemplateResult */
1517
/** @typedef {import('@anypoint-web-components/awc').AnypointListboxElement} AnypointListbox */
18+
/** @typedef {import('@advanced-rest-client/events').OAuth2AuthorizeEvent} OAuth2AuthorizeEvent */
19+
/** @typedef {import('@advanced-rest-client/events').OidcAuthorizeEvent} OidcAuthorizeEvent */
20+
/** @typedef {import('@advanced-rest-client/events').Authorization.TokenInfo} TokenInfo */
21+
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2Authorization} OAuth2Settings */
22+
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenInfo} OidcTokenInfo */
23+
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenError} OidcTokenError */
1624
/** @typedef {import('../../src/events/NavigationEvents').ApiNavigationEvent} ApiNavigationEvent */
1725
/** @typedef {import('../../src/events/ReportingEvents').ReportingErrorEventDetail} ReportingErrorEventDetail */
1826
/** @typedef {import('../../').AmfStore} AmfStore */
@@ -42,7 +50,7 @@ export class AmfDemoBase extends AmfHelperMixin(DemoPage) {
4250

4351
constructor() {
4452
super();
45-
this.initObservableProperties(["initialized", "loaded", 'selectedFile']);
53+
this.initObservableProperties(["initialized", "loaded", 'selectedFile', 'redirectUri']);
4654
/** @type {AmfStore & AmfStoreDomEventsMixin} */
4755
this.store = new DomEventsAmfStore(window);
4856
this.store.listen();
@@ -95,6 +103,10 @@ export class AmfDemoBase extends AmfHelperMixin(DemoPage) {
95103
* @type {string}
96104
*/
97105
this.selectedFile = undefined;
106+
this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth/oauth-popup.html`;
107+
window.addEventListener(ArcEventTypes.Authorization.OAuth2.authorize, this.oauth2authorizeHandler.bind(this));
108+
window.addEventListener(ArcEventTypes.Authorization.Oidc.authorize, this.oidcAuthorizeHandler.bind(this));
109+
98110
window.addEventListener(EventTypes.Navigation.apiNavigate, this._navChanged.bind(this));
99111
window.addEventListener(EventTypes.Reporting.error, this._errorHandler.bind(this));
100112

@@ -189,6 +201,47 @@ export class AmfDemoBase extends AmfHelperMixin(DemoPage) {
189201
this.loaded = true;
190202
}
191203

204+
/**
205+
* @param {OAuth2AuthorizeEvent} e
206+
*/
207+
oauth2authorizeHandler(e) {
208+
e.preventDefault();
209+
const config = { ...e.detail };
210+
e.detail.result = this.authorizeOauth2(config);
211+
}
212+
213+
/**
214+
* Authorize the user using provided settings.
215+
*
216+
* @param {OAuth2Settings} settings The authorization configuration.
217+
* @returns {Promise<TokenInfo>}
218+
*/
219+
async authorizeOauth2(settings) {
220+
const auth = new OAuth2Authorization(settings);
221+
auth.checkConfig();
222+
return auth.authorize();
223+
}
224+
225+
/**
226+
* @param {OidcAuthorizeEvent} e
227+
*/
228+
oidcAuthorizeHandler(e) {
229+
const config = { ...e.detail };
230+
e.detail.result = this.authorizeOidc(config);
231+
}
232+
233+
/**
234+
* Authorize the user using provided settings.
235+
*
236+
* @param {OAuth2Settings} settings The authorization configuration.
237+
* @returns {Promise<(OidcTokenInfo|OidcTokenError)[]>}
238+
*/
239+
async authorizeOidc(settings) {
240+
const auth = new OidcAuthorization(settings);
241+
auth.checkConfig();
242+
return auth.authorize();
243+
}
244+
192245
/**
193246
* This method to be overridden in child class to handle navigation.
194247
* @param {ApiNavigationEvent} e Dispatched navigation event

demo/lib/ApplicationPage.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Authorization, OAuth2AuthorizeEvent, OidcAuthorizeEvent } from '@advanced-rest-client/events';
12
import { ReactiveMixin } from './mixins/ReactiveMixin.js';
23
import { RenderableMixin } from './mixins/RenderableMixin.js';
34

@@ -21,8 +22,27 @@ export declare class ApplicationPage extends RenderableMixin(ReactiveMixin(Event
2122
* True when the app should render mobile friendly view.
2223
*/
2324
isMobile: boolean;
25+
redirectUri: string;
2426
/**
2527
* Initializes media queries and observers.
2628
*/
2729
initMediaQueries(): void;
30+
31+
oauth2authorizeHandler(e: OAuth2AuthorizeEvent): void;
32+
33+
/**
34+
* Authorize the user using provided settings.
35+
*
36+
* @param settings The authorization configuration.
37+
*/
38+
authorizeOauth2(settings: Authorization.OAuth2Authorization): Promise<Authorization.TokenInfo>;
39+
40+
oidcAuthorizeHandler(e: OidcAuthorizeEvent): void;
41+
42+
/**
43+
* Authorize the user using provided settings.
44+
*
45+
* @param settings The authorization configuration.
46+
*/
47+
authorizeOidc(settings: Authorization.OAuth2Authorization): Promise<(Authorization.OidcTokenInfo|Authorization.OidcTokenError)[]>;
2848
}

0 commit comments

Comments
 (0)