From eb7cb068205844071a9145015db9ef911a933108 Mon Sep 17 00:00:00 2001
From: Dan Jones <dan.jones@noc.ac.uk>
Date: Thu, 19 Jan 2023 14:33:43 +0000
Subject: [PATCH] docs: add comments and examples

+ use response from implicit auth in get auth header
---
 README.md             | 4 ++++
 dist/adapter.esm.js   | 2 +-
 dist/adapter.js       | 2 +-
 dist/protocol.esm.js  | 6 ++++++
 dist/protocol.js      | 6 ++++++
 src/adapter/index.js  | 2 +-
 src/protocol/index.js | 6 ++++++
 7 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 5d0c553..0d6e0f2 100644
--- a/README.md
+++ b/README.md
@@ -92,6 +92,10 @@ The topics have the following structure:
 
 ```
 project.operator.vehicleType.vehicleID.[send|receive].messageType
+# eg 
+soar.noc.autosub.ah1.send.platform-mission 
+# or 
+soar.po.ecosub.eco1.receive.platform-status
 ```
 
 Subscriptions may contain single-word wildcards (*) or multi-word wildcards (#).
diff --git a/dist/adapter.esm.js b/dist/adapter.esm.js
index d1375d7..1acacf6 100644
--- a/dist/adapter.esm.js
+++ b/dist/adapter.esm.js
@@ -47,7 +47,7 @@ class Adapter {
     if (!this.tokenValid())
       return this.auth().then((response) => {
         return {
-          Authorization: `Bearer ${this.credentials.token}`,
+          Authorization: `Bearer ${response.data.token}`,
         };
       });
     else {
diff --git a/dist/adapter.js b/dist/adapter.js
index 8471c08..c868d51 100644
--- a/dist/adapter.js
+++ b/dist/adapter.js
@@ -49,7 +49,7 @@ class Adapter {
     if (!this.tokenValid())
       return this.auth().then((response) => {
         return {
-          Authorization: `Bearer ${this.credentials.token}`,
+          Authorization: `Bearer ${response.data.token}`,
         };
       });
     else {
diff --git a/dist/protocol.esm.js b/dist/protocol.esm.js
index 1577188..3971ac0 100644
--- a/dist/protocol.esm.js
+++ b/dist/protocol.esm.js
@@ -59,6 +59,9 @@ class GenericProtocol {
 
   /**
    * Invoked on receiving a message from the backbone 
+   * 
+   * Whilst type isn't used in the generic stub it will 
+   * be needed by sub-classes overriding the decode method
    * @param {string} type 
    * @param {object} message 
    * @returns {*}
@@ -69,6 +72,9 @@ class GenericProtocol {
 
   /**
    * Optionally invoked before delivering a message to the backbone
+   * 
+   * Whilst type isn't used in the generic stub it will 
+   * be needed by sub-classes overriding the encode method
    * @param {string} type 
    * @param {*} message 
    * @returns {object}
diff --git a/dist/protocol.js b/dist/protocol.js
index 772a3ca..6d8c468 100644
--- a/dist/protocol.js
+++ b/dist/protocol.js
@@ -61,6 +61,9 @@ class GenericProtocol {
 
   /**
    * Invoked on receiving a message from the backbone 
+   * 
+   * Whilst type isn't used in the generic stub it will 
+   * be needed by sub-classes overriding the decode method
    * @param {string} type 
    * @param {object} message 
    * @returns {*}
@@ -71,6 +74,9 @@ class GenericProtocol {
 
   /**
    * Optionally invoked before delivering a message to the backbone
+   * 
+   * Whilst type isn't used in the generic stub it will 
+   * be needed by sub-classes overriding the encode method
    * @param {string} type 
    * @param {*} message 
    * @returns {object}
diff --git a/src/adapter/index.js b/src/adapter/index.js
index b4dc835..d52101f 100644
--- a/src/adapter/index.js
+++ b/src/adapter/index.js
@@ -47,7 +47,7 @@ export class Adapter {
     if (!this.tokenValid())
       return this.auth().then((response) => {
         return {
-          Authorization: `Bearer ${this.credentials.token}`,
+          Authorization: `Bearer ${response.data.token}`,
         };
       });
     else {
diff --git a/src/protocol/index.js b/src/protocol/index.js
index bb67711..266542c 100644
--- a/src/protocol/index.js
+++ b/src/protocol/index.js
@@ -59,6 +59,9 @@ export class GenericProtocol {
 
   /**
    * Invoked on receiving a message from the backbone 
+   * 
+   * Whilst type isn't used in the generic stub it will 
+   * be needed by sub-classes overriding the decode method
    * @param {string} type 
    * @param {object} message 
    * @returns {*}
@@ -69,6 +72,9 @@ export class GenericProtocol {
 
   /**
    * Optionally invoked before delivering a message to the backbone
+   * 
+   * Whilst type isn't used in the generic stub it will 
+   * be needed by sub-classes overriding the encode method
    * @param {string} type 
    * @param {*} message 
    * @returns {object}
-- 
GitLab