Skip to content

Commit 8d7585a

Browse files
fix: stabilize Studio authentication and stack updates
1 parent 065a9b7 commit 8d7585a

4 files changed

Lines changed: 87 additions & 7 deletions

File tree

_c8oProject/mobileNgxApp.yaml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,66 @@ tplProjectName: mobilebuilder_tpl_8_4_0_ngx
742742
resolve();
743743
'
744744
comment: Applies host-provided language before falling back to the local assistant preference
745+
↓AuthenticateStudioSession [ngx.components.UICustomAction-1788427068063]:
746+
actionValue:
747+
- xmlizable:
748+
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
749+
- com.twinsoft.convertigo.beans.common.FormatedContent:
750+
: |
751+
' var hash = "";
752+
try {
753+
hash = "" + (window.location.hash || "");
754+
} catch (e0) {}
755+
var match = /(?:^#|[&#])authToken=([^&]+)/.exec(hash);
756+
if (match === null) {
757+
resolve();
758+
return;
759+
}
760+
var authToken = "";
761+
try {
762+
authToken = decodeURIComponent(match[1]);
763+
} catch (e1) {
764+
authToken = match[1];
765+
}
766+
try {
767+
var cleanHash = hash
768+
.replace(/(?:^#|[&#])authToken=[^&]*/g, "")
769+
.replace(/^&/, "#");
770+
window.history.replaceState(null, document.title,
771+
window.location.pathname + window.location.search + cleanHash);
772+
} catch (e2) {}
773+
var pathname = "";
774+
try {
775+
pathname = "" + window.location.pathname;
776+
} catch (e3) {}
777+
var projectsIndex = pathname.indexOf("/projects/");
778+
var convertigoRoot = projectsIndex >= 0 ? pathname.substring(0, projectsIndex) : "";
779+
var authenticateUrl = convertigoRoot + "/admin/services/engine.Authenticate";
780+
fetch(authenticateUrl, {
781+
method: "POST",
782+
credentials: "same-origin",
783+
headers: {
784+
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
785+
"Accept": "application/json, text/xml, */*"
786+
},
787+
body: "authType=login&authToken=" + encodeURIComponent(authToken)
788+
}).then(function(response) {
789+
if (!response.ok) {
790+
throw new Error("Studio authentication failed with HTTP " + response.status);
791+
}
792+
return response.text();
793+
}).then(function(responseText) {
794+
var text = ("" + responseText).toLowerCase();
795+
if (text.indexOf("<authenticated>false</authenticated>") !== -1
796+
|| text.indexOf(''"authenticated":false'') !== -1
797+
|| text.indexOf("authtoken not valid") !== -1) {
798+
throw new Error("The Studio authentication token was rejected.");
799+
}
800+
resolve();
801+
}).catch(function(error) {
802+
reject(error);
803+
});'
804+
comment: Exchange the one-use Eclipse Studio token before any Assistant sequence runs.
745805
↓Style [ngx.components.UIStyle-1771929741648]:
746806
comment: You can add some global application styles here
747807
styleContent:
@@ -4766,4 +4826,4 @@ tplProjectName: mobilebuilder_tpl_8_4_0_ngx
47664826
display: inline-block;
47674827
}
47684828
}
4769-
'
4829+
'

_c8oProject/mobilePages/Page.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ scriptContent:
403403
if (!this.local) { this.local = {}; }
404404
this.local.AgentHostContext = next;
405405
this.scheduleAgentSettingsRefreshAfterHostContext();
406+
if (this.tick) { this.tick(); }
406407
} catch (e) {}
407408
}
408409

@@ -661,6 +662,7 @@ scriptContent:
661662
this.setAgentSettingsUrlState(true);
662663
if (this.setEnableChat) { this.setEnableChat(); }
663664
this.tick();
665+
this.requestAgentHostContext(0);
664666
this.refreshAgentStackRelease(true);
665667
this.refreshAgentSettingsAfterHostContext(true);
666668
}
@@ -736,6 +738,21 @@ scriptContent:
736738
}, 120);
737739
}
738740

