@pb33f/cowboy-components 0.5.8 → 0.6.1

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.
Files changed (33) hide show
  1. package/dist/components/kv-view/kv-view.css.js +6 -0
  2. package/dist/components/kv-view/kv-view.d.ts +3 -0
  3. package/dist/components/kv-view/kv-view.js +23 -9
  4. package/dist/components/rodeo/rodeo.css.js +1 -0
  5. package/dist/components/rodeo/rodeo.d.ts +20 -0
  6. package/dist/components/rodeo/rodeo.js +124 -4
  7. package/dist/components/rodeo/roundup.css.d.ts +2 -0
  8. package/dist/components/rodeo/roundup.css.js +16 -0
  9. package/dist/components/rodeo/roundup.d.ts +17 -1
  10. package/dist/components/rodeo/roundup.js +83 -5
  11. package/dist/components/rodeo/statistic.css.d.ts +2 -0
  12. package/dist/components/rodeo/statistic.css.js +69 -0
  13. package/dist/components/rodeo/statistic.d.ts +10 -0
  14. package/dist/components/rodeo/statistic.js +59 -0
  15. package/dist/components/terminal-emulator/terminal-emulator.css.d.ts +2 -0
  16. package/dist/components/terminal-emulator/terminal-emulator.css.js +197 -0
  17. package/dist/components/terminal-emulator/terminal-emulator.d.ts +21 -0
  18. package/dist/components/terminal-emulator/terminal-emulator.js +95 -0
  19. package/dist/components/the-doctor/the-doctor.d.ts +1 -2
  20. package/dist/components/the-doctor/the-doctor.js +99 -94
  21. package/dist/controllers/auth.d.ts +8 -2
  22. package/dist/controllers/auth.js +55 -4
  23. package/dist/cowboy-components.umd.cjs +344 -338
  24. package/dist/model/channels.d.ts +3 -0
  25. package/dist/model/channels.js +4 -0
  26. package/dist/model/platform-events.d.ts +13 -0
  27. package/dist/model/platform-events.js +7 -0
  28. package/dist/model/roundup-stats.d.ts +10 -0
  29. package/dist/model/roundup-stats.js +1 -0
  30. package/dist/services/linting-service.js +1 -0
  31. package/dist/services/rodeo-service.d.ts +5 -0
  32. package/dist/services/rodeo-service.js +29 -0
  33. package/package.json +2 -2
@@ -1,8 +1,9 @@
1
- import { AuthenticationGithubRequested, LogoutRequested } from "../events/doctor";
2
- import { AuthService } from "../services/auth-service";
1
+ import { AuthenticationGithubRequested, LogoutRequested } from "../events/doctor.js";
2
+ import { AuthService } from "../services/auth-service.js";
3
+ import { HeaderService } from "../services/header-service";
3
4
  const PreAuthURL = "pb33f-preauth-url";
4
5
  export class AuthController {
5
- constructor(host) {
6
+ constructor(host, sessionCallback, autoStart = false) {
6
7
  this.host = host;
7
8
  this.host.addController(this);
8
9
  this.doctorEndpoint = 'https://doctor.pb33f.io';
@@ -11,13 +12,16 @@ export class AuthController {
11
12
  this.doctorEndpoint = sessionEndpoint;
12
13
  }
13
14
  AuthService.doctorEndpoint = this.doctorEndpoint;
15
+ if (sessionCallback) {
16
+ this.sessionCallback = sessionCallback;
17
+ }
18
+ this.startSessionAutomatically = autoStart;
14
19
  }
15
20
  hostConnected() {
16
21
  window.addEventListener(AuthenticationGithubRequested, this.authGithub.bind(this));
17
22
  window.addEventListener(LogoutRequested, this.logout.bind(this));
18
23
  // check for urlcapture
19
24
  const urlState = sessionStorage.getItem(PreAuthURL);
20
- debugger;
21
25
  if (urlState) {
22
26
  this.urlCapture = urlState;
23
27
  sessionStorage.removeItem(PreAuthURL);
@@ -31,6 +35,53 @@ export class AuthController {
31
35
  this.urlCapture = null;
32
36
  window.location.href = c;
33
37
  }
38
+ }).catch(() => {
39
+ 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
+ });
47
+ }
48
+ });
49
+ }
50
+ async startSession() {
51
+ return new Promise(async (resolve, reject) => {
52
+ try {
53
+ const sessionJSON = await fetch(this.doctorEndpoint + '/start-session', {
54
+ method: 'GET',
55
+ credentials: 'include',
56
+ });
57
+ const session = await sessionJSON.json();
58
+ if (session.type && session.title && session.status) {
59
+ reject();
60
+ }
61
+ resolve(session);
62
+ }
63
+ catch (e) {
64
+ reject({ detail: "the pb33f platform is unresponsive" });
65
+ }
66
+ });
67
+ }
68
+ async associateBroker(brokerId) {
69
+ return new Promise(async (resolve, reject) => {
70
+ try {
71
+ const headers = HeaderService.buildDefaultHeaders(brokerId);
72
+ const sessionJSON = await fetch(this.doctorEndpoint + '/associate-broker', {
73
+ method: 'GET',
74
+ credentials: 'include',
75
+ headers: headers
76
+ });
77
+ if (!sessionJSON.ok) {
78
+ reject(false);
79
+ }
80
+ resolve(true);
81
+ }
82
+ catch (e) {
83
+ reject({ detail: "cannot associate broker with session" });
84
+ }
34
85
  });
35
86
  }
36
87
  authGithub() {