feat: NIP-46 oAuth sign up
This commit is contained in:
parent
0d9d5a0a4c
commit
c19e7ad20c
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snort/shared",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.13",
|
||||
"description": "Shared components for Snort",
|
||||
"type": "module",
|
||||
"module": "src/index.ts",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snort/system",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "Snort nostr system package",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
@ -36,7 +36,7 @@
|
||||
"@noble/curves": "^1.2.0",
|
||||
"@noble/hashes": "^1.3.2",
|
||||
"@scure/base": "^1.1.2",
|
||||
"@snort/shared": "^1.0.12",
|
||||
"@snort/shared": "^1.0.13",
|
||||
"@stablelib/xchacha20": "^1.0.1",
|
||||
"debug": "^4.3.4",
|
||||
"eventemitter3": "^5.0.1",
|
||||
|
@ -193,6 +193,32 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
|
||||
return JSON.parse(rsp.result as string);
|
||||
}
|
||||
|
||||
/**
|
||||
* NIP-46 oAuth bunker signup
|
||||
* @param name Desired name
|
||||
* @param domain Desired domain
|
||||
* @param email Backup email address
|
||||
* @returns
|
||||
*/
|
||||
async createAccount(name: string, domain: string, email?: string) {
|
||||
const rsp = await this.#rpc("create_account", [name, domain, email ?? ""]);
|
||||
if (rsp.result === "auth_url") {
|
||||
return await new Promise<void>((resolve, reject) => {
|
||||
this.#commandQueue.set(rsp.id, {
|
||||
resolve: async (o: Nip46Response) => {
|
||||
if (o.result === "ack") {
|
||||
resolve();
|
||||
} else {
|
||||
reject(o.error);
|
||||
}
|
||||
},
|
||||
reject,
|
||||
});
|
||||
this.emit("oauth", rsp.error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async #disconnect() {
|
||||
return await this.#rpc("disconnect", []);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user