@pb33f/cowboy-components 0.6.1 → 0.6.3
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/dist/components/rodeo/rodeo-nav.js +2 -2
- package/dist/components/rodeo/rodeo.d.ts +3 -3
- package/dist/components/rodeo/rodeo.js +16 -11
- package/dist/controllers/auth.js +11 -7
- package/dist/cowboy-components.umd.cjs +1 -1
- package/dist/services/auth-service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -17,8 +17,8 @@ let RodeoNav = class RodeoNav extends LitElement {
|
|
|
17
17
|
return html `
|
|
18
18
|
<nav>
|
|
19
19
|
<ul>
|
|
20
|
-
<li><a href="/">roundup</a></li>
|
|
21
|
-
<li><a href="users/">patrons</a></li>
|
|
20
|
+
<li><a href="/rodeo/roundup/">roundup</a></li>
|
|
21
|
+
<li><a href="/rodeo/users/">patrons</a></li>
|
|
22
22
|
</ul>
|
|
23
23
|
</nav>
|
|
24
24
|
`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import './rodeo-nav.js';
|
|
3
|
-
import './roundup.
|
|
4
|
-
import './users.
|
|
3
|
+
import './roundup.js';
|
|
4
|
+
import './users.js';
|
|
5
5
|
import { BusCallback, CommandResponse } from "@pb33f/ranch";
|
|
6
|
-
import { PlatformEvent } from "../../model/platform-events";
|
|
6
|
+
import { PlatformEvent } from "../../model/platform-events.js";
|
|
7
7
|
export declare class Rodeo extends LitElement {
|
|
8
8
|
static styles: import("lit").CSSResult[];
|
|
9
9
|
private readonly bus;
|
|
@@ -7,18 +7,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { html, LitElement } from "lit";
|
|
8
8
|
import { customElement } from "lit/decorators.js";
|
|
9
9
|
import rodeoCss from "./rodeo.css";
|
|
10
|
-
import listsCss from "../../css/lists.css";
|
|
10
|
+
import listsCss from "../../css/lists.css.js";
|
|
11
11
|
import { Router } from '@vaadin/router';
|
|
12
12
|
import './rodeo-nav.js';
|
|
13
|
-
import './roundup.
|
|
14
|
-
import './users.
|
|
13
|
+
import './roundup.js';
|
|
14
|
+
import './users.js';
|
|
15
15
|
import { CreateBus } from "@pb33f/ranch";
|
|
16
|
-
import { Command, DoctorServiceChannel, isBrokerResponse, QueuePrefix, TopicPrefix, RodeoServiceChannel, isPlatformEvent } from "../../model/channels";
|
|
17
|
-
import { LintingService } from "../../services/linting-service";
|
|
18
|
-
import { AuthController } from "../../controllers/auth";
|
|
19
|
-
import { RodeoService } from "../../services/rodeo-service";
|
|
20
|
-
import { RodeoRoundup } from "./roundup";
|
|
21
|
-
import { PlatformEventType } from "../../model/platform-events";
|
|
16
|
+
import { Command, DoctorServiceChannel, isBrokerResponse, QueuePrefix, TopicPrefix, RodeoServiceChannel, isPlatformEvent } from "../../model/channels.js";
|
|
17
|
+
import { LintingService } from "../../services/linting-service.js";
|
|
18
|
+
import { AuthController } from "../../controllers/auth.js";
|
|
19
|
+
import { RodeoService } from "../../services/rodeo-service.js";
|
|
20
|
+
import { RodeoRoundup } from "./roundup.js";
|
|
21
|
+
import { PlatformEventType } from "../../model/platform-events.js";
|
|
22
22
|
let Rodeo = class Rodeo extends LitElement {
|
|
23
23
|
constructor() {
|
|
24
24
|
super();
|
|
@@ -79,11 +79,16 @@ let Rodeo = class Rodeo extends LitElement {
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
|
-
path: '/', action: () => {
|
|
82
|
+
path: '/rodeo/roundup', action: () => {
|
|
83
83
|
return this.roundupComponent;
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
{
|
|
86
|
+
{
|
|
87
|
+
path: '/rodeo/', action: () => {
|
|
88
|
+
return this.roundupComponent;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{ path: '/rodeo/users', component: 'pb33f-rodeo-users' }
|
|
87
92
|
]);
|
|
88
93
|
this.connectToBroker();
|
|
89
94
|
}
|
package/dist/controllers/auth.js
CHANGED
|
@@ -26,10 +26,20 @@ export class AuthController {
|
|
|
26
26
|
this.urlCapture = urlState;
|
|
27
27
|
sessionStorage.removeItem(PreAuthURL);
|
|
28
28
|
}
|
|
29
|
+
const startBroker = () => {
|
|
30
|
+
this.startSession().then((session) => {
|
|
31
|
+
this.session = session;
|
|
32
|
+
if (this.sessionCallback) {
|
|
33
|
+
// call back if defined.
|
|
34
|
+
this.sessionCallback.call(this.host, session);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
29
38
|
this.checkState().then((state) => {
|
|
30
39
|
this.authenticated = true;
|
|
31
40
|
this.state = state;
|
|
32
41
|
this.host.requestUpdate();
|
|
42
|
+
startBroker();
|
|
33
43
|
if (this.urlCapture) {
|
|
34
44
|
const c = this.urlCapture;
|
|
35
45
|
this.urlCapture = null;
|
|
@@ -37,13 +47,7 @@ export class AuthController {
|
|
|
37
47
|
}
|
|
38
48
|
}).catch(() => {
|
|
39
49
|
if (this.startSessionAutomatically) {
|
|
40
|
-
|
|
41
|
-
this.session = session;
|
|
42
|
-
if (this.sessionCallback) {
|
|
43
|
-
// call back if defined.
|
|
44
|
-
this.sessionCallback.call(this.host, session);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
50
|
+
startBroker();
|
|
47
51
|
}
|
|
48
52
|
});
|
|
49
53
|
}
|
|
@@ -1933,7 +1933,7 @@ Please report this to https://github.com/markedjs/marked.`,d){const m="<p>An err
|
|
|
1933
1933
|
|
|
1934
1934
|
</div>
|
|
1935
1935
|
</pb33f-electric-box>
|
|
1936
|
-
</div>`}};dg.styles=[pmt,o1],s3([V.property()],dg.prototype,"title",2),s3([V.property()],dg.prototype,"instruction",2),s3([V.state()],dg.prototype,"mintravel",2),s3([V.state()],dg.prototype,"maxtravel",2),s3([V.state()],dg.prototype,"spin",2),s3([V.state()],dg.prototype,"orbs",2),s3([V.query("#button-anim")],dg.prototype,"buttonAnimation",2),s3([V.query("#github-button")],dg.prototype,"githubButton",2),dg=s3([V.customElement("pb33f-oauth-login")],dg);const _R=class _R{static async checkAuth(){return new Promise(async(d,h)=>{try{const w=await fetch(_R.doctorEndpoint+"/auth/check-auth",{method:"GET",credentials:"include"});let m=await w.json();w.ok||h(!1),d(m)}catch{h({tile:"platform error",detail:"cannot check authentication state please try again later."})}})}};_R.doctorEndpoint="https://doctor.pb33f.io";let dN=_R;class pN{static buildDefaultHeaders(d){const h={};return pN.addBrokerHeader(h,d),pN.addJSONHeader(h),h}static addBrokerHeader(d,h){h&&(d["x-pb33f-broker"]=h)}static addJSONHeader(d){d["Content-Type"]="application/json"}}const NX="pb33f-preauth-url";class u4e{constructor(d,h,w=!1){this.host=d,this.host.addController(this),this.doctorEndpoint="https://doctor.pb33f.io";const m=sessionStorage.getItem("doctor-endpoint");m&&(this.doctorEndpoint=m),dN.doctorEndpoint=this.doctorEndpoint,h&&(this.sessionCallback=h),this.startSessionAutomatically=w}hostConnected(){window.addEventListener(l4e,this.authGithub.bind(this)),window.addEventListener(a4e,this.logout.bind(this));const d=sessionStorage.getItem(NX);d&&(this.urlCapture=d,sessionStorage.removeItem(NX)),this.checkState().then(
|
|
1936
|
+
</div>`}};dg.styles=[pmt,o1],s3([V.property()],dg.prototype,"title",2),s3([V.property()],dg.prototype,"instruction",2),s3([V.state()],dg.prototype,"mintravel",2),s3([V.state()],dg.prototype,"maxtravel",2),s3([V.state()],dg.prototype,"spin",2),s3([V.state()],dg.prototype,"orbs",2),s3([V.query("#button-anim")],dg.prototype,"buttonAnimation",2),s3([V.query("#github-button")],dg.prototype,"githubButton",2),dg=s3([V.customElement("pb33f-oauth-login")],dg);const _R=class _R{static async checkAuth(){return new Promise(async(d,h)=>{try{const w=await fetch(_R.doctorEndpoint+"/auth/check-auth",{method:"GET",credentials:"include"});let m=await w.json();w.ok||h(!1),d(m)}catch{h({tile:"platform error",detail:"cannot check authentication state please try again later."})}})}};_R.doctorEndpoint="https://doctor.pb33f.io";let dN=_R;class pN{static buildDefaultHeaders(d){const h={};return pN.addBrokerHeader(h,d),pN.addJSONHeader(h),h}static addBrokerHeader(d,h){h&&(d["x-pb33f-broker"]=h)}static addJSONHeader(d){d["Content-Type"]="application/json"}}const NX="pb33f-preauth-url";class u4e{constructor(d,h,w=!1){this.host=d,this.host.addController(this),this.doctorEndpoint="https://doctor.pb33f.io";const m=sessionStorage.getItem("doctor-endpoint");m&&(this.doctorEndpoint=m),dN.doctorEndpoint=this.doctorEndpoint,h&&(this.sessionCallback=h),this.startSessionAutomatically=w}hostConnected(){window.addEventListener(l4e,this.authGithub.bind(this)),window.addEventListener(a4e,this.logout.bind(this));const d=sessionStorage.getItem(NX);d&&(this.urlCapture=d,sessionStorage.removeItem(NX));const h=()=>{this.startSession().then(w=>{this.session=w,this.sessionCallback&&this.sessionCallback.call(this.host,w)})};this.checkState().then(w=>{if(this.authenticated=!0,this.state=w,this.host.requestUpdate(),h(),this.urlCapture){const m=this.urlCapture;this.urlCapture=null,window.location.href=m}}).catch(()=>{this.startSessionAutomatically&&h()})}async startSession(){return new Promise(async(d,h)=>{try{const m=await(await fetch(this.doctorEndpoint+"/start-session",{method:"GET",credentials:"include"})).json();m.type&&m.title&&m.status&&h(),d(m)}catch{h({detail:"the pb33f platform is unresponsive"})}})}async associateBroker(d){return new Promise(async(h,w)=>{try{const m=pN.buildDefaultHeaders(d);(await fetch(this.doctorEndpoint+"/associate-broker",{method:"GET",credentials:"include",headers:m})).ok||w(!1),h(!0)}catch{w({detail:"cannot associate broker with session"})}})}authGithub(){sessionStorage.setItem(NX,window.location.toString()),window.location.href=this.doctorEndpoint+"/auth/github/start"}logout(){window.location.href=this.doctorEndpoint+"/auth/logout"}checkState(){return dN.checkAuth()}}const h4e=I.css`
|
|
1937
1937
|
|
|
1938
1938
|
sl-dialog::part(panel) {
|
|
1939
1939
|
border: 1px dashed var(--secondary-color);
|
package/package.json
CHANGED