Skip to content

type: extend Link type and ResourceDescriptor #402

@dodok8

Description

@dodok8

Summary

  • Add a new type or add a 'template' field to Link
  • Make href field in Link optional

Problem

Before handling #119, we need to extend our type definition of the return type of lookupWebFinger(), ResourceDescriptor that supports non-RFC standard, OStatus 1.0 Draft 2.

And According to the RFC 7033 Section 4.4.4.3, href is also OPTIONAL, so it needed to be changed.

Proposed Solution

Add type like OStatusSubscribeLink

export interface ResourceDescriptor {
  subject?: string;
  aliases?: string[];
  properties?: Record<string, string>;
  links?: Array<Link | OStatusSubscribeLink>;
}

/**
 * References a link. See also
 * [OStatus 1.0 Draft 2](https://www.w3.org/community/ostatus/wiki/images/9/93/OStatus_1.0_Draft_2.pdf)
 */
export interface OStatusSubscribeLink {
  rel: "http://ostatus.org/schema/1.0/subscribe";
  /**
   * A URI template (RFC 6570) that can be used to construct URIs by
   * substituting variables. Used primarily for subscription endpoints
   * where parameters like account URIs need to be dynamically inserted.
   */
  template: string;
}

Alternatives Considered

/**
 * Describes a resource.  See also
 * [RFC 7033 section 4.4](https://datatracker.ietf.org/doc/html/rfc7033#section-4.4).
 */
export interface ResourceDescriptor {
  subject?: string;
  aliases?: string[];
  properties?: Record<string, string>;
  links?: Link[];
}

/**
 * Represents a link.  See also
 * [RFC 7033 section 4.4.4](https://datatracker.ietf.org/doc/html/rfc7033#section-4.4.4).
 */
export interface Link {
  rel: string;
  type?: string;
  href?: string;
  titles?: Record<string, string>;
  properties?: Record<string, string>;
  template?: string;
}

Scope / Dependencies

  • packages/cli/webfinger.ts
  • packages/fedify/src/webfinger/*(especially jrd.ts)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions