upgrade to new inspector

This commit is contained in:
dskvr
2022-11-27 02:54:42 +01:00
parent 52f8ae3954
commit 00952033eb
11 changed files with 149 additions and 45 deletions

View File

@@ -1 +0,0 @@
.q-tabs[data-v-d6bd2fc4]{border-bottom:1px solid var(--q-accent)}table[data-v-d6bd2fc4]{width:100%}.left-align[data-v-d6bd2fc4]{text-align:left}tr.relay td[data-v-d6bd2fc4]{font-style:italic;opacity:.5}tr.relay.loaded td[data-v-d6bd2fc4]{font-style:normal;opacity:1}.indicator[data-v-d6bd2fc4]{display:block;margin:0 auto;height:14px;width:14px;border-radius:7px;border-width:0}.badge[data-v-d6bd2fc4]{height:auto;width:auto;display:inline-block;padding:2px 5px;font-size:15px;position:relative;top:-3px;min-width:15px;margin-right:5px}.badge.offline[data-v-d6bd2fc4],.badge.readwrite[data-v-d6bd2fc4]{color:#fff}.badge.read-only[data-v-d6bd2fc4],.badge.write-only[data-v-d6bd2fc4]{background-color:orange!important}.aggregate.indicator[data-v-d6bd2fc4]{background-color:transparent;border-radius:0;border-style:solid}.indicator.silver[data-v-d6bd2fc4]{background-color:silver;border-color:rgba(55,55,55,.5)}.indicator.green[data-v-d6bd2fc4]{background-color:green;border-color:rgba(0,255,0,.5)}.indicator.red[data-v-d6bd2fc4]{background-color:red;border-color:rgba(255,0,0,.5)}.indicator.orange[data-v-d6bd2fc4]{background-color:orange;border-color:rgba(255,191,0,.5)}.indicator.readwrite[data-v-d6bd2fc4]{background-color:green;border-color:rgba(0,255,0,.5)}.indicator.read-only[data-v-d6bd2fc4]{position:relative;border-color:transparent;background-color:transparent}.indicator.read-only span[data-v-d6bd2fc4]:first-child{position:absolute;width:0;height:0;border-top:14px solid green;border-right:14px solid transparent}.indicator.read-only span[data-v-d6bd2fc4]:last-child{position:absolute;width:0;height:0;border-bottom:14px solid orange;border-left:14px solid transparent}.indicator.write-only[data-v-d6bd2fc4]{position:relative;border-color:transparent;background-color:transparent}.indicator.write-only span[data-v-d6bd2fc4]:first-child{position:absolute;width:0;height:0;border-bottom:14px solid orange;border-left:14px solid transparent}.indicator.write-only span[data-v-d6bd2fc4]:last-child{position:absolute;width:0;height:0;border-top:14px solid green;border-right:14px solid transparent}.indicator.offline[data-v-d6bd2fc4]{background-color:red;border-color:rgba(255,0,0,.5)}table.online .relay-url[data-v-d6bd2fc4]{cursor:pointer}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px}

1
dist/index.html vendored
View File

@@ -1 +0,0 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><script defer="defer" src="/js/chunk-vendors.cd206719.js"></script><script defer="defer" src="/js/app.27fea23d.js"></script><link href="/css/app.cb51cbcb.css" rel="stylesheet"></head><body><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -27,7 +27,7 @@
"node-emoji": "1.11.0", "node-emoji": "1.11.0",
"node-polyfill-webpack-plugin": "2.0.1", "node-polyfill-webpack-plugin": "2.0.1",
"nostr": "0.2.5", "nostr": "0.2.5",
"nostr-relay-inspector": "0.0.3", "nostr-relay-inspector": "0.0.5",
"nostr-tools": "0.24.1", "nostr-tools": "0.24.1",
"onion-regex": "2.0.8", "onion-regex": "2.0.8",
"requests": "0.3.0", "requests": "0.3.0",
@@ -36,6 +36,7 @@
"socks-proxy-agent": "7.0.0", "socks-proxy-agent": "7.0.0",
"stream-browserify": "3.0.0", "stream-browserify": "3.0.0",
"vue": "^3.2.13", "vue": "^3.2.13",
"vue-final-modal": "3",
"vue-grid-responsive": "1.3.0", "vue-grid-responsive": "1.3.0",
"vue-nav-tabs": "0.5.7", "vue-nav-tabs": "0.5.7",
"vue-simple-maps": "1.1.3", "vue-simple-maps": "1.1.3",

View File

@@ -24,7 +24,6 @@ relays:
- 'wss://relay.cynsar.foundation' - 'wss://relay.cynsar.foundation'
- 'wss://nostr-pub.wellorder.net' - 'wss://nostr-pub.wellorder.net'
- 'wss://relayer.fiatjaf.com' - 'wss://relayer.fiatjaf.com'
- 'wss://nostr.sandwich.farm'
- 'wss://relay.sovereign-stack.org' - 'wss://relay.sovereign-stack.org'
- 'wss://relay.oldcity-bitcoiners.info' - 'wss://relay.oldcity-bitcoiners.info'
- 'wss://relay.bitid.nz' - 'wss://relay.bitid.nz'
@@ -34,3 +33,4 @@ relays:
- 'wss://relay.farscapian.com' - 'wss://relay.farscapian.com'
- 'wss://astral.ninja' - 'wss://astral.ninja'
- 'wss://relay.sovereign-stack.org' - 'wss://relay.sovereign-stack.org'
- 'wss://nostr.sandwich.farm'

View File

@@ -34,11 +34,14 @@
<th class="table-column info" v-tooltip:top.tooltip="'Additional information detected regarding the relay during processing'"> <th class="table-column info" v-tooltip:top.tooltip="'Additional information detected regarding the relay during processing'">
</th> </th>
<th class="table-column nip nip-15" v-tooltip:top.tooltip="'Does the relay support NIP-15'"> <!-- <th class="table-column nip nip-15" v-tooltip:top.tooltip="'Does the relay support NIP-15'">
<span>NIP-15</span> <span>NIP-15</span>
</th> </th>
<th class="table-column nip nip-20" v-tooltip:top.tooltip="'Does the relay support NIP-20'"> <th class="table-column nip nip-20" v-tooltip:top.tooltip="'Does the relay support NIP-20'">
<span>NIP-20</span> <span>NIP-20</span>
</th> -->
<th class="table-column nip nip-20" v-tooltip:top.tooltip="'Does the relay support NIP-20'">
<span>NIP-11</span>
</th> </th>
<!-- <th>FILTER: LIMIT</th> --> <!-- <th>FILTER: LIMIT</th> -->
</tr> </tr>

View File

@@ -6,12 +6,12 @@
</span> </span>
</td> </td>
<td class="relay left-align relay-url" @click="copy(relay)"> <td class="relay left-align relay-url">
{{ relay }} <span @click="copy">{{ relay }}</span>
</td> </td>
<td class="verified"> <td class="verified">
<span v-tooltip:top.tooltip="nip05List()"> <span class="verified-shape-wrapper" v-if="result.nips[5]"><span class="shape verified"></span></span></span> <span v-tooltip:top.tooltip="identityList()"> <span class="verified-shape-wrapper" v-if="result.identities"><span class="shape verified"></span></span></span>
</td> </td>
<!-- <td>{{result.flag}}</td> --> <!-- <td>{{result.flag}}</td> -->
@@ -41,29 +41,69 @@
</ul> </ul>
</td> </td>
<td class="nip nip-15"> <td class="nip nip-11">
<a v-if="result.info" @click="showModal=true"> </a>
</td>
<!-- <td class="nip nip-15">
{{ setCheck(connection.nip(15)) }} {{ setCheck(connection.nip(15)) }}
</td> </td>
<td class="nip nip-20"> <td class="nip nip-20">
{{ setCheck(connection.nip(20)) }} {{ setCheck(connection.nip(20)) }}
</td> </td> -->
<vue-final-modal v-model="showModal" classes="modal-container" content-class="modal-content">
<div class="modal__title">
<slot name="title">{{ result.info?.name }}</slot>
</div>
<div class="modal__content">
<div v-if="result.info?.description">
{{ result.info?.description }} <br/>
<strong v-if="result.info?.pubkey">Public Key:</strong> {{ result.info?.pubkey }} <br/>
<strong v-if="result.info?.contact">Contact:</strong> {{ result.info?.contact }}
</div>
<!-- <div>
<h4>Status</h4>
<ul>
<li><strong>Connected</strong> <span :class="getResultClass(relay, 'connect')" class="connect indicator"></span></li>
<li><strong>Read</strong> <span :class="getResultClass(relay, 'read')" class="read indicator"></span></li>
<li><strong>Write</strong> <span :class="getResultClass(relay, 'write')" class="write indicator"></span></li>
</ul>
</div> -->
<h4>Relay Info</h4>
<ul>
<li><strong>Software:</strong> {{ result.info?.software }} </li>
<li><strong>Version</strong>: {{ result.info?.version }} </li>
</ul>
<h4>NIP Support</h4>
<ul>
<li v-for="(nip) in result.info?.supported_nips" :key="`${relay}_${nip}`">
<a :href="nipLink(nip)" target="_blank">{{ nipFormatted(nip) }}</a>
</li>
</ul>
</div>
</vue-final-modal>
</template> </template>
<script> <script>
/* eslint-disable */ /* eslint-disable */
import { defineComponent} from 'vue' import { defineComponent} from 'vue'
// import InspectorRelayResult from 'nostr-relay-inspector' import { VueFinalModal, ModalsContainer } from 'vue-final-modal'
import InspectorRelayResult from 'nostr-relay-inspector'
export default defineComponent({ export default defineComponent({
name: 'RelaySingleComponent', name: 'RelaySingleComponent',
components: {}, components: {
RelaySingleModalComponent,
VueFinalModal,
ModalsContainer,
},
props: { props: {
relay: String, relay: String,
result: { result: {
type: Object, type: Object,
default(rawProps){ default(rawProps){
return {} return structuredClone(InspectorRelayResult)
} }
}, },
showColumns: { showColumns: {
@@ -90,11 +130,12 @@ export default defineComponent({
} }
}, },
data() { data() {
return {} return {
showModal: false
}
}, },
methods: { methods: {
getResultClass (url, key) { getResultClass (url, key) {
let result = this.result?.check?.[key] === true let result = this.result?.check?.[key] === true
? 'success' ? 'success'
: this.result?.check?.[key] === false : this.result?.check?.[key] === false
@@ -122,14 +163,15 @@ export default defineComponent({
setCaution (bool) { setCaution (bool) {
return !bool ? '⚠️' : '' return !bool ? '⚠️' : ''
}, },
nip05List () { identityList () {
// console.log(this.result) // console.log(this.result)
let string = '' let string = ''
if(this.result.nips[5]) { if(this.result.identities) {
string = `${string}Relay domain contains NIP-05 verification data for:` string = `${string}Relay domain contains NIP-05 verification data for:`
let users = Object.entries(this.result.nips[5]), let users = Object.entries(this.result.identities),
count = 0 count = 0
users.forEach( ([key, value]) => { users.forEach( ([key, value]) => {
count++ count++
string = `${string} @${key} ${(count!=users.length) ? 'and' : ''}` string = `${string} @${key} ${(count!=users.length) ? 'and' : ''}`
@@ -137,6 +179,90 @@ export default defineComponent({
} }
return string return string
}, },
nipSignature(key){
return key.toString().length == 1 ? `0${key}` : key
},
nipFormatted(key){
return `NIP-${this.nipSignature(key)}`
},
nipLink(key){
return `https://github.com/nostr-protocol/nips/blob/master/${this.nipSignature(key)}.md`
},
getResultClass (url, key) {
let result = this.result?.check?.[key] === true
? 'success'
: this.result?.check?.[key] === false
? 'failure'
: 'pending'
return `indicator ${result}`
},
async copy(text) {
try {
await navigator.clipboard.writeText(text);
} catch($e) {
//console.log('Cannot copy');
}
},
} }
}) })
</script> </script>
<style scoped>
ul {
margin:0;
padding:0;
}
li {
margin:0;
padding:0;
list-style:none;
}
::v-deep(.modal-container) {
display: flex;
justify-content: center;
align-items: center;
}
::v-deep(.modal-content) {
position: relative;
display: flex;
flex-direction: column;
max-height: 90%;
margin: 0 1rem;
padding: 1rem;
border: 1px solid #e2e8f0;
border-radius: 0.25rem;
background: #fff;
}
.modal__title {
margin: 0 2rem 0 0;
font-size: 1.5rem;
font-weight: 700;
}
.modal__content {
flex-grow: 1;
overflow-y: auto;
}
.modal__action {
display: flex;
justify-content: center;
align-items: center;
flex-shrink: 0;
padding: 1rem 0 0;
}
.modal__close {
position: absolute;
top: 0.5rem;
right: 0.5rem;
}
.nip-11 a { cursor: pointer }
</style>
<style scoped>
.dark-mode div ::v-deep(.modal-content) {
border-color: #2d3748;
background-color: #1a202c;
}
</style>

View File

@@ -82,8 +82,8 @@ import emoji from 'node-emoji'
import { relays } from '../../relays.yaml' import { relays } from '../../relays.yaml'
import { messages as RELAY_MESSAGES, codes as RELAY_CODES } from '../../codes.yaml' import { messages as RELAY_MESSAGES, codes as RELAY_CODES } from '../../codes.yaml'
// import { Inspector, Observation } from 'nostr-relay-inspector' // import { Inspector, InspectorObservation } from 'nostr-relay-inspector'
import { Inspector, Observation } from '../../lib/nostr-relay-inspector' import { Inspector, InspectorObservation } from '../../lib/nostr-relay-inspector'
import crypto from "crypto" import crypto from "crypto"
@@ -151,7 +151,7 @@ export default defineComponent({
let response_obj = {...message_obj, ...code_obj} let response_obj = {...message_obj, ...code_obj}
this.result[relay].observations.push( new Observation('notice', response_obj.code, response_obj.description, response_obj.relates_to) ) this.result[relay].observations.push( new InspectorObservation('notice', response_obj.code, response_obj.description, response_obj.relates_to) )
console.log(this.result[relay].observations) console.log(this.result[relay].observations)
}) })
@@ -286,7 +286,6 @@ export default defineComponent({
relaysCompleted () { relaysCompleted () {
let value = Object.entries(this.result).length let value = Object.entries(this.result).length
console.log(value)
return value return value
}, },