mirror of
https://github.com/versia-pub/api.git
synced 2025-12-06 08:28:19 +01:00
feat(federation): ✨ Allow specifying custom hostname in WebFinger requests
This commit is contained in:
parent
0945a72a79
commit
88cfd005fd
|
|
@ -71,6 +71,7 @@ export class FederationRequester {
|
||||||
/**
|
/**
|
||||||
* Get the user's profile link from their username.
|
* Get the user's profile link from their username.
|
||||||
* @param username The username to get the profile link for.
|
* @param username The username to get the profile link for.
|
||||||
|
* @param hostname The hostname to get the profile link for (defaults to the server's hostname).
|
||||||
* @returns The user's profile link.
|
* @returns The user's profile link.
|
||||||
* @throws If the request fails or the response is invalid.
|
* @throws If the request fails or the response is invalid.
|
||||||
* @example
|
* @example
|
||||||
|
|
@ -79,10 +80,13 @@ export class FederationRequester {
|
||||||
* console.log(profileLink);
|
* console.log(profileLink);
|
||||||
* // => "https://example.com/users/1"
|
* // => "https://example.com/users/1"
|
||||||
*/
|
*/
|
||||||
public async webFinger(username: string): Promise<string> {
|
public async webFinger(
|
||||||
|
username: string,
|
||||||
|
hostname = this.serverUrl.hostname,
|
||||||
|
): Promise<string> {
|
||||||
const result = await this.get<User>(
|
const result = await this.get<User>(
|
||||||
`/.well-known/webfinger?${new URLSearchParams({
|
`/.well-known/webfinger?${new URLSearchParams({
|
||||||
resource: `acct:${username}@${this.serverUrl.hostname}`,
|
resource: `acct:${username}@${hostname}`,
|
||||||
})}`,
|
})}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue