Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndieAuthでのJSON形式メタデータのサポート #14072

Open
1 task done
saschanaz opened this issue Jun 22, 2024 · 0 comments
Open
1 task done

IndieAuthでのJSON形式メタデータのサポート #14072

saschanaz opened this issue Jun 22, 2024 · 0 comments
Assignees
Labels
🧩API Interface between server and client ✨Feature This adds/improves/enhances a feature packages/backend Server side specific issue/PR

Comments

@saschanaz
Copy link
Member

Summary

indieweb/indieauth#138 で現在実装されているh-appなどのmicroformatサポートは消してJSONに変えようとしているので、それを実装します

Purpose

microformatは嫌がる人が多かったようで、この辺りでJSONをサポートするようにします

// https://indieauth.spec.indieweb.org/#client-information-discovery
// "Authorization servers SHOULD support parsing the [h-app] Microformat from the client_id,
// and if there is an [h-app] with a url property matching the client_id URL,
// then it should use the name and icon and display them on the authorization prompt."
// (But we don't display any icon for now)
// https://indieauth.spec.indieweb.org/#redirect-url
// "The client SHOULD publish one or more <link> tags or Link HTTP headers with a rel attribute
// of redirect_uri at the client_id URL.
// Authorization endpoints verifying that a redirect_uri is allowed for use by a client MUST
// look for an exact match of the given redirect_uri in the request against the list of
// redirect_uris discovered after resolving any relative URLs."
async function discoverClientInformation(logger: Logger, httpRequestService: HttpRequestService, id: string): Promise<ClientInformation> {
try {
const res = await httpRequestService.send(id);
const redirectUris: string[] = [];
const linkHeader = res.headers.get('link');
if (linkHeader) {
redirectUris.push(...httpLinkHeader.parse(linkHeader).get('rel', 'redirect_uri').map(r => r.uri));
}
const text = await res.text();
const fragment = JSDOM.fragment(text);
redirectUris.push(...[...fragment.querySelectorAll<HTMLLinkElement>('link[rel=redirect_uri][href]')].map(el => el.href));
let name = id;
if (text) {
const microformats = mf2(text, { baseUrl: res.url });
const nameProperty = microformats.items.find(item => item.type?.includes('h-app') && item.properties.url.includes(id))?.properties.name[0];
if (typeof nameProperty === 'string') {
name = nameProperty;
}
}
return {
id,
redirectUris: redirectUris.map(uri => new URL(uri, res.url).toString()),
name: typeof name === 'string' ? name : id,
};
} catch (err) {
console.error(err);
logger.error('Error while fetching client information', { err });
if (err instanceof StatusError) {
throw new AuthorizationError('Failed to fetch client information', 'invalid_request');
} else {
throw new AuthorizationError('Failed to parse client information', 'server_error');
}
}
}

Do you want to implement this feature yourself?

  • Yes, I will implement this by myself and send a pull request
@saschanaz saschanaz added 🧩API Interface between server and client ✨Feature This adds/improves/enhances a feature packages/backend Server side specific issue/PR labels Jun 22, 2024
@saschanaz saschanaz self-assigned this Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧩API Interface between server and client ✨Feature This adds/improves/enhances a feature packages/backend Server side specific issue/PR
Projects
None yet
Development

No branches or pull requests

1 participant