Skip to content

Commit a363eec

Browse files
committed
Merge stage
2 parents 68d93f0 + 60f409f commit a363eec

26 files changed

+28239
-9462
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,12 @@
162162

163163

164164

165+
# 4.0.0 (2019-10-13)
166+
167+
168+
### Bug Fixes
169+
170+
* fixing travis config ([c052eb1](https://github.com/advanced-rest-client/api-security-documentation/commit/c052eb1))
171+
172+
173+

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
Documentation view for AMF security model of an API.
1010

11+
## Version compatibility
12+
13+
This version only works with AMF model version 2 (AMF parser >= 4.0.0).
14+
For compatibility with previous model version use `3.x.x` version of the component.
15+
1116
## Usage
1217

1318
### Installation
@@ -16,7 +21,7 @@ npm install --save @api-components/api-security-documentation
1621
```
1722

1823
The component requires to set 2 properties: `amf` and `security`.
19-
The `amf` property is the whole API model generated by the AMF parser. This property is used to resolve compact moodel's keys.
24+
The `amf` property is the whole API model generated by the AMF parser. This property is used to resolve compact moodel's keys.
2025
The `security` property is the part of the API model describing security method. The shape type is `http://a.ml/vocabularies/security#SecurityScheme`.
2126

2227
### In an html file
@@ -56,7 +61,7 @@ class SampleElement extends PolymerElement {
5661
customElements.define('sample-element', SampleElement);
5762
```
5863

59-
### Development
64+
## Development
6065

6166
```sh
6267
git clone https://github.com/advanced-rest-client/api-security-documentation
@@ -75,6 +80,6 @@ npm start
7580
npm test
7681
```
7782

78-
### API components
83+
## API components
7984

8085
This components is a part of [API components ecosystem](https://elements.advancedrestclient.com/)

api-oauth1-settings-document.d.ts

Lines changed: 1 addition & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -10,133 +10,5 @@
1010

1111

1212
// tslint:disable:variable-name Describing an API that's defined elsewhere.
13-
// tslint:disable:no-any describes the API as best we are able today
1413

15-
import {LitElement, html, css} from 'lit-element';
16-
17-
import {AmfHelperMixin} from '@api-components/amf-helper-mixin/amf-helper-mixin.js';
18-
19-
declare namespace ApiElements {
20-
21-
/**
22-
* `api-oauth1-settings-document`
23-
*
24-
* Documentation view for AMF OAuth2 security settings.
25-
*
26-
* Settings can be passed by setting the `settings` property to AMF's
27-
* settings property of Security Scheme.
28-
*
29-
* ```html
30-
* <api-oauth1-settings-document
31-
* amf-model="{...}"
32-
* settings="{...}"></api-oauth1-settings-document>
33-
* ```
34-
*
35-
* It is also possible to set corresponding properties directly.
36-
*
37-
* ```html
38-
* <api-oauth1-settings-document
39-
* amf-model="{...}"
40-
* request-token-uri="https://..."
41-
* authorization-uri="https://..."
42-
* signatures='["RSA-SHA1"]'></api-oauth1-settings-document>
43-
* ```
44-
*
45-
* ## Styling
46-
*
47-
* `<api-oauth1-settings-document>` provides the following custom properties and mixins for styling:
48-
*
49-
* Custom property | Description | Default
50-
* ----------------|-------------|----------
51-
* `--api-oauth1-settings-document` | Mixin applied to this elment | `{}`
52-
*/
53-
class ApiOauth1SettingsDocument extends
54-
AmfHelperMixin(
55-
Object) {
56-
57-
/**
58-
* OAuth1 settings scheme of AMF.
59-
* When this property changes it resets other properties.
60-
*/
61-
settings: object|null;
62-
63-
/**
64-
* The request token URI from the settings model.
65-
* Automatically set when `settings` property change.
66-
*/
67-
requestTokenUri: string|null|undefined;
68-
69-
/**
70-
* The authorization endpoint URI.
71-
* Automatically set when `settings` property change.
72-
*/
73-
authorizationUri: string|null|undefined;
74-
75-
/**
76-
* Token credentials endpoint URI.
77-
* Automatically set when `settings` property change.
78-
*/
79-
tokenCredentialsUri: string|null|undefined;
80-
81-
/**
82-
* List of signatures used by this authorization server.
83-
* Automatically set when `settings` property change.
84-
*/
85-
signatures: Array<String|null>|null;
86-
render(): any;
87-
88-
/**
89-
* Called automatically when `settings` property change (whole object,
90-
* not sub property).
91-
* Sets values of all other properties to the one found in the AMF.
92-
*
93-
* @param settings AMF settings to process.
94-
*/
95-
_settingsChanged(settings: object|null): void;
96-
97-
/**
98-
* If passed argument is an array it returns first object from it. Otherwise
99-
* it returns the object.
100-
*/
101-
_deArray(result: any|null): any|null;
102-
103-
/**
104-
* Computes value of request token endpoint URI.
105-
*
106-
* @param settings AMF settings to process.
107-
* @returns Request token URI value
108-
*/
109-
_computeRequestTokenUri(settings: object|null): String|null|undefined;
110-
111-
/**
112-
* Computes value of authorization endpoint URI.
113-
*
114-
* @param settings AMF settings to process.
115-
* @returns Authorization URI value
116-
*/
117-
_computeAuthorizationUri(settings: object|null): String|null|undefined;
118-
119-
/**
120-
* Computes value of token credentials endpoint URI.
121-
*
122-
* @param settings AMF settings to process.
123-
* @returns Token credentials URI value
124-
*/
125-
_computeTokenCredentialsUri(settings: object|null): String|null|undefined;
126-
127-
/**
128-
* Computes value of OAuth1 signatures.
129-
*
130-
* @param settings AMF settings to process.
131-
* @returns List of signatures.
132-
*/
133-
_computeSignatures(settings: object|null): Array<String|null>|null|undefined;
134-
}
135-
}
136-
137-
declare global {
138-
139-
interface HTMLElementTagNameMap {
140-
"api-oauth1-settings-document": ApiElements.ApiOauth1SettingsDocument;
141-
}
142-
}
14+
import {ApiOauth1SettingsDocument} from './src/ApiOauth1SettingsDocument.js';

api-oauth1-settings-document.js

Lines changed: 1 addition & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,2 @@
1-
import { LitElement, html, css } from 'lit-element';
2-
import { AmfHelperMixin } from '@api-components/amf-helper-mixin/amf-helper-mixin.js';
3-
/**
4-
* `api-oauth1-settings-document`
5-
*
6-
* Documentation view for AMF OAuth2 security settings.
7-
*
8-
* Settings can be passed by setting the `settings` property to AMF's
9-
* settings property of Security Scheme.
10-
*
11-
* ```html
12-
* <api-oauth1-settings-document
13-
* amf-model="{...}"
14-
* settings="{...}"></api-oauth1-settings-document>
15-
* ```
16-
*
17-
* It is also possible to set corresponding properties directly.
18-
*
19-
* ```html
20-
* <api-oauth1-settings-document
21-
* amf-model="{...}"
22-
* request-token-uri="https://..."
23-
* authorization-uri="https://..."
24-
* signatures='["RSA-SHA1"]'></api-oauth1-settings-document>
25-
* ```
26-
*
27-
* ## Styling
28-
*
29-
* `<api-oauth1-settings-document>` provides the following custom properties and mixins for styling:
30-
*
31-
* Custom property | Description | Default
32-
* ----------------|-------------|----------
33-
* `--api-oauth1-settings-document` | Mixin applied to this elment | `{}`
34-
*
35-
* @customElement
36-
* @polymer
37-
* @demo demo/index.html
38-
* @memberof ApiElements
39-
* @appliesMixin AmfHelperMixin
40-
*/
41-
class ApiOauth1SettingsDocument extends AmfHelperMixin(LitElement) {
42-
get styles() {
43-
return css`:host {
44-
display: block;
45-
}
46-
47-
h4 {
48-
font-size: var(--arc-font-subhead-font-size);
49-
font-weight: var(--arc-font-subhead-font-weight);
50-
line-height: var(--arc-font-subhead-line-height);
51-
}
52-
53-
.settings-value {
54-
background: var(--code-background-color, #f5f2f0);
55-
display: block;
56-
padding: 1em;
57-
margin: .5em 0;
58-
}`;
59-
}
60-
61-
render() {
62-
const { requestTokenUri, authorizationUri, tokenCredentialsUri, signatures } = this;
63-
return html`<style>${this.styles}</style>
64-
${requestTokenUri ? html`<h4 data-type="request-token-uri">Request token URI</h4>
65-
<code class="settings-value">${requestTokenUri}</code>` : undefined}
66-
67-
${authorizationUri ? html`<h4 data-type="authorization-uri">Authorization URI</h4>
68-
<code class="settings-value">${authorizationUri}</code>` : undefined}
69-
70-
${tokenCredentialsUri ? html`<h4 data-type="token-credentials-uri">Token credentials URI</h4>
71-
<code class="settings-value">${tokenCredentialsUri}</code>` : undefined}
72-
73-
${signatures && signatures.length ? html`
74-
<h4 data-type="signatures">Supported signatures</h4>
75-
<ul>
76-
${signatures.map((item) => html`<li>${item}</li>`)}
77-
</ul>
78-
` : undefined}`;
79-
}
80-
81-
static get properties() {
82-
return {
83-
/**
84-
* OAuth1 settings scheme of AMF.
85-
* When this property changes it resets other properties.
86-
* @type {Object}
87-
*/
88-
settings: { type: Object },
89-
/**
90-
* The request token URI from the settings model.
91-
* Automatically set when `settings` property change.
92-
*/
93-
requestTokenUri: { type: String },
94-
/**
95-
* The authorization endpoint URI.
96-
* Automatically set when `settings` property change.
97-
*/
98-
authorizationUri: { type: String },
99-
/**
100-
* Token credentials endpoint URI.
101-
* Automatically set when `settings` property change.
102-
*/
103-
tokenCredentialsUri: { type: String },
104-
/**
105-
* List of signatures used by this authorization server.
106-
* Automatically set when `settings` property change.
107-
* @type {Array<String>}
108-
*/
109-
signatures: { type: Array }
110-
};
111-
}
112-
113-
get settings() {
114-
return this._settings;
115-
}
116-
117-
set settings(value) {
118-
const old = this._settings;
119-
/* istanbul ignore if */
120-
if (old === value) {
121-
return;
122-
}
123-
this._settings = value;
124-
this._settingsChanged(value);
125-
}
126-
127-
/**
128-
* Called automatically when `settings` property change (whole object,
129-
* not sub property).
130-
* Sets values of all other properties to the one found in the AMF.
131-
*
132-
* @param {Object} settings AMF settings to process.
133-
*/
134-
_settingsChanged(settings) {
135-
const requestTokenUri = this._computeRequestTokenUri(settings);
136-
const authorizationUri = this._computeAuthorizationUri(settings);
137-
const tokenCredentialsUri = this._computeTokenCredentialsUri(settings);
138-
const signatures = this._computeSignatures(settings);
139-
140-
this.requestTokenUri = requestTokenUri;
141-
this.authorizationUri = authorizationUri;
142-
this.tokenCredentialsUri = tokenCredentialsUri;
143-
this.signatures = signatures;
144-
}
145-
/**
146-
* If passed argument is an array it returns first object from it. Otherwise
147-
* it returns the object.
148-
* @param {any} result
149-
* @return {any}
150-
*/
151-
_deArray(result) {
152-
if (result instanceof Array) {
153-
result = result[0];
154-
}
155-
return result;
156-
}
157-
/**
158-
* Computes value of request token endpoint URI.
159-
* @param {Object} settings AMF settings to process.
160-
* @return {String|undefined} Request token URI value
161-
*/
162-
_computeRequestTokenUri(settings) {
163-
const result = this._getValue(settings, this.ns.raml.vocabularies.security + 'requestTokenUri');
164-
return this._deArray(result);
165-
}
166-
/**
167-
* Computes value of authorization endpoint URI.
168-
* @param {Object} settings AMF settings to process.
169-
* @return {String|undefined} Authorization URI value
170-
*/
171-
_computeAuthorizationUri(settings) {
172-
const result = this._getValue(settings, this.ns.raml.vocabularies.security + 'authorizationUri');
173-
return this._deArray(result);
174-
}
175-
/**
176-
* Computes value of token credentials endpoint URI.
177-
* @param {Object} settings AMF settings to process.
178-
* @return {String|undefined} Token credentials URI value
179-
*/
180-
_computeTokenCredentialsUri(settings) {
181-
const result = this._getValue(settings, this.ns.raml.vocabularies.security + 'tokenCredentialsUri');
182-
return this._deArray(result);
183-
}
184-
/**
185-
* Computes value of OAuth1 signatures.
186-
* @param {Object} settings AMF settings to process.
187-
* @return {Array<String>|undefined} List of signatures.
188-
*/
189-
_computeSignatures(settings) {
190-
return this._getValueArray(settings, this.ns.raml.vocabularies.security + 'signature');
191-
}
192-
}
1+
import { ApiOauth1SettingsDocument } from './src/ApiOauth1SettingsDocument.js';
1932
window.customElements.define('api-oauth1-settings-document', ApiOauth1SettingsDocument);

0 commit comments

Comments
 (0)