scimgateway 5.4.0 → 5.4.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.
- package/README.md +44 -38
- package/lib/scimgateway.ts +36 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -799,51 +799,51 @@ const auth = 'Basic ' + btoa('gwadmin' + ':' + 'password') // const auth = 'Bear
|
|
|
799
799
|
|
|
800
800
|
const tls: any = {}
|
|
801
801
|
if (url.startsWith('wss:')) {
|
|
802
|
-
|
|
803
|
-
|
|
802
|
+
tls.ca = [Bun.file('/path/to/self-signed-cert.pem')], // only needed for self-signed certs
|
|
803
|
+
tls.rejectUnauthorized = false
|
|
804
804
|
}
|
|
805
805
|
|
|
806
806
|
// messageHandler implements message handling and custom logic
|
|
807
807
|
// could also use JSON.parse(message) and granular filtering on log "level"
|
|
808
808
|
const messageHandler = async (message: string) => {
|
|
809
|
-
|
|
809
|
+
console.log(message)
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
const startWebSocket = async () => {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
813
|
+
try {
|
|
814
|
+
const ws = new WebSocket(url, {
|
|
815
|
+
headers: {
|
|
816
|
+
Authorization: auth,
|
|
817
|
+
},
|
|
818
|
+
tls,
|
|
819
|
+
})
|
|
820
|
+
|
|
821
|
+
// message is received
|
|
822
|
+
ws.addEventListener("message", event => {
|
|
823
|
+
messageHandler(event.data)
|
|
824
|
+
})
|
|
825
|
+
|
|
826
|
+
// socket opened
|
|
827
|
+
ws.addEventListener("open", event => {
|
|
828
|
+
console.log('✅ Now awaiting log events...\n')
|
|
829
|
+
})
|
|
830
|
+
|
|
831
|
+
// socket closed
|
|
832
|
+
ws.addEventListener("close", event => {
|
|
833
|
+
let addInfo = ''
|
|
834
|
+
if (event.code === 1002) addInfo = ' => most likely authentication failure?'
|
|
835
|
+
console.warn(`⚠️ Connection closed (${event.code}): ${event.reason || 'no reason'}${addInfo}`)
|
|
836
|
+
retry()
|
|
837
|
+
})
|
|
838
|
+
|
|
839
|
+
// error handler
|
|
840
|
+
ws.addEventListener("error", event => {
|
|
841
|
+
// console.error('❌ WebSocket error:', event.message)
|
|
842
|
+
})
|
|
843
|
+
|
|
844
|
+
} catch (err: any) {
|
|
845
|
+
console.error('❌ Unexpected error:', err)
|
|
846
|
+
}
|
|
847
847
|
}
|
|
848
848
|
|
|
849
849
|
const retry = async () => {
|
|
@@ -1473,11 +1473,17 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
|
|
|
1473
1473
|
|
|
1474
1474
|
## Change log
|
|
1475
1475
|
|
|
1476
|
+
### v5.4.1
|
|
1477
|
+
|
|
1478
|
+
[Improved]
|
|
1479
|
+
|
|
1480
|
+
- Remote real-time logger, stop/start button added when using browser
|
|
1481
|
+
|
|
1476
1482
|
### v5.4.0
|
|
1477
1483
|
|
|
1478
1484
|
[Improved]
|
|
1479
1485
|
|
|
1480
|
-
-
|
|
1486
|
+
- Some underlying enhancements have been made to the remote real-time logger. When using a browser, log level colors are now shown. Note: the remote logger is not supported via Azure Relay
|
|
1481
1487
|
|
|
1482
1488
|
### v5.3.8
|
|
1483
1489
|
|
package/lib/scimgateway.ts
CHANGED
|
@@ -2705,20 +2705,41 @@ export class ScimGateway {
|
|
|
2705
2705
|
const wssInit = `
|
|
2706
2706
|
<!DOCTYPE html>
|
|
2707
2707
|
<html>
|
|
2708
|
+
<head>
|
|
2709
|
+
<style>
|
|
2710
|
+
.header-flex {
|
|
2711
|
+
display: flex;
|
|
2712
|
+
align-items: center;
|
|
2713
|
+
gap: 16px;
|
|
2714
|
+
}
|
|
2715
|
+
#stopBtn {
|
|
2716
|
+
padding: 4px 18px;
|
|
2717
|
+
font-size: 12px;
|
|
2718
|
+
background: #eee;
|
|
2719
|
+
border: 1px solid #888;
|
|
2720
|
+
border-radius: 4px;
|
|
2721
|
+
color: #222;
|
|
2722
|
+
cursor: pointer;
|
|
2723
|
+
}
|
|
2724
|
+
</style>
|
|
2725
|
+
</head>
|
|
2708
2726
|
<body>
|
|
2709
|
-
<
|
|
2727
|
+
<div class="header-flex">
|
|
2728
|
+
<h3 style="margin:0;">SCIM Gateway remote logger</h3>
|
|
2729
|
+
<button id="stopBtn" type="button">Stop</button>
|
|
2730
|
+
</div>
|
|
2710
2731
|
<pre id="log"></pre>
|
|
2711
2732
|
<script>
|
|
2733
|
+
const stopBtn = document.getElementById('stopBtn')
|
|
2712
2734
|
const logElem = document.getElementById('log')
|
|
2713
|
-
|
|
2735
|
+
let ws = new WebSocket('{{protocol}}//' + location.host + '/logger')
|
|
2714
2736
|
ws.onmessage = function(event) {
|
|
2715
2737
|
event.data.split('\\n').forEach(function(line) {
|
|
2716
2738
|
if (!line.trim()) return
|
|
2717
|
-
|
|
2718
|
-
var htmlLine = line.replace(
|
|
2739
|
+
const htmlLine = line.replace(
|
|
2719
2740
|
/(level":"\\s*)(debug|info|warn|error)/i,
|
|
2720
2741
|
function(match, p1, p2) {
|
|
2721
|
-
|
|
2742
|
+
let color = ''
|
|
2722
2743
|
switch (p2.toLowerCase()) {
|
|
2723
2744
|
case 'debug': color = '#888'; break
|
|
2724
2745
|
case 'info': color = 'blue'; break
|
|
@@ -2732,6 +2753,16 @@ export class ScimGateway {
|
|
|
2732
2753
|
logElem.innerHTML += htmlLine + '<br>'
|
|
2733
2754
|
})
|
|
2734
2755
|
}
|
|
2756
|
+
stopBtn.onclick = function() {
|
|
2757
|
+
if (ws) {
|
|
2758
|
+
ws.close()
|
|
2759
|
+
ws = null
|
|
2760
|
+
stopBtn.textContent = 'Start'
|
|
2761
|
+
stopBtn.onclick = function() {
|
|
2762
|
+
location.reload()
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2735
2766
|
</script>
|
|
2736
2767
|
</body>
|
|
2737
2768
|
</html>
|
package/package.json
CHANGED