Skip to content

Stable ID generator for off-protocol services #2604

@43081j

Description

@43081j

The stuff in #2584 basically summarises as "we need a way to identify non-atproto documents".

Given that the authority in such a situation is the service (e.g. GitHub), this means we need a function which basically computes a stable ID given a URL on said service.

This is necessary because we need a stable way to reference github repos, packages, and anything else from a service which isn't on atproto.

Implementation

in the case of GitHub, each repo already has an ID which doesn't change even if it gets transferred. So it'd look like this:

async function githubStableID(url: URL): Promise<string | null> {
  // do a bunch of stuff to check if this is a repo...
  if (!isRepo) {
    return null; // can't compute IDs for non-repos yet
  }
  const repoDoc = await somehowGetRepoFromGitHub(repoName);
  return repoDoc.id;
}

over time, we'd end up with a function like this for each "integration". For example, the npm one may just be a sync piece of logic that returns {name}@{version}.

we should make a function (here or in a new published library others can share) which essentially exports:

export function generateId(url: URL): Promise<string | null> {
  switch (somehowGetType(url)) {
    case 'github': return githubStableId(url);
    // ...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions