feat(federation): Port to Versia 0.6

This commit is contained in:
Jesse Wierzbinski 2026-02-25 02:34:27 +01:00
parent de69f27877
commit fca30b4dad
No known key found for this signature in database
62 changed files with 1614 additions and 2008 deletions

View file

@ -15,3 +15,31 @@ export class Entity {
return this.data;
}
}
export class Reference {
public constructor(
public id: string,
public domain?: string,
) {}
public static fromString(str: string): Reference {
// Expect format: domain:id or id (if domain is the local instance)
// Handle IPv6 addresses in brackets
const chunks = str.split(":");
if (chunks.length === 2) {
return new Reference(chunks[1], chunks[0]);
}
if (chunks.length > 2) {
const domain = chunks.slice(0, -1).join(":");
const id = chunks.at(-1) as string;
return new Reference(id, domain);
}
return new Reference(str);
}
public toString(): string {
return this.domain ? `${this.domain}:${this.id}` : this.id;
}
}