kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Merge branch 'main' into remove-immutable-compose
commit
7dd213d3b5
|
@ -57,18 +57,25 @@ export class MastodonClient {
|
|||
? opts.searchParams
|
||||
: Object
|
||||
.entries(opts.searchParams)
|
||||
.reduce<[string, string][]>((acc, [key, value]) => {
|
||||
.reduce<URLSearchParams>((acc, [key, value]) => {
|
||||
if (Array.isArray(value)) {
|
||||
for (const v of value) {
|
||||
acc.push([`${key}[]`, String(v)]);
|
||||
acc.append(`${key}[]`, String(v));
|
||||
}
|
||||
} else if (value !== undefined && value !== null) {
|
||||
acc.push([key, String(value)]);
|
||||
acc.append(key, String(value));
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}, new URLSearchParams());
|
||||
|
||||
url.search = new URLSearchParams(params).toString();
|
||||
// Merge search params.
|
||||
// If a key exists in the URL, it will be replaced. Otherwise it will be added.
|
||||
for (const key of params.keys()) {
|
||||
url.searchParams.delete(key);
|
||||
}
|
||||
for (const [key, value] of params) {
|
||||
url.searchParams.append(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
const headers = new Headers(opts.headers);
|
||||
|
|
|
@ -22,7 +22,7 @@ export const baseClient = (
|
|||
accessToken?: string | null,
|
||||
baseURL?: string,
|
||||
): MastodonClient => {
|
||||
return new MastodonClient(baseURL || location.origin, accessToken || undefined);
|
||||
return new MastodonClient(baseURL || BuildConfig.BACKEND_URL || location.origin, accessToken || undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -183,7 +183,7 @@ export class NBunker {
|
|||
private async sendResponse(pubkey: string, response: NostrConnectResponse): Promise<void> {
|
||||
const { bunkerSigner, relay } = this.opts;
|
||||
|
||||
const content = await bunkerSigner.nip04!.encrypt(pubkey, JSON.stringify(response));
|
||||
const content = await bunkerSigner.nip44!.encrypt(pubkey, JSON.stringify(response));
|
||||
|
||||
const event = await bunkerSigner.signEvent({
|
||||
kind: 24133,
|
||||
|
@ -198,11 +198,7 @@ export class NBunker {
|
|||
/** Auto-decrypt NIP-44 or NIP-04 ciphertext. */
|
||||
private async decrypt(pubkey: string, ciphertext: string): Promise<string> {
|
||||
const { bunkerSigner } = this.opts;
|
||||
try {
|
||||
return await bunkerSigner.nip44!.decrypt(pubkey, ciphertext);
|
||||
} catch {
|
||||
return await bunkerSigner.nip04!.decrypt(pubkey, ciphertext);
|
||||
}
|
||||
return await bunkerSigner.nip44!.decrypt(pubkey, ciphertext);
|
||||
}
|
||||
|
||||
/** Authorize the pubkey to perform signer actions (ie any other actions besides `connect`). */
|
||||
|
|
Ładowanie…
Reference in New Issue