@pb33f/cowboy-components 0.1.7 → 0.1.8
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.
|
@@ -16,6 +16,7 @@ export declare const DiagnosticBag = "pb33f-doctor-diagnostic";
|
|
|
16
16
|
export declare const OWASPBag = "pb33f-doctor-owasp";
|
|
17
17
|
export declare const DefaultDocument = "document";
|
|
18
18
|
export declare const DocumentProblems = "problems";
|
|
19
|
+
export declare const DoctorEndpoint = "doctor-endpoint";
|
|
19
20
|
export declare class TheDoctor extends LitElement {
|
|
20
21
|
static styles: import("lit").CSSResult[];
|
|
21
22
|
overviewPanel: SlTab;
|
|
@@ -43,7 +44,7 @@ export declare class TheDoctor extends LitElement {
|
|
|
43
44
|
private OWASPEnabled;
|
|
44
45
|
private readonly statusBar;
|
|
45
46
|
private session;
|
|
46
|
-
constructor();
|
|
47
|
+
constructor(doctorEndpoint?: string);
|
|
47
48
|
ruleGroupClicked(event: CustomEvent<ProblemRuleFilterChangedEvent>): void;
|
|
48
49
|
ruleDocsClicked(event: CustomEvent<ProblemDrawerEvent>): void;
|
|
49
50
|
private lintSpec;
|
|
@@ -32,8 +32,9 @@ export const DiagnosticBag = "pb33f-doctor-diagnostic";
|
|
|
32
32
|
export const OWASPBag = "pb33f-doctor-owasp";
|
|
33
33
|
export const DefaultDocument = "document";
|
|
34
34
|
export const DocumentProblems = "problems";
|
|
35
|
+
export const DoctorEndpoint = "doctor-endpoint";
|
|
35
36
|
let TheDoctor = class TheDoctor extends LitElement {
|
|
36
|
-
constructor() {
|
|
37
|
+
constructor(doctorEndpoint = "https://doctor.pb33f.io") {
|
|
37
38
|
super();
|
|
38
39
|
this.debounceTime = 300;
|
|
39
40
|
this.bounceId = 0;
|
|
@@ -48,7 +49,14 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
48
49
|
this.statusBar = new StatusBar();
|
|
49
50
|
this.ruleDocsWorker = new RuleDocumentationWorker();
|
|
50
51
|
this.unavailable = false;
|
|
51
|
-
|
|
52
|
+
// extract the doctor endpoint from session storage.
|
|
53
|
+
const sessionEndpoint = sessionStorage.getItem(DoctorEndpoint);
|
|
54
|
+
if (sessionEndpoint) {
|
|
55
|
+
this.doctorEndpoint = sessionEndpoint;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.doctorEndpoint = doctorEndpoint;
|
|
59
|
+
}
|
|
52
60
|
// TODO: make this configurable
|
|
53
61
|
this.editor.language = "yaml";
|
|
54
62
|
//@ts-ignore
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(a,c){typeof exports=="object"&&typeof module<"u"?c(require("lit"),require("lit/decorators.js"),require("prismjs"),require("monaco-editor"),require("@shoelace-style/shoelace/dist/components/dropdown/dropdown.js"),require("@shoelace-style/shoelace/dist/components/menu/menu.js"),require("@shoelace-style/shoelace/dist/components/menu-item/menu-item.js"),require("@shoelace-style/shoelace/dist/components/carousel/carousel.js"),require("@shoelace-style/shoelace/dist/components/carousel-item/carousel-item.js"),require("@shoelace-style/shoelace/dist/components/drawer/drawer.js"),require("@shoelace-style/shoelace/dist/components/format-number/format-number.js"),require("@shoelace-style/shoelace/dist/components/split-panel/split-panel.js"),require("@shoelace-style/shoelace/dist/components/tab-group/tab-group.js"),require("@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js"),require("@shoelace-style/shoelace/dist/components/tab/tab.js"),require("@shoelace-style/shoelace/dist/components/switch/switch.js"),require("@shoelace-style/shoelace/dist/components/dialog/dialog.js"),require("@shoelace-style/shoelace/dist/components/alert/alert.js"),require("@shoelace-style/shoelace/dist/components/card/card.js"),require("@shoelace-style/shoelace/dist/utilities/base-path.js")):typeof define=="function"&&define.amd?define(["lit","lit/decorators.js","prismjs","monaco-editor","@shoelace-style/shoelace/dist/components/dropdown/dropdown.js","@shoelace-style/shoelace/dist/components/menu/menu.js","@shoelace-style/shoelace/dist/components/menu-item/menu-item.js","@shoelace-style/shoelace/dist/components/carousel/carousel.js","@shoelace-style/shoelace/dist/components/carousel-item/carousel-item.js","@shoelace-style/shoelace/dist/components/drawer/drawer.js","@shoelace-style/shoelace/dist/components/format-number/format-number.js","@shoelace-style/shoelace/dist/components/split-panel/split-panel.js","@shoelace-style/shoelace/dist/components/tab-group/tab-group.js","@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js","@shoelace-style/shoelace/dist/components/tab/tab.js","@shoelace-style/shoelace/dist/components/switch/switch.js","@shoelace-style/shoelace/dist/components/dialog/dialog.js","@shoelace-style/shoelace/dist/components/alert/alert.js","@shoelace-style/shoelace/dist/components/card/card.js","@shoelace-style/shoelace/dist/utilities/base-path.js"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a.lit,a["lit/decorators"].js,a.prismjs,a.monaco,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,a.basePath))})(this,function(a,c,x,nt,
|
|
1
|
+
(function(a,c){typeof exports=="object"&&typeof module<"u"?c(require("lit"),require("lit/decorators.js"),require("prismjs"),require("monaco-editor"),require("@shoelace-style/shoelace/dist/components/dropdown/dropdown.js"),require("@shoelace-style/shoelace/dist/components/menu/menu.js"),require("@shoelace-style/shoelace/dist/components/menu-item/menu-item.js"),require("@shoelace-style/shoelace/dist/components/carousel/carousel.js"),require("@shoelace-style/shoelace/dist/components/carousel-item/carousel-item.js"),require("@shoelace-style/shoelace/dist/components/drawer/drawer.js"),require("@shoelace-style/shoelace/dist/components/format-number/format-number.js"),require("@shoelace-style/shoelace/dist/components/split-panel/split-panel.js"),require("@shoelace-style/shoelace/dist/components/tab-group/tab-group.js"),require("@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js"),require("@shoelace-style/shoelace/dist/components/tab/tab.js"),require("@shoelace-style/shoelace/dist/components/switch/switch.js"),require("@shoelace-style/shoelace/dist/components/dialog/dialog.js"),require("@shoelace-style/shoelace/dist/components/alert/alert.js"),require("@shoelace-style/shoelace/dist/components/card/card.js"),require("@shoelace-style/shoelace/dist/utilities/base-path.js")):typeof define=="function"&&define.amd?define(["lit","lit/decorators.js","prismjs","monaco-editor","@shoelace-style/shoelace/dist/components/dropdown/dropdown.js","@shoelace-style/shoelace/dist/components/menu/menu.js","@shoelace-style/shoelace/dist/components/menu-item/menu-item.js","@shoelace-style/shoelace/dist/components/carousel/carousel.js","@shoelace-style/shoelace/dist/components/carousel-item/carousel-item.js","@shoelace-style/shoelace/dist/components/drawer/drawer.js","@shoelace-style/shoelace/dist/components/format-number/format-number.js","@shoelace-style/shoelace/dist/components/split-panel/split-panel.js","@shoelace-style/shoelace/dist/components/tab-group/tab-group.js","@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js","@shoelace-style/shoelace/dist/components/tab/tab.js","@shoelace-style/shoelace/dist/components/switch/switch.js","@shoelace-style/shoelace/dist/components/dialog/dialog.js","@shoelace-style/shoelace/dist/components/alert/alert.js","@shoelace-style/shoelace/dist/components/card/card.js","@shoelace-style/shoelace/dist/utilities/base-path.js"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a.lit,a["lit/decorators"].js,a.prismjs,a.monaco,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,a.basePath))})(this,function(a,c,x,nt,Nn,Un,Yn,Sn,Jn,Rn,Hn,Gn,Tn,Ln,On,jn,Pn,Vn,Xn,at){"use strict";var kn=Object.defineProperty;var Fn=(a,c,x)=>c in a?kn(a,c,{enumerable:!0,configurable:!0,writable:!0,value:x}):a[c]=x;var w=(a,c,x)=>(Fn(a,typeof c!="symbol"?c+"":c,x),x),zn=(a,c,x)=>{if(!c.has(a))throw TypeError("Cannot "+x)};var eA=(a,c,x)=>{if(c.has(a))throw TypeError("Cannot add the same private member more than once");c instanceof WeakSet?c.add(a):c.set(a,x)};var Eo=(a,c,x)=>(zn(a,c,"access private method"),x);var We,oA,uo,it;function ct(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const A=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(e,o,A.get?A:{enumerable:!0,get:()=>r[o]})}}return e.default=r,Object.freeze(e)}const I=ct(nt),st=a.css`
|
|
2
2
|
:host {
|
|
3
3
|
display: flex;
|
|
4
4
|
column-gap: 10px;
|
|
@@ -3557,7 +3557,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const t="<p>An err
|
|
|
3557
3557
|
<span class="status-text">Credits remaining: <strong>${this.callsRemaining}</strong></span> |
|
|
3558
3558
|
<span class="action-text">${o}</span>
|
|
3559
3559
|
${this.callsRemaining<=0?a.html` | <a href="#" @click="${this.openDialog}"><strong>Get more credit</strong></a>`:""}
|
|
3560
|
-
</div>`}}};de.styles=[En,xn],Bo([c.property({type:Boolean})],de.prototype,"visible",2),Bo([c.property({type:Number})],de.prototype,"callsRemaining",2),Bo([c.query("sl-dialog")],de.prototype,"dialog",2),de=Bo([c.customElement("pb33f-doctor-statusbar")],de);var Mn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,ge=(r,e,o,A)=>{for(var t=A>1?void 0:A?vn(e,o):e,n=r.length-1,i;n>=0;n--)(i=r[n])&&(t=(A?i(e,o,t):i(t))||t);return A&&t&&Mn(e,o,t),t};const Cn="pb33f-doctor-editor",yn="pb33f-doctor-howtofix",Dn="pb33f-doctor-ruledocs",Zo="pb33f-doctor-diagnostic",Ko="pb33f-doctor-owasp",qo="document",bo="problems";let T=class extends a.LitElement{constructor(){super(),this.debounceTime=300,this.bounceId=0,this.bagManager=Gi(!0),this.bagManager.loadStatefulBags().then(this.loadState.bind(this)),this.editor=new P,this.problemList=new go,this.detailsDrawer=new Le,this.problemsOverview=new Z,this.errorBanner=new le,this.statusBar=new de,this.ruleDocsWorker=new Oi,this.unavailable=!1
|
|
3560
|
+
</div>`}}};de.styles=[En,xn],Bo([c.property({type:Boolean})],de.prototype,"visible",2),Bo([c.property({type:Number})],de.prototype,"callsRemaining",2),Bo([c.query("sl-dialog")],de.prototype,"dialog",2),de=Bo([c.customElement("pb33f-doctor-statusbar")],de);var Mn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,ge=(r,e,o,A)=>{for(var t=A>1?void 0:A?vn(e,o):e,n=r.length-1,i;n>=0;n--)(i=r[n])&&(t=(A?i(e,o,t):i(t))||t);return A&&t&&Mn(e,o,t),t};const Cn="pb33f-doctor-editor",yn="pb33f-doctor-howtofix",Dn="pb33f-doctor-ruledocs",Zo="pb33f-doctor-diagnostic",Ko="pb33f-doctor-owasp",qo="document",bo="problems",In="doctor-endpoint";let T=class extends a.LitElement{constructor(r="https://doctor.pb33f.io"){super(),this.debounceTime=300,this.bounceId=0,this.bagManager=Gi(!0),this.bagManager.loadStatefulBags().then(this.loadState.bind(this)),this.editor=new P,this.problemList=new go,this.detailsDrawer=new Le,this.problemsOverview=new Z,this.errorBanner=new le,this.statusBar=new de,this.ruleDocsWorker=new Oi,this.unavailable=!1;const e=sessionStorage.getItem(In);e?this.doctorEndpoint=e:this.doctorEndpoint=r,this.editor.language="yaml",this.addEventListener(SA,this.specChanged),this.addEventListener(JA,this.specClicked),this.addEventListener(co,this.problemClicked),this.addEventListener(Ge,this.ruleDocsClicked),this.addEventListener(jA,this.ruleGroupClicked),window.addEventListener("popstate",o=>{const A=o.state;if(A)switch(A.view){case z.Problems:this.tabGroup.show(z.Problems);break;case z.Overview:this.tabGroup.show(z.Overview);break}}),history.pushState({view:z.Overview},"",z.Overview)}ruleGroupClicked(r){this.problemsPanel.focus();const e=new CustomEvent(LA,{bubbles:!0,composed:!0,detail:{rule:r.detail.rule}});this.problemsPanel.focus(),this.problemList.dispatchEvent(e),history.pushState({rule:r.detail.rule},"",`/${z.Problems}?rule=${r.detail.rule}`),this.tabGroup.show(z.Problems)}ruleDocsClicked(r){var o,A;const e=r.detail.rule;if(e)switch(r.detail.type){case ne.RULE_DOCS:const t=(o=this.ruleDocsBag)==null?void 0:o.get(e);t&&(r.detail.body=t.body,this.detailsDrawer.open(r.detail));break;case ne.HOW_TO_FIX:const n=(A=this.howToFixBag)==null?void 0:A.get(e);n&&(r.detail.body=n.howToFix,this.detailsDrawer.open(r.detail))}}lintSpec(r){se.lintFile(r,this.OWASPEnabled).then(e=>{var o,A;e&&!Array.isArray(e)&&(this.editor.setMarkers([e]),(o=this.problemBag)==null||o.set(bo,[e]),this.problemList.problems=[e],this.problems=[e],this.problemsOverview.problems=this.problemList.problemItems),e&&Array.isArray(e)&&(this.editor.setMarkers(e),(A=this.problemBag)==null||A.set(bo,e),this.problemList.problems=e,this.problems=e,this.problemsOverview.problems=this.problemList.problemItems),se.fetchStatistics().then(t=>{var n;this.problemsOverview.statistics=t,(n=this.diagnosticBag)==null||n.set(Zo,t),(t==null?void 0:t.remainingCredit)<=10&&(this.statusBar.callsRemaining=t.remainingCredit,this.statusBar.visible=!0,console.warn("You are running low on credit, you will need to authenticate soon. "+t.remainingCredit+" credits remaining."))}).catch(t=>{console.error("statistics service is down"),this.platformUnavailable(t)})}).catch(e=>{this.platformUnavailable(e),console.error("so sorry, the doctor cannot see you right now, the clinic is closed."),e&&(console.error(e.detail),e.instance==="https://pb33f.io/errors/no-credit-remaining"&&(this.statusBar.callsRemaining=0,this.statusBar.visible=!0))})}platformUnavailable(r){this.unavailable||(this.errorBanner.errorTitle="The doctor is out.",r?this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because "+r.detail:this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because there is no response from the platform.",this.errorBanner.visible=!0,this.unavailable=!0,this.problemsOverview.unavailable=!0,this.tabGroup.show(z.Overview))}specClicked(r){var e;this.detailsDrawer.close();for(let o=0;o<((e=this.problems)==null?void 0:e.length);o++)if(this.problems[o].startLineNumber===r.detail.line){this.problemList.lineClicked(r.detail.line,!0),this.tabGroup.show(z.Problems);break}}problemClicked(r){var e,o;(e=this.editor.editor)==null||e.revealLineInCenter(r.detail.problem.line),(o=this.editor.editor)==null||o.setPosition({lineNumber:r.detail.problem.line,column:r.detail.problem.column}),this.detailsDrawer.close(),r.detail.launchedFromProblems||this.problemList.lineClicked(r.detail.problem.problemObject.startLineNumber),this.tabGroup.show(z.Problems)}loadState(){if(se.doctorEndpoint=this.doctorEndpoint,this.docBag=this.bagManager.getBag(Cn),this.docBag){const r=this.docBag.get(qo);r&&this.editor.setValue(r,!0)}if(this.problemBag=this.bagManager.getBag(bo),this.problemBag){const r=this.problemBag.get(bo);if(r){this.problems=r,this.editor.setMarkers(r);for(let e=0;e<r.length;e++)r[e]=O.reconstruct(r[e]);this.problemList.problems=r,this.problemsOverview.problems=this.problemList.problemItems}}if(this.howToFixBag=this.bagManager.getBag(yn),this.diagnosticBag=this.bagManager.getBag(Zo),this.diagnosticBag){const r=this.diagnosticBag.get(Zo);r&&(this.problemsOverview.statistics=r)}this.OWASPBag=this.bagManager.getBag(Ko),this.OWASPBag&&(this.OWASPEnabled=this.OWASPBag.get(Ko),this.owaspSwitch.checked=this.OWASPEnabled),this.fetchDocs()}fetchDocs(){se.startSession().then(r=>{this.session=r,se.fetchAllHowToFix().then(e=>{e&&e.forEach(o=>{var A;(A=this.howToFixBag)==null||A.set(o.ruleId,o)})}).catch(e=>{this.platformUnavailable(e),console.error("documentation service is down")}),this.ruleDocsBag=this.bagManager.getBag(Dn),this.ruleDocsWorker.addEventListener("message",e=>{const o=e.data;o&&o.forEach(A=>{var t;(t=this.ruleDocsBag)==null||t.set(A.ruleId,A)})}),this.ruleDocsWorker.postMessage({start:!0,endpoint:this.doctorEndpoint})}).catch(r=>{this.platformUnavailable(r),console.error("cannot start session")})}specChanged(r){this.docBag&&this.docBag.set(qo,r.detail.content),clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{this.lintSpec(r.detail.content)},this.debounceTime)}toggleOWASP(){var r;if(this.OWASPEnabled=this.owaspSwitch.checked,(r=this.OWASPBag)==null||r.set(Ko,this.OWASPEnabled),this.docBag){const e=this.docBag.get(qo);this.lintSpec(e)}}render(){let r=a.html``;return this.unavailable&&(r=a.html`
|
|
3561
3561
|
<div class="overlay" @click="return false"></div>`),a.html`
|
|
3562
3562
|
<div class="doctor">
|
|
3563
3563
|
${this.errorBanner}
|
package/package.json
CHANGED