@pb33f/cowboy-components 0.6.1 → 0.6.2

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.
@@ -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
- this.startSession().then((session) => {
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(h=>{if(this.authenticated=!0,this.state=h,this.host.requestUpdate(),this.urlCapture){const w=this.urlCapture;this.urlCapture=null,window.location.href=w}}).catch(()=>{this.startSessionAutomatically&&this.startSession().then(h=>{this.session=h,this.sessionCallback&&this.sessionCallback.call(this.host,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`
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
@@ -3,7 +3,7 @@
3
3
  "description": "Princess Beef Heavy Industries Cowboy Components",
4
4
  "private": false,
5
5
  "license": "BUSL-1.1",
6
- "version": "0.6.1",
6
+ "version": "0.6.2",
7
7
  "type": "module",
8
8
  "main": "./dist/cowboy-components.umd.cjs",
9
9
  "module": "./dist/cowboy-components.js",