mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
ConnectSigner: do call getPublicKey of the upstream signer
This commit is contained in:
parent
9eaeeb3234
commit
6a63724864
1 changed files with 20 additions and 12 deletions
|
|
@ -30,8 +30,8 @@ export class ConnectSigner implements NostrSigner {
|
||||||
const signer = await this.signer;
|
const signer = await this.signer;
|
||||||
try {
|
try {
|
||||||
return await signer.signEvent(event);
|
return await signer.signEvent(event);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
if (e.name === 'AbortError') {
|
if (e instanceof Error && e.name === 'AbortError') {
|
||||||
throw new HTTPException(408, { message: 'The event was not signed quickly enough' });
|
throw new HTTPException(408, { message: 'The event was not signed quickly enough' });
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
@ -44,8 +44,8 @@ export class ConnectSigner implements NostrSigner {
|
||||||
const signer = await this.signer;
|
const signer = await this.signer;
|
||||||
try {
|
try {
|
||||||
return await signer.nip04.encrypt(pubkey, plaintext);
|
return await signer.nip04.encrypt(pubkey, plaintext);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
if (e.name === 'AbortError') {
|
if (e instanceof Error && e.name === 'AbortError') {
|
||||||
throw new HTTPException(408, {
|
throw new HTTPException(408, {
|
||||||
message: 'Text was not encrypted quickly enough',
|
message: 'Text was not encrypted quickly enough',
|
||||||
});
|
});
|
||||||
|
|
@ -59,8 +59,8 @@ export class ConnectSigner implements NostrSigner {
|
||||||
const signer = await this.signer;
|
const signer = await this.signer;
|
||||||
try {
|
try {
|
||||||
return await signer.nip04.decrypt(pubkey, ciphertext);
|
return await signer.nip04.decrypt(pubkey, ciphertext);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
if (e.name === 'AbortError') {
|
if (e instanceof Error && e.name === 'AbortError') {
|
||||||
throw new HTTPException(408, {
|
throw new HTTPException(408, {
|
||||||
message: 'Text was not decrypted quickly enough',
|
message: 'Text was not decrypted quickly enough',
|
||||||
});
|
});
|
||||||
|
|
@ -76,8 +76,8 @@ export class ConnectSigner implements NostrSigner {
|
||||||
const signer = await this.signer;
|
const signer = await this.signer;
|
||||||
try {
|
try {
|
||||||
return await signer.nip44.encrypt(pubkey, plaintext);
|
return await signer.nip44.encrypt(pubkey, plaintext);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
if (e.name === 'AbortError') {
|
if (e instanceof Error && e.name === 'AbortError') {
|
||||||
throw new HTTPException(408, {
|
throw new HTTPException(408, {
|
||||||
message: 'Text was not encrypted quickly enough',
|
message: 'Text was not encrypted quickly enough',
|
||||||
});
|
});
|
||||||
|
|
@ -91,8 +91,8 @@ export class ConnectSigner implements NostrSigner {
|
||||||
const signer = await this.signer;
|
const signer = await this.signer;
|
||||||
try {
|
try {
|
||||||
return await signer.nip44.decrypt(pubkey, ciphertext);
|
return await signer.nip44.decrypt(pubkey, ciphertext);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
if (e.name === 'AbortError') {
|
if (e instanceof Error && e.name === 'AbortError') {
|
||||||
throw new HTTPException(408, {
|
throw new HTTPException(408, {
|
||||||
message: 'Text was not decrypted quickly enough',
|
message: 'Text was not decrypted quickly enough',
|
||||||
});
|
});
|
||||||
|
|
@ -103,9 +103,17 @@ export class ConnectSigner implements NostrSigner {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prevent unnecessary NIP-46 round-trips.
|
|
||||||
async getPublicKey(): Promise<string> {
|
async getPublicKey(): Promise<string> {
|
||||||
return this.pubkey;
|
const signer = await this.signer;
|
||||||
|
try {
|
||||||
|
return await signer.getPublicKey();
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error && e.name === 'AbortError') {
|
||||||
|
throw new HTTPException(408, { message: 'Public key not received quickly enough' });
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the user's relays if they passed in an `nprofile` auth token. */
|
/** Get the user's relays if they passed in an `nprofile` auth token. */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue