mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 08:38:50 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4f9bece6e | ||
|
|
e217f751da | ||
|
|
d0ae8b36a2 | ||
|
|
fd945757be | ||
|
|
c12ddd3c53 |
@@ -259,7 +259,7 @@ export class AbstractRelay {
|
|||||||
const ret = new Promise<number>((resolve, reject) => {
|
const ret = new Promise<number>((resolve, reject) => {
|
||||||
this.openCountRequests.set(id, { resolve, reject })
|
this.openCountRequests.set(id, { resolve, reject })
|
||||||
})
|
})
|
||||||
this.send('["COUNT","' + id + '",' + JSON.stringify(filters) + ']')
|
this.send('["COUNT","' + id + '",' + JSON.stringify(filters).substring(1))
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
nip46.ts
8
nip46.ts
@@ -17,7 +17,7 @@ export function useFetchImplementation(fetchImplementation: any) {
|
|||||||
_fetch = fetchImplementation
|
_fetch = fetchImplementation
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BUNKER_REGEX = /^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%]*)$/
|
export const BUNKER_REGEX = /^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/
|
||||||
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||||
|
|
||||||
export type BunkerPointer = {
|
export type BunkerPointer = {
|
||||||
@@ -254,6 +254,8 @@ export class BunkerSigner {
|
|||||||
* @param username - The username for the account.
|
* @param username - The username for the account.
|
||||||
* @param domain - The domain for the account.
|
* @param domain - The domain for the account.
|
||||||
* @param email - The optional email for the account.
|
* @param email - The optional email for the account.
|
||||||
|
* @param localSecretKey - Optionally pass a local secret key that will be used to communicate with the bunker,
|
||||||
|
this will default to generating a random key.
|
||||||
* @throws Error if the email is present but invalid.
|
* @throws Error if the email is present but invalid.
|
||||||
* @returns A Promise that resolves to the auth_url that the client should follow to create an account.
|
* @returns A Promise that resolves to the auth_url that the client should follow to create an account.
|
||||||
*/
|
*/
|
||||||
@@ -263,11 +265,11 @@ export async function createAccount(
|
|||||||
username: string,
|
username: string,
|
||||||
domain: string,
|
domain: string,
|
||||||
email?: string,
|
email?: string,
|
||||||
|
localSecretKey: Uint8Array = generateSecretKey()
|
||||||
): Promise<BunkerSigner> {
|
): Promise<BunkerSigner> {
|
||||||
if (email && !EMAIL_REGEX.test(email)) throw new Error('Invalid email')
|
if (email && !EMAIL_REGEX.test(email)) throw new Error('Invalid email')
|
||||||
|
|
||||||
let sk = generateSecretKey()
|
let rpc = new BunkerSigner(localSecretKey, bunker.bunkerPointer, params)
|
||||||
let rpc = new BunkerSigner(sk, bunker.bunkerPointer, params)
|
|
||||||
|
|
||||||
let pubkey = await rpc.sendRequest('create_account', [username, domain, email || ''])
|
let pubkey = await rpc.sendRequest('create_account', [username, domain, email || ''])
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "nostr-tools",
|
"name": "nostr-tools",
|
||||||
"version": "2.5.0",
|
"version": "2.5.2",
|
||||||
"description": "Tools for making a Nostr client.",
|
"description": "Tools for making a Nostr client.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
Reference in New Issue
Block a user