🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

num-client

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

num-client - npm Package Compare versions

Comparing version

to
1.0.11

dist/scratch.d.ts

1

dist/client.js

@@ -85,3 +85,2 @@ "use strict";

exports.createDefaultCallbackHandler = function () { return new DefaultCallbackHandler(); };
loglevel_1.default.setLevel('info');
var DEFAULT_LOCALES_BASE_URL = new URL('https://modules.numprotocol.com/1/locales/');

@@ -88,0 +87,0 @@ var DEFAULT_LANGUAGE = 'en';

{
"name": "num-client",
"version": "1.0.10",
"version": "1.0.11",
"description": "A NUM Protocol Client in TypeScript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -101,5 +101,4 @@ # NUM Client

const DEFAULT_RESOLVER = new DoHResolver('Google', 'https://dns.google.com/resolve');
const dnsClient = createDnsClient(DEFAULT_RESOLVER);
const client = createClient(dnsClient); // Use a custom DoH service
const client = createClient([DEFAULT_RESOLVER]); // Use a custom DoH service
// ...

@@ -131,9 +130,12 @@ };

const handler: CallbackHandler = { // Provide a custom CallbackHandler
setLocation: (l: Location): void => {
console.log(l); // `l` is the `Location` where the result was found
const handler: CallbackHandler = {
setLocation: (l: NumLocation): void => {
console.log(l); // `l` is the `Location` where the result was found
},
setResult: (r: string): void => {
console.log(r); // `r` is the NUM record as a JSON string
console.log(r); // `r` is the NUM record as a JSON string
},
setErrorCode: (e: string): void => {
console.log(e); // `e` is the error message
}
};

@@ -143,3 +145,3 @@

// Ignore because the callback handler will handle it
});
}, (err) => console.error(err));
}

@@ -177,6 +179,5 @@ ```

const DEFAULT_RESOLVER = new num.DoHResolver('Google', 'https://dns.google.com/resolve');
const dnsClient = num.createDnsClient(DEFAULT_RESOLVER);
const DEFAULT_RESOLVER = new num.DoHResolver('Cloudflare', 'https://cloudflare-dns.com/dns-query');
const client = num.createClient(dnsClient); // Use a custom DNS client
const client = num.createClient([DEFAULT_RESOLVER]);

@@ -199,2 +200,5 @@ const ctx1 = client.createContext(numUri1);

},
setErrorCode: (e) => {
console.log(JSON.stringify(e));
}
};

@@ -225,26 +229,39 @@

<body>
<script src="https://unpkg.com/num-client/web/num-client-latest.js"></script>
<h1>num.uk:1</h1>
<pre id='num'></pre>
<script src="../dist/bundle.js"></script>
<h1>NUM Protocol Example</h1>
<div>
NUM URI = <input type="text" value="num.uk:1" id='urivalue' onchange="reloadRecord()">
<input type="button" value="Reload" onclick="reloadRecord()">
</div>
<div style="border: 1px solid blue;width: fit-content;">
<pre id='num'></pre>
</div>
<script>
window.addEventListener('load', function () {
const CUSTOM_RESOLVERS = [
new NumClient.DoHResolver('Cloudflare', 'https://cloudflare-dns.com/dns-query')
];
const num = require('num-client');
const client = NumClient.createClient(CUSTOM_RESOLVERS);
function lookup(uri) {
const numUri = num.parseNumUri(uri);
const client = num.createClient();
const ctx = client.createContext(numUri);
function lookup(uri) {
const numUri = NumClient.parseNumUri(uri);
return client.retrieveNumRecord(ctx);
}
const ctx = client.createContext(numUri);
lookup('num.uk:1').then((result) => {
const pretty = JSON.stringify(JSON.parse(result), null, 4);
return client.retrieveNumRecord(ctx);
}
function reloadRecord() {
const uri = document.getElementById('urivalue').value;
lookup(uri).then((result) => {
const pretty = JSON.stringify(JSON.parse(result), null, 1);
document.getElementById('num').innerHTML = pretty;
});
}
window.addEventListener('load', function () {
reloadRecord();
});

@@ -251,0 +268,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet