include node_modules so release .zip is deployable
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// nip05.ts
|
||||
var nip05_exports = {};
|
||||
__export(nip05_exports, {
|
||||
NIP05_REGEX: () => NIP05_REGEX,
|
||||
queryProfile: () => queryProfile,
|
||||
searchDomain: () => searchDomain,
|
||||
useFetchImplementation: () => useFetchImplementation
|
||||
});
|
||||
module.exports = __toCommonJS(nip05_exports);
|
||||
var NIP05_REGEX = /^(?:([\w.+-]+)@)?([\w.-]+)$/;
|
||||
var _fetch;
|
||||
try {
|
||||
_fetch = fetch;
|
||||
} catch {
|
||||
}
|
||||
function useFetchImplementation(fetchImplementation) {
|
||||
_fetch = fetchImplementation;
|
||||
}
|
||||
async function searchDomain(domain, query = "") {
|
||||
try {
|
||||
let res = await (await _fetch(`https://${domain}/.well-known/nostr.json?name=${query}`)).json();
|
||||
return res.names;
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
async function queryProfile(fullname) {
|
||||
const match = fullname.match(NIP05_REGEX);
|
||||
if (!match)
|
||||
return null;
|
||||
const [_, name = "_", domain] = match;
|
||||
try {
|
||||
const res = await _fetch(`https://${domain}/.well-known/nostr.json?name=${name}`);
|
||||
const { names, relays } = parseNIP05Result(await res.json());
|
||||
const pubkey = names[name];
|
||||
return pubkey ? { pubkey, relays: relays?.[pubkey] } : null;
|
||||
} catch (_e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function parseNIP05Result(json) {
|
||||
const result = {
|
||||
names: {}
|
||||
};
|
||||
for (const [name, pubkey] of Object.entries(json.names)) {
|
||||
if (typeof name === "string" && typeof pubkey === "string") {
|
||||
result.names[name] = pubkey;
|
||||
}
|
||||
}
|
||||
if (json.relays) {
|
||||
result.relays = {};
|
||||
for (const [pubkey, relays] of Object.entries(json.relays)) {
|
||||
if (typeof pubkey === "string" && Array.isArray(relays)) {
|
||||
result.relays[pubkey] = relays.filter((relay) => typeof relay === "string");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user