741+
public requestAgentHostContext(attempt = 0) {
742+
try {
743+
this.postAgentHostMessage({ type: ''lib_ConvertigoAssistant.context.request'' });
744+
if (attempt >= 5) {
745+
if (this[''_agentHostContextRequestTimer'']) { clearTimeout(this[''_agentHostContextRequestTimer'']); }
746+
this[''_agentHostContextRequestTimer''] = null;
747+
return;
748+
}
749+
if (this[''_agentHostContextRequestTimer'']) { clearTimeout(this[''_agentHostContextRequestTimer'']); }
750+
this[''_agentHostContextRequestTimer''] = setTimeout(() => {
751+
try { this.requestAgentHostContext(attempt + 1); } catch (eRetry) {}
752+
}, attempt < 2 ? 250 : 750);
753+
} catch (e) {}
754+
}
755+
739756
public bindAgentHostContextListener() {
740757
try {
741758
if (this.agentHostContextMessageHandler) { return; }
@@ -770,12 +787,14 @@ scriptContent:
770787
this.agentHostReceiveFromJavaWrapped = true;
771788
}
772789
window.addEventListener(''message'', this.agentHostContextMessageHandler, false);
773-
this.postAgentHostMessage({ type: ''lib_ConvertigoAssistant.context.request'' });
790+
this.requestAgentHostContext(0);
774791
} catch (e3) {}
775792
}
776793

777794
public unbindAgentHostContextListener() {
778795
try {
796+
if (this[''_agentHostContextRequestTimer'']) { clearTimeout(this[''_agentHostContextRequestTimer'']); }
797+
this[''_agentHostContextRequestTimer''] = null;
779798
if (this.agentHostContextMessageHandler) {
780799
window.removeEventListener(''message'', this.agentHostContextMessageHandler, false);
781800
this.agentHostContextMessageHandler = null;
@@ -6820,7 +6839,8 @@ title: Tigo
68206839
}).catch(function(error) {
68216840
reject(error);
68226841
});'
6823-
comment: Exchange the one-use Eclipse Studio token before any Assistant sequence runs.
6842+
comment: Legacy page-level copy; authentication now runs during onAppInit before page sequences.
6843+
isEnabled: false
68246844
↓ApplyAssistantModeFromUrl [ngx.components.UICustomAction-1782236253363]:
68256845
actionValue:
68266846
- xmlizable:

c8oProject.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
contextTimeout: 510
88
corsOrigin: =Origin
99
httpSessionTimeout: 520
10-
version: 1.4.0
10+
version: 1.4.1
1111
↓AgentStackRelease [connectors.HttpConnector]: 🗏 connectors/AgentStackRelease.yaml
1212
↓HostedAssistant [connectors.HttpConnector]: 🗏 connectors/HostedAssistant.yaml
1313
↓HostedAssistantBuffer [connectors.HttpConnector]: 🗏 connectors/HostedAssistantBuffer.yaml

stack-release.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
},
1717
{
1818
"name": "lib_ConvertigoAssistant",
19-
"version": "1.4.1-beta1",
20-
"tag": "v1.4.1-beta1",
21-
"importUrl": "lib_ConvertigoAssistant=https://github.com/convertigo/c8oprj-lib-convertigo-assistant/releases/download/v1.4.1-beta1/lib_ConvertigoAssistant.car"
19+
"version": "1.4.1-beta2",
20+
"tag": "v1.4.1-beta2",
21+
"importUrl": "lib_ConvertigoAssistant=https://github.com/convertigo/c8oprj-lib-convertigo-assistant/releases/download/v1.4.1-beta2/lib_ConvertigoAssistant.car"
2222
}
2323
]
2424
}

0 commit comments

Comments
 (0)