rapidoc 9.3.7 → 10.0.0
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/README.md +193 -61
- package/dist/rapidoc-min.js +279 -3912
- package/package.json +24 -47
- package/.babelrc.json +0 -42
- package/.eslintrc +0 -53
- package/.github/FUNDING.yml +0 -13
- package/.github/workflow/words.yaml +0 -22
- package/CONTRIBUTING.md +0 -35
- package/dist/index.html +0 -6
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js.LICENSE.txt +0 -64
- package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
- package/dist/rapidoc-min.js.gz +0 -0
- package/dist/rapidoc-min.js.map +0 -1
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +0 -21594
- package/dist/report.html +0 -39
- package/index-hashroute.html +0 -65
- package/index.html +0 -249
- package/index1.html +0 -244
- package/jsconfig.json +0 -11
- package/logo.png +0 -0
- package/performance.html +0 -31
- package/src/components/api-request.js +0 -1787
- package/src/components/api-response.js +0 -335
- package/src/components/dialog-box.js +0 -73
- package/src/components/json-tree.js +0 -145
- package/src/components/schema-table.js +0 -358
- package/src/components/schema-tree.js +0 -378
- package/src/components/tag-input.js +0 -135
- package/src/index.js +0 -7
- package/src/json-schema-viewer.js +0 -345
- package/src/oauth-receiver.js +0 -56
- package/src/rapidoc-mini.js +0 -380
- package/src/rapidoc.js +0 -1082
- package/src/styles/border-styles.js +0 -24
- package/src/styles/custom-styles.js +0 -10
- package/src/styles/dialog-box-styles.js +0 -75
- package/src/styles/endpoint-styles.js +0 -202
- package/src/styles/flex-styles.js +0 -15
- package/src/styles/font-styles.js +0 -268
- package/src/styles/info-styles.js +0 -21
- package/src/styles/input-styles.js +0 -202
- package/src/styles/nav-styles.js +0 -198
- package/src/styles/prism-styles.js +0 -105
- package/src/styles/schema-styles.js +0 -121
- package/src/styles/tab-styles.js +0 -47
- package/src/styles/table-styles.js +0 -58
- package/src/templates/advance-search-template.js +0 -72
- package/src/templates/callback-template.js +0 -73
- package/src/templates/code-samples-template.js +0 -34
- package/src/templates/components-template.js +0 -76
- package/src/templates/endpoint-template.js +0 -249
- package/src/templates/expanded-endpoint-template.js +0 -197
- package/src/templates/focused-endpoint-template.js +0 -110
- package/src/templates/header-template.js +0 -66
- package/src/templates/json-schema-viewer-template.js +0 -185
- package/src/templates/logo-template.js +0 -18
- package/src/templates/main-body-template.js +0 -121
- package/src/templates/navbar-template.js +0 -272
- package/src/templates/overview-template.js +0 -79
- package/src/templates/security-scheme-template.js +0 -610
- package/src/templates/server-template.js +0 -115
- package/src/utils/color-utils.js +0 -59
- package/src/utils/common-utils.js +0 -168
- package/src/utils/schema-utils.js +0 -1086
- package/src/utils/spec-parser.js +0 -462
- package/src/utils/theme.js +0 -288
- package/webpack.config.js +0 -142
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import { css, LitElement } from 'lit';
|
|
2
|
-
import { marked } from 'marked';
|
|
3
|
-
import Prism from 'prismjs';
|
|
4
|
-
import 'prismjs/components/prism-css';
|
|
5
|
-
import 'prismjs/components/prism-yaml';
|
|
6
|
-
import 'prismjs/components/prism-go';
|
|
7
|
-
import 'prismjs/components/prism-java';
|
|
8
|
-
import 'prismjs/components/prism-json';
|
|
9
|
-
import 'prismjs/components/prism-bash';
|
|
10
|
-
import 'prismjs/components/prism-python';
|
|
11
|
-
import 'prismjs/components/prism-http';
|
|
12
|
-
import 'prismjs/components/prism-csharp';
|
|
13
|
-
|
|
14
|
-
// Styles
|
|
15
|
-
import FontStyles from '~/styles/font-styles';
|
|
16
|
-
import InputStyles from '~/styles/input-styles';
|
|
17
|
-
import FlexStyles from '~/styles/flex-styles';
|
|
18
|
-
import TableStyles from '~/styles/table-styles';
|
|
19
|
-
import PrismStyles from '~/styles/prism-styles';
|
|
20
|
-
import TabStyles from '~/styles/tab-styles';
|
|
21
|
-
import NavStyles from '~/styles/nav-styles';
|
|
22
|
-
import InfoStyles from '~/styles/info-styles';
|
|
23
|
-
|
|
24
|
-
import EndpointStyles from '~/styles/endpoint-styles';
|
|
25
|
-
import ProcessSpec from '~/utils/spec-parser';
|
|
26
|
-
import jsonSchemaViewerTemplate from '~/templates/json-schema-viewer-template';
|
|
27
|
-
|
|
28
|
-
export default class JsonSchemaViewer extends LitElement {
|
|
29
|
-
constructor() {
|
|
30
|
-
super();
|
|
31
|
-
this.isMini = false;
|
|
32
|
-
this.updateRoute = 'false';
|
|
33
|
-
this.renderStyle = 'focused';
|
|
34
|
-
this.showHeader = 'true';
|
|
35
|
-
this.allowAdvancedSearch = 'false';
|
|
36
|
-
this.selectedExampleForEachSchema = {};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static get properties() {
|
|
40
|
-
return {
|
|
41
|
-
// Spec
|
|
42
|
-
specUrl: { type: String, attribute: 'spec-url' },
|
|
43
|
-
|
|
44
|
-
// Schema Styles
|
|
45
|
-
schemaStyle: { type: String, attribute: 'schema-style' },
|
|
46
|
-
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
|
|
47
|
-
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
|
|
48
|
-
allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
|
|
49
|
-
|
|
50
|
-
// Hide/show Sections
|
|
51
|
-
showHeader: { type: String, attribute: 'show-header' },
|
|
52
|
-
showSideNav: { type: String, attribute: 'show-side-nav' },
|
|
53
|
-
showInfo: { type: String, attribute: 'show-info' },
|
|
54
|
-
|
|
55
|
-
// Allow or restrict features
|
|
56
|
-
allowSpecUrlLoad: { type: String, attribute: 'allow-spec-url-load' },
|
|
57
|
-
allowSpecFileLoad: { type: String, attribute: 'allow-spec-file-load' },
|
|
58
|
-
allowSpecFileDownload: { type: String, attribute: 'allow-spec-file-download' },
|
|
59
|
-
allowSearch: { type: String, attribute: 'allow-search' },
|
|
60
|
-
|
|
61
|
-
// Main Colors and Font
|
|
62
|
-
theme: { type: String },
|
|
63
|
-
bgColor: { type: String, attribute: 'bg-color' },
|
|
64
|
-
textColor: { type: String, attribute: 'text-color' },
|
|
65
|
-
primaryColor: { type: String, attribute: 'primary-color' },
|
|
66
|
-
fontSize: { type: String, attribute: 'font-size' },
|
|
67
|
-
regularFont: { type: String, attribute: 'regular-font' },
|
|
68
|
-
monoFont: { type: String, attribute: 'mono-font' },
|
|
69
|
-
loadFonts: { type: String, attribute: 'load-fonts' },
|
|
70
|
-
|
|
71
|
-
// Internal Properties
|
|
72
|
-
loading: { type: Boolean }, // indicates spec is being loaded
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static get styles() {
|
|
77
|
-
return [
|
|
78
|
-
FontStyles,
|
|
79
|
-
InputStyles,
|
|
80
|
-
FlexStyles,
|
|
81
|
-
TableStyles,
|
|
82
|
-
EndpointStyles,
|
|
83
|
-
PrismStyles,
|
|
84
|
-
TabStyles,
|
|
85
|
-
NavStyles,
|
|
86
|
-
InfoStyles,
|
|
87
|
-
css`
|
|
88
|
-
:host {
|
|
89
|
-
display:flex;
|
|
90
|
-
flex-direction: column;
|
|
91
|
-
min-width:360px;
|
|
92
|
-
width:100%;
|
|
93
|
-
height:100%;
|
|
94
|
-
margin:0;
|
|
95
|
-
padding:0;
|
|
96
|
-
overflow: hidden;
|
|
97
|
-
letter-spacing:normal;
|
|
98
|
-
color:var(--fg);
|
|
99
|
-
background-color:var(--bg);
|
|
100
|
-
font-family:var(--font-regular);
|
|
101
|
-
container-type: inline-size;
|
|
102
|
-
}
|
|
103
|
-
.body {
|
|
104
|
-
display:flex;
|
|
105
|
-
height:100%;
|
|
106
|
-
width:100%;
|
|
107
|
-
overflow:hidden;
|
|
108
|
-
}
|
|
109
|
-
.nav-bar {
|
|
110
|
-
width: 230px;
|
|
111
|
-
display:flex;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.main-content {
|
|
115
|
-
margin:0;
|
|
116
|
-
padding: 16px;
|
|
117
|
-
display:block;
|
|
118
|
-
flex:1;
|
|
119
|
-
height:100%;
|
|
120
|
-
overflow-y: auto;
|
|
121
|
-
overflow-x: hidden;
|
|
122
|
-
scrollbar-width: thin;
|
|
123
|
-
scrollbar-color: var(--border-color) transparent;
|
|
124
|
-
}
|
|
125
|
-
.main-content-inner--view-mode {
|
|
126
|
-
padding: 0 8px;
|
|
127
|
-
}
|
|
128
|
-
.main-content::-webkit-scrollbar {
|
|
129
|
-
width: 8px;
|
|
130
|
-
height: 8px;
|
|
131
|
-
}
|
|
132
|
-
.main-content::-webkit-scrollbar-track {
|
|
133
|
-
background:transparent;
|
|
134
|
-
}
|
|
135
|
-
.main-content::-webkit-scrollbar-thumb {
|
|
136
|
-
background-color: var(--border-color);
|
|
137
|
-
}
|
|
138
|
-
.main-header {
|
|
139
|
-
background-color:var(--header-bg);
|
|
140
|
-
color:var(--header-fg);
|
|
141
|
-
width:100%;
|
|
142
|
-
}
|
|
143
|
-
.header-title {
|
|
144
|
-
font-size:calc(var(--font-size-regular) + 8px);
|
|
145
|
-
padding:0 8px;
|
|
146
|
-
}
|
|
147
|
-
input.header-input{
|
|
148
|
-
background:var(--header-color-darker);
|
|
149
|
-
color:var(--header-fg);
|
|
150
|
-
border:1px solid var(--header-color-border);
|
|
151
|
-
flex:1;
|
|
152
|
-
padding-right:24px;
|
|
153
|
-
border-radius:3px;
|
|
154
|
-
}
|
|
155
|
-
input.header-input::placeholder {
|
|
156
|
-
opacity:0.4;
|
|
157
|
-
}
|
|
158
|
-
.loader {
|
|
159
|
-
margin: 16px auto 16px auto;
|
|
160
|
-
border: 4px solid var(--bg3);
|
|
161
|
-
border-radius: 50%;
|
|
162
|
-
border-top: 4px solid var(--primary-color);
|
|
163
|
-
width: 36px;
|
|
164
|
-
height: 36px;
|
|
165
|
-
animation: spin 2s linear infinite;
|
|
166
|
-
}
|
|
167
|
-
@container (min-width: 768px) {
|
|
168
|
-
.only-large-screen{
|
|
169
|
-
display:block;
|
|
170
|
-
}
|
|
171
|
-
.only-large-screen-flex {
|
|
172
|
-
display:flex;
|
|
173
|
-
}
|
|
174
|
-
}`,
|
|
175
|
-
];
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Startup
|
|
179
|
-
connectedCallback() {
|
|
180
|
-
super.connectedCallback();
|
|
181
|
-
const parent = this.parentElement;
|
|
182
|
-
if (parent) {
|
|
183
|
-
if (parent.offsetWidth === 0 && parent.style.width === '') {
|
|
184
|
-
parent.style.width = '100vw';
|
|
185
|
-
}
|
|
186
|
-
if (parent.offsetHeight === 0 && parent.style.height === '') {
|
|
187
|
-
parent.style.height = '100vh';
|
|
188
|
-
}
|
|
189
|
-
if (parent.tagName === 'BODY') {
|
|
190
|
-
if (!parent.style.marginTop) { parent.style.marginTop = '0'; }
|
|
191
|
-
if (!parent.style.marginRight) { parent.style.marginRight = '0'; }
|
|
192
|
-
if (!parent.style.marginBottom) { parent.style.marginBottom = '0'; }
|
|
193
|
-
if (!parent.style.marginLeft) { parent.style.marginLeft = '0'; }
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (this.loadFonts !== 'false') {
|
|
198
|
-
const fontDescriptor = {
|
|
199
|
-
family: 'Open Sans',
|
|
200
|
-
style: 'normal',
|
|
201
|
-
weight: '300',
|
|
202
|
-
unicodeRange: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
|
|
203
|
-
};
|
|
204
|
-
const fontWeight300 = new FontFace(
|
|
205
|
-
'Open Sans',
|
|
206
|
-
"url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UN_r8OUuhpKKSTjw.woff2) format('woff2')",
|
|
207
|
-
fontDescriptor,
|
|
208
|
-
);
|
|
209
|
-
fontDescriptor.weight = '600';
|
|
210
|
-
const fontWeight600 = new FontFace(
|
|
211
|
-
'Open Sans',
|
|
212
|
-
"url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UNirkOUuhpKKSTjw.woff2) format('woff2')",
|
|
213
|
-
fontDescriptor,
|
|
214
|
-
);
|
|
215
|
-
fontWeight300.load().then((font) => { document.fonts.add(font); });
|
|
216
|
-
fontWeight600.load().then((font) => { document.fonts.add(font); });
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
this.renderStyle = 'focused';
|
|
220
|
-
this.pathsExpanded = this.pathsExpanded === 'true';
|
|
221
|
-
|
|
222
|
-
if (!this.showInfo || !'true, false,'.includes(`${this.showInfo},`)) { this.showInfo = 'true'; }
|
|
223
|
-
if (!this.showSideNav || !'true false'.includes(this.showSideNav)) { this.showSideNav = 'true'; }
|
|
224
|
-
if (!this.showHeader || !'true, false,'.includes(`${this.showHeader},`)) { this.showHeader = 'true'; }
|
|
225
|
-
|
|
226
|
-
if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) { this.schemaStyle = 'tree'; }
|
|
227
|
-
if (!this.theme || !'light, dark,'.includes(`${this.theme},`)) {
|
|
228
|
-
this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
|
|
229
|
-
}
|
|
230
|
-
if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
|
|
231
|
-
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
|
|
232
|
-
if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
|
|
233
|
-
if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
|
|
234
|
-
if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
|
|
235
|
-
if (!this.allowSchemaDescriptionExpandToggle || !'true, false,'.includes(`${this.allowSchemaDescriptionExpandToggle},`)) { this.allowSchemaDescriptionExpandToggle = 'true'; }
|
|
236
|
-
|
|
237
|
-
marked.setOptions({
|
|
238
|
-
highlight: (code, lang) => {
|
|
239
|
-
if (Prism.languages[lang]) {
|
|
240
|
-
return Prism.highlight(code, Prism.languages[lang], lang);
|
|
241
|
-
}
|
|
242
|
-
return code;
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
render() {
|
|
248
|
-
return jsonSchemaViewerTemplate.call(this, true, false, false, this.pathsExpanded);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
252
|
-
if (name === 'spec-url') {
|
|
253
|
-
if (oldVal !== newVal) {
|
|
254
|
-
// put it at the end of event-loop to load all the attributes
|
|
255
|
-
window.setTimeout(async () => {
|
|
256
|
-
await this.loadSpec(newVal);
|
|
257
|
-
}, 0);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
super.attributeChangedCallback(name, oldVal, newVal);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
onSpecUrlChange() {
|
|
264
|
-
this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
onSearchChange(e) {
|
|
268
|
-
// Todo: Filter Search
|
|
269
|
-
this.matchPaths = e.target.value;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Public Method
|
|
273
|
-
async loadSpec(specUrl) {
|
|
274
|
-
if (!specUrl) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
try {
|
|
278
|
-
this.resolvedSpec = {
|
|
279
|
-
specLoadError: false,
|
|
280
|
-
isSpecLoading: true,
|
|
281
|
-
tags: [],
|
|
282
|
-
};
|
|
283
|
-
this.loading = true;
|
|
284
|
-
this.loadFailed = false;
|
|
285
|
-
this.requestUpdate();
|
|
286
|
-
const spec = await ProcessSpec.call(
|
|
287
|
-
this,
|
|
288
|
-
specUrl,
|
|
289
|
-
this.generateMissingTags === 'true',
|
|
290
|
-
this.sortTags === 'true',
|
|
291
|
-
this.sortSchemas === 'true',
|
|
292
|
-
this.getAttribute('sort-endpoints-by'),
|
|
293
|
-
this.getAttribute('match-paths'),
|
|
294
|
-
this.getAttribute('match-type'),
|
|
295
|
-
this.getAttribute('remove-endpoints-with-badge-label-as'),
|
|
296
|
-
);
|
|
297
|
-
this.loading = false;
|
|
298
|
-
this.afterSpecParsedAndValidated(spec);
|
|
299
|
-
} catch (err) {
|
|
300
|
-
this.loading = false;
|
|
301
|
-
this.loadFailed = true;
|
|
302
|
-
this.resolvedSpec = null;
|
|
303
|
-
console.error(`RapiDoc: Unable to resolve the API spec.. ${err.message}`); // eslint-disable-line no-console
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async afterSpecParsedAndValidated(spec) {
|
|
308
|
-
this.resolvedSpec = spec;
|
|
309
|
-
const specLoadedEvent = new CustomEvent('spec-loaded', { detail: spec });
|
|
310
|
-
this.dispatchEvent(specLoadedEvent);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Called by anchor tags created using markdown
|
|
314
|
-
handleHref(e) {
|
|
315
|
-
if (e.target.tagName.toLowerCase() === 'a') {
|
|
316
|
-
if (e.target.getAttribute('href').startsWith('#')) {
|
|
317
|
-
const gotoEl = this.shadowRoot.getElementById(e.target.getAttribute('href').replace('#', ''));
|
|
318
|
-
if (gotoEl) {
|
|
319
|
-
gotoEl.scrollIntoView({ behavior: 'auto', block: 'start' });
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// Example Dropdown @change Handler
|
|
326
|
-
onSelectExample(e) {
|
|
327
|
-
const exampleContainerEl = e.target.closest('.json-schema-example-panel');
|
|
328
|
-
const exampleEls = [...exampleContainerEl.querySelectorAll('.example')];
|
|
329
|
-
exampleEls.forEach((v) => {
|
|
330
|
-
v.style.display = v.dataset.example === e.target.value ? 'flex' : 'none';
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async scrollToEventTarget(event) {
|
|
335
|
-
const navEl = event.currentTarget;
|
|
336
|
-
if (!navEl.dataset.contentId) {
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
const contentEl = this.shadowRoot.getElementById(navEl.dataset.contentId);
|
|
340
|
-
if (contentEl) {
|
|
341
|
-
contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
customElements.define('json-schema-viewer', JsonSchemaViewer);
|
package/src/oauth-receiver.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export default class OauthReceiver extends HTMLElement {
|
|
2
|
-
connectedCallback() {
|
|
3
|
-
this.receiveAuthParms();
|
|
4
|
-
window.addEventListener('storage', (e) => this.receiveStorage(e), true);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Read OAuth2 parameters and sends them off
|
|
9
|
-
* to the window opener through `window.postMessage`.
|
|
10
|
-
*/
|
|
11
|
-
receiveAuthParms() {
|
|
12
|
-
let authData = {};
|
|
13
|
-
if (document.location.search) { // Applies to authorizationCode flow
|
|
14
|
-
const params = new URLSearchParams(document.location.search);
|
|
15
|
-
const code = params.get('code');
|
|
16
|
-
const error = params.get('error');
|
|
17
|
-
const state = params.get('state');
|
|
18
|
-
authData = {
|
|
19
|
-
code,
|
|
20
|
-
error,
|
|
21
|
-
state,
|
|
22
|
-
responseType: 'code',
|
|
23
|
-
};
|
|
24
|
-
} else if (window.location.hash) { // Applies to Implicit flow
|
|
25
|
-
const token_type = this.parseQueryString(window.location.hash.substring(1), 'token_type'); // eslint-disable-line camelcase
|
|
26
|
-
const access_token = this.parseQueryString(window.location.hash.substring(1), 'access_token'); // eslint-disable-line camelcase
|
|
27
|
-
authData = { token_type, access_token, responseType: 'token' }; // eslint-disable-line camelcase
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (window.opener) {
|
|
31
|
-
window.opener.postMessage(authData, this.target);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
sessionStorage.setItem('rapidoc-oauth-data', JSON.stringify(authData)); // Fallback to session storage if window.opener dont exist
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
relayAuthParams(e) {
|
|
38
|
-
if (window.parent) {
|
|
39
|
-
if (e.key === 'rapidoc-oauth-data') {
|
|
40
|
-
const authData = JSON.parse(e.newValue);
|
|
41
|
-
window.parent.postMessage(authData, this.target);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
parseQueryString(queryString, key) {
|
|
47
|
-
const vars = queryString.split('&');
|
|
48
|
-
for (let i = 0; i < vars.length; i++) {
|
|
49
|
-
const pair = vars[i].split('=');
|
|
50
|
-
if (decodeURIComponent(pair[0]) === key) {
|
|
51
|
-
return decodeURIComponent(pair[1]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
customElements.define('oauth-receiver', OauthReceiver);
|