nostr-tools
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -13,3 +13,5 @@ export * from './keys'; | ||
export * as nip19 from './nip19'; | ||
export * as nip21 from './nip21'; | ||
export * as nip26 from './nip26'; | ||
export * as nip27 from './nip27'; | ||
export * as nip39 from './nip39'; | ||
@@ -16,0 +18,0 @@ export * as nip42 from './nip42'; |
@@ -45,3 +45,5 @@ "use strict"; | ||
nip19: () => nip19_exports, | ||
nip21: () => nip21_exports, | ||
nip26: () => nip26_exports, | ||
nip27: () => nip27_exports, | ||
nip39: () => nip39_exports, | ||
@@ -1279,2 +1281,26 @@ nip42: () => nip42_exports, | ||
// nip21.ts | ||
var nip21_exports = {}; | ||
__export(nip21_exports, { | ||
BECH32_REGEX: () => BECH32_REGEX, | ||
NOSTR_URI_REGEX: () => NOSTR_URI_REGEX, | ||
parse: () => parse2, | ||
test: () => test | ||
}); | ||
var BECH32_REGEX = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/; | ||
var NOSTR_URI_REGEX = new RegExp(`nostr:(${BECH32_REGEX.source})`); | ||
function test(value) { | ||
return typeof value === "string" && new RegExp(`^${NOSTR_URI_REGEX.source}$`).test(value); | ||
} | ||
function parse2(uri) { | ||
const match = uri.match(new RegExp(`^${NOSTR_URI_REGEX.source}$`)); | ||
if (!match) | ||
throw new Error(`Invalid Nostr URI: ${uri}`); | ||
return { | ||
uri: match[0], | ||
value: match[1], | ||
decoded: decode(match[1]) | ||
}; | ||
} | ||
// nip26.ts | ||
@@ -1339,2 +1365,33 @@ var nip26_exports = {}; | ||
// nip27.ts | ||
var nip27_exports = {}; | ||
__export(nip27_exports, { | ||
matchAll: () => matchAll, | ||
regex: () => regex, | ||
replaceAll: () => replaceAll | ||
}); | ||
var regex = () => new RegExp(`\\b${NOSTR_URI_REGEX.source}\\b`, "g"); | ||
function* matchAll(content) { | ||
const matches = content.matchAll(regex()); | ||
for (const match of matches) { | ||
const [uri, value] = match; | ||
yield { | ||
uri, | ||
value, | ||
decoded: decode(value), | ||
start: match.index, | ||
end: match.index + uri.length | ||
}; | ||
} | ||
} | ||
function replaceAll(content, replacer) { | ||
return content.replaceAll(regex(), (uri, value) => { | ||
return replacer({ | ||
uri, | ||
value, | ||
decoded: decode(value) | ||
}); | ||
}); | ||
} | ||
// nip39.ts | ||
@@ -1341,0 +1398,0 @@ var nip39_exports = {}; |
{ | ||
"name": "nostr-tools", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "Tools for making a Nostr client.", | ||
@@ -19,3 +19,3 @@ "repository": { | ||
}, | ||
"license": "Public domain", | ||
"license": "Unlicense", | ||
"dependencies": { | ||
@@ -22,0 +22,0 @@ "@noble/hashes": "1.2.0", |
@@ -328,2 +328,2 @@ # nostr-tools | ||
Public domain. | ||
This is free and unencumbered software released into the public domain. By submitting patches to this project, you agree to dedicate any and all copyright interest in this software to the public domain. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
871961
31
0
0
11253