decentralised sync engine

feat: more atproto helpers

serenity 6a37dd36 9fce8adc

Changed files
+14 -3
src
lib
utils
+14 -3
src/lib/utils/atproto.ts
···
import type {
AtprotoHandle,
+
AtUri,
Did,
-
DidDocument} from "@/lib/types/atproto";
-
import {
-
atprotoHandleSchema
+
DidDocument,
} from "@/lib/types/atproto";
+
import { atprotoHandleSchema } from "@/lib/types/atproto";
import type { Result } from "@/lib/utils/result";
import type { DidDocumentResolver } from "@atcute/identity-resolver";
import {
···
return { ok: false, error: err };
}
};
+
+
// thank u julie
+
export const atUriRegexp =
+
/^at:\/\/([a-zA-Z0-9._:%-]+)(?:\/([a-zA-Z0-9-.]+)(?:\/([a-zA-Z0-9._~:@!$&%')(*+,;=-]+))?)?(?:#(\/[a-zA-Z0-9._~:@!$&%')(*+,;=\-[\]/\\]*))?$/;
+
+
export const atUriToString = ({ authority, collection, rKey }: AtUri) => {
+
let result = `at://${authority}`;
+
result += collection ? `/${collection}` : "";
+
result += rKey ? `/${rKey}` : "";
+
return result;
+
